CMIS repository must have following two basic types.
a. cmis:document
b.
cmis:folder
In additon to the above two basic types, a repository may
support following base types.
a.
cmis:relationship
b.
cmis:policy
c.
cmis:item
d.
cmis:secondary
As per CMIS specification, there must be only 6 base
types that are specified above. You can create new types as sub types of these
base types.
By using following statements, you can get all the base
types that are supported by the repository.
ItemIterable<ObjectType>
objTypes = session.getTypeChildren(null, false);
TestCmis.java
package com.sample.util;
import java.util.HashMap;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
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";
public 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 main(String args[]) {
Session session = getSession();
ItemIterable<ObjectType> objTypes = session.getTypeChildren(null, false);
for(ObjectType objectType : objTypes){
System.out.println(objectType.getId());
}
}
}
Output
cmis:secondary
cmis:item
cmis:relationship
cmis:policy
cmis:folder
cmis:document
Points should be noted about object types
a. Other than the 6
base types (cmis:document, cmis:folder, cmis:relationship, cmis:policy,
cmis:item, cmis:secondary), no other base type should exists in the repository
b. A base type do not
have parent type
c. A non-base type has one and only one parent
type.
Following application prints all the types and their
parent types.
TestCmis.java
package com.sample.util;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.ObjectType;
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 final String NULL_STRING = null;
public 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 printTypeAndParentType(List<Tree<ObjectType>> types) {
for (Tree<ObjectType> typeTree : types) {
ObjectType objType = typeTree.getItem();
ObjectType parentType = objType.getParentType();
StringBuilder builder = new StringBuilder("type : ").append(objType.getId()).append(" -> ");
if (parentType == null) {
builder.append("parentType : ").append(NULL_STRING);
} else {
builder.append("parentType : ").append(parentType.getId());
}
System.out.println(builder.toString());
printTypeAndParentType(typeTree.getChildren());
}
}
public static void main(String args[]) {
Session session = getSession();
List<Tree<ObjectType>> typeDescendants = session.getTypeDescendants(null, -1, false);
printTypeAndParentType(typeDescendants);
}
}
Output
type : cmis:secondary -> parentType : null
type : MySecondaryType -> parentType : cmis:secondary
type : cmis:item -> parentType : null
type : MyItemType -> parentType : cmis:item
type : cmis:relationship -> parentType : null
type : CrossReferenceType -> parentType : cmis:relationship
type : cmis:policy -> parentType : null
type : AuditPolicy -> parentType : cmis:policy
type : cmis:folder -> parentType : null
type : cmis:document -> parentType : null
type : MyDocType1 -> parentType : cmis:document
type : MyDocType1.1 -> parentType : MyDocType1
type : MyDocType1.1.1 -> parentType : MyDocType1.1
type : MyDocType1.1.2 -> parentType : MyDocType1.1
type : MyDocType1.2 -> parentType : MyDocType1
type : MyDocType2 -> parentType : cmis:document
type : MyDocType2.1 -> parentType : MyDocType2
type : MyDocType2.2 -> parentType : MyDocType2
type : MyDocType2.3 -> parentType : MyDocType2
type : MyDocType2.4 -> parentType : MyDocType2
type : MyDocType2.5 -> parentType : MyDocType2
type : MyDocType2.6 -> parentType : MyDocType2
type : MyDocType2.7 -> parentType : MyDocType2
type : MyDocType2.8 -> parentType : MyDocType2
type : MyDocType2.9 -> parentType : MyDocType2
type : ComplexType -> parentType : cmis:document
type : DocumentTopLevel -> parentType : cmis:document
type : DocumentLevel1 -> parentType : DocumentTopLevel
type : DocumentLevel2 -> parentType : DocumentLevel1
type : VersionableType -> parentType : cmis:document
type : BigContentFakeType -> parentType : cmis:document
type : audioFile -> parentType : cmis:document
type : emailDocument -> parentType : cmis:document
type : exifImage -> parentType : cmis:document
type : officeDocument -> parentType : cmis:document
type : pdfDocument -> parentType : officeDocument
type : videoFile -> parentType : cmis:document
You can notify from the above output, for the base types
(cmis:secondary, cmis:item, cmis:relationship, cmis:policy, cmis:folder,
cmis:document), the parent type is null.
d. The scope of a
query on a given object-type is automatically expanded to include all the
descendant types of the given object-type.
For example,
If you query on type 'cmis:document', the query will
expand to the type 'cmis:document' and all the sub types.