a. Every CMIS Object
has uique id
Every CMIS object has unique id, it is created by the
repository at the time of creation of the object. This id is used to uniquely
identify the object within the repository. Once the id is assigned to the
obect, it will not change during the lifespan of the object.
For example, following statements prints the id of cmis folder.
Folder
folder = session.getRootFolder();
System.out.println("id
: " + folder.getId());
TestCmis.java
package com.sample.util; import java.util.HashMap; import java.util.Map; 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.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(); Folder folder = session.getRootFolder(); System.out.println("id : " + folder.getId()); } }
Output
id : 100
b. Every cmis object
has set of properties, these properties defined by the object type. Within an
object, each property is uniquely identified by its property definition id.
Object
|
Type
corresponding to the object
|
Document
|
DocumentType
|
Folder
|
FolderType
|
Item
|
ItemType
|
Policy
|
PolicyType
|
RelationShip
|
RelationshipType
|
What are the
properties of cmis object?
Every object has id, name, creationDate and who created
the document, lastmodification date etc., These properties are used to get the
information about the cmis object.
Let’s see it by an example.
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.Folder; import org.apache.chemistry.opencmis.client.api.Property; 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(); Folder folder = session.getRootFolder(); List<Property<?>> properties = folder.getProperties(); System.out.println("propertyId | displayName | value"); for(Property<?> property : properties){ System.out.println(property.getId() + " | " + property.getDisplayName() + " | " + property.getValue()); } } }
Output
propertyId | displayName | value cmis:objectId | Object Id | 100 cmis:path | Path | / cmis:allowedChildObjectTypeIds | Allowed Child Object Type Ids | [] cmis:lastModifiedBy | Last Modified By | Admin cmis:secondaryObjectTypeIds | Secondary Type Ids | [] cmis:objectTypeId | Object Type Id | cmis:folder cmis:description | Description | null cmis:createdBy | Created By | Admin cmis:baseTypeId | Base Type Id | cmis:folder cmis:parentId | Parent Id | null cmis:creationDate | Creation Date | java.util.GregorianCalendar[time=1496383132689,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2017,MONTH=5,WEEK_OF_YEAR=22,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=153,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=5,HOUR_OF_DAY=5,MINUTE=58,SECOND=52,MILLISECOND=689,ZONE_OFFSET=0,DST_OFFSET=0] cmis:changeToken | Change Token | 1496383132690 cmis:name | Name | RootFolder cmis:lastModificationDate | Last Modification Date | java.util.GregorianCalendar[time=1496383132690,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2017,MONTH=5,WEEK_OF_YEAR=22,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=153,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=5,HOUR_OF_DAY=5,MINUTE=58,SECOND=52,MILLISECOND=690,ZONE_OFFSET=0,DST_OFFSET=0]
The properties of the cmis object are defined by the
property definitions.
What are these
property definitions?
Property definitions are used to define the property. For
example, take the property ‘lastModificationDate’ of the cmis object, it should
be well defined like what is the id of the property, how it should be
displayed, what is the query name (CMIS support SQL query syntax, to query the
repository, query name is used while running queries) of the property, what is
the data type of the property, description of the property, whether user can
able to update this property or not etc., Following table summarizes all the
attributes of the property ‘lastModificationDate’ of the cmis object.
Attribute
|
Value
|
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
|
Following program prints all the property definitions of
the type FolderType.
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.Folder; import org.apache.chemistry.opencmis.client.api.FolderType; import org.apache.chemistry.opencmis.client.api.Property; 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.definitions.PropertyDefinition; 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(); Folder folder = session.getRootFolder(); FolderType folderType = folder.getFolderType(); Map<String, PropertyDefinition<?>> propertyDefintions = folderType.getPropertyDefinitions(); for (String key : propertyDefintions.keySet()) { PropertyDefinition propDefinition = propertyDefintions.get(key); System.out.println(propDefinition); } } }
Output
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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] Property Definition [id=cmis:parentId, display name=Parent Id, description=Parent Id, local name=cmis:parentId, local namespace=null, query name=cmis:parentId, property type=ID, 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] Property Definition [id=cmis:path, display name=Path, description=Path, local name=cmis:path, local namespace=null, query name=cmis:path, 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] Property Definition [id=cmis:allowedChildObjectTypeIds, display name=Allowed Child Object Type Ids, description=Allowed Child Object Type Ids, local name=cmis:allowedChildObjectTypeIds, local namespace=null, query name=cmis:allowedChildObjectTypeIds, property type=ID, cardinality=MULTI, choice list=null, default value=[], is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]
c. An object must
have one and only one primary object-type, which cannot be changed. An object's
primary object-type may be simply called its object-type. The primary
object-type of an object classifies the object and defines the properties that
the object must have.
d. An object MAY have
zero or more secondary object types applied to it. A secondary type is a named marking
that may add extra properties to an object in addition to the properties
defined by the object's primary type. That is, applying a secondary type to an
object adds the properties defined by this type to the object. Removing a
secondary type removes the properties. Secondary object-types can only be
defined as subtypes or descendant types of the cmis:secondary base type. All
other base object types and their descendant types are primary object-types.
e. An object may have
access control list (ACL) associated with it. It controls the access to the
object. An ACL represents a list of Access Control Entries (ACEs). An ACE in
turn represents one or more permissions being granted to a principal (a user,
group, role, or something similar).
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.Folder; 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.data.Ace; import org.apache.chemistry.opencmis.commons.data.Acl; 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(); Folder folder = session.getRootFolder(); Acl acl = folder.getAcl(); if(acl == null){ System.out.println("No acl is assocaited with root folder"); return; } List<Ace> aces = acl.getAces(); for(Ace ace : aces){ System.out.println(ace.getPermissions()); } } }
f. All CMIS objects
are strongly typed. If a property not specified in an object's object-type
definition is supplied by an application, an exception SHOULD be thrown.
g. Is all the
repositories should support for Secondary types?
No, the support for secondary types is optional.
No comments:
Post a Comment