Interface Batch

  • All Known Subinterfaces:
    ChangeLog
    All Known Implementing Classes:
    AbstractChangeLog, BatchLogger, ChangeLogImpl, ConsolidatingChangeLog, SerializableBatch

    public interface Batch
    The Batch defines an ordered list of of operations that must be executed at once on the persistent layer. If any of the modifications added to the batch fails, none of the other changes must be persisted, thus leaving the persistent layer unaffected.

    The Batch object is obtained by calling RepositoryService.createBatch(SessionInfo,ItemId). The following methods can then be called on the returned Batch object to queue the corresponding operations:

    • addNode,
    • addProperty,
    • setValue,
    • remove,
    • reorderNodes,
    • setMixins,
    • move
    The operations collected in a Batch are persisted upon a successful call to RepositoryService.submit(Batch). The operations queued in the batch must be validated as a single unit and (if validation succeeds) applied to the persistent layer. If validation fails submitting the Batch is aborted and an exception is thrown.

    The Batch mechanism is required because there are sets of operations for which the following are both true:

    • The set can only be validated and put into effect as a single logical unit.
      For example, adding mutually referring reference properties.
    • The set contains operations that can only be validated on the persistent layer.
      For example, operations that require a referential integrity check.
    In addition the Batch mechanism is desirable in order to minimize calls to the persistent layer, which enables client-server implementations to reduce the number of network roundtrips.

    Since the batch records the delta of pending changes within the scope of an Item.save() (or a Session.save() it is intended to be constructed upon save (not before) and then submitted to the persistent layer as a single logical operation (see above).

    Note however, that methods of the JCR API that have immediate effect on the persistent storage have to call that storage, validate and return. The batch does not play a role in these operations, instead they are covered by the RepositoryService.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addNode​(NodeId parentId, Name nodeName, Name nodetypeName, java.lang.String uuid)
      Add a new node to the persistent layer.
      void addProperty​(NodeId parentId, Name propertyName, QValue value)
      Add a new property to the persistent layer.
      void addProperty​(NodeId parentId, Name propertyName, QValue[] values)
      Add a new multi-valued property to the persistent layer.
      void move​(NodeId srcNodeId, NodeId destParentNodeId, Name destName)
      Move the node identified by the given srcNodeId to the new parent identified by destParentNodeId and change its name to destName.
      void remove​(ItemId itemId)
      Remove an existing item.
      void reorderNodes​(NodeId parentId, NodeId srcNodeId, NodeId beforeNodeId)
      Modify the order of the child nodes identified by the given NodeIds.
      void setMixins​(NodeId nodeId, Name[] mixinNodeTypeNames)
      Modify the set of mixin node types present on the node identified by the given id.
      void setPrimaryType​(NodeId nodeId, Name primaryNodeTypeName)
      Change the primary type of the node identified by the given nodeId.
      void setTree​(NodeId parentId, Tree contentTree)
      Add a new content tree to the persistent layer.
      void setValue​(PropertyId propertyId, QValue value)
      Modify the value of an existing property.
      void setValue​(PropertyId propertyId, QValue[] values)
      Modify the value of an existing, multi-valued property.
    • Method Detail

      • addNode

        void addNode​(NodeId parentId,
                     Name nodeName,
                     Name nodetypeName,
                     java.lang.String uuid)
              throws javax.jcr.RepositoryException
        Add a new node to the persistent layer.
        Parameters:
        parentId - NodeId identifying the parent node.
        nodeName - Name of the node to be created.
        nodetypeName - Primary node type name of the node to be created.
        uuid - Value for the jcr:uuid property of the node to be created or null. If due to an import the uuid of the resulting node is already defined, it must be passed as separate uuid parameter, indicating a binding value for the server. Otherwise the uuid must be null.
        Throws:
        javax.jcr.ItemExistsException
        javax.jcr.PathNotFoundException
        javax.jcr.version.VersionException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.nodetype.NoSuchNodeTypeException
        javax.jcr.lock.LockException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Node.addNode(String), Node.addNode(String, String), Session.importXML(String, java.io.InputStream, int), Query.storeAsNode(String)
      • addProperty

        void addProperty​(NodeId parentId,
                         Name propertyName,
                         QValue value)
                  throws javax.jcr.ValueFormatException,
                         javax.jcr.version.VersionException,
                         javax.jcr.lock.LockException,
                         javax.jcr.nodetype.ConstraintViolationException,
                         javax.jcr.PathNotFoundException,
                         javax.jcr.ItemExistsException,
                         javax.jcr.AccessDeniedException,
                         javax.jcr.UnsupportedRepositoryOperationException,
                         javax.jcr.RepositoryException
        Add a new property to the persistent layer.

        Note: this call should succeed in case the property already exists.

        Parameters:
        parentId - NodeId identifying the parent node.
        propertyName - Name of the property to be created.
        value - The value of the property to be created.
        Throws:
        javax.jcr.ValueFormatException
        javax.jcr.version.VersionException
        javax.jcr.lock.LockException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.PathNotFoundException
        javax.jcr.ItemExistsException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Node.setProperty(String, javax.jcr.Value), Node.setProperty(String, javax.jcr.Value, int), Node.setProperty(String, String), Node.setProperty(String, String, int), Node.setProperty(String, java.util.Calendar), Node.setProperty(String, boolean), Node.setProperty(String, double), Node.setProperty(String, long), Node.setProperty(String, javax.jcr.Node), Session.importXML(String, java.io.InputStream, int), Query.storeAsNode(String)
      • addProperty

        void addProperty​(NodeId parentId,
                         Name propertyName,
                         QValue[] values)
                  throws javax.jcr.ValueFormatException,
                         javax.jcr.version.VersionException,
                         javax.jcr.lock.LockException,
                         javax.jcr.nodetype.ConstraintViolationException,
                         javax.jcr.PathNotFoundException,
                         javax.jcr.ItemExistsException,
                         javax.jcr.AccessDeniedException,
                         javax.jcr.UnsupportedRepositoryOperationException,
                         javax.jcr.RepositoryException
        Add a new multi-valued property to the persistent layer.

        Note: this call should succeed in case the property already exists.

        Parameters:
        parentId - NodeId identifying the parent node.
        propertyName - Name of the property to be created.
        values - The values of the property to be created.
        Throws:
        javax.jcr.ValueFormatException
        javax.jcr.version.VersionException
        javax.jcr.lock.LockException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.PathNotFoundException
        javax.jcr.ItemExistsException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Node.setProperty(String, javax.jcr.Value[]), Node.setProperty(String, javax.jcr.Value[], int), Node.setProperty(String, String[]), Node.setProperty(String, String[], int), Session.importXML(String, java.io.InputStream, int)
      • setValue

        void setValue​(PropertyId propertyId,
                      QValue value)
               throws javax.jcr.RepositoryException
        Modify the value of an existing property. Note that in contrast to the JCR API this method should not accept a null value. Removing a property is achieved by calling remove(ItemId).
        Parameters:
        propertyId - PropertyId identifying the property to be modified.
        value - The new value.
        Throws:
        javax.jcr.ValueFormatException
        javax.jcr.version.VersionException
        javax.jcr.lock.LockException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Property.setValue(javax.jcr.Value), Property.setValue(String), Property.setValue(long), Property.setValue(double), Property.setValue(java.util.Calendar), Property.setValue(boolean), Property.setValue(javax.jcr.Node)
      • setValue

        void setValue​(PropertyId propertyId,
                      QValue[] values)
               throws javax.jcr.RepositoryException
        Modify the value of an existing, multi-valued property. Note that in contrast to the JCR API this method should not accept a null value. Removing a property is achieved by calling remove(ItemId).
        Parameters:
        propertyId - PropertyId identifying the property to be modified.
        values - The new values.
        Throws:
        javax.jcr.ValueFormatException
        javax.jcr.version.VersionException
        javax.jcr.lock.LockException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Property.setValue(javax.jcr.Value[]), Property.setValue(String[])
      • remove

        void remove​(ItemId itemId)
             throws javax.jcr.RepositoryException
        Remove an existing item.
        Parameters:
        itemId - ItemId identifying the item to be removed.
        Throws:
        javax.jcr.version.VersionException
        javax.jcr.lock.LockException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Item.remove()
      • reorderNodes

        void reorderNodes​(NodeId parentId,
                          NodeId srcNodeId,
                          NodeId beforeNodeId)
                   throws javax.jcr.RepositoryException
        Modify the order of the child nodes identified by the given NodeIds.
        Parameters:
        parentId - NodeId identifying the parent node.
        srcNodeId - NodeId identifying the node to be reordered.
        beforeNodeId - NodeId identifying the child node, before which the source node must be placed.
        Throws:
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.version.VersionException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.ItemNotFoundException
        javax.jcr.lock.LockException
        javax.jcr.AccessDeniedException
        javax.jcr.RepositoryException
        See Also:
        Node.orderBefore(String, String)
      • setMixins

        void setMixins​(NodeId nodeId,
                       Name[] mixinNodeTypeNames)
                throws javax.jcr.RepositoryException
        Modify the set of mixin node types present on the node identified by the given id.
        Parameters:
        nodeId - NodeId identifying the node to be modified.
        mixinNodeTypeNames - The new set of mixin types. Compared to the previous values this may result in both adding and/or removing mixin types.
        Throws:
        javax.jcr.nodetype.NoSuchNodeTypeException
        javax.jcr.version.VersionException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.lock.LockException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Node.addMixin(String), Node.removeMixin(String)
      • setPrimaryType

        void setPrimaryType​(NodeId nodeId,
                            Name primaryNodeTypeName)
                     throws javax.jcr.RepositoryException
        Change the primary type of the node identified by the given nodeId.
        Parameters:
        nodeId - NodeId identifying the node to be modified.
        primaryNodeTypeName -
        Throws:
        javax.jcr.RepositoryException
        See Also:
        Node.setPrimaryType(String)
      • move

        void move​(NodeId srcNodeId,
                  NodeId destParentNodeId,
                  Name destName)
           throws javax.jcr.RepositoryException
        Move the node identified by the given srcNodeId to the new parent identified by destParentNodeId and change its name to destName.
        Parameters:
        srcNodeId - NodeId identifying the node to be moved.
        destParentNodeId - NodeId identifying the new parent.
        destName - The new name of the moved node.
        Throws:
        javax.jcr.ItemExistsException
        javax.jcr.PathNotFoundException
        javax.jcr.version.VersionException
        javax.jcr.nodetype.ConstraintViolationException
        javax.jcr.lock.LockException
        javax.jcr.AccessDeniedException
        javax.jcr.UnsupportedRepositoryOperationException
        javax.jcr.RepositoryException
        See Also:
        Session.move(String, String)
      • setTree

        void setTree​(NodeId parentId,
                     Tree contentTree)
              throws javax.jcr.RepositoryException
        Add a new content tree to the persistent layer.
        Parameters:
        parentId -
        contentTree -
        Throws:
        javax.jcr.RepositoryException