Package org.opencms.cmis
Class CmsCmisUtil
java.lang.Object
org.opencms.cmis.CmsCmisUtil
Utility class for operations which are frequently used by CMIS service methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAction
(Set<org.apache.chemistry.opencmis.commons.enums.Action> aas, org.apache.chemistry.opencmis.commons.enums.Action action, boolean condition) Adds an action to a set of actions if a condition is fulfilled.static void
addDynamicProperties
(CmsObject cms, CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, CmsResource resource, Set<String> filter) Helper method to add the dynamic properties for a resource.static void
addPropertyBigInteger
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, BigInteger value) Adds bigint property to a PropertiesImpl.static void
addPropertyBoolean
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, boolean value) Adds a boolean property to a PropertiesImpl.static void
addPropertyDateTime
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, GregorianCalendar value) Adds a date/time property to a PropertiesImpl.static boolean
addPropertyDefault
(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition<?> propDef) Adds the default value of property if defined.static void
addPropertyId
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, String value) Helper method for adding an id-valued property.static void
addPropertyIdList
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, List<String> value) Helper method for adding an id-list-valued property.static void
addPropertyInteger
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, long value) Adds an integer property to a PropertiesImpl.static void
addPropertyString
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, String value) Adds a string property to a PropertiesImpl.static boolean
checkAddProperty
(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.data.Properties properties, String typeId, Set<String> filter, String id) Checks whether a property can be added to a Properties.static void
checkResourceName
(String name) Checks whether a name is a valid OpenCms resource name and throws an exception otherwise.static boolean
ensureLock
(CmsObject cms, CmsResource resource) Tries to lock a resource and throws an exception if it can't be locked.static String
getAcePrincipalName
(CmsObject cms, CmsUUID principalId) Gets a user-readable name for a principal id read from an ACE.Converts an OpenCms ACE to a list of basic CMIS permissions.getNativePermissions
(int permissionBits, boolean denied) Converts an OpenCms access control bitset to a list of CMIS permissions representing native OpenCms permissions.Converts an OpenCms access control entry to a list of CMIS permissions which represent native OpenCms permissions.static void
Wrap OpenCms into OpenCMIS exceptions and rethrow them.static boolean
hasChildren
(CmsObject cms, CmsResource resource) Checks whether the given resource has any children.static GregorianCalendar
millisToCalendar
(long millis) Converts milliseconds into a calendar object.splitFilter
(String filter) Splits a filter statement into a collection of properties.
-
Method Details
-
addAction
public static void addAction(Set<org.apache.chemistry.opencmis.commons.enums.Action> aas, org.apache.chemistry.opencmis.commons.enums.Action action, boolean condition) Adds an action to a set of actions if a condition is fulfilled.- Parameters:
aas
- the set of actionsaction
- the action to addcondition
- the value of the condition for adding the action
-
addDynamicProperties
public static void addDynamicProperties(CmsObject cms, CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, CmsResource resource, Set<String> filter) Helper method to add the dynamic properties for a resource.- Parameters:
cms
- the current CMS contexttypeManager
- the type manager instanceprops
- the properties to which the dynamic properties should be addedtypeId
- the type idresource
- the resourcefilter
- the property filter
-
addPropertyBigInteger
public static void addPropertyBigInteger(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, BigInteger value) Adds bigint property to a PropertiesImpl.- Parameters:
typeManager
- the type managerprops
- the propertiestypeId
- the type idfilter
- the property filter stringid
- the property idvalue
- the property value
-
addPropertyBoolean
public static void addPropertyBoolean(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, boolean value) Adds a boolean property to a PropertiesImpl.- Parameters:
typeManager
-props
- the propertiestypeId
- the type idfilter
- the property filter stringid
- the property idvalue
- the property value
-
addPropertyDateTime
public static void addPropertyDateTime(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, GregorianCalendar value) Adds a date/time property to a PropertiesImpl.- Parameters:
typeManager
- the type managerprops
- the propertiestypeId
- the type idfilter
- the property filter stringid
- the property idvalue
- the property value
-
addPropertyDefault
public static boolean addPropertyDefault(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition<?> propDef) Adds the default value of property if defined.- Parameters:
props
- the Properties objectpropDef
- the property definition- Returns:
- true if the property could be added
-
addPropertyId
public static void addPropertyId(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, String value) Helper method for adding an id-valued property.- Parameters:
typeManager
- the type managerprops
- the properties to add totypeId
- the type idfilter
- the property filterid
- the property idvalue
- the property value
-
addPropertyIdList
public static void addPropertyIdList(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, List<String> value) Helper method for adding an id-list-valued property.- Parameters:
typeManager
-props
- the properties to add totypeId
- the type idfilter
- the property filterid
- the property idvalue
- the property value
-
addPropertyInteger
public static void addPropertyInteger(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, long value) Adds an integer property to a PropertiesImpl.- Parameters:
typeManager
- the type managerprops
- the propertiestypeId
- the type idfilter
- the property filter stringid
- the property idvalue
- the property value
-
addPropertyString
public static void addPropertyString(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, String value) Adds a string property to a PropertiesImpl.- Parameters:
typeManager
-props
- the propertiestypeId
- the type idfilter
- the property filter stringid
- the property idvalue
- the property value
-
checkAddProperty
public static boolean checkAddProperty(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.data.Properties properties, String typeId, Set<String> filter, String id) Checks whether a property can be added to a Properties.- Parameters:
typeManager
-properties
- the properties objecttypeId
- the type idfilter
- the property filterid
- the property id- Returns:
- true if the property should be added
-
checkResourceName
Checks whether a name is a valid OpenCms resource name and throws an exception otherwise.- Parameters:
name
- the name to check
-
ensureLock
Tries to lock a resource and throws an exception if it can't be locked.Returns true only if the resource wasn't already locked before.
- Parameters:
cms
- the CMS contextresource
- the resource to lock- Returns:
- true if the resource wasn't already locked
- Throws:
CmsException
- if something goes wrong
-
getAcePrincipalName
Gets a user-readable name for a principal id read from an ACE.- Parameters:
cms
- the current CMS contextprincipalId
- the principal id from the ACE- Returns:
- the name of the principle
-
getCmisPermissions
Converts an OpenCms ACE to a list of basic CMIS permissions.- Parameters:
ace
- the access control entry- Returns:
- the list of permissions
-
getNativePermissions
Converts an OpenCms access control entry to a list of CMIS permissions which represent native OpenCms permissions.- Parameters:
ace
- the access control entry- Returns:
- the list of permissions for the entry
-
getNativePermissions
Converts an OpenCms access control bitset to a list of CMIS permissions representing native OpenCms permissions.- Parameters:
permissionBits
- the permission bitsdenied
- if the permission bitset refers to a list of denied rather than allowed permissions- Returns:
- the list of native permissions
-
handleCmsException
Wrap OpenCms into OpenCMIS exceptions and rethrow them.- Parameters:
e
- the exception to handle
-
hasChildren
Checks whether the given resource has any children.- Parameters:
cms
- the CMS contextresource
- the resource to check- Returns:
- true if the resource has children
- Throws:
CmsException
- if something goes wrong
-
millisToCalendar
Converts milliseconds into a calendar object.- Parameters:
millis
- a time given in milliseconds after epoch- Returns:
- the calendar object for the given time
-
splitFilter
Splits a filter statement into a collection of properties. Iffilter
isnull
, empty or one of the properties is '*' , an empty collection will be returned.- Parameters:
filter
- the filter string- Returns:
- the set of components of the filter
-