Sunday 24 March 2019

Objects in CMIS


CMIS modeled the entities as typed objects. There are primarily five base type objects.
a.   document
b.   folder
c.    relationship
d.   policy
e.   item

document
These are primary entities in content management system. A document is used to store the information.

folder
It is a logical container, for a collection of fileable objects like documents. It can include documents, sub folders, policies and item objects.

relationship
relationship object is used to specify the relationship between two objects. As per cmis specification, the support for these objects is optional.

policy
It represents an administrative policy. It may be "applied" to one or more "controllablePolicy" objects. Whether or not an object is controllable is specified in its object-type definition. The support for policy objects is optional.

For example,
For the Item type definition, the attribute, is controllable policy is set to true, that means you can apply policy on the object.

Type Definition [base id=CMIS_ITEM, id=cmis:item, display Name=Item, description=Item, local name=cmis:item, local namespace=http://apache.org, query name=cmis:item, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={cmis:name=Property Definition [id=cmis:name, display name=Name, description=Name, local name=cmis:name, local namespace=null, query name=cmis:name, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=true, updatability=READWRITE][extensions=null], cmis:description=Property Definition [id=cmis:description, display name=Description, description=Description, local name=cmis:description, local namespace=null, query name=cmis:description, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READWRITE][extensions=null], cmis:objectId=Property Definition [id=cmis:objectId, display name=Object Id, description=Object Id, local name=cmis:objectId, local namespace=null, query name=cmis:objectId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:baseTypeId=Property Definition [id=cmis:baseTypeId, display name=Base Type Id, description=Base Type Id, local name=cmis:baseTypeId, local namespace=null, query name=cmis:baseTypeId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:objectTypeId=Property Definition [id=cmis:objectTypeId, display name=Object Type Id, description=Object Type Id, local name=cmis:objectTypeId, local namespace=null, query name=cmis:objectTypeId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=true, updatability=ONCREATE][extensions=null], cmis:secondaryObjectTypeIds=Property Definition [id=cmis:secondaryObjectTypeIds, display name=Secondary Type Ids, description=Secondary Type Ids, local name=cmis:secondaryObjectTypeIds, local namespace=null, query name=cmis:secondaryObjectTypeIds, property type=ID, cardinality=MULTI, choice list=null, default value=[], is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READWRITE][extensions=null], cmis:createdBy=Property Definition [id=cmis:createdBy, display name=Created By, description=Created By, local name=cmis:createdBy, local namespace=null, query name=cmis:createdBy, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:creationDate=Property Definition [id=cmis:creationDate, display name=Creation Date, description=Creation Date, local name=cmis:creationDate, local namespace=null, query name=cmis:creationDate, property type=DATETIME, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:lastModifiedBy=Property Definition [id=cmis:lastModifiedBy, display name=Last Modified By, description=Last Modified By, local name=cmis:lastModifiedBy, local namespace=null, query name=cmis:lastModifiedBy, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:lastModificationDate=Property Definition [id=cmis:lastModificationDate, display name=Last Modification Date, description=Last Modification Date, local name=cmis:lastModificationDate, local namespace=null, query name=cmis:lastModificationDate, property type=DATETIME, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:changeToken=Property Definition [id=cmis:changeToken, display name=Change Token, description=Change Token, local name=cmis:changeToken, local namespace=null, query name=cmis:changeToken, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]

item
In addition to Folder and Document types openCMIS provides new type called Item. Items are light weight as compared to documents, for example they may not have content streams associated with them. You can assume that Item is a collection of properties, but do not have any content associated with them. if you would like to store some configuration information, then create an Item object and store it.

In addition to above primary base types, there is another new base type added in CMIS specification 1.1, that is ‘secondary type’. I will explain much about this in later posts.

Following program prints all the basic types of cmis specification.
Session interface provides 'getTypeChildren' method, by passing 'typeId' as null, you can get all the base types.

ItemIterable<ObjectType> getTypeChildren(String typeId, boolean includePropertyDefinitions);


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> baseTypes = session.getTypeChildren(null, false);
  
  for(ObjectType objectType : baseTypes){
   System.out.println(objectType);
  }
  
 }

}


Output
Type Definition [base id=CMIS_SECONDARY, id=cmis:secondary, display Name=Secondary, description=Secondary, local name=cmis:secondary, local namespace=http://apache.org, query name=cmis:secondary, parent id=null, is controllable ACL=false, is controllable policy=false, is creatable=false, is fileable=false, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_ITEM, id=cmis:item, display Name=Item, description=Item, local name=cmis:item, local namespace=http://apache.org, query name=cmis:item, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_RELATIONSHIP, id=cmis:relationship, display Name=Relationship, description=Relationship, local name=cmis:relationship, local namespace=http://apache.org, query name=cmis:relationship, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=false, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_POLICY, id=cmis:policy, display Name=Policy, description=Policy, local name=cmis:policy, local namespace=http://apache.org, query name=cmis:policy, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=false, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_FOLDER, id=cmis:folder, display Name=Folder, description=Folder, local name=cmis:folder, local namespace=http://apache.org, query name=cmis:folder, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=cmis:document, display Name=Document, description=Document, local name=cmis:document, local namespace=http://apache.org, query name=cmis:document, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]


Depends on the repository support level, you can crate new custom types by extending the existing base types. You can alslo perform updation and deletion of custom types. I will explain how to create new custom types in my later posts.


Previous                                                 Next                                                 Home

No comments:

Post a Comment