Folder tasks

Creating a root folder

From the module, you may create a folder at the root.

public void library_createFolder( IDocumentManagementModule module, IContext context ) throws Exception 
{ 
        // creating a folder under the root folder 
        IFolder folder = module.CreateFolder( context, "Folder SDK" ); 
        // positioning the inherited rights 
        folder.setInheritRights( true ); 
        // spreading the rights to the sub-folders 
        folder.setPropagateRights( true ); 
        // validating the folder creation 
        folder.Save(); 
}

Creating a folder

From the module, you may create a sub-folder passing by the root folder.

public void library_createChildFolder( IDocumentManagementModule module, IContext context ) throws Exception 
{ 
        IFolder rootFolder = module.getRootFolder(); 
        IFolder parentFolder = module.GetFolderByName( context, rootFolder, "Folder SDK" ); 
        // creating a child folder 
        IFolder folder = module.CreateFolderIntoFolder( context, parentFolder, "Sub folder SDK" ); 
        // positioning the inherited rights 
        folder.setInheritRights( true ); 
        // spreading the rights to the sub-folders 
        folder.setPropagateRights( true ); 
        // validating the child folder creation 
        folder.Save(); 
}

Retrieving the root folder

From the module, you may recover the root folder.

public void library_getRootFolder( IDocumentManagementModule module ) throws Exception
{ 
        // recovering the root folder 
        IFolder rootFolder = module.getRootFolder(); 
}

Retrieving the child files

Example of browsing the child folders of a folder The example presents the class _FolderCollection.

public void library_getChildrenFolder( IDocumentManagementModule module, IContext context ) throws Exception 
{ 
        IFolder rootFolder = module.getRootFolder(); 
        // retrieving all the folders contained in the root folder 
        FolderCollection folders = module.GetFolders( context, rootFolder ); 
        for ( int index = 0 ; index < folders.getCount() ; index++ ) 
        { 
                IFolder folder = folders.getItem( index ); 
                LOGGER.info( "resource definition: " + folder.getId().getAsString() + ", name: " + folder.getname() ); 
        } 
}

Retrieving a child file

Example of retrieving a child folder by its system name

public void library_getChildFolder( IDocumentManagementModule module, IContext context ) throws Exception 
{ 
        IFolder rootFolder = module.getRootFolder(); 
        // retrieving a specific folder under the root folder 
        IFolder childFolder = module.GetFolderByName( context, rootFolder, "Folder SDK" ); 
}