CMIS imposes following constraints on Folder objects.
a.
Every folder object, except for one which is
called the root folder, must have one and only one parent folder. The root
folder does not have a parent.
b.
A cycle in folder containment relationships
is not allowed. That is, a folder object cannot have itself as one of its
descendant objects.
c.
A child object that is a folder object can
itself be the parent object of other file-able objects.
d.
The root folder is a special folder such that
it cannot be created, deleted, or moved using CMIS services.
e.
A non-folder object does not have any descendant
objects.
Conventions used in
folder hierarchy
Descendents: The child
objects of a given folder object, their child objects, and grandchild objects,
etc., are called descendant objects of the given folder object.
Tree: A folder
object together with all its descendant objects are collectively called a tree.
File-able objects
A file-able object is the one, that is placed inside a
folder. Following table summarizes, which base types are file-able.
Base
Type
|
Is
File-able
|
cmis:folder
|
MUST be file-able
|
cmis:document
|
MAY be file-able
|
cmis:relationship
|
MUST NOT be file-able
|
cmis:policy
|
MAY be file-able
|
cmis:item
|
MAY be file-able
|
Following application prints complete folder hierarchy
from the root folder of the repository.
TestCmis.java
package com.sample.util; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.chemistry.opencmis.client.api.FileableCmisObject; import org.apache.chemistry.opencmis.client.api.Folder; import org.apache.chemistry.opencmis.client.api.Session; import org.apache.chemistry.opencmis.client.api.SessionFactory; import org.apache.chemistry.opencmis.client.api.Tree; import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; import org.apache.chemistry.opencmis.commons.SessionParameter; import org.apache.chemistry.opencmis.commons.enums.BindingType; public class TestCmis { private static String serverURL = "http://localhost:8080/chemistry-opencmis-server-inmemory-1.1.0/browser"; private static String repositoryId = "A1"; private static Session getSession() { Map<String, String> parameters = new HashMap<>(); parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value()); parameters.put(SessionParameter.USER, ""); parameters.put(SessionParameter.PASSWORD, ""); parameters.put(SessionParameter.REPOSITORY_ID, repositoryId); parameters.put(SessionParameter.BROWSER_URL, serverURL); SessionFactory sessionFactory = SessionFactoryImpl.newInstance(); return sessionFactory.createSession(parameters); } public static void printHierarchy(List<Tree<FileableCmisObject>> objects, String space) { for (Tree<FileableCmisObject> obj : objects) { FileableCmisObject fileableObj = obj.getItem(); System.out.println(space + fileableObj.getName()); printHierarchy(obj.getChildren(), " " + space); } } public static void main(String args[]) throws IOException { Session session = getSession(); Folder rootFolder = session.getRootFolder(); List<Tree<FileableCmisObject>> fileableCmisObjects = rootFolder.getDescendants(-1); printHierarchy(fileableCmisObjects, ""); } }
Output
My_Document-0-0 My_Document-0-1 My_Document-0-2 My_Folder-0-0 My_Document-1-0 My_Document-1-1 My_Document-1-2 My_Folder-1-0 My_Document-2-0 My_Document-2-1 My_Document-2-2 My_Folder-2-0 My_Folder-2-1 My_Folder-1-1 My_Document-2-0 My_Document-2-1 My_Document-2-2 My_Folder-2-0 My_Folder-2-1 My_Folder-0-1 My_Document-1-0 My_Document-1-1 My_Document-1-2 My_Folder-1-0 My_Document-2-0 My_Document-2-1 My_Document-2-2 My_Folder-2-0 My_Folder-2-1 My_Folder-1-1 My_Document-2-0 My_Document-2-1 My_Document-2-2 My_Folder-2-0 My_Folder-2-1
No comments:
Post a Comment