org.apache.chemistry.opencmis.jcr
Class JcrNode

java.lang.Object
  extended by org.apache.chemistry.opencmis.jcr.JcrNode
Direct Known Subclasses:
JcrDocument, JcrFolder

public abstract class JcrNode
extends Object

Common base class for all JCR Nodes to be represented as CMIS objects. Instances of this class are responsible for mapping from CMIS to JCR and vice versa.


Field Summary
static GregorianCalendar DATE_UNKNOWN
          Default value for cmis:createdBy and cmis:lastModifiedDate (Thu Jan 01 01:11:59 CET 1970)
protected  PathManager pathManager
           
protected  TypeManager typeManager
           
static String USER_UNKNOWN
          Default value for last cmis:createdBy and cmis:modifiedBy
 
Constructor Summary
JcrNode(javax.jcr.Node node, TypeManager typeManager, PathManager pathManager, JcrNodeFactory nodeFactory)
          Create a new instance wrapping a JCR node.
 
Method Summary
protected  void addPropertyBoolean(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, boolean value)
          Add boolean property to the CMIS object represented by this instance
protected  void addPropertyDateTime(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, GregorianCalendar value)
          Add date-time property to the CMIS object represented by this instance
protected  void addPropertyId(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, String value)
          Add Id property to the CMIS object represented by this instance
protected  void addPropertyInteger(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, long value)
          Add integer property to the CMIS object represented by this instance
protected  void addPropertyString(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props, String typeId, Set<String> filter, String id, String value)
          Add string property to the CMIS object represented by this instance
 JcrDocument asDocument()
           
 JcrFolder asFolder()
           
 JcrVersionBase asVersion()
           
protected  boolean checkAddProperty(Properties properties, String typeId, Set<String> filter, String id)
          Validate a set of properties against a filter and its definitions
protected  Set<Action> compileAllowableActions(Set<Action> aas)
          Compile the allowed actions on the CMIS object represented by this instance See CMIS 1.0 section 2.2.4.6 getAllowableActions
 ObjectData compileObjectType(Set<String> filter, Boolean includeAllowableActions, ObjectInfoHandler objectInfos, boolean requiresObjectInfo)
          Compile the ObjectData for this node
protected  void compileProperties(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl properties, Set<String> filter, org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl objectInfo)
          Compile the properties of the CMIS object represented by this instance.
protected  JcrNode create(javax.jcr.Node node)
          Factory method for creating a new JcrNode instance from a JCR Node
 void delete(boolean allVersions, boolean isPwc)
          See CMIS 1.0 section 2.2.4.14 deleteObject
 AllowableActions getAllowableActions()
          See CMIS 1.0 section 2.2.4.6 getAllowableActions
protected abstract  BaseTypeId getBaseTypeId()
           
protected static javax.jcr.version.Version getBaseVersion(javax.jcr.Node node)
          Utility function for retrieving the base version of a JCR Node.
protected  String getChangeToken()
           
protected abstract  javax.jcr.Node getContextNode()
          Retrieve the context node of the CMIS object represented by this instance.
protected  GregorianCalendar getCreated()
           
protected  String getCreatedBy()
           
 String getId()
           
protected  GregorianCalendar getLastModified()
           
protected  String getLastModifiedBy()
           
 String getName()
           
 javax.jcr.Node getNode()
           
 JcrNode getNode(String path)
          Factory method creating a new JcrNode from a node at a given JCR path.
protected  String getNodeName()
           
protected  String getObjectId()
           
 JcrFolder getParent()
          See CMIS 1.0 section 2.2.3.5 getObjectParents
protected static long getPropertyLength(javax.jcr.Node node, String propertyName)
          Utility function to retrieve the length of a property of a JCR Node.
protected static GregorianCalendar getPropertyOrElse(javax.jcr.Node node, String propertyName, GregorianCalendar defaultValue)
          Utility function for retrieving a date property from a JCR Node or a default value in case of an error.
protected static String getPropertyOrElse(javax.jcr.Node node, String propertyName, String defaultValue)
          Utility function for retrieving a string property from a JCR Node or a default value in case of an error.
 String getTypeId()
           
protected abstract  String getTypeIdInternal()
           
protected static javax.jcr.version.VersionHistory getVersionHistory(javax.jcr.Node node)
          Utility function for retrieving the version history of a JCR Node.
protected static javax.jcr.version.VersionManager getVersionManager(javax.jcr.Node node)
          Utility function for retrieving the version manager from a JCR Node.
protected  String getVersionSeriesId()
           
 boolean isDocument()
           
 boolean isFolder()
           
 boolean isRoot()
           
 boolean isVersionable()
           
 JcrNode move(JcrFolder parent)
          See CMIS 1.0 section 2.2.4.13 moveObject
protected static void setAction(Set<Action> actions, Action action, boolean condition)
          Add action to actions iff condition is true.
 String toString()
           
