org.opencms.cmis
Class CmsCmisUtil

java.lang.Object
  extended by org.opencms.cmis.CmsCmisUtil

public final class CmsCmisUtil
extends java.lang.Object

Utility class for operations which are frequently used by CMIS service methods.


Method Summary
static void addAction(java.util.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, java.lang.String typeId, CmsResource resource, java.util.Set<java.lang.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, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.String id, java.math.BigInteger value)
          Adds bigint property to a PropertiesImpl.
static void addPropertyBoolean(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.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, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.String id, java.util.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, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.String id, java.lang.String value)
          Helper method for adding an id-valued property.
static void addPropertyIdList(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.String id, java.util.List<java.lang.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, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.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, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.String id, java.lang.String value)
          Adds a string property to a PropertiesImpl.
static boolean checkAddProperty(CmsCmisTypeManager typeManager, org.apache.chemistry.opencmis.commons.data.Properties properties, java.lang.String typeId, java.util.Set<java.lang.String> filter, java.lang.String id)
          Checks whether a property can be added to a Properties.
static void checkResourceName(java.lang.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 java.lang.String getAcePrincipalName(CmsObject cms, CmsUUID principalId)
          Gets a user-readable name for a principal id read from an ACE.
static java.util.List<java.lang.String> getCmisPermissions(CmsAccessControlEntry ace)
          Converts an OpenCms ACE to a list of basic CMIS permissions.
static java.util.List<java.lang.String> getNativePermissions(CmsAccessControlEntry ace)
          Converts an OpenCms access control entry to a list of CMIS permissions which represent native OpenCms permissions.
static java.util.List<java.lang.String> getNativePermissions(int permissionBits, boolean denied)
          Converts an OpenCms access control bitset to a list of CMIS permissions representing native OpenCms permissions.
static void handleCmsException(CmsException e)
          Wrap OpenCms into OpenCMIS exceptions and rethrow them.
static boolean hasChildren(CmsObject cms, CmsResource resource)
          Checks whether the given resource has any children.
static java.util.GregorianCalendar millisToCalendar(long millis)
          Converts milliseconds into a calendar object.
static java.util.Set<java.lang.String> splitFilter(java.lang.String filter)
          Splits a filter statement into a collection of properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addAction

public static void addAction(java.util.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 actions
action - the action to add
condition - 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,
                                        java.lang.String typeId,
                                        CmsResource resource,
                                        java.util.Set<java.lang.String> filter)
Helper method to add the dynamic properties for a resource.

Parameters:
cms - the current CMS context
typeManager - the type manager instance
props - the properties to which the dynamic properties should be added
typeId - the type id
resource - the resource
filter - the property filter

addPropertyBigInteger

public static void addPropertyBigInteger(CmsCmisTypeManager typeManager,
                                         org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                         java.lang.String typeId,
                                         java.util.Set<java.lang.String> filter,
                                         java.lang.String id,
                                         java.math.BigInteger value)
Adds bigint property to a PropertiesImpl.

Parameters:
typeManager - the type manager
props - the properties
typeId - the type id
filter - the property filter string
id - the property id
value - the property value

addPropertyBoolean

public static void addPropertyBoolean(CmsCmisTypeManager typeManager,
                                      org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                      java.lang.String typeId,
                                      java.util.Set<java.lang.String> filter,
                                      java.lang.String id,
                                      boolean value)
Adds a boolean property to a PropertiesImpl.

Parameters:
typeManager -
props - the properties
typeId - the type id
filter - the property filter string
id - the property id
value - the property value

addPropertyDateTime

public static void addPropertyDateTime(CmsCmisTypeManager typeManager,
                                       org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                       java.lang.String typeId,
                                       java.util.Set<java.lang.String> filter,
                                       java.lang.String id,
                                       java.util.GregorianCalendar value)
Adds a date/time property to a PropertiesImpl.

Parameters:
typeManager - the type manager
props - the properties
typeId - the type id
filter - the property filter string
id - the property id
value - 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 object
propDef - 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,
                                 java.lang.String typeId,
                                 java.util.Set<java.lang.String> filter,
                                 java.lang.String id,
                                 java.lang.String value)
