org.opencms.cmis
Class CmsCmisRelationHelper

java.lang.Object
  extended by org.opencms.cmis.CmsCmisRelationHelper
All Implemented Interfaces:
I_CmsCmisObjectHelper

public class CmsCmisRelationHelper
extends java.lang.Object
implements I_CmsCmisObjectHelper

Helper class for CMIS CRUD operations on relation objects.

Since CMIS requires any object to have an ID by which it is accessed, but OpenCms relations are not addressable by ids, we invent an artificial relation id string of the form REL_(SOURCE_ID)_(TARGET_ID)_(TYPE).


Nested Class Summary
static class CmsCmisRelationHelper.RelationKey
          A class which contains the necessary information to identify a relation object.
 
Field Summary
static java.lang.String RELATION_ID_PREFIX
          The prefix used to identify relation ids.
static java.util.regex.Pattern RELATION_PATTERN
          The pattern which relation ids should match.
 
Constructor Summary
CmsCmisRelationHelper(CmsCmisRepository repository)
          Creates a new relation helper for the given repository.
 
Method Summary
protected  org.apache.chemistry.opencmis.commons.data.Acl collectAcl(CmsObject cms, CmsResource resource, boolean onlyBasic)
          Compiles the ACL for a relation.
protected  org.apache.chemistry.opencmis.commons.data.AllowableActions collectAllowableActions(CmsObject cms, CmsResource file, CmsRelation relation)
          Collects the allowable actions for a relation.
protected  org.apache.chemistry.opencmis.commons.data.ObjectData collectObjectData(CmsCmisCallContext context, CmsObject cms, CmsResource resource, CmsRelation relation, java.util.Set<java.lang.String> filter, boolean includeAllowableActions, boolean includeAcl)
          Fills in an ObjectData record.
protected  org.apache.chemistry.opencmis.commons.data.Properties collectProperties(CmsObject cms, CmsResource resource, CmsRelation relation, java.util.Set<java.lang.String> orgfilter, org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl objectInfo)
          Gathers all base properties of a file or folder.
protected static java.lang.String createKey(CmsUUID source, CmsUUID target, java.lang.String relType)
          Creates a relation id string from the source and target ids and a relation type.
protected  java.lang.String createReadableName(CmsRelation relation)
          Creates a user-readable name from the given relation object.
 void deleteObject(CmsCmisCallContext context, java.lang.String objectId, boolean allVersions)
          Deletes a CMIS object.
 org.apache.chemistry.opencmis.commons.data.Acl getAcl(CmsCmisCallContext context, java.lang.String objectId, boolean onlyBasicPermissions)
          Gets the ACL for an object.
 org.apache.chemistry.opencmis.commons.data.AllowableActions getAllowableActions(CmsCmisCallContext context, java.lang.String objectId)
          Gets the allowable actions for an object.
 org.apache.chemistry.opencmis.commons.data.ObjectData getObject(CmsCmisCallContext context, java.lang.String objectId, java.lang.String filter, boolean includeAllowableActions, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships includeRelationships, java.lang.String renditionFilter, boolean includePolicyIds, boolean includeAcl)
          Gets the data for a CMIS object.
protected static CmsRelationType getRelationType(java.lang.String typeName)
          Gets a relation type by name.
protected  CmsCmisRelationHelper.RelationKey parseRelationKey(java.lang.String id)
          Extracts the source/target ids and the type from a relation id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELATION_ID_PREFIX

public static final java.lang.String RELATION_ID_PREFIX
The prefix used to identify relation ids.

See Also:
Constant Field Values

RELATION_PATTERN

public static final java.util.regex.Pattern RELATION_PATTERN
The pattern which relation ids should match.

Constructor Detail

CmsCmisRelationHelper

public CmsCmisRelationHelper(CmsCmisRepository repository)
Creates a new relation helper for the given repository.

Parameters:
repository - the repository
Method Detail

createKey

protected static java.lang.String createKey(CmsUUID source,
                                            CmsUUID target,
                                            java.lang.String relType)
Creates a relation id string from the source and target ids and a relation type.

Parameters:
source - the source id
target - the target id
relType - the relation type
Returns:
the relation id

getRelationType

protected static CmsRelationType getRelationType(java.lang.String typeName)
Gets a relation type by name.

Parameters:
typeName - the relation type name
Returns:
the relation type with the matching name

deleteObject

public void deleteObject(CmsCmisCallContext context,
                         java.lang.String objectId,
                         boolean allVersions)
Description copied from interface: I_CmsCmisObjectHelper
Deletes a CMIS object.

Specified by:
deleteObject in interface I_CmsCmisObjectHelper
Parameters:
context - the call context
objectId - the id of the object to delete
allVersions - flag to delete all version
See Also:
I_CmsCmisObjectHelper.deleteObject(org.opencms.cmis.CmsCmisCallContext, java.lang.String, boolean)