protected  void updateProperties(javax.jcr.Node node, String typeId, Properties properties)
          Update the properties of the CMIS object represented by this instance
 JcrNode updateProperties(Properties properties)
          See CMIS 1.0 section 2.2.4.12 updateProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USER_UNKNOWN

public static final String USER_UNKNOWN
Default value for last cmis:createdBy and cmis:modifiedBy

See Also:
Constant Field Values

DATE_UNKNOWN

public static final GregorianCalendar DATE_UNKNOWN
Default value for cmis:createdBy and cmis:lastModifiedDate (Thu Jan 01 01:11:59 CET 1970)


typeManager

protected final TypeManager typeManager

pathManager

protected final PathManager pathManager
Constructor Detail

JcrNode

public JcrNode(javax.jcr.Node node,
               TypeManager typeManager,
               PathManager pathManager,
               JcrNodeFactory nodeFactory)
Create a new instance wrapping a JCR node.

Parameters:
node - the JCR node to represent
typeManager -
pathManager -
nodeFactory -
Method Detail

getNode

public javax.jcr.Node getNode()
Returns:
the JCR node represented by this instance

getName

public String getName()
Returns:
the name of the CMIS object represented by this instance
Throws:
CmisRuntimeException

getId

public String getId()
Returns:
the id of the CMIS object represented by this instance
Throws:
CmisRuntimeException

getTypeId

public String getTypeId()
Returns:
the typeId of the CMIS object represented by this instance

isRoot

public boolean isRoot()
Returns:
true iff this instance represent the root of the CMIS folder hierarchy.

isDocument

public boolean isDocument()
Returns:
true iff this instance represents a cmis:document type

isFolder

public boolean isFolder()
Returns:
true iff this instance represents a cmis:folder type

isVersionable

public boolean isVersionable()
Returns:
true iff this instance represents a versionable CMIS object

asDocument

public JcrDocument asDocument()
Returns:
this instance as a JcrDocument
Throws:
CmisConstraintException - if this.isDocument() == false

asFolder

public JcrFolder asFolder()
Returns:
this instance as a JcrFolder
Throws:
CmisConstraintException - if this.isFolder() == false

asVersion

public JcrVersionBase asVersion()
Returns:
this instance as a JcrVersionBase
Throws:
CmisConstraintException - if this.isVersionable() == false

getNode

public JcrNode getNode(String path)
Factory method creating a new JcrNode from a node at a given JCR path.

Parameters:
path - JCR path of the node
Returns:
A new instance representing the JCR node at path
Throws:
CmisObjectNotFoundException - if path does not identify a JCR node
CmisRuntimeException

compileObjectType

public ObjectData compileObjectType(Set<String> filter,
                                    Boolean includeAllowableActions,
                                    ObjectInfoHandler objectInfos,
                                    boolean requiresObjectInfo)
Compile the ObjectData for this node


getAllowableActions

public AllowableActions getAllowableActions()
See CMIS 1.0 section 2.2.4.6 getAllowableActions


getParent

public JcrFolder getParent()
See CMIS 1.0 section 2.2.3.5 getObjectParents

Returns:
parent of this object
Throws:
CmisObjectNotFoundException - if this is the root folder
CmisRuntimeException

updateProperties

public JcrNode updateProperties(Properties properties)
See CMIS 1.0 section 2.2.4.12 updateProperties

Throws:
CmisStorageException

delete

public void delete(boolean allVersions,
                   boolean isPwc)
See CMIS 1.0 section 2.2.4.14 deleteObject

Throws:
CmisRuntimeException

move

public JcrNode move(JcrFolder parent)
See CMIS 1.0 section 2.2.4.13 moveObject

Throws:
CmisStorageException

toString

public String toString()
Overrides:
toString in class Object

getContextNode

protected abstract javax.jcr.Node getContextNode()
                                          throws javax.jcr.RepositoryException
Retrieve the context node of the CMIS object represented by this instance. The context node is the node which is used to derive the common properties from (creation date, modification date, ...)

Returns:
the context node
Throws:
javax.jcr.RepositoryException

getBaseTypeId

protected abstract BaseTypeId getBaseTypeId()
Returns:
the value of the cmis:baseTypeId property

getTypeIdInternal

protected abstract String getTypeIdInternal()
Returns:
the value of the cmis:objectTypeId property

compileProperties

protected void compileProperties(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl properties,
                                 Set<String> filter,
                                 org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl objectInfo)
                          throws javax.jcr.RepositoryException
Compile the properties of the CMIS object represented by this instance. See CMIS 1.0 section 2.2.4.7 getObject

Parameters:
properties - compilation of properties
filter -
objectInfo -
Throws:
javax.jcr.RepositoryException

compileAllowableActions

protected Set<Action> compileAllowableActions(Set<Action> aas)
Compile the allowed actions on the CMIS object represented by this instance See CMIS 1.0 section 2.2.4.6 getAllowableActions

Parameters:
aas - compilation of allowed actions
Returns:

getChangeToken

