In my previous post, I explained how to get the
properties of a cmis object by calling the getType() method. As I said, every
property in CMIS is defined properly. You can see the property definitions of a
property by calling the ‘getPropertyDefinitions’ method of the object type.
Example
Folder folder = session.getRootFolder();
ObjectType objectType = folder.getType();
Map<String, PropertyDefinition<?>>
propertyDefinitions = objectType.getPropertyDefinitions();
TestCmis.java
package com.sample.util; import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.apache.chemistry.opencmis.client.api.Folder; 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.definitions.PropertyDefinition; import org.apache.chemistry.opencmis.commons.enums.BindingType; import org.apache.chemistry.opencmis.commons.enums.PropertyType; 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 printPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) { for (String key : propertyDefinitions.keySet()) { System.out.println("Property definitions for the property : " + key); System.out.println("************************************************"); PropertyDefinition<?> propertyDefinition = propertyDefinitions.get(key); String description = propertyDefinition.getDescription(); String displayName = propertyDefinition.getDisplayName(); String id = propertyDefinition.getId(); String localName = propertyDefinition.getLocalName(); String queryName = propertyDefinition.getQueryName(); PropertyType propertyType = propertyDefinition.getPropertyType(); System.out.println("description = " + description); System.out.println("displayName = " + displayName); System.out.println("id = " + id); System.out.println("localName = " + localName); System.out.println("queryName = " + queryName); System.out.println("propertyType = " + propertyType); } } public static void main(String args[]) throws IOException { Session session = getSession(); Folder folder = session.getRootFolder(); ObjectType objectType = folder.getType(); Map<String, PropertyDefinition<?>> propertyDefinitions = objectType.getPropertyDefinitions(); printPropertyDefinitions(propertyDefinitions); } }
Output
Property definitions for the property : cmis:name ************************************************ description = Name displayName = Name id = cmis:name localName = cmis:name queryName = cmis:name propertyType = STRING Property definitions for the property : cmis:description ************************************************ description = Description displayName = Description id = cmis:description localName = cmis:description queryName = cmis:description propertyType = STRING Property definitions for the property : cmis:objectId ************************************************ description = Object Id displayName = Object Id id = cmis:objectId localName = cmis:objectId queryName = cmis:objectId propertyType = ID Property definitions for the property : cmis:baseTypeId ************************************************ description = Base Type Id displayName = Base Type Id id = cmis:baseTypeId localName = cmis:baseTypeId queryName = cmis:baseTypeId propertyType = ID Property definitions for the property : cmis:objectTypeId ************************************************ description = Object Type Id displayName = Object Type Id id = cmis:objectTypeId localName = cmis:objectTypeId queryName = cmis:objectTypeId propertyType = ID Property definitions for the property : cmis:secondaryObjectTypeIds ************************************************ description = Secondary Type Ids displayName = Secondary Type Ids id = cmis:secondaryObjectTypeIds localName = cmis:secondaryObjectTypeIds queryName = cmis:secondaryObjectTypeIds propertyType = ID Property definitions for the property : cmis:createdBy ************************************************ description = Created By displayName = Created By id = cmis:createdBy localName = cmis:createdBy queryName = cmis:createdBy propertyType = STRING Property definitions for the property : cmis:creationDate ************************************************ description = Creation Date displayName = Creation Date id = cmis:creationDate localName = cmis:creationDate queryName = cmis:creationDate propertyType = DATETIME Property definitions for the property : cmis:lastModifiedBy ************************************************ description = Last Modified By displayName = Last Modified By id = cmis:lastModifiedBy localName = cmis:lastModifiedBy queryName = cmis:lastModifiedBy propertyType = STRING Property definitions for the property : cmis:lastModificationDate ************************************************ description = Last Modification Date displayName = Last Modification Date id = cmis:lastModificationDate localName = cmis:lastModificationDate queryName = cmis:lastModificationDate propertyType = DATETIME Property definitions for the property : cmis:changeToken ************************************************ description = Change Token displayName = Change Token id = cmis:changeToken localName = cmis:changeToken queryName = cmis:changeToken propertyType = STRING Property definitions for the property : cmis:parentId ************************************************ description = Parent Id displayName = Parent Id id = cmis:parentId localName = cmis:parentId queryName = cmis:parentId propertyType = ID Property definitions for the property : cmis:path ************************************************ description = Path displayName = Path id = cmis:path localName = cmis:path queryName = cmis:path propertyType = STRING Property definitions for the property : cmis:allowedChildObjectTypeIds ************************************************ description = Allowed Child Object Type Ids displayName = Allowed Child Object Type Ids id = cmis:allowedChildObjectTypeIds localName = cmis:allowedChildObjectTypeIds queryName = cmis:allowedChildObjectTypeIds propertyType = ID
No comments:
Post a Comment