Package javax.jcr

Interface Node

    • Field Detail

      • JCR_CONTENT

        static final java.lang.String JCR_CONTENT
        A constant for the JCR name jcr:content. This is the name of a child node declared in nt:file and a property declared in nt:linkedFile.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_PROPERTY_DEFINITION

        static final java.lang.String JCR_PROPERTY_DEFINITION
        A constant for the node name jcr:propertyDefinition declared in nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CHILD_NODE_DEFINITION

        static final java.lang.String JCR_CHILD_NODE_DEFINITION
        A constant for the node name jcr:childNodeDefinition declared in nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_VERSION_LABELS

        static final java.lang.String JCR_VERSION_LABELS
        A constant for the node name jcr:versionLabels declared in nt:versionHistory.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_FROZEN_NODE

        static final java.lang.String JCR_FROZEN_NODE
        A constant for the node name jcr:frozenNode declared in nt:version.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
    • Method Detail

      • addNode

        Node addNode​(java.lang.String relPath)
              throws ItemExistsException,
                     PathNotFoundException,
                     VersionException,
                     ConstraintViolationException,
                     LockException,
                     RepositoryException
        Creates a new node at relPath.

        This is session-write method, meaning that the addition of the new node is dispatch upon Session.save().

        The relPath provided must not have an index on its final element, otherwise a Repository

        If 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 ItemExistsException will 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 PathNotFoundException will 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 ConstraintViolationException will 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 VersionException will 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 LockException will 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 intermediary Nodes that do not exist or the last element of relPath has 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 of relPath has an index or if another error occurs.
      • addNode

        Node addNode​(java.lang.String relPath,
                     java.lang.String primaryNodeTypeName)
              throws ItemExistsException,
                     PathNotFoundException,
                     NoSuchNodeTypeException,
                     LockException,
                     VersionException,
                     ConstraintViolationException,
                     RepositoryException
        Creates a new node at relPath of the specified node type. The behavior of this method is identical to addNode(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 until save.
        PathNotFoundException - if the specified path implies intermediary Nodes that do not exist or the last element of relPath has an index, and this implementation performs this validation immediately instead of waiting until save.
        NoSuchNodeTypeException - if the specified node type is not recognized and this implementation performs this validation immediately instead of waiting until save.
        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 until save.
        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 until save.
        LockException - if a lock prevents the addition of the node and this implementation performs this validation immediately instead of waiting until save.
        RepositoryException - if the last element of relPath has an index or if another error occurs.
      • orderBefore

        void orderBefore​(java.lang.String srcChildRelPath,
                         java.lang.String destChildRelPath)
                  throws UnsupportedRepositoryOperationException,
                         VersionException,
                         ConstraintViolationException,
                         ItemNotFoundException,
                         LockException,
                         RepositoryException
        If this node supports child node ordering, this method inserts the child node at srcChildRelPath into the child node list at the position immediately the child node at destChildRelPath.

        To place the node srcChildRelPath at the end of the list, a destChildRelPath of null is used.

        Note that (apart from the case where destChildRelPath is null) 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 srcChildRelPath and destChildRelPath are the same, then no change is made.

        This is session-write method, meaning that a change made by this method is dispatched on save

        A ConstraintViolationException will 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 VersionException will 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 LockException will be thrown either immediately (by this method), or on save, 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 ordering
        destChildRelPath - the the relative path to the child node (that is, name plus possible index) before which the node srcChildRelPath will 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​(java.lang.String name,
                             Value value)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        Sets the single-value property of this node called name to the specified value.

        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 name and value passed, there is more than one property definition that applies, the repository chooses one definition according to some implementation-specific criteria. Once a property with name P has been created, the behavior of a subsequent setProperty(P,V) may differ across implementations. Some repositories may allow P to 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 Value object 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 Value object is used and if the property already exists it assumes both the new value and new property type.

        Passing a null as the second parameter removes the property. It is equivalent to calling remove on the Property object itself.

        This is a session-write method, meaning that changes made through this method are dispatched on Session.save().

        A ConstraintViolationException will 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 VersionException will 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 LockException will 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 node
        value - The value to be assigned
        Returns:
        The updated Property object
        Throws:
        ValueFormatException - if the specified property is a DATE but the value cannot 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 if value cannot 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​(java.lang.String name,
                             Value value,
                             int type)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        Sets the single-value property of this node called name to the specified value and the specified type.

        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 - a Value object.
        type - the type of the property.
        Returns:
        the Property object set, or null if this method was used to remove a property (by setting its value to null).
        Throws:
        ValueFormatException - if value cannot 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​(java.lang.String name,
                             Value[] values)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        Sets the multi-value property of this node called name to 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 of Value objects is assigned instead of a single Value.

        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 Value objects 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, a ValueFormatException is thrown.

        If the property is not multi-valued then a ValueFormatException is also thrown. If another error occurs, a RepositoryException is thrown.

        If the node type of this node does not indicate a specific property type, then the property type of the supplied Value objects is used and if the property already exists it assumes both the new values and the new property type.

        Passing a null as the second parameter removes the property. It is equivalent to calling remove on the Property object itself. Note that this is different from passing an array that contains null elements. In such a case, the array is compacted by removing the null values. 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 of Value objects.
        Returns:
        the updated Property object.
        Throws:
        ValueFormatException - if 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​(java.lang.String name,
                             Value[] values,
                             int type)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        Sets the multi-value property of this node called name to 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 type parameter specified.

        If the property type of one or more of the supplied Value objects 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, a ValueFormatException is 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 of Value objects.
        type - the type of the property.
        Returns:
        the updated Property object.
        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​(java.lang.String name,
                             java.lang.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 of setProperty(String name, Value value) except that the value is specified as a String. and, if possible, the type assigned to the property is STRING, otherwise a best-effort conversion is attempted.
        Parameters:
        name - The name of a property of this node
        value - The value to assigned
        Returns:
        The updated Property object
        Throws:
        ValueFormatException - if value cannot 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​(java.lang.String name,
                             java.lang.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 the type parameter.

        Parameters:
        name - the name of the property to be set.
        value - a String object.
        type - the type of the property.
        Returns:
        the Property object set, or null if this method was used to remove a property (by setting its value to null).
        Throws:
        ValueFormatException - if value cannot 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​(java.lang.String name,
                             java.io.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 of setProperty(String name, Value value) except that the value is specified as a InputStream and, if possible, the type assigned to the property is BINARY, 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 node
        value - The value to assigned
        Returns:
        The updated Property object
        Throws:
        ValueFormatException - if value cannot 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​(java.lang.String name,
                             java.math.BigDecimal value)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        The behavior of this method is identical to that of setProperty(String name, Value value) except that the value is specified as a BigDecimal and, if possible, the type assigned to the property is DECIMAL, otherwise a best-effort conversion is attempted.
        Parameters:
        name - The name of a property of this node
        value - The value to assigned
        Returns:
        The updated Property object
        Throws:
        ValueFormatException - if value cannot 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​(java.lang.String name,
                             java.util.Calendar value)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        The behavior of this method is identical to that of setProperty(String name, Value value) except that the value is specified as a Calendar and, if possible, the type assigned to the property is DATE, otherwise a best-effort conversion is attempted.
        Parameters:
        name - The name of a property of this node
        value - The value to assigned
        Returns:
        The updated Property object
        Throws:
        ValueFormatException - if the specified property is a DATE but the value cannot 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 if value cannot 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​(java.lang.String name,
                             Node value)
                      throws ValueFormatException,
                             VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        The behavior of this method is identical to that of setProperty(String name, Value value) except that the value is specified as a Node and, if possible, the type assigned to the property is REFERENCE or WEAKREFERENCE, 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 REFERENCE or WEAKREFERENCE property is intended, then a REFERENCE property is created.

        Parameters:
        name - The name of a property of this node
        value - The value to assigned
        Returns:
        The updated Property object.
        Throws:
        ValueFormatException - if this property is not of type REFERENCE or WEAKREFERENCE or 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

        Node getNode​(java.lang.String relPath)
              throws PathNotFoundException,
                     RepositoryException
        Returns the node at relPath relative to this node.

        If relPath contains 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 Session object, if a Node object has been acquired, any subsequent call of getNode reacquiring the same node must return a Node object reflecting the same state as the earlier Node object. Whether this object is actually the same Node instance, 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 current Session does not read access to the node at the specified path.
        RepositoryException - If another error occurs.
      • getNodes

        NodeIterator getNodes()
                       throws RepositoryException
        Returns all child nodes of this node accessible through the current Session. Does not include properties of this Node. The same reacquisition semantics apply as with getNode(String). If this node has no accessible child nodes, then an empty iterator is returned.
        Returns:
        A NodeIterator over all child Nodes of this Node.
        Throws:
        RepositoryException - if an error occurs.
      • getNodes

        NodeIterator getNodes​(java.lang.String namePattern)
                       throws RepositoryException
        Gets all child nodes of this node accessible through the current Session that match namePattern. 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 logical OR) of these. For example,

        N.getNodes("jcr:* | myapp:report | my doc")

        would return a NodeIterator holding all accessible child nodes of N that 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

        NodeIterator getNodes​(java.lang.String[] nameGlobs)
                       throws RepositoryException
        Gets all child nodes of this node accessible through the current Session that match one or more of the nameGlob strings 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 NodeIterator holding all accessible child nodes of N that 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

        Property getProperty​(java.lang.String relPath)
                      throws PathNotFoundException,
                             RepositoryException
        Returns the property at relPath relative to this node. 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 current

        Session does not have read access to the specified property.

        RepositoryException - If another error occurs.
      • getProperties

        PropertyIterator getProperties()
                                throws RepositoryException
        Returns all properties of this node accessible through the current Session. Does not include child nodes of this node. The same reacquisition semantics apply as with getNode(String). If this node has no accessible properties, then an empty iterator is returned.
        Returns:
        A PropertyIterator.
        Throws:
        RepositoryException - if an error occurs.
      • getProperties

        PropertyIterator getProperties​(java.lang.String namePattern)
                                throws RepositoryException
        Gets all properties of this node accessible through the current Session that match namePattern. 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 logical OR) of these. For example,

        N.getProperties("jcr:* | myapp:name | my doc")

        would return a PropertyIterator holding all accessible properties of N that 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

        PropertyIterator getProperties​(java.lang.String[] nameGlobs)
                                throws RepositoryException
        Gets all properties of this node accessible through the current Session that match one or more of the nameGlob strings 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 PropertyIterator holding all accessible properties of N that 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

        Item getPrimaryItem()
                     throws ItemNotFoundException,
                            RepositoryException
        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 current Session.
        RepositoryException - if another error occurs.
      • getIdentifier

        java.lang.String getIdentifier()
                                throws RepositoryException
        Returns the identifier of this node. Applies to both referenceable and non-referenceable nodes.

        A RepositoryException is thrown if an error occurs.

        Returns:
        the identifier of this node.
        Throws:
        RepositoryException - if an error occurs.
        Since:
        JCR 2.0
      • getIndex

        int getIndex()
              throws RepositoryException
        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

        PropertyIterator getReferences()
                                throws RepositoryException
        This method returns all REFERENCE properties that refer to this node and that are accessible through the current Session. Equivalent to Node.getReferences(null).

        If this node has no referring REFERENCE properties, 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

        PropertyIterator getReferences​(java.lang.String name)
                                throws RepositoryException
        This method returns all REFERENCE properties that refer to this node, have the specified name and that are accessible through the current Session.

        If the name parameter is null then all referring REFERENCES are 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 REFERENCE properties with the specified name, an empty iterator is returned. This includes the case where this node is not referenceable.

        Parameters:
        name - name of referring REFERENCE properties to be returned; if null then all referring REFERENCEs are returned.
        Returns:
        A PropertyIterator.
        Throws:
        RepositoryException - if an error occurs.
        Since:
        JCR 2.0
      • getWeakReferences

        PropertyIterator getWeakReferences()
                                    throws RepositoryException
        This method returns all WEAKREFERENCE properties that refer to this node and that are accessible through the current Session. Equivalent to Node.getWeakReferences(null).

        If this node has no referring WEAKREFERENCE properties, 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

        PropertyIterator getWeakReferences​(java.lang.String name)
                                    throws RepositoryException
        This method returns all WEAKREFERENCE properties that refer to this node, have the specified name and that are accessible through the current Session.

        If the name parameter is null then all referring WEAKREFERENCE are 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 WEAKREFERENCE properties with the specified name, an empty iterator is returned. This includes the case where this node is not referenceable.

        Parameters:
        name - name of referring WEAKREFERENCE properties to be returned; if null then all referring WEAKREFERENCEs are returned.
        Returns:
        A PropertyIterator.
        Throws:
        RepositoryException - if an error occurs.
        Since:
        JCR 2.0
      • hasNode

        boolean hasNode​(java.lang.String relPath)
                 throws RepositoryException
        Indicates whether a node exists at relPath Returns true if a node accessible through the current Session exists at relPath and false otherwise.
        Parameters:
        relPath - The path of a (possible) node.
        Returns:
        true if a node exists at relPath; false otherwise.
        Throws:
        RepositoryException - if an error occurs.
      • hasProperty

        boolean hasProperty​(java.lang.String relPath)
                     throws RepositoryException
        Indicates whether a property exists at relPath Returns true if a property accessible through the current Session exists at relPath and false otherwise.
        Parameters:
        relPath - The path of a (possible) property.
        Returns:
        true if a property exists at relPath; false otherwise.
        Throws:
        RepositoryException - if an error occurs.
      • hasNodes

        boolean hasNodes()
                  throws RepositoryException
        Indicates whether this node has child nodes. Returns true if this node has one or more child nodes accessible through the current Session; false otherwise.
        Returns:
        true if this node has one or more child nodes; false otherwise.
        Throws:
        RepositoryException - if an error occurs.
      • hasProperties

        boolean hasProperties()
                       throws RepositoryException
        Indicates whether this node has properties. Returns true if this node has one or more properties accessible through the current Session; false otherwise.
        Returns:
        true if this node has one or more properties; false otherwise.
        Throws:
        RepositoryException - if an error occurs.
      • getPrimaryNodeType

        NodeType getPrimaryNodeType()
                             throws RepositoryException
        Returns the primary node type in effect for this node. Which NodeType is returned when this method is called on the root node of a workspace is up to the implementation.
        Returns:
        a NodeType object.
        Throws:
        RepositoryException - if an error occurs
      • getMixinNodeTypes

        NodeType[] getMixinNodeTypes()
                              throws RepositoryException
        Returns an array of NodeType objects 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 NodeType objects.
        Throws:
        RepositoryException - if an error occurs
      • isNodeType

        boolean isNodeType​(java.lang.String nodeTypeName)
                    throws RepositoryException
        Returns true if this node is of the specified primary node type or mixin type, or a subtype thereof. Returns false otherwise.

        This method respects the effective node type of the node.

        Parameters:
        nodeTypeName - the name of a node type.
        Returns:
        true If this node is of the specified primary node type or mixin type, or a subtype thereof. Returns false otherwise.
        Throws:
        RepositoryException - if an error occurs.
      • setPrimaryType

        void setPrimaryType​(java.lang.String nodeTypeName)
                     throws NoSuchNodeTypeException,
                            VersionException,
                            ConstraintViolationException,
                            LockException,
                            RepositoryException
        Changes the primary node type of this node to nodeTypeName. Also immediately changes this node's jcr:primaryType property 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 for addMixin(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 ConstraintViolationException is 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 ConstraintViolationException is thrown either immediately, on dispatch or on persist.

        A ConstraintViolationException is also thrown either immediately, on dispatch or on persist if a conflict with an already assigned mixin occurs.

        A ConstraintViolationException may 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 NoSuchNodeTypeException is thrown either immediately, on dispatch or on persist.

        A VersionException is thrown either immediately , on dispatch or on persist if this node is read-only dues to a check-in.

        A LockException is 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 specified nodeTypeName is 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​(java.lang.String mixinName)
               throws NoSuchNodeTypeException,
                      VersionException,
                      ConstraintViolationException,
                      LockException,
                      RepositoryException
        Adds the mixin node type named mixinName to this node. If this node is already of type mixinName (either due to a previously added mixin or due to its primary type, through inheritance) then this method has no effect. Otherwise mixinName is added to this node's jcr:mixinTypes property.

        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 ConstraintViolationException is 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 addMixin will throw a ConstraintViolationException either immediately, on dispatch or on persist.

        A NoSuchNodeTypeException is thrown either immediately, on dispatch or on persist, if the specified mixinName is not recognized. Implementations may differ on when this validation is done.

        A VersionException is 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 LockException is 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 specified mixinName is 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​(java.lang.String mixinName)
                  throws NoSuchNodeTypeException,
                         VersionException,
                         ConstraintViolationException,
                         LockException,
                         RepositoryException
        Removes the specified mixin node type from this node and removes mixinName from this node's jcr:mixinTypes property. Both the semantic change in effective node type and the persistence of the change to the jcr:mixinTypes property occur on persist.

        If this node does not have the specified mixin, a NoSuchNodeTypeException is thrown either immediately, on dispatch or on persist. Implementations may differ on when this validation is done.

        A ConstraintViolationException will 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 VersionException is 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 LockException is thrown either immediately or on save if 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 specified mixinName is 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

        boolean canAddMixin​(java.lang.String mixinName)
                     throws NoSuchNodeTypeException,
                            RepositoryException
        Returns true if calling addMixin(java.lang.String) on this node with the mixn node type mixinName will not fail. Returns false otherwise.
        Parameters:
        mixinName - The name of the mixin to be tested.
        Returns:
        true if addMixin will not fail when called on this node with the specified mixinName; false otherwise.
        Throws:
        NoSuchNodeTypeException - if the specified mixin node type name is not recognized.
        RepositoryException - if another error occurs.
      • getDefinition

        NodeDefinition getDefinition()
                              throws RepositoryException
        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. The NodeDefinition returned when this method is called on the root node of a workspace is also up to the implementation.
        Returns:
        a NodeDefinition object.
        Throws:
        RepositoryException - if an error occurs.
        See Also:
        NodeType.getChildNodeDefinitions()
      • checkin

        Version checkin()
                 throws VersionException,
                        UnsupportedRepositoryOperationException,
                        InvalidItemStateException,
                        LockException,
                        RepositoryException
        Deprecated.
        As of JCR 2.0, VersionManager.checkin(java.lang.String) should be used instead.
        Creates a new version of this node and returns that Version object. 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:checkedOut property 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 a save.

        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 an OnParentVersion status of ABORT. This includes the case (under full versioning) where an unresolved merge failure exists on this node, as indicated by the presence of a jcr:mergeFailed property. Under full versioning this exception is also thrown if the 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.
      • doneMerge

        void doneMerge​(Version version)
                throws VersionException,
                       InvalidItemStateException,
                       UnsupportedRepositoryOperationException,
                       RepositoryException
        Deprecated.
        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:

        1. 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).
        2. This node will be left alone (if this node's base version is more recent in terms of version history).
        3. 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).
        (See 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:mergeFailed property of this node. After a merge, 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 the jcr:mergeFailed property that the client wishes to connect to this node in the version graph. This has the effect of moving the reference to the indicated version from the jcr:mergeFailed property of this node to the jcr:predecessors.

        If the client chooses not to connect this node to a particular version referenced in the jcr:mergeFailed property, he calls cancelMerge(Version version). This has the effect of removing the reference to the specified version from jcr:mergeFailed without adding it to jcr:predecessors.

        Once the last reference in jcr:mergeFailed has been either moved to jcr:predecessors (with doneMerge) or just removed from jcr:mergeFailed (with cancelMerge) the jcr:mergeFailed property is automatically removed, thus enabling this node to be checked-in, creating a new version (note that before the jcr:mergeFailed is removed, its OnParentVersion setting of ABORT prevents checkin). This new version will have a predecessor connection to each version for which doneMerge was 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's jcr:mergeFailed property.
        Throws:
        VersionException - if the version specifed is not among those referenced in this node's jcr:mergeFailed or 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​(java.lang.String srcWorkspace)
             throws NoSuchWorkspaceException,
                    AccessDeniedException,
                    LockException,
                    InvalidItemStateException,
                    RepositoryException
        If this node does have a corresponding node in the workspace srcWorkspace, 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 the update method has no effect.

        If the update succeeds the changes made are persisted immediately, there is no need to call save.

        Note that update does not respect the checked-in status of nodes. An update may 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 - If srcWorkspace does not exist.
        InvalidItemStateException - if this Session (not necessarily this Node) 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​(java.lang.String srcWorkspace,
                           boolean bestEffort)
                    throws NoSuchWorkspaceException,
                           AccessDeniedException,
                           MergeException,
                           LockException,
                           InvalidItemStateException,
                           RepositoryException
        Deprecated.
        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 srcWorkspace with 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 MergeException is thrown if bestEffort is false and 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 NodeIterator over all versionable nodes in the subgraph that received a merge result of fail. If bestEffort is false, this iterator will be empty (since if merge returns successfully, instead of throwing an exception, it will be because no failures were encountered). If bestEffort is true, this iterator will contain all nodes that received a fail during the course of this merge operation.

        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 - if bestEffort is false and a failed merge result is encountered.
        InvalidItemStateException - if this session (not necessarily this node) has pending unsaved changes.
        NoSuchWorkspaceException - if the specified srcWorkspace does 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.
      • getSharedSet

        NodeIterator getSharedSet()
                           throws RepositoryException
        Returns an iterator over all nodes that are in the shared set of this node. If this node is not shared then the returned iterator contains only this node.
        Returns:
        a NodeIterator.
        Throws:
        RepositoryException - if an error occurs.
        Since:
        JCR 2.0
      • removeSharedSet

        void removeSharedSet()
                      throws VersionException,
                             LockException,
                             ConstraintViolationException,
                             RepositoryException
        Removes this node and every other node in the shared set of this node.

        This removal must be done atomically, i.e., if one of the nodes cannot be removed, the method throws the exception Item.remove() would have thrown in that case, and none of the nodes are removed.

        If this node is not shared this method removes only this node.

        Throws:
        VersionException - if the parent node of this item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until save.
        LockException - if a lock prevents the removal of this item and this implementation performs this validation immediately instead of waiting until save.
        ConstraintViolationException - if removing the specified item would violate a node type or implementation-specific constraint and this implementation performs this validation immediately instead of waiting until save.
        RepositoryException - if another error occurs.
        Since:
        JCR 2.0
        See Also:
        removeShare(), Item.remove(), Session.removeItem(String)
      • removeShare

        void removeShare()
                  throws VersionException,
                         LockException,
                         ConstraintViolationException,
                         RepositoryException
        Removes this node, but does not remove any other node in the shared set of this node.
        Throws:
        VersionException - if the parent node of this item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until save.
        LockException - if a lock prevents the removal of this item and this implementation performs this validation immediately instead of waiting until save.
        ConstraintViolationException - if removing the specified item would violate a node type or implementation-specific constraint and this implementation performs this validation immediately instead of waiting until save.
        RepositoryException - if if this node cannot be removed without removing another node in the shared set of this node or another error occurs.
        Since:
        JCR 2.0
        See Also:
        removeSharedSet(), Item.remove(), Session.removeItem(String)
      • isCheckedOut

        boolean isCheckedOut()
                      throws RepositoryException
        Returns false if 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 returns true. 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​(java.lang.String versionName,
                     boolean removeExisting)
              throws VersionException,
                     ItemExistsException,
                     UnsupportedRepositoryOperationException,
                     LockException,
                     InvalidItemStateException,
                     RepositoryException
        Deprecated.
        Restores this node to the state defined by the version with the specified versionName.

        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 restore operation into the subgraph at this node. The result in such a case is governed by the removeExisting flag. If removeExisting is true, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise a RepositoryException is thrown). If removeExisting is false, then a ItemExistsException is 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 have OnParentVersion settings of COPY or VERSION are also governed by the removeExisting flag.

        Parameters:
        versionName - a Version object
        removeExisting - a boolean flag that governs what happens in case of an identifier collision.
        Throws:
        UnsupportedRepositoryOperationException - if this node is not versionable.
        VersionException - if the specified version is not part of this node's version history or if an attempt is made to restore the root version (jcr:rootVersion).
        ItemExistsException - if removeExisting is false and an identifier collision occurs.
        LockException - if a lock prevents the restore.
        InvalidItemStateException - if this Session (not necessarily this Node) has pending unsaved changes.
        RepositoryException - If another error occurs.
      • restore

        void restore​(Version version,
                     boolean removeExisting)
              throws VersionException,
                     ItemExistsException,
                     InvalidItemStateException,
                     UnsupportedRepositoryOperationException,
                     LockException,
                     RepositoryException
        Deprecated.
        Restores this node to the state defined by the specified version.

        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 restore operation into the subgraph at this node. The result in such a case is governed by the removeExisting flag. If removeExisting is true, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise a RepositoryException is thrown). If removeExisting is false, then a ItemExistsException is 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 have OnParentVersion settings of COPY or VERSION are also governed by the removeExisting flag.

        Parameters:
        version - a Version object
        removeExisting - a boolean flag that governs what happens in case of an identifier collision.
        Throws:
        UnsupportedRepositoryOperationException - if this node is not versionable.
        VersionException - if the specified version is not part of this node's version history or if an attempt is made to restore the root version (jcr:rootVersion).
        ItemExistsException - if removeExisting is false and an identifier collision occurs.
        InvalidItemStateException - if this Session (not necessarily this Node) has pending unsaved changes.
        LockException - if a lock prevents the restore.
        RepositoryException - if another error occurs.
      • restore

        void restore​(Version version,
                     java.lang.String relPath,
                     boolean removeExisting)
              throws PathNotFoundException,
                     ItemExistsException,
                     VersionException,
                     ConstraintViolationException,
                     UnsupportedRepositoryOperationException,
                     LockException,
                     InvalidItemStateException,
                     RepositoryException
        Deprecated.
        Restores the specified version to relPath, relative to this node.

        If the restore succeeds, the changes made to this node are persisted immediately, there is no need to call save.

        A node need not exist at relPath, though the parent of relPath must 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 a VersionException is thrown.

        If no node exists at relPath then a VersionException is thrown if the parent node of relPath is read-only due to a check-in. However, If there is a node at relPath then 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 relPath with the same identifier as a node that would be introduced by the restore operation into the subgraph at relPath (Note that in cases where there is no node at relPath, 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 the restore). The result in such a case is governed by the removeExisting flag. If removeExisting is true, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise a RepositoryException is thrown). If removeExisting is false, then a ItemExistsException is 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 have OnParentVersion settings of COPY or VERSION are also governed by the removeExisting flag.

        Parameters:
        version - a version object
        relPath - the path to which the version is to be restored
        removeExisting - governs what happens on identifier collision.
        Throws:
        PathNotFoundException - if the parent of relPath does not exist.
        ItemExistsException - if removeExisting is false and an identifier collision occurs
        ConstraintViolationException - if the would-be parent of the location relPath is actually a property, or if a node type restriction would be violated
        VersionException - if the parent node of relPath is read-only due to a checked-in node or if a node exists at relPath that is not the node corresponding to the specified version or 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 this Session (not necessarily this Node) has pending unsaved changes.
        RepositoryException - if another error occurs
      • restoreByLabel

        void restoreByLabel​(java.lang.String versionLabel,
                            boolean removeExisting)
                     throws VersionException,
                            ItemExistsException,
                            UnsupportedRepositoryOperationException,
                            LockException,
                            InvalidItemStateException,
                            RepositoryException
        Deprecated.
        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 restoreByLabel operation into the subgraph at this node. The result in such a case is governed by the removeExisting flag. If removeExisting is true, then the incoming node takes precedence, and the existing node (and its subgraph) is removed (if possible; otherwise a RepositoryException is thrown). If removeExisting is false, then a ItemExistsException is 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 have OnParentVersion settings of COPY or VERSION are also governed by the removeExisting flag.

        Note the special behavior in case of chained versions where a child node of this node has an on OnParentVersionsettings of VERSION and 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 String
        removeExisting - a boolean flag that governs what happens in case of an identifier collision.
        Throws:
        UnsupportedRepositoryOperationException - if this node is not versionable.
        VersionException - if the specified versionLabel does not exist in this node's version history.
        ItemExistsException - if removeExisting is false and an identifier collision occurs.
        LockException - if a lock prevents the restore.
        InvalidItemStateException - if this Session (not necessarily this Node) has pending unsaved changes.
        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 isDeep is true then the lock applies to this node and all its descendant nodes; if false, the lock applies only to this, the holding node.

        If isSessionScoped is true then this lock will expire upon the expiration of the current session (either through an automatic or explicit Session.logout); if false, this lock does not expire until explicitly unlocked or automatically unlocked due to a implementation-specific limitation, such as a timeout.

        Returns a Lock object 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:lockOwner is created and set to the value of Session.getUserID for the current session and the property jcr:lockIsDeep is set to the value passed in as isDeep. These changes are persisted automatically; there is no need to call save.

        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 - if true this lock will apply to this node and all its descendants; if false, it applies only to this node.
        isSessionScoped - if true, this lock expires with the current session; if false it expires when explicitly or automatically unlocked for some other reason.
        Returns:
        A Lock object containing a lock token.
        Throws:
        UnsupportedRepositoryOperationException - if this implementation does not support locking.
        LockException - if this node is not mix:lockable or this node is already locked or isDeep is true and 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.
      • unlock

        void unlock()
             throws UnsupportedRepositoryOperationException,
                    LockException,
                    AccessDeniedException,
                    InvalidItemStateException,
                    RepositoryException
        Deprecated.
        As of JCR 2.0, LockManager.unlock(String) should be used instead.
        Removes the lock on this node. Also removes the properties jcr:lockOwner and jcr:lockIsDeep from this node. These changes are persisted automatically; there is no need to call save. As well, the corresponding lock token is removed from the set of lock tokens held by the current Session.

        If this node does not currently hold a lock or holds a lock for which this Session is not the owner, then a LockException is 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 token
        AccessDeniedException - 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

        boolean holdsLock()
                   throws RepositoryException
        Deprecated.
        As of JCR 2.0, LockManager.holdsLock(String) should be used instead.
        Returns true if this node holds a lock; otherwise returns false. 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

        boolean isLocked()
                  throws RepositoryException
        Returns true if 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 returns false. 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​(java.lang.String transition)
                                throws UnsupportedRepositoryOperationException,
                                       InvalidLifecycleTransitionException,
                                       RepositoryException
        Causes the lifecycle state of this node to undergo the specified transition.

        This method may change the value of the jcr:currentLifecycleState property, in most cases it is expected that the implementation will change the value to that of the passed transition parameter, though this is an implementation-specific issue. If the jcr:currentLifecycleState property is changed the change is persisted immediately, there is no need to call save.

        Parameters:
        transition - a state transition
        Throws:
        UnsupportedRepositoryOperationException - if this implementation does not support lifecycle actions or if this node does not have the mix:lifecycle mixin.
        InvalidLifecycleTransitionException - if the lifecycle transition is not successful.
        RepositoryException - if another error occurs.
        Since:
        JCR 2.0