!--a11y-->
Implementing the Namespace Submanager
(INamespaceManager) 
The namespace submanager of the repository manager is responsible for exposing objects from the backend system in a hierarchically organized structure. The namespace refers to the range of names that can be assigned to the resources in the repository. The namespace submanager mainly provides functions to navigate through resources in the namespace.
The most important method of the interface that you implement is findResources(), which has two different signatures. The method provides functions to find resources for a specific IResourceHandle. These enable navigation through the hierarchy of a repository.
public List findResources(IResourceHandle handle,
IFindResourcesDescriptor desc,
int start,
int offset,
java.lang.Object cursor)
throws ResourceException,
OperationNotSupportedException {
if( desc instanceof AdvancedChildrenFindResourcesDescriptor )
throw new OperationNotSupportedException(
null,
"only basic children find descriptor supported",
true
);
Within the findResources() method, you have to distinguish several IFindResourceDescriptors. This implementation only handles the IBasicChildrenFindDescriptor and throws an OperationNotSupportedException if any other IFindResourceDescriptors is passed to the method.
if( desc instanceof IBasicChildrenFindResourcesDescriptor ) {
List children = new ArrayList();
Node node = ((SimpleHandle) handle).getNode();
if( node instanceof FolderNode ) {
List nodeChildren = ((FolderNode) node).getChildren();
Iterator iter = nodeChildren.iterator();
while( iter.hasNext() ) {
Node nodeChild = (Node) iter.next();
children.add(new SimpleHandle(
nodeChild,
this.getUser(handle.getRid()),
this.getLocale(handle.getRid()),
));
}
}
return children;
}
throw new OperationNotSupportedException(
null,
"only basic children find descriptor supported",
true
);
}
The
method must return a List (java.util.List) that contains the child handles from
the requested IResourceHandle. If no children are available, it returns an
empty list.
The second signature is almost the same, but returns an Iterator object (java.util.Iterator) for the list instead of the list itself.
public Iterator findResources(IResourceHandle handle,
IFindResourcesDescriptor desc,
int start,
int size)
throws ResourceException,
OperationNotSupportedException {
List children = this.findResources(handle, desc, start, size, null);
return children.iterator();
}
To determine whether a handle is a node or a leaf, you implement the isCollection()method.
public boolean isCollection(IResourceHandle handle)
throws ResourceException {
if( handle instanceof SimpleHandle )
return ((SimpleHandle) handle).isCollection();
}
throw new OperationNotSupportedException(
null,
"given IResourceHandle is not a SimpleHandle",
true
);
}
The table shows the methods that you implement for the INamespaceManager must be implemented:
findResources(…) |
Provides functions for finding resources for a specific IResourceHandle. We recommended that you implement all signatures of this method properly. |
isCollection(IResourceHandle) |
Must return true if the IResourceHandle passed is a node object, or false if it is a leaf. |
getCollectionOrderMechanism(…) |
Must return a valid OrderMechanism object. Ffor example, OrderMechanism(OrderMechanismType.NONE) if no sorting is available. |
getLinkDescriptor(…) |
Must return a valid LinkDescriptor object. For example, LinkDescriptor.TYPE_NONE if its not a link. |