Library tasks

Recovering the categories

This example shows how to recover the library categories.

public void server_getCategories( ILibraryModule libraryModule, IContext context, ILibrary library ) throws LibraryModuleException
{
        // recovering categories placed at the library root
        Collection categories = libraryModule.getCategories( context, library, false );
        for ( Iterator iterator = categories.iterator() ; iterator.hasNext() ; )
        {
                ICategory category = (ICategory)iterator.next();
                System.out.println( category.getName() );
        }
}

Recovering the sub-categories

This example shows how to recover the sub-categories.

public void server_getSubCategories( ILibraryModule libraryModule, IContext context, ICategory category ) throws LibraryModuleException
{
        // recovering categories from a parent category
        Collection categories = libraryModule.getCategories( context, category, false );
}

Creating categories

This example shows how to create new categories and sub-categories.

public void server_createCategory( ILibraryModule libraryModule, IContext context, ILibrary library ) throws LibraryModuleException
{
        // creating a category
        ICategory category = libraryModule.createCategory( context, library, "test-category" );

        // creating a sub-category
        ICategory subCategory = libraryModule.createCategory( context, category, "test-sub-category" );
}
        

Creating a folder

This example shows how to create folders on the library level.

public void library_createFolder( ILibraryModule libraryModule, IContext context, ILibrary library ) throws LibraryModuleException
{
        IFolder folder = libraryModule.createFolder( context, library, "test-folder" );
        folder.setDescription( "test-folder description" );
}

Creating a sub-folder

This example shows how to create sub-folders.

public void library_createFolder( ILibraryModule libraryModule, IContext context, IFolder parent ) throws LibraryModuleException
{
        IFolder folder = libraryModule.createFolder( context, parent, "test-sub-folder" );
        folder.setDescription( "test-sub-folder description" );
}

Recovering the definitions

This example enables to recover definition from a library.

public void library_getDefinitions( ILibraryModule libraryModule, IContext context, ILibrary library ) throws LibraryModuleException
{
        // recovering every definitions
        Collection definitions = libraryModule.getResourceDefinitions( context, library );
        for ( Iterator iterator = definitions.iterator() ; iterator.hasNext() ; )
        {
                IResourceDefinition definition = (IResourceDefinition)iterator.next();
                System.out.println( definition.getLabel() + " [" + definition.getName() + "]" );
        }
}

Recovering a definition

This example shows how to recover a definition

public void library_getDefinition( ILibraryModule libraryModule, IContext context, ILibrary library ) throws LibraryModuleException
{
        // recovering a definition
        IResourceDefinition definition = libraryModule.getResourceDefinition( context, library, "test-definition" );
        System.out.println( definition.getLabel() + " [" + definition.getName() + "]" );
}

Recovering the properties

This example shows how to recover the definition properties.

public void library_getProperties( ILibraryModule libraryModule, IContext context, IResourceDefinition definition ) throws LibraryModuleException
{
        // recover all the properties
        for ( Iterator iterator = definition.getProperties().iterator() ; iterator.hasNext() ; )
        {
                IProperty property = (IProperty)iterator.next();
                System.out.println( property.getLabel() + " [" + property.getName() + "]" );
        }
}