Class CmsCmisUtil

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

public final class CmsCmisUtil extends Object
Utility class for operations which are frequently used by CMIS service methods.

  • 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 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, String typeId, CmsResource resource, Set<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, String typeId, Set<String> filter, String id, 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, String typeId, Set<String> filter, 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, String typeId, Set<String> filter, String id, 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, String typeId, Set<String> filter, String id, 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, 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 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, String typeId, Set<String> filter, 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, String typeId, Set<String> filter, String id, 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, String typeId, Set<String> filter, 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(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 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

      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

      public static List<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 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 Set<String> splitFilter(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