Saturday, April 25, 2009

Fetch all PDM libraries from the context root using Content APIs

You are unable to fetch all libraries from context root using Content API as follows:

ContentRoot conroot=contentService.getContentRoot(loginContext);
List lis= conroot.getLibraries();

Iterator itr=lis.iterator();

The call to ContentService.getContentRoot(loginContext).getLibraries() to create the List of libraries returns a zero (0), because it returns a datagraph that only includes the node requested and its attributes.

Resolving the problem
To get the libraries list, use the information from that node and do a getChildren, for example:

public DataContainer getChildrenByID(LoginContext loginContext,
java.lang.String id,
Service.PaginationParams paginationParams,
commonj.sdo.Type[] filter,
Service.Order order,
int options)
throws AccessDeniedException,

This method returns a list of children that can be filtered, paginated and ordered. The list is always guaranteed to be a flat list since depth is not an option and the object represented by the path will not be returned.

Some information on this Content API has been removed in version 6.1 (pdm library and its usage of cmapi). Lotus Quickr and the supported REST APIs are the preferred content solution going forward.