getAcl

public org.apache.chemistry.opencmis.commons.data.Acl getAcl(CmsCmisCallContext context,
                                                             java.lang.String objectId,
                                                             boolean onlyBasicPermissions)
Description copied from interface: I_CmsCmisObjectHelper
Gets the ACL for an object.

Specified by:
getAcl in interface I_CmsCmisObjectHelper
Parameters:
context - the call context
objectId - the object id
onlyBasicPermissions - flag to only get basic permissions
Returns:
the ACL for the object
See Also:
I_CmsCmisObjectHelper.getAcl(org.opencms.cmis.CmsCmisCallContext, java.lang.String, boolean)

getAllowableActions

public org.apache.chemistry.opencmis.commons.data.AllowableActions getAllowableActions(CmsCmisCallContext context,
                                                                                       java.lang.String objectId)
Description copied from interface: I_CmsCmisObjectHelper
Gets the allowable actions for an object.

Specified by:
getAllowableActions in interface I_CmsCmisObjectHelper
Parameters:
context - the call context
objectId - the object id
Returns:
the allowable actions
See Also:
I_CmsCmisObjectHelper.getAllowableActions(org.opencms.cmis.CmsCmisCallContext, java.lang.String)

getObject

public org.apache.chemistry.opencmis.commons.data.ObjectData getObject(CmsCmisCallContext context,
                                                                       java.lang.String objectId,
                                                                       java.lang.String filter,
                                                                       boolean includeAllowableActions,
                                                                       org.apache.chemistry.opencmis.commons.enums.IncludeRelationships includeRelationships,
                                                                       java.lang.String renditionFilter,
                                                                       boolean includePolicyIds,
                                                                       boolean includeAcl)
Description copied from interface: I_CmsCmisObjectHelper
Gets the data for a CMIS object.

Specified by:
getObject in interface I_CmsCmisObjectHelper
Parameters:
context - the CMIS call context
objectId - the id of the object
filter - the property filter
includeAllowableActions - flag to include allowable actions
includeRelationships - flag to include relationships
renditionFilter - the rendition filter string
includePolicyIds - flag to include policy ids
includeAcl - flag to include ACLs
Returns:
the CMIS object data
See Also:
I_CmsCmisObjectHelper.getObject(org.opencms.cmis.CmsCmisCallContext, java.lang.String, java.lang.String, boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, boolean, boolean)

collectAcl

protected org.apache.chemistry.opencmis.commons.data.Acl collectAcl(CmsObject cms,
                                                                    CmsResource resource,
                                                                    boolean onlyBasic)
Compiles the ACL for a relation.

Parameters:
cms - the CMS context
resource - the resource for which to collect the ACLs
onlyBasic - flag to only include basic ACEs
Returns:
the ACL for the resource

collectAllowableActions

protected org.apache.chemistry.opencmis.commons.data.AllowableActions collectAllowableActions(CmsObject cms,
                                                                                              CmsResource file,
                                                                                              CmsRelation relation)
Collects the allowable actions for a relation.

Parameters:
cms - the current CMS context
file - the source of the relation
relation - the relation object
Returns:
the allowable actions for the given resource

collectObjectData

protected org.apache.chemistry.opencmis.commons.data.ObjectData collectObjectData(CmsCmisCallContext context,
                                                                                  CmsObject cms,
                                                                                  CmsResource resource,
                                                                                  CmsRelation relation,
                                                                                  java.util.Set<java.lang.String> filter,
                                                                                  boolean includeAllowableActions,
                                                                                  boolean includeAcl)
Fills in an ObjectData record.

Parameters:
context - the call context
cms - the CMS context
resource - the resource for which we want the ObjectData
relation - the relation object
filter - the property filter string
includeAllowableActions - true if the allowable actions should be included
includeAcl - true if the ACL entries should be included
Returns:
the object data

collectProperties

protected org.apache.chemistry.opencmis.commons.data.Properties collectProperties(CmsObject cms,
                                                                                  CmsResource resource,
                                                                                  CmsRelation relation,
                                                                                  java.util.Set<java.lang.String> orgfilter,
                                                                                  org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl objectInfo)
Gathers all base properties of a file or folder.

Parameters:
cms - the current CMS context
resource - the file for which we want the properties
relation - the relation object
orgfilter - the property filter
objectInfo - the object info handler
Returns:
the properties for the given resource

createReadableName

protected java.lang.String createReadableName(CmsRelation relation)
Creates a user-readable name from the given relation object.

Parameters:
relation - the relation object
Returns:
the readable name

parseRelationKey

protected CmsCmisRelationHelper.RelationKey parseRelationKey(java.lang.String id)
Extracts the source/target ids and the type from a relation id.

Parameters:
id - the relation id
Returns:
the relation key object