Interface Node
- All Superinterfaces:
Item
- All Known Subinterfaces:
JackrabbitNode,Version,VersionHistory
- All Known Implementing Classes:
AbstractNode
Node interface represents a node in a workspace.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA constant for the node namejcr:childNodeDefinitiondeclared innt:nodeType.static final StringA constant for the JCR namejcr:content.static final StringA constant for the node namejcr:frozenNodedeclared innt:version.static final StringA constant for the node namejcr:propertyDefinitiondeclared innt:nodeType.static final StringA constant for the node namejcr:rootVersiondeclared innt:versionHistory.static final StringA constant for the node namejcr:versionLabelsdeclared innt:versionHistory. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the mixin node type namedmixinNameto this node.Creates a new node atrelPath.Creates a new node atrelPathof the specified node type.booleancanAddMixin(String mixinName) Returnstrueif callingaddMixin(java.lang.String)on this node with the mixn node typemixinNamewill not fail.voidcancelMerge(Version version) Deprecated.checkin()Deprecated.As of JCR 2.0,VersionManager.checkin(java.lang.String)should be used instead.voidcheckout()Deprecated.As of JCR 2.0,VersionManager.checkout(java.lang.String)should be used instead.voidDeprecated.As of JCR 2.0,VersionManager.doneMerge(java.lang.String, javax.jcr.version.Version)should be used instead.voidfollowLifecycleTransition(String transition) Causes the lifecycle state of this node to undergo the specifiedtransition.String[]Returns the list of valid state transitions for this node.Deprecated.As of JCR 2.0,VersionManager.getBaseVersion(java.lang.String)should be used instead.getCorrespondingNodePath(String workspaceName) Returns the absolute path of the node in the specified workspace that corresponds tothisnode.Returns the node definition that applies to this node.Returns the identifier of this node.intgetIndex()This method returns the index of this node within the ordered set of its same-name sibling nodes.getLock()Deprecated.As of JCR 2.0,LockManager.getLock(String)should be used instead.NodeType[]Returns an array ofNodeTypeobjects representing the mixin node types in effect for this node.Returns the node atrelPathrelative to this node.getNodes()Returns all child nodes of this node accessible through the currentSession.Gets all child nodes of this node accessible through the currentSessionthat matchnamePattern.Gets all child nodes of this node accessible through the currentSessionthat match one or more of thenameGlobstrings in the passed array.Returns the primary child item of this node.Returns the primary node type in effect for this node.Returns all properties of this node accessible through the currentSession.getProperties(String namePattern) Gets all properties of this node accessible through the currentSessionthat matchnamePattern.getProperties(String[] nameGlobs) Gets all properties of this node accessible through the currentSessionthat match one or more of thenameGlobstrings in the passed array.getProperty(String relPath) Returns the property atrelPathrelative tothisnode.This method returns allREFERENCEproperties that refer to this node and that are accessible through the currentSession.getReferences(String name) This method returns allREFERENCEproperties that refer to this node, have the specifiednameand that are accessible through the currentSession.Returns an iterator over all nodes that are in the shared set of this node.getUUID()Deprecated.As of JCR 2.0,getIdentifier()should be used instead.Deprecated.As of JCR 2.0,VersionManager.getVersionHistory(java.lang.String)should be used instead.This method returns allWEAKREFERENCEproperties that refer to this node and that are accessible through the currentSession.getWeakReferences(String name) This method returns allWEAKREFERENCEproperties that refer to this node, have the specifiednameand that are accessible through the currentSession.booleanIndicates whether a node exists atrelPathReturnstrueif a node accessible through the currentSessionexists atrelPathandfalseotherwise.booleanhasNodes()Indicates whether this node has child nodes.booleanIndicates whether this node has properties.booleanhasProperty(String relPath) Indicates whether a property exists atrelPathReturnstrueif a property accessible through the currentSessionexists atrelPathandfalseotherwise.booleanDeprecated.As of JCR 2.0,LockManager.holdsLock(String)should be used instead.booleanReturnsfalseif this node is currently in the checked-in state (either due to its own status as a versionable node or due to the effect of a versionable node being checked in above it).booleanisLocked()Returnstrueif this node is locked either as a result of a lock held by this node or by a deep lock on a node above this node; otherwise returnsfalse.booleanisNodeType(String nodeTypeName) Returnstrueif this node is of the specified primary node type or mixin type, or a subtype thereof.lock(boolean isDeep, boolean isSessionScoped) Deprecated.As of JCR 2.0,LockManager.lock(String, boolean, boolean, long, String)should be used instead.Deprecated.As of JCR 2.0,VersionManager.merge(java.lang.String, java.lang.String, boolean)should be used instead.voidorderBefore(String srcChildRelPath, String destChildRelPath) If this node supports child node ordering, this method inserts the child node atsrcChildRelPathinto the child node list at the position immediately the child node atdestChildRelPath.voidremoveMixin(String mixinName) Removes the specified mixin node type from this node and removesmixinNamefrom this node'sjcr:mixinTypesproperty.voidRemoves this node, but does not remove any other node in the shared set of this node.voidRemoves this node and every other node in the shared set of this node.voidDeprecated.As of JCR 2.0,VersionManager.restore(javax.jcr.version.Version[], boolean)should be used instead.voidDeprecated.As of JCR 2.0,VersionManager.restore(javax.jcr.version.Version[], boolean)should be used instead.voidDeprecated.As of JCR 2.0,VersionManager.restore(javax.jcr.version.Version[], boolean)should be used instead.voidrestoreByLabel(String versionLabel, boolean removeExisting) Deprecated.As of JCR 2.0,VersionManager.restoreByLabel(java.lang.String, java.lang.String, boolean)should be used instead.voidsetPrimaryType(String nodeTypeName) Changes the primary node type of this node tonodeTypeName.setProperty(String name, boolean value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as abooleanand, if possible, the type assigned to the property isBOOLEAN, otherwise a best-effort conversion is attempted.setProperty(String name, double value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as adoubleand, if possible, the type assigned to the property isDOUBLE, otherwise a best-effort conversion is attempted.setProperty(String name, long value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as alongand, if possible, the type assigned to the property isLONG, otherwise a best-effort conversion is attempted.setProperty(String name, InputStream value) Deprecated.As of JCR 2.0,setProperty(String, Binary)should be used instead.setProperty(String name, String value) Sets the specified single-value property to the specified value.setProperty(String name, String[] values) Sets the specified property to the specified array of values.setProperty(String name, String[] values, int type) Sets the specified property to the specified array of values and to the specified type.setProperty(String name, String value, int type) Sets the specified single-value property to the specified value.setProperty(String name, BigDecimal value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aBigDecimaland, if possible, the type assigned to the property isDECIMAL, otherwise a best-effort conversion is attempted.setProperty(String name, Calendar value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aCalendarand, if possible, the type assigned to the property isDATE, otherwise a best-effort conversion is attempted.setProperty(String name, Binary value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aBinaryand, if possible, the type assigned to the property isBINARY, otherwise a best-effort conversion is attempted.setProperty(String name, Node value) The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aNodeand, if possible, the type assigned to the property isREFERENCEorWEAKREFERENCE, otherwise a best-effort conversion is attempted.setProperty(String name, Value value) Sets the single-value property of this node callednameto the specifiedvalue.setProperty(String name, Value[] values) Sets the multi-value property of this node callednameto the specified array of values.setProperty(String name, Value[] values, int type) Sets the multi-value property of this node callednameto the specified array of values.setProperty(String name, Value value, int type) Sets the single-value property of this node callednameto the specifiedvalueand the specifiedtype.voidunlock()Deprecated.As of JCR 2.0,LockManager.unlock(String)should be used instead.voidIf this node does have a corresponding node in the workspacesrcWorkspace, then this replaces this node and its subgraph with a clone of the corresponding node and its subgraph.Methods inherited from interface javax.jcr.Item
accept, getAncestor, getDepth, getName, getParent, getPath, getSession, isModified, isNew, isNode, isSame, refresh, remove, save
-
Field Details
-
JCR_CONTENT
A constant for the JCR namejcr:content. This is the name of a child node declared innt:fileand a property declared innt:linkedFile.- Since:
- JCR 2.0
- See Also:
-
JCR_PROPERTY_DEFINITION
A constant for the node namejcr:propertyDefinitiondeclared innt:nodeType.- Since:
- JCR 2.0
- See Also:
-
JCR_CHILD_NODE_DEFINITION
A constant for the node namejcr:childNodeDefinitiondeclared innt:nodeType.- Since:
- JCR 2.0
- See Also:
-
JCR_ROOT_VERSION
A constant for the node namejcr:rootVersiondeclared innt:versionHistory.- Since:
- JCR 2.0
- See Also:
-
JCR_VERSION_LABELS
A constant for the node namejcr:versionLabelsdeclared innt:versionHistory.- Since:
- JCR 2.0
- See Also:
-
JCR_FROZEN_NODE
A constant for the node namejcr:frozenNodedeclared innt:version.- Since:
- JCR 2.0
- See Also:
-
-
Method Details
-
addNode
Node addNode(String relPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException Creates a new node atrelPath.This is session-write method, meaning that the addition of the new node is dispatch upon
Session.save().The
relPathprovided must not have an index on its final element, otherwise a RepositoryIf ordering is supported by the node type of the parent node of the new node then the new node is appended to the end of the child node list.
The new node's primary node type will be determined by the child node definitions in the node types of its parent. This may occur either immediately, on dispatch (save, whether within or without transactions) or on persist (save without transactions, commit within a transaction), depending on the implementation.
An
ItemExistsExceptionwill be thrown either immediately, on dispatch (save, whether within or without transactions) or on persist (save without transactions, commit within a transaction), if an item at the specified path already exists and same-name siblings are not allowed. Implementations may differ on when this validation is performed.A
PathNotFoundExceptionwill be thrown either immediately, on dispatch (save, whether within or without transactions) or on persist (save without transactions, commit within a transaction), if the specified path implies intermediary nodes that do not exist. Implementations may differ on when this validation is performed.A
ConstraintViolationExceptionwill be thrown either immediately, on dispatch (save, whether within or without transactions) or on persist (save without transactions, commit within a transaction), if adding the node would violate a node type or implementation-specific constraint or if an attempt is made to add a node as the child of a property. Implementations may differ on when this validation is performed.A
VersionExceptionwill be thrown either immediately, on dispatch (save, whether within or without transactions) or on persist (save without transactions, commit within a transaction), if the node to which the new child is being added is read-only due to a checked-in node. Implementations may differ on when this validation is performed.A
LockExceptionwill be thrown either immediately, on dispatch (save, whether within or without transactions) or on persist (save without transactions, commit within a transaction), if a lock prevents the addition of the node. Implementations may differ on when this validation is performed.- Parameters:
relPath- The path of the new node to be created.- Returns:
- The node that was added.
- Throws:
ItemExistsException- if an item at the specified path already exists, same-name siblings are not allowed and this implementation performs this validation immediately.PathNotFoundException- if the specified path implies intermediaryNodes that do not exist or the last element ofrelPathhas an index, and this implementation performs this validation immediately.ConstraintViolationException- if a node type or implementation-specific constraint is violated or if an attempt is made to add a node as the child of a property and this implementation performs this validation immediately.VersionException- if the node to which the new child is being added is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the addition of the node and this implementation performs this validation immediately.RepositoryException- If the last element ofrelPathhas an index or if another error occurs.
-
addNode
Node addNode(String relPath, String primaryNodeTypeName) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException Creates a new node atrelPathof the specified node type. The behavior of this method is identical toaddNode(String relPath)except that the primary node type of the new node is explicitly specified.- Parameters:
relPath- the path of the new node to be created.primaryNodeTypeName- The name of the primary node type of the new node.- Returns:
- the node that was added.
- Throws:
ItemExistsException- if an item at the specified path already exists, same-name siblings are not allowed and this implementation performs this validation immediately instead of waiting untilsave.PathNotFoundException- if the specified path implies intermediaryNodes that do not exist or the last element ofrelPathhas an index, and this implementation performs this validation immediately instead of waiting untilsave.NoSuchNodeTypeException- if the specified node type is not recognized and this implementation performs this validation immediately instead of waiting untilsave.ConstraintViolationException- if a node type or implementation-specific constraint is violated or if an attempt is made to add a node as the child of a property and this implementation performs this validation immediately instead of waiting untilsave.VersionException- if the node to which the new child is being added is read-only due to a checked-in node and this implementation performs this validation immediately instead of waiting untilsave.LockException- if a lock prevents the addition of the node and this implementation performs this validation immediately instead of waiting untilsave.RepositoryException- if the last element ofrelPathhas an index or if another error occurs.
-
orderBefore
void orderBefore(String srcChildRelPath, String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException If this node supports child node ordering, this method inserts the child node atsrcChildRelPathinto the child node list at the position immediately the child node atdestChildRelPath.To place the node
srcChildRelPathat the end of the list, adestChildRelPathofnullis used.Note that (apart from the case where
destChildRelPathisnull) both of these arguments must be relative paths of depth one, in other words they are the names of the child nodes, possibly suffixed with an index.If
srcChildRelPathanddestChildRelPathare the same, then no change is made.This is session-write method, meaning that a change made by this method is dispatched on
saveA
ConstraintViolationExceptionwill be thrown either immediately, on dispatch (save whether within or without transactions) or on persist (save without transactions, commit within a transaction), if this operation would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.A
VersionExceptionwill be thrown either immediately, on dispatch (save whether within or without transactions) or on persist (save without transactions, commit within a transaction), if this node is read-only due to it or a node above it being checked-in Implementations may differ on when this validation is performed.A
LockExceptionwill be thrown either immediately (by this method), or onsave, if a lock prevents the re-ordering. Implementations may differ on when this validation is performed.- Parameters:
srcChildRelPath- the relative path to the child node (that is, name plus possible index) to be moved in the orderingdestChildRelPath- the the relative path to the child node (that is, name plus possible index) before which the nodesrcChildRelPathwill be placed.- Throws:
UnsupportedRepositoryOperationException- if ordering is not supported on this node.ConstraintViolationException- if an implementation-specific ordering restriction is violated and this implementation performs this validation immediately.ItemNotFoundException- if either parameter is not the relative path of a child node of this node.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the re-ordering and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the single-value property of this node callednameto the specifiedvalue.If the property does not yet exist, it is created and its property type determined by the by the node type of this node. If, based on the
nameandvaluepassed, there is more than one property definition that applies, the repository chooses one definition according to some implementation-specific criteria. Once a property with namePhas been created, the behavior of a subsequentsetProperty(P,V)may differ across implementations. Some repositories may allowPto be dynamically re-bound to a different property definition (based for example, on the new value being of a different type than the original value) while other repositories may not allow such dynamic re-binding.If the property type of the supplied
Valueobject is different from that required, then a best-effort conversion is attempted.If the node type of this node does not indicate a specific property type, then the property type of the supplied
Valueobject is used and if the property already exists it assumes both the new value and new property type.Passing a
nullas the second parameter removes the property. It is equivalent to callingremoveon thePropertyobject itself.This is a session-write method, meaning that changes made through this method are dispatched on
Session.save().A
ConstraintViolationExceptionwill be thrown either immediately, on dispatch (save whether within or without transactions) or on persist (save without transactions, commit within a transaction), if the change would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.A
VersionExceptionwill be thrown either immediately, on dispatch (save whether within or without transactions) or on persist (save without transactions, commit within a transaction), if this node is read-only due to a checked-in node. Implementations may differ on when this validation is performed.A
LockExceptionwill be thrown either immediately, on dispatch (save whether within or without transactions) or on persist (save without transactions, commit within a transaction), if a lock prevents the setting of the property. Implementations may differ on when this validation is performed.- Parameters:
name- The name of a property of this nodevalue- The value to be assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- if the specified property is aDATEbut thevaluecannot be expressed in the ISO 8601-based format defined in the JCR 2.0 specification and the implementation does not support dates incompatible with that format or ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Value value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the single-value property of this node callednameto the specifiedvalueand the specifiedtype.The behavior of this method is identical to that of
setProperty(String name, Value value)except that the intended property type is explicitly specified.If the property does not yet exist, it is created. If the property already exists it assumes both the new value and the new property type.
- Parameters:
name- the name of the property to be set.value- aValueobject.type- the type of the property.- Returns:
- the
Propertyobject set, ornullif this method was used to remove a property (by setting its value tonull). - Throws:
ValueFormatException- ifvaluecannot be converted to the specified type or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the multi-value property of this node callednameto the specified array of values.If the property does not yet exist, it is created.
The behavior of this method is identical to that of
setProperty(String name, Value value)except that an array ofValueobjects is assigned instead of a singleValue.The property type of the property will be that specified by the node type of this node. If the property type of one or more of the supplied
Valueobjects is different from that required, then a best-effort conversion is attempted, according to an implemention-dependent definition of "best effort". If the conversion fails, aValueFormatExceptionis thrown.If the property is not multi-valued then a
ValueFormatExceptionis also thrown. If another error occurs, aRepositoryExceptionis thrown.If the node type of this node does not indicate a specific property type, then the property type of the supplied
Valueobjects is used and if the property already exists it assumes both the new values and the new property type.Passing a
nullas the second parameter removes the property. It is equivalent to callingremoveon thePropertyobject itself. Note that this is different from passing an array that containsnullelements. In such a case, the array is compacted by removing thenullvalues. The resulting set of values never contains a null. However, the set may be empty:N.setProperty("P", new Value[]{null})would set the property to the empty set of values.- Parameters:
name- the name of the property to be set.values- an array ofValueobjects.- Returns:
- the updated
Propertyobject. - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is not multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Value[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the multi-value property of this node callednameto the specified array of values.The behavior of this method is identical to that of
setProperty(String name, Value[] values)except that the type of the property is explicitly specified.If the property does not yet exist, it is created. The type of the property is determined by the
typeparameter specified.If the property type of one or more of the supplied
Valueobjects is different from that specified, then a best-effort conversion is attempted, according to an implemention-dependent definition of "best effort". If the conversion fails, aValueFormatExceptionis thrown.If the property already exists it assumes both the new values and the new property type.
- Parameters:
name- the name of the property to be set.values- an array ofValueobjects.type- the type of the property.- Returns:
- the updated
Propertyobject. - Throws:
ValueFormatException- if a value cannot be converted to the specified type or if the property already exists and is not multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the specified property to the specified array of values. Same assetProperty(String name, Value[] values)except that the values are specified asStringobjects instead ofValueobjects.- Parameters:
name- the name of the property to be set.values- an array ofValueobjects.- Returns:
- the updated
Propertyobject. - Throws:
ValueFormatException- if a value cannot be converted to the type of the specified property or if the property already exists and is not multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, String[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the specified property to the specified array of values and to the specified type. Same assetProperty(String name, Value[] values, int type)except that the values are specified asStringobjects instead ofValueobjects.- Parameters:
name- the name of the property to be set.values- an array ofValueobjects.type- the type of the property.- Returns:
- the updated
Propertyobject. - Throws:
ValueFormatException- if a value cannot be converted to the specified type or if the property already exists and is not multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the specified single-value property to the specified value. The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aString. and, if possible, the type assigned to the property isSTRING, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, String value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Sets the specified single-value property to the specified value. If the property does not yet exist, it is created.The behavior of this method is identical to that of
setProperty(String name, String value)except that the intended type of the property is explicitly specified by thetypeparameter.- Parameters:
name- the name of the property to be set.value- aStringobject.type- the type of the property.- Returns:
- the
Propertyobject set, ornullif this method was used to remove a property (by setting its value tonull). - Throws:
ValueFormatException- ifvaluecannot be converted to the specified type or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, InputStream value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException Deprecated.As of JCR 2.0,setProperty(String, Binary)should be used instead.The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aInputStreamand, if possible, the type assigned to the property isBINARY, otherwise a best-effort conversion is attempted.The passed stream is closed before this method returns either normally or because of an exception.
- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Binary value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aBinaryand, if possible, the type assigned to the property isBINARY, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
setProperty
Property setProperty(String name, boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as abooleanand, if possible, the type assigned to the property isBOOLEAN, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as adoubleand, if possible, the type assigned to the property isDOUBLE, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, BigDecimal value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aBigDecimaland, if possible, the type assigned to the property isDECIMAL, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
setProperty
Property setProperty(String name, long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as alongand, if possible, the type assigned to the property isLONG, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Calendar value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aCalendarand, if possible, the type assigned to the property isDATE, otherwise a best-effort conversion is attempted.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject - Throws:
ValueFormatException- if the specified property is aDATEbut thevaluecannot be expressed in the ISO 8601-based format defined in the JCR 2.0 specification (section 3.6.4.3) and the implementation does not support dates incompatible with that format or ifvaluecannot be converted to the type of the specified property or if the property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
setProperty
Property setProperty(String name, Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException The behavior of this method is identical to that ofsetProperty(String name, Value value)except that the value is specified as aNodeand, if possible, the type assigned to the property isREFERENCEorWEAKREFERENCE, otherwise a best-effort conversion is attempted.The value to which the property is set is the identifier of the passed node.
If the named property does not yet exist and the repository cannot determine whether a
REFERENCEorWEAKREFERENCEproperty is intended, then aREFERENCEproperty is created.- Parameters:
name- The name of a property of this nodevalue- The value to assigned- Returns:
- The updated
Propertyobject. - Throws:
ValueFormatException- if this property is not of typeREFERENCEorWEAKREFERENCEor the specified node is not referenceable or if the specified property already exists and is multi-valued.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the setting of the property and this implementation performs this validation immediately.ConstraintViolationException- if the change would violate a node-type or other constraint and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
getNode
Returns the node atrelPathrelative to this node.If
relPathcontains a path element that refers to a node with same-name sibling nodes without explicitly including an index using the array-style notation ([x]), then the index [1] is assumed (indexing of same name siblings begins at 1, not 0, in order to preserve compatibility with XPath).Within the scope of a single
Sessionobject, if aNodeobject has been acquired, any subsequent call ofgetNodereacquiring the same node must return aNodeobject reflecting the same state as the earlierNodeobject. Whether this object is actually the sameNodeinstance, or simply one wrapping the same state, is up to the implementation.- Parameters:
relPath- The relative path of the node to retrieve.- Returns:
- The node at
relPath. - Throws:
PathNotFoundException- if no node exists at the specified path or the currentSessiondoes not read access to the node at the specified path.RepositoryException- If another error occurs.
-
getNodes
Returns all child nodes of this node accessible through the currentSession. Does not include properties of thisNode. The same reacquisition semantics apply as withgetNode(String). If this node has no accessible child nodes, then an empty iterator is returned.- Returns:
- A
NodeIteratorover all childNodes of thisNode. - Throws:
RepositoryException- if an error occurs.
-
getNodes
Gets all child nodes of this node accessible through the currentSessionthat matchnamePattern. The pattern may be a full name or a partial name with one or more wildcard characters ("*"), or a disjunction (using the "|" character to represent logicalOR) of these. For example,N.getNodes("jcr:* | myapp:report | my doc")would return a
NodeIteratorholding all accessible child nodes ofNthat are either called 'myapp:report', begin with the prefix 'jcr:' or are called 'my doc'.The substrings within the pattern that are delimited by "
|" characters and which may contain wildcard characters ("*") are called globs.Note that leading and trailing whitespace around a glob is ignored, but whitespace within a disjunct forms part of the pattern to be matched.
The pattern is matched against the names (not the paths) of the immediate child nodes of this node.
If this node has no accessible matching child nodes, then an empty iterator is returned.
The same reacquisition semantics apply as with
.getNode(String)- Parameters:
namePattern- a name pattern.- Returns:
- a
NodeIterator. - Throws:
RepositoryException- if an unexpected error occurs.
-
getNodes
Gets all child nodes of this node accessible through the currentSessionthat match one or more of thenameGlobstrings in the passed array.A glob may be a full name or a partial name with one or more wildcard characters ("
*"). For example,N.getNodes(new String[] {"jcr:*", "myapp:report", "my doc"})would return a
NodeIteratorholding all accessible child nodes ofNthat are either called 'myapp:report', begin with the prefix 'jcr:' or are called 'my doc'.Note that unlike in the case of the
getNodes(String)leading and trailing whitespace around a glob is not ignored.The globs are matched against the names (not the paths) of the immediate child nodes of this node.
If this node has no accessible matching child nodes, then an empty iterator is returned.
The same reacquisition semantics apply as with
.getNode(String)- Parameters:
nameGlobs- an array of globbing strings.- Returns:
- a
NodeIterator. - Throws:
RepositoryException- if an unexpected error occurs.- Since:
- JCR 2.0
-
getProperty
Returns the property atrelPathrelative tothisnode. The same reacquisition semantics apply as with.getNode(String)- Parameters:
relPath- The relative path of the property to retrieve.- Returns:
- The property at
relPath. - Throws:
PathNotFoundException- if no property exists at the specified path or if the currentSessiondoes not have read access to the specified property.RepositoryException- If another error occurs.
-
getProperties
Returns all properties of this node accessible through the currentSession. Does not include child nodes of this node. The same reacquisition semantics apply as with. If this node has no accessible properties, then an empty iterator is returned.getNode(String)- Returns:
- A
PropertyIterator. - Throws:
RepositoryException- if an error occurs.
-
getProperties
Gets all properties of this node accessible through the currentSessionthat matchnamePattern. The pattern may be a full name or a partial name with one or more wildcard characters ("*"), or a disjunction (using the "|" character to represent logicalOR) of these. For example,N.getProperties("jcr:* | myapp:name | my doc")would return a
PropertyIteratorholding all accessible properties ofNthat are either called 'myapp:name', begin with the prefix 'jcr:' or are called 'my doc'.The substrings within the pattern that are delimited by "
|" characters and which may contain wildcard characters ("*") are called globs.Note that leading and trailing whitespace around a glob is ignored, but whitespace within a disjunct forms part of the pattern to be matched.
The pattern is matched against the names (not the paths) of the immediate child properties of this node.
If this node has no accessible matching properties, then an empty iterator is returned.
The same reacquisition semantics apply as with
.getNode(String)- Parameters:
namePattern- a name pattern.- Returns:
- a
PropertyIterator. - Throws:
RepositoryException- if an unexpected error occurs.
-
getProperties
Gets all properties of this node accessible through the currentSessionthat match one or more of thenameGlobstrings in the passed array.A glob may be a full name or a partial name with one or more wildcard characters ("
*"). For example,N.getProperties(new String[] {"jcr:*", "myapp:report", "my doc"})would return a
PropertyIteratorholding all accessible properties ofNthat are either called 'myapp:report', begin with the prefix 'jcr:' or are called 'my doc'.Note that unlike in the case of the
getProperties(String)leading and trailing whitespace around a glob is not ignored.The globs are matched against the names (not the paths) of the properties of this node.
If this node has no accessible matching properties, then an empty iterator is returned.
The same reacquisition semantics apply as with
.getProperty(String)- Parameters:
nameGlobs- an array of globbing strings.- Returns:
- a
PropertyIterator. - Throws:
RepositoryException- if an unexpected error occurs.- Since:
- JCR 2.0
-
getPrimaryItem
Returns the primary child item of this node. The primary node type of this node may specify one child item (child node or property) of this node as the primary child item. This method returns that item.In cases where the primary child item specifies the name of a set same-name sibling child nodes, the node returned will be the one among the same-name siblings with index [1].
The same reacquisition semantics apply as with
.getNode(String)- Returns:
- the primary child item.
- Throws:
ItemNotFoundException- if this node does not have a primary child item, either because none is declared in the node type or because a declared primary item is not present on this node instance, or because none is accessible through the currentSession.RepositoryException- if another error occurs.
-
getUUID
Deprecated.As of JCR 2.0,getIdentifier()should be used instead.Returns the UUID of this node as recorded in this node'sjcr:uuidproperty. This method only works on nodes of mixin node typemix:referenceable.On nonreferenceable nodes, this method throws an
UnsupportedRepositoryOperationException. To avoid throwing an exception to determine whether a node has a UUID, a call toisNodeType("mix:referenceable")can be made.- Returns:
- the UUID of this node.
- Throws:
UnsupportedRepositoryOperationException- if this node nonreferenceable.RepositoryException- if another error occurs.
-
getIdentifier
Returns the identifier of this node. Applies to both referenceable and non-referenceable nodes.A
RepositoryExceptionis thrown if an error occurs.- Returns:
- the identifier of this node.
- Throws:
RepositoryException- if an error occurs.- Since:
- JCR 2.0
-
getIndex
This method returns the index of this node within the ordered set of its same-name sibling nodes. This index is the one used to address same-name siblings using the square-bracket notation, e.g.,/a[3]/b[4]. Note that the index always starts at 1 (not 0), for compatibility with XPath. As a result, for nodes that do not have same-name-siblings, this method will always return 1.- Returns:
- The index of this node within the ordered set of its same-name sibling nodes.
- Throws:
RepositoryException- if an error occurs.
-
getReferences
This method returns allREFERENCEproperties that refer to this node and that are accessible through the currentSession. Equivalent toNode.getReferences(null).If this node has no referring
REFERENCEproperties, an empty iterator is returned. This includes the case where this node is not referenceable.- Returns:
- A
PropertyIterator. - Throws:
RepositoryException- if an error occurs.
-
getReferences
This method returns allREFERENCEproperties that refer to this node, have the specifiednameand that are accessible through the currentSession.If the
nameparameter isnullthen all referringREFERENCESare returned regardless of name.Some implementations may only return properties that have been persisted. Some may return both properties that have been persisted and those that have been dispatched but not persisted (for example, those saved within a transaction but not yet committed) while others implementations may return these two categories of property as well as properties that are still pending and not yet dispatched.
In implementations that support versioning, this method does not return properties that are part of the frozen state of a version in version storage.
If this node has no referring
REFERENCEproperties with the specified name, an empty iterator is returned. This includes the case where this node is not referenceable.- Parameters:
name- name of referringREFERENCEproperties to be returned; ifnullthen all referringREFERENCEs are returned.- Returns:
- A
PropertyIterator. - Throws:
RepositoryException- if an error occurs.- Since:
- JCR 2.0
-
getWeakReferences
This method returns allWEAKREFERENCEproperties that refer to this node and that are accessible through the currentSession. Equivalent toNode.getWeakReferences(null).If this node has no referring
WEAKREFERENCEproperties, an empty iterator is returned. This includes the case where this node is not referenceable.- Returns:
- A
PropertyIterator. - Throws:
RepositoryException- if an error occurs.- Since:
- JCR 2.0
-
getWeakReferences
This method returns allWEAKREFERENCEproperties that refer to this node, have the specifiednameand that are accessible through the currentSession.If the
nameparameter isnullthen all referringWEAKREFERENCEare returned regardless of name.Some implementations may only return properties that have been persisted. Some may return both properties that have been persisted and those that have been dispatched but not persisted (for example, those saved within a transaction but not yet committed) while others implementations may return these two categories of property as well as properties that are still pending and not yet dispatched.
In implementations that support versioning, this method does not return properties that are part of the frozen state of a version in version storage.
If this node has no referring
WEAKREFERENCEproperties with the specified name, an empty iterator is returned. This includes the case where this node is not referenceable.- Parameters:
name- name of referringWEAKREFERENCEproperties to be returned; ifnullthen all referringWEAKREFERENCEs are returned.- Returns:
- A
PropertyIterator. - Throws:
RepositoryException- if an error occurs.- Since:
- JCR 2.0
-
hasNode
Indicates whether a node exists atrelPathReturnstrueif a node accessible through the currentSessionexists atrelPathandfalseotherwise.- Parameters:
relPath- The path of a (possible) node.- Returns:
trueif a node exists atrelPath;falseotherwise.- Throws:
RepositoryException- if an error occurs.
-
hasProperty
Indicates whether a property exists atrelPathReturnstrueif a property accessible through the currentSessionexists atrelPathandfalseotherwise.- Parameters:
relPath- The path of a (possible) property.- Returns:
trueif a property exists atrelPath;falseotherwise.- Throws:
RepositoryException- if an error occurs.
-
hasNodes
Indicates whether this node has child nodes. Returnstrueif this node has one or more child nodes accessible through the currentSession;falseotherwise.- Returns:
trueif this node has one or more child nodes;falseotherwise.- Throws:
RepositoryException- if an error occurs.
-
hasProperties
Indicates whether this node has properties. Returnstrueif this node has one or more properties accessible through the currentSession;falseotherwise.- Returns:
trueif this node has one or more properties;falseotherwise.- Throws:
RepositoryException- if an error occurs.
-
getPrimaryNodeType
Returns the primary node type in effect for this node. WhichNodeTypeis returned when this method is called on the root node of a workspace is up to the implementation.- Returns:
- a
NodeTypeobject. - Throws:
RepositoryException- if an error occurs
-
getMixinNodeTypes
Returns an array ofNodeTypeobjects representing the mixin node types in effect for this node. This includes only those mixin types explicitly assigned to this node. It does not include mixin types inherited through the addition of supertypes to the primary type hierarchy or through the addition of supertypes to the type hierarchy of any of the declared mixin types.- Returns:
- an array of
NodeTypeobjects. - Throws:
RepositoryException- if an error occurs
-
isNodeType
Returnstrueif this node is of the specified primary node type or mixin type, or a subtype thereof. Returnsfalseotherwise.This method respects the effective node type of the node.
- Parameters:
nodeTypeName- the name of a node type.- Returns:
trueIf this node is of the specified primary node type or mixin type, or a subtype thereof. Returnsfalseotherwise.- Throws:
RepositoryException- if an error occurs.
-
setPrimaryType
void setPrimaryType(String nodeTypeName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException Changes the primary node type of this node tonodeTypeName. Also immediately changes this node'sjcr:primaryTypeproperty appropriately. Semantically, the new node type may take effect immediately or on dispatch but must take effect on persist. The behavior adopted must be the same as the behavior adopted foraddMixin(java.lang.String)and the behavior that occurs when a node is first created.If the presence of an existing property or child node would cause an incompatibility with the new node type then a
ConstraintViolationExceptionis thrown either immediately, on dispatch or on persist.If the new node type would cause this node to be incompatible with the node type of its parent then a
ConstraintViolationExceptionis thrown either immediately, on dispatch or on persist.A
ConstraintViolationExceptionis also thrown either immediately, on dispatch or on persist if a conflict with an already assigned mixin occurs.A
ConstraintViolationExceptionmay also be thrown either immediately , on dispatch or on persist if the attempted change violates implementation-specific node type transition rules. A repository that disallows all primary node type changes would simple throw this exception in all cases.If the specified node type is not recognized a
NoSuchNodeTypeExceptionis thrown either immediately, on dispatch or on persist.A
VersionExceptionis thrown either immediately , on dispatch or on persist if this node is read-only dues to a check-in.A
LockExceptionis thrown either immediately, on dispatch or on persist if a lock prevents the change of node type.- Parameters:
nodeTypeName- the name of the new node type.- Throws:
ConstraintViolationException- if the specified primary node type creates a type conflict and this implementation performs this validation immediately.NoSuchNodeTypeException- If the specifiednodeTypeNameis not recognized and this implementation performs this validation immediately.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the change of the primary node type and this implementation performs this validation immediately.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
addMixin
void addMixin(String mixinName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException Adds the mixin node type namedmixinNameto this node. If this node is already of typemixinName(either due to a previously added mixin or due to its primary type, through inheritance) then this method has no effect. OtherwisemixinNameis added to this node'sjcr:mixinTypesproperty.Semantically, the new node type may take effect immediately, on dispatch or on persist. The behavior adopted must be the same as the behavior adopted for
setPrimaryType(java.lang.String)and the behavior that occurs when a node is first created.A
ConstraintViolationExceptionis thrown either immediately, on dispatch or on persist, if a conflict with another assigned mixin or the primary node type or for an implementation-specific reason. Implementations may differ on when this validation is done.In some implementations it may only be possible to add mixin types before a a node is persisted for the first time. I such cases any later calls to
addMixinwill throw aConstraintViolationExceptioneither immediately, on dispatch or on persist.A
NoSuchNodeTypeExceptionis thrown either immediately, on dispatch or on persist, if the specifiedmixinNameis not recognized. Implementations may differ on when this validation is done.A
VersionExceptionis thrown either immediately, on dispatch or on persist, if this node is read-only due to a checked-in node. Implementations may differ on when this validation is done.A
LockExceptionis thrown either immediately, on dispatch or on persist, if a lock prevents the addition of the mixin. Implementations may differ on when this validation is done.- Parameters:
mixinName- the name of the mixin node type to be added- Throws:
NoSuchNodeTypeException- If the specifiedmixinNameis not recognized and this implementation performs this validation immediately.ConstraintViolationException- if the specified mixin node type creates a conflict and this implementation performs this validation immediately.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the addition of the mixin and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
removeMixin
void removeMixin(String mixinName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException Removes the specified mixin node type from this node and removesmixinNamefrom this node'sjcr:mixinTypesproperty. Both the semantic change in effective node type and the persistence of the change to thejcr:mixinTypesproperty occur on persist.If this node does not have the specified mixin, a
NoSuchNodeTypeExceptionis thrown either immediately, on dispatch or on persist. Implementations may differ on when this validation is done.A
ConstraintViolationExceptionwill be thrown either immediately, on dispatch or on persist, if the removal of a mixin is not allowed. Implementations are free to enforce any policy with regard to mixin removal and may differ on when this validation is done.A
VersionExceptionis thrown either immediately, on dispatch or on persist, if this node is read-only due to a checked-in node. Implementations may differ on when this validation is done.A
LockExceptionis thrown either immediately or onsaveif a lock prevents the removal of the mixin. Implementations may differ on when this validation is done.- Parameters:
mixinName- the name of the mixin node type to be removed.- Throws:
NoSuchNodeTypeException- if the specifiedmixinNameis not currently assigned to this node and this implementation performs this validation immediately.ConstraintViolationException- if the specified mixin node type is prevented from being removed and this implementation performs this validation immediately.VersionException- if this node is read-only due to a checked-in node and this implementation performs this validation immediately.LockException- if a lock prevents the removal of the mixin and this implementation performs this validation immediately.RepositoryException- if another error occurs.
-
canAddMixin
Returnstrueif callingaddMixin(java.lang.String)on this node with the mixn node typemixinNamewill not fail. Returnsfalseotherwise.- Parameters:
mixinName- The name of the mixin to be tested.- Returns:
trueif addMixin will not fail when called on this node with the specifiedmixinName;falseotherwise.- Throws:
NoSuchNodeTypeException- if the specified mixin node type name is not recognized.RepositoryException- if another error occurs.
-
getDefinition
Returns the node definition that applies to this node. In some cases there may appear to be more than one definition that could apply to this node. However, it is assumed that upon creation of this node, a single particular definition was used and it is that definition that this method returns. How this governing definition is selected upon node creation from among others which may have been applicable is an implementation issue and is not covered by this specification. TheNodeDefinitionreturned when this method is called on the root node of a workspace is also up to the implementation.- Returns:
- a
NodeDefinitionobject. - Throws:
RepositoryException- if an error occurs.- See Also:
-
checkin
Version checkin() throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryExceptionDeprecated.As of JCR 2.0,VersionManager.checkin(java.lang.String)should be used instead.Creates a new version of this node and returns thatVersionobject. The new version becomes the base version of this node. The name of the new version is implementaion determined.This node becomes checked-in and its
jcr:checkedOutproperty is set to false to reflect this. On a successful check-in the change to this property is made as a workspace-write, and therefore does not require asave.The part of the subgraph of this node that is affected by check-in becomes read-only (see the specification for details).
If this node is already checked-in, this method has no effect but returns the current base version of this node.
- Returns:
- the created version.
- Throws:
VersionException- if a child item of this node has anOnParentVersionstatus ofABORT. This includes the case (under full versioning) where an unresolved merge failure exists on this node, as indicated by the presence of ajcr:mergeFailedproperty. Under full versioning this exception is also thrown if the invalid input: '<'jcr:predecessors property of the node has no values.UnsupportedRepositoryOperationException- if this node is not versionable.InvalidItemStateException- if unsaved changes exist on this node.LockException- If a lock prevents the operation.RepositoryException- If another error occurs.
-
checkout
void checkout() throws UnsupportedRepositoryOperationException, LockException, ActivityViolationException, RepositoryExceptionDeprecated.As of JCR 2.0,VersionManager.checkout(java.lang.String)should be used instead.Sets this versionable node to checked-out status by setting itsjcr:isCheckedOutproperty totrue. Under full versioning it also sets thejcr:predecessorsproperty to be a reference to the current base version (the same value as held injcr:baseVersion). These changes are made by worksapce-write and therefore do require asave.The part of the subgraph of this node that is affected by the checked-out status of this node becomes no longer read-only.
If this node is already checked-out, this method has no effect.
- Throws:
UnsupportedRepositoryOperationException- if this node is not versionable.LockException- if a lock prevents the checkout.ActivityViolationException- if the checkout conflicts with the activity present on the current session.RepositoryException- if another error occurs.
-
doneMerge
void doneMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.doneMerge(java.lang.String, javax.jcr.version.Version)should be used instead.Support for this method is only required under full versioning.Completes the merge process with respect to this node and the specified
version.When the
merge(java.lang.String, boolean)method is called on a node, every versionable node in that subgraph is compared with its corresponding node in the indicated other workspace and a "merge test result" is determined indicating one of the following:- This node will be updated to the state of its correspondee (if the base version of the correspondee is more recent in terms of version history).
- This node will be left alone (if this node's base version is more recent in terms of version history).
- This node will be marked as having failed the merge test (if this node's base version is on a different branch of the version history from the base version of its corresponding node in the other workspace, thus preventing an automatic determination of which is more recent).
merge(java.lang.String, boolean)for more details)In the last case the merging of the subgraph of the versionable node in question must be done by the application (for example, by providing a merge tool for the user).
Additionally, once the subgraphs of the nodes has been merged, their version graph branches must also be merged. The JCR versioning system provides for this by keeping a record, for each versionable node that fails the merge test, of the base version of the corresponding node that caused the merge failure. This record is kept in the
jcr:mergeFailedproperty of this node. After amerge, this property will contain one or more (if multiple merges have been performed)REFERENCEs that point to the "failed versions".To complete the merge process, the client calls
doneMerge(Version v)passing the version object referred to be thejcr:mergeFailedproperty that the client wishes to connect tothisnode in the version graph. This has the effect of moving the reference to the indicated version from thejcr:mergeFailedproperty ofthisnode to thejcr:predecessors.If the client chooses not to connect this node to a particular version referenced in the
jcr:mergeFailedproperty, he callscancelMerge(Version version). This has the effect of removing the reference to the specifiedversionfromjcr:mergeFailedwithout adding it tojcr:predecessors.Once the last reference in
jcr:mergeFailedhas been either moved tojcr:predecessors(withdoneMerge) or just removed fromjcr:mergeFailed(withcancelMerge) thejcr:mergeFailedproperty is automatically removed, thus enablingthisnode to be checked-in, creating a new version (note that before thejcr:mergeFailedis removed, itsOnParentVersionsetting ofABORTprevents checkin). This new version will have a predecessor connection to each version for whichdoneMergewas called, thus joining those branches of the version graph.If successful, these changes are persisted immediately, there is no need to call
save.- Parameters:
version- a version referred to by this node'sjcr:mergeFailedproperty.- Throws:
VersionException- if the version specifed is not among those referenced in this node'sjcr:mergeFailedor if this node is currently checked-in.InvalidItemStateException- if there are unsaved changes pending on this node.UnsupportedRepositoryOperationException- if this node is not versionable.RepositoryException- if another error occurs.
-
cancelMerge
void cancelMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.cancelMerge(java.lang.String, javax.jcr.version.Version)should be used instead.Support for this method is only required under full versioning.Cancels the merge process with respect to this node and specified
version.See
doneMerge(javax.jcr.version.Version)for a full explanation. Also seemerge(java.lang.String, boolean)for more details.If successful, these changes are persisted immediately, there is no need to call
save.- Parameters:
version- a version referred to by this node'sjcr:mergeFailedproperty.- Throws:
VersionException- if the version specified is not among those referenced in this node'sjcr:mergeFailedor if this node is currently checked-in.InvalidItemStateException- if there are unsaved changes pending on this node.UnsupportedRepositoryOperationException- if this node is not versionable.RepositoryException- if another error occurs.
-
update
void update(String srcWorkspace) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException If this node does have a corresponding node in the workspacesrcWorkspace, then this replaces this node and its subgraph with a clone of the corresponding node and its subgraph.If this node does not have a corresponding node in the workspace
srcWorkspace, then theupdatemethod has no effect.If the
updatesucceeds the changes made are persisted immediately, there is no need to callsave.Note that
updatedoes not respect the checked-in status of nodes. Anupdatemay change a node even if it is currently checked-in (This fact is only relevant in an implementation that supports versioning).- Parameters:
srcWorkspace- the name of the source workspace.- Throws:
NoSuchWorkspaceException- IfsrcWorkspacedoes not exist.InvalidItemStateException- if thisSession(not necessarily thisNode) has pending unsaved changes.AccessDeniedException- If the current session does not have sufficent access to perform the operation.LockException- if a lock prevents the update.RepositoryException- If another error occurs.
-
merge
NodeIterator merge(String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.merge(java.lang.String, java.lang.String, boolean)should be used instead.Support for this method is only required under full versioning.This method can be thought of as a version-sensitive update.
It recursively tests each versionable node in the subgraph of this node against its corresponding node in
srcWorkspacewith respect to the relation between their respective base versions and either updates the node in question or not, depending on the outcome of the test.A
MergeExceptionis thrown ifbestEffortisfalseand a versionable node is encountered whose corresponding node's base version is on a divergent branch from this node's base version.If successful, the changes are persisted immediately, there is no need to call
save.This method returns a
NodeIteratorover all versionable nodes in the subgraph that received a merge result of fail. IfbestEffortisfalse, this iterator will be empty (since ifmergereturns successfully, instead of throwing an exception, it will be because no failures were encountered). IfbestEffortistrue, this iterator will contain all nodes that received a fail during the course of thismergeoperation.- Parameters:
srcWorkspace- the name of the source workspace.bestEffort- a boolean- Returns:
- iterator over all nodes that received a merge result of "fail" in the course of this operation.
- Throws:
MergeException- ifbestEffortisfalseand a failed merge result is encountered.InvalidItemStateException- if this session (not necessarily thisnode) has pending unsaved changes.NoSuchWorkspaceException- if the specifiedsrcWorkspacedoes not exist.AccessDeniedException- if the current session does not have sufficient rights to perform the operation.LockException- if a lock prevents the merge.RepositoryException- if another error occurs.
-
getCorrespondingNodePath
String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException Returns the absolute path of the node in the specified workspace that corresponds tothisnode.- Parameters:
workspaceName- the name of the workspace.- Returns:
- the absolute path to the corresponding node.
- Throws:
ItemNotFoundException- if no corresponding node is found.NoSuchWorkspaceException- if the workspace is unknown.AccessDeniedException- if the currentsessionhas insufficent access capabilities to perform this operation.RepositoryException- if another error occurs.
-
isCheckedOut
Returnsfalseif this node is currently in the checked-in state (either due to its own status as a versionable node or due to the effect of a versionable node being checked in above it). Otherwise this method returnstrue. This includes the case where the repository does not support versioning (and therefore all nodes are always "checked-out", by default).- Returns:
- a boolean
- Throws:
RepositoryException- if an error occurs.
-
restore
void restore(String versionName, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.restore(javax.jcr.version.Version[], boolean)should be used instead.Restoresthisnode to the state defined by the version with the specifiedversionName.This method will work regardless of whether this node is checked-in or not.
An identifier collision occurs when a node exists outside the subgraph rooted at this node with the same identifier as a node that would be introduced by the
restoreoperation into the subgraph at this node. The result in such a case is governed by theremoveExistingflag. IfremoveExistingistrue, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise aRepositoryExceptionis thrown). IfremoveExistingisfalse, then aItemExistsExceptionis thrown and no changes are made. Note that this applies not only to cases where the restored node itself conflicts with an existing node but also to cases where a conflict occurs with any node that would be introduced into the workspace by the restore operation. In particular, conflicts involving subnodes of the restored node that haveOnParentVersionsettings ofCOPYorVERSIONare also governed by theremoveExistingflag.- Parameters:
versionName- aVersionobjectremoveExisting- a boolean flag that governs what happens in case of an identifier collision.- Throws:
UnsupportedRepositoryOperationException- if this node is not versionable.VersionException- if the specifiedversionis not part of this node's version history or if an attempt is made to restore the root version (jcr:rootVersion).ItemExistsException- ifremoveExistingisfalseand an identifier collision occurs.LockException- if a lock prevents the restore.InvalidItemStateException- if thisSession(not necessarily thisNode) has pending unsaved changes.RepositoryException- If another error occurs.
-
restore
void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException, InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.restore(javax.jcr.version.Version[], boolean)should be used instead.Restoresthisnode to the state defined by the specifiedversion.If successful, the change is persisted immediately and there is no need to call
save.This method will work regardless of whether this node is checked-in or not.
An identifier collision occurs when a node exists outside the subgraph rooted at this node with the same identifier as a node that would be introduced by the
restoreoperation into the subgraph at this node. The result in such a case is governed by theremoveExistingflag. IfremoveExistingistrue, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise aRepositoryExceptionis thrown). IfremoveExistingisfalse, then aItemExistsExceptionis thrown and no changes are made. Note that this applies not only to cases where the restored node itself conflicts with an existing node but also to cases where a conflict occurs with any node that would be introduced into the workspace by the restore operation. In particular, conflicts involving subnodes of the restored node that haveOnParentVersionsettings ofCOPYorVERSIONare also governed by theremoveExistingflag.- Parameters:
version- aVersionobjectremoveExisting- a boolean flag that governs what happens in case of an identifier collision.- Throws:
UnsupportedRepositoryOperationException- if this node is not versionable.VersionException- if the specifiedversionis not part of this node's version history or if an attempt is made to restore the root version (jcr:rootVersion).ItemExistsException- ifremoveExistingisfalseand an identifier collision occurs.InvalidItemStateException- if thisSession(not necessarily thisNode) has pending unsaved changes.LockException- if a lock prevents the restore.RepositoryException- if another error occurs.
-
restore
void restore(Version version, String relPath, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.restore(javax.jcr.version.Version[], boolean)should be used instead.Restores the specified version torelPath, relative to this node.If the
restoresucceeds, the changes made to this node are persisted immediately, there is no need to callsave.A node need not exist at relPath, though the parent of
relPathmust exist.If a node does exist at relPath then it must correspond to the version being restored (the version must be a version of that node) and must not be a root version (
jcr:rootVersion), otherwise aVersionExceptionis thrown.If no node exists at
relPaththen aVersionExceptionis thrown if the parent node ofrelPathis read-only due to a check-in. However, If there is a node atrelPaththen the read-only status of that node itself and the read-only status of its parent are irrelevant. The restore will work even if one or both are read-only due to a checked-in node.An identifier collision occurs when a node exists outside the subgraph rooted at
relPathwith the same identifier as a node that would be introduced by therestoreoperation into the subgraph atrelPath(Note that in cases where there is no node atrelPath, this amounts to saying that an identifier collision occurs if there exists a node anywhere in this workspace with the same identifier as a node that would be introduced by therestore). The result in such a case is governed by theremoveExistingflag. IfremoveExistingistrue, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise aRepositoryExceptionis thrown). IfremoveExistingisfalse, then aItemExistsExceptionis thrown and no changes are made. Note that this applies not only to cases where the restored node itself conflicts with an existing node but also to cases where a conflict occurs with any node that would be introduced into the workspace by the restore operation. In particular, conflicts involving subnodes of the restored node that haveOnParentVersionsettings ofCOPYorVERSIONare also governed by theremoveExistingflag.- Parameters:
version- a version objectrelPath- the path to which the version is to be restoredremoveExisting- governs what happens on identifier collision.- Throws:
PathNotFoundException- if the parent ofrelPathdoes not exist.ItemExistsException- if removeExisting is false and an identifier collision occursConstraintViolationException- if the would-be parent of the locationrelPathis actually a property, or if a node type restriction would be violatedVersionException- if the parent node ofrelPathis read-only due to a checked-in node or if a node exists at relPath that is not the node corresponding to the specifiedversionor if an attempt is made to restore the root version (jcr:rootVersion).UnsupportedRepositoryOperationException- if versioning is not supported.LockException- if a lock prevents the restore.InvalidItemStateException- if thisSession(not necessarily thisNode) has pending unsaved changes.RepositoryException- if another error occurs
-
restoreByLabel
void restoreByLabel(String versionLabel, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException Deprecated.As of JCR 2.0,VersionManager.restoreByLabel(java.lang.String, java.lang.String, boolean)should be used instead.Restores the version of this node with the specified version label.If successful, the change is persisted immediately and there is no need to call
save.This method will work regardless of whether this node is checked-in or not.
An identifier collision occurs when a node exists outside the subgraph rooted at this node with the same identifier as a node that would be introduced by the
restoreByLabeloperation into the subgraph at this node. The result in such a case is governed by theremoveExistingflag. IfremoveExistingistrue, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise aRepositoryExceptionis thrown). IfremoveExistingisfalse, then aItemExistsExceptionis thrown and no changes are made. Note that this applies not only to cases where the restored node itself conflicts with an existing node but also to cases where a conflict occurs with any node that would be introduced into the workspace by the restore operation. In particular, conflicts involving subnodes of the restored node that haveOnParentVersionsettings ofCOPYorVERSIONare also governed by theremoveExistingflag.Note the special behavior in case of chained versions where a child node of this node has an on
OnParentVersionsettings ofVERSIONand is mix:versionable: If there is a version of the child node with the specified label, then that version is restored; otherwise the determination depends on the configuration of the workspace and is defined by the implementation.- Parameters:
versionLabel- a StringremoveExisting- a boolean flag that governs what happens in case of an identifier collision.- Throws:
UnsupportedRepositoryOperationException- if this node is not versionable.VersionException- if the specifiedversionLabeldoes not exist in this node's version history.ItemExistsException- ifremoveExistingisfalseand an identifier collision occurs.LockException- if a lock prevents the restore.InvalidItemStateException- if thisSession(not necessarily thisNode) has pending unsaved changes.RepositoryException- If another error occurs.
-
getVersionHistory
VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryExceptionDeprecated.As of JCR 2.0,VersionManager.getVersionHistory(java.lang.String)should be used instead.Returns theVersionHistoryobject of this node. Under full versioning this object provides access to thent:versionHistorynode holding this node's versions.- Returns:
- a
VersionHistoryobject - Throws:
UnsupportedRepositoryOperationException- if this node is not versionable.RepositoryException- if another error occurs.
-
getBaseVersion
Deprecated.As of JCR 2.0,VersionManager.getBaseVersion(java.lang.String)should be used instead.Returns the current base version of this versionable node.- Returns:
- a
Versionobject. - Throws:
UnsupportedRepositoryOperationException- if this node is not versionable.RepositoryException- if another error occurs.
-
lock
Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException Deprecated.As of JCR 2.0,LockManager.lock(String, boolean, boolean, long, String)should be used instead.Places a lock on this node. If successful, this node is said to hold the lock.If
isDeepistruethen the lock applies to this node and all its descendant nodes; iffalse, the lock applies only to this, the holding node.If
isSessionScopedistruethen this lock will expire upon the expiration of the current session (either through an automatic or explicitSession.logout); iffalse, this lock does not expire until explicitly unlocked or automatically unlocked due to a implementation-specific limitation, such as a timeout.Returns a
Lockobject reflecting the state of the new lock.If the lock is open-scoped the returned lock will include a lock token.
The lock token is also automatically added to the set of lock tokens held by the current
Session.If successful, then the property
jcr:lockOwneris created and set to the value ofSession.getUserIDfor the current session and the propertyjcr:lockIsDeepis set to the value passed in asisDeep. These changes are persisted automatically; there is no need to callsave.Note that it is possible to lock a node even if it is checked-in (the lock-related properties will be changed despite the checked-in status).
- Parameters:
isDeep- iftruethis lock will apply to this node and all its descendants; iffalse, it applies only to this node.isSessionScoped- iftrue, this lock expires with the current session; iffalseit expires when explicitly or automatically unlocked for some other reason.- Returns:
- A
Lockobject containing a lock token. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support locking.LockException- if this node is notmix:lockableor this node is already locked orisDeepistrueand a descendant node of this node already holds a lock or if this node has not yet been persisted.AccessDeniedException- if this session does not have sufficient access capabilities to lock this node.InvalidItemStateException- if this node has pending unsaved changes.RepositoryException- if another error occurs.
-
getLock
Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryExceptionDeprecated.As of JCR 2.0,LockManager.getLock(String)should be used instead.Returns theLockobject that applies to this node. This may be either a lock on this node itself or a deep lock on a node above this node.- Returns:
- The applicable
Lockobject. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support locking.LockException- if no lock applies to this node.AccessDeniedException- if the curent session does not have sufficent access to get the lock.RepositoryException- if another error occurs.
-
unlock
void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryExceptionDeprecated.As of JCR 2.0,LockManager.unlock(String)should be used instead.Removes the lock on this node. Also removes the propertiesjcr:lockOwnerandjcr:lockIsDeepfrom this node. These changes are persisted automatically; there is no need to callsave. As well, the corresponding lock token is removed from the set of lock tokens held by the currentSession.If this node does not currently hold a lock or holds a lock for which this
Sessionis not the owner, then aLockExceptionis thrown. Note however that the system may give permission to a non-owning session to unlock a lock. Typically such "lock-superuser" capability is intended to facilitate administrational clean-up of orphaned open-scoped locks.Note that it is possible to unlock a node even if it is checked-in (the lock-related properties will be changed despite the checked-in status).
- Throws:
UnsupportedRepositoryOperationException- if this implementation does not support locking.LockException- if this node does not currently hold a lock or holds a lock for which this Session does not have the correct lock tokenAccessDeniedException- if the current session does not have sufficent access to unlock this node.InvalidItemStateException- if this node has pending unsaved changes.RepositoryException- if another error occurs.
-
holdsLock
Deprecated.As of JCR 2.0,LockManager.holdsLock(String)should be used instead.Returnstrueif this node holds a lock; otherwise returnsfalse. To hold a lock means that this node has actually had a lock placed on it specifically, as opposed to just having a lock apply to it due to a deep lock held by a node above.- Returns:
- a
boolean. - Throws:
RepositoryException- if an error occurs.
-
isLocked
Returnstrueif this node is locked either as a result of a lock held by this node or by a deep lock on a node above this node; otherwise returnsfalse. This includes the case where a repository does not support locking (in which case all nodes are "unlocked" by default).- Returns:
- a
boolean. - Throws:
RepositoryException- if an error occurs.
-
followLifecycleTransition
void followLifecycleTransition(String transition) throws UnsupportedRepositoryOperationException, InvalidLifecycleTransitionException, RepositoryException Causes the lifecycle state of this node to undergo the specifiedtransition.This method may change the value of the
jcr:currentLifecycleStateproperty, in most cases it is expected that the implementation will change the value to that of the passedtransitionparameter, though this is an implementation-specific issue. If thejcr:currentLifecycleStateproperty is changed the change is persisted immediately, there is no need to callsave.- Parameters:
transition- a state transition- Throws:
UnsupportedRepositoryOperationException- if this implementation does not support lifecycle actions or if this node does not have themix:lifecyclemixin.InvalidLifecycleTransitionException- if the lifecycle transition is not successful.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
getAllowedLifecycleTransistions
String[] getAllowedLifecycleTransistions() throws UnsupportedRepositoryOperationException, RepositoryExceptionReturns the list of valid state transitions for this node.- Returns:
- a
Stringarray. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support lifecycle actions or if this node does not have themix:lifecyclemixin.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
VersionManager.cancelMerge(java.lang.String, javax.jcr.version.Version)should be used instead.