Cmis specification define 8 types.
a.
boolean
b.
id
c.
integer
d.
datetime
e.
decimal
f.
html
g.
string
h.
uri
'org.apache.chemistry.opencmis.commons.enums.PropertyType'
enum defined above property types.
For single valued String, Id and HTML properties, a
repository MAY support the distinction between a set value with an empty string
(length = 0), and a "not set" value. In this case an empty value
element (e.g.<cmis:value/>) inside of a property element will indicate a
"set but empty" string property. A property element without a
<cmis:value/> will indicate a property in a "not set" state.
id property
'id' represents a random string used to uniquely identify
a cmis object. You can only use 'id' property in "equal" or a
"not equal" comparison with a string literal or with another id.
html property
'html' property is used to hold the document or fragment
of Hypertext Markup Language (HTML) content.
Following application print all the properties
(displayname, type and value) of the root folder.
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<?>> props = folder.getProperties(); System.out.println("Display Name|type|value"); for (Property<?> prop : props) { System.out.println(prop.getDisplayName() + "|" + prop.getType() + "|" + prop.getValue()); } } }
Output
Display Name|type|value Object Id|ID|100 Path|STRING|/ Allowed Child Object Type Ids|ID|[] Last Modified By|STRING|Admin Secondary Type Ids|ID|[] Object Type Id|ID|cmis:folder Description|STRING|null Created By|STRING|Admin Base Type Id|ID|cmis:folder Parent Id|ID|null Creation Date|DATETIME|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] Change Token|STRING|1496383132690 Name|STRING|RootFolder Last Modification Date|DATETIME|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]
No comments:
Post a Comment