Helper method for adding an id-valued property.

Parameters:
typeManager - the type manager
props - the properties to add to
typeId - the type id
filter - the property filter
id - the property id
value - the property value

addPropertyIdList

public static void addPropertyIdList(CmsCmisTypeManager typeManager,
                                     org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                     java.lang.String typeId,
                                     java.util.Set<java.lang.String> filter,
                                     java.lang.String id,
                                     java.util.List<java.lang.String> value)
Helper method for adding an id-list-valued property.

Parameters:
typeManager -
props - the properties to add to
typeId - the type id
filter - the property filter
id - the property id
value - the property value

addPropertyInteger

public static void addPropertyInteger(CmsCmisTypeManager typeManager,
                                      org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                      java.lang.String typeId,
                                      java.util.Set<java.lang.String> filter,
                                      java.lang.String id,
                                      long value)
Adds an integer property to a PropertiesImpl.

Parameters:
typeManager - the type manager
props - the properties
typeId - the type id
filter - the property filter string
id - the property id
value - the property value

addPropertyString

public static void addPropertyString(CmsCmisTypeManager typeManager,
                                     org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                     java.lang.String typeId,
                                     java.util.Set<java.lang.String> filter,
                                     java.lang.String id,
                                     java.lang.String value)
Adds a string property to a PropertiesImpl.

Parameters:
typeManager -
props - the properties
typeId - the type id
filter - the property filter string
id - the property id
value - the property value

checkAddProperty

public static boolean checkAddProperty(CmsCmisTypeManager typeManager,
                                       org.apache.chemistry.opencmis.commons.data.Properties properties,
                                       java.lang.String typeId,
                                       java.util.Set<java.lang.String> filter,
                                       java.lang.String id)
Checks whether a property can be added to a Properties.

Parameters:
typeManager -
properties - the properties object
typeId - the type id
filter - the property filter
id - the property id
Returns:
true if the property should be added

checkResourceName

public static void checkResourceName(java.lang.String name)
Checks whether a name is a valid OpenCms resource name and throws an exception otherwise.

Parameters:
name - the name to check

ensureLock

public static boolean ensureLock(CmsObject cms,
                                 CmsResource resource)
                          throws CmsException
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 context
resource - the resource to lock
Returns:
true if the resource wasn't already locked
Throws:
CmsException - if something goes wrong

getAcePrincipalName

public static java.lang.String getAcePrincipalName(CmsObject cms,
                                                   CmsUUID principalId)
Gets a user-readable name for a principal id read from an ACE.

Parameters:
cms - the current CMS context
principalId - the principal id from the ACE
Returns:
the name of the principle

getCmisPermissions

public static java.util.List<java.lang.String> getCmisPermissions(CmsAccessControlEntry ace)
Converts an OpenCms ACE to a list of basic CMIS permissions.

Parameters:
ace - the access control entry
Returns:
the list of permissions

getNativePermissions

public static java.util.List<java.lang.String> getNativePermissions(CmsAccessControlEntry ace)
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

public static java.util.List<java.lang.String> getNativePermissions(int permissionBits,
                                                                    boolean denied)
Converts an OpenCms access control bitset to a list of CMIS permissions representing native OpenCms permissions.

Parameters:
permissionBits - the permission bits
denied - if the permission bitset refers to a list of denied rather than allowed permissions
Returns:
the list of native permissions

handleCmsException

public static void handleCmsException(CmsException e)
Wrap OpenCms into OpenCMIS exceptions and rethrow them.

Parameters:
e - the exception to handle

hasChildren

public static boolean hasChildren(CmsObject cms,
                                  CmsResource resource)
                           throws CmsException
Checks whether the given resource has any children.

Parameters:
cms - the CMS context
resource - the resource to check
Returns:
true if the resource has children
Throws:
CmsException - if something goes wrong

millisToCalendar

public static java.util.GregorianCalendar millisToCalendar(long millis)
Converts milliseconds into a calendar object.

Parameters:
millis - a time given in milliseconds after epoch
Returns:
the calendar object for the given time

splitFilter

public static java.util.Set<java.lang.String> splitFilter(java.lang.String filter)
Splits a filter statement into a collection of properties. If filter is null, 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