protected String getChangeToken()
                         throws javax.jcr.RepositoryException
Returns:
the change token of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

getLastModifiedBy

protected String getLastModifiedBy()
                            throws javax.jcr.RepositoryException
Returns:
the last modifier of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

getLastModified

protected GregorianCalendar getLastModified()
                                     throws javax.jcr.RepositoryException
Returns:
the last modification date of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

getCreated

protected GregorianCalendar getCreated()
                                throws javax.jcr.RepositoryException
Returns:
the creation date of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

getCreatedBy

protected String getCreatedBy()
                       throws javax.jcr.RepositoryException
Returns:
the creator of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

getNodeName

protected String getNodeName()
                      throws javax.jcr.RepositoryException
Returns:
the name of the underlying JCR node.
Throws:
javax.jcr.RepositoryException

getObjectId

protected String getObjectId()
                      throws javax.jcr.RepositoryException
Returns:
the object id of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

getVersionSeriesId

protected String getVersionSeriesId()
                             throws javax.jcr.RepositoryException
Returns:
the versions series id of the CMIS object represented by this instance
Throws:
javax.jcr.RepositoryException

create

protected final JcrNode create(javax.jcr.Node node)
Factory method for creating a new JcrNode instance from a JCR Node

Parameters:
node - the JCR Node
Returns:
a new JcrNode

addPropertyId

protected final void addPropertyId(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                   String typeId,
                                   Set<String> filter,
                                   String id,
                                   String value)
Add Id property to the CMIS object represented by this instance


addPropertyString

protected final void addPropertyString(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                       String typeId,
                                       Set<String> filter,
                                       String id,
                                       String value)
Add string property to the CMIS object represented by this instance


addPropertyInteger

protected final void addPropertyInteger(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                        String typeId,
                                        Set<String> filter,
                                        String id,
                                        long value)
Add integer property to the CMIS object represented by this instance


addPropertyBoolean

protected final void addPropertyBoolean(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                        String typeId,
                                        Set<String> filter,
                                        String id,
                                        boolean value)
Add boolean property to the CMIS object represented by this instance


addPropertyDateTime

protected final void addPropertyDateTime(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl props,
                                         String typeId,
                                         Set<String> filter,
                                         String id,
                                         GregorianCalendar value)
Add date-time property to the CMIS object represented by this instance


checkAddProperty

protected final boolean checkAddProperty(Properties properties,
                                         String typeId,
                                         Set<String> filter,
                                         String id)
Validate a set of properties against a filter and its definitions


updateProperties

protected final void updateProperties(javax.jcr.Node node,
                                      String typeId,
                                      Properties properties)
Update the properties of the CMIS object represented by this instance


getVersionHistory

protected static javax.jcr.version.VersionHistory getVersionHistory(javax.jcr.Node node)
                                                             throws javax.jcr.RepositoryException
Utility function for retrieving the version history of a JCR Node.

Parameters:
node - the node for which to retrieve the version history
Returns:
version history of node
Throws:
javax.jcr.RepositoryException - if node is not versionable

getVersionManager

protected static javax.jcr.version.VersionManager getVersionManager(javax.jcr.Node node)
                                                             throws javax.jcr.RepositoryException
Utility function for retrieving the version manager from a JCR Node.

Parameters:
node -
Returns:
Throws:
javax.jcr.RepositoryException

getBaseVersion

protected static javax.jcr.version.Version getBaseVersion(javax.jcr.Node node)
                                                   throws javax.jcr.RepositoryException
Utility function for retrieving the base version of a JCR Node.

Parameters:
node - the node for which to retrieve the base version
Returns:
version base version of node
Throws:
javax.jcr.RepositoryException - if node is not versionable

getPropertyLength

protected static long getPropertyLength(javax.jcr.Node node,
                                        String propertyName)
                                 throws javax.jcr.RepositoryException
Utility function to retrieve the length of a property of a JCR Node.

Parameters:
node -
propertyName -
Returns:
Throws:
javax.jcr.RepositoryException

getPropertyOrElse

protected static String getPropertyOrElse(javax.jcr.Node node,
                                          String propertyName,
                                          String defaultValue)
                                   throws javax.jcr.RepositoryException
Utility function for retrieving a string property from a JCR Node or a default value in case of an error.

Parameters:
node -
propertyName -
defaultValue -
Returns:
Throws:
javax.jcr.RepositoryException

getPropertyOrElse

protected static GregorianCalendar getPropertyOrElse(javax.jcr.Node node,
                                                     String propertyName,
                                                     GregorianCalendar defaultValue)
                                              throws javax.jcr.RepositoryException
Utility function for retrieving a date property from a JCR Node or a default value in case of an error.

Parameters:
node -
propertyName -
defaultValue -
Returns:
Throws:
javax.jcr.RepositoryException

setAction

protected static void setAction(Set<Action> actions,
                                Action action,
                                boolean condition)
Add action to actions iff condition is true.

Parameters:
actions -
action -
condition -


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.