Class InternalXAVersionManager

    • Method Detail

      • internalRemoveActivity

        protected void internalRemoveActivity​(org.apache.jackrabbit.core.version.InternalActivityImpl activity)
                                       throws VersionException,
                                              RepositoryException
        Removes the specified activity

        Before modifying activity, make a local copy of it.

        Parameters:
        activity - the activity to remove
        Throws:
        RepositoryException - if any other error occurs.
        VersionException
      • setVersionLabel

        public InternalVersion setVersionLabel​(Session session,
                                               InternalVersionHistory history,
                                               org.apache.jackrabbit.spi.Name version,
                                               org.apache.jackrabbit.spi.Name label,
                                               boolean move)
                                        throws RepositoryException
        Sets the version label to the given version. If the label is already assigned to another version, a VersionException is thrown unless move is true. If version is null, the label is removed from the respective version. In either case, the version the label was previously assigned is returned, or null of the label was not moved.
        Specified by:
        setVersionLabel in interface InternalVersionManager
        Parameters:
        session - the session that performs the operation
        history - version history
        version - name of the version
        label - new label
        move - if true label will be moved
        Returns:
        the version that had the label or null
        Throws:
        RepositoryException - if an error occurs
      • close

        public void close()
                   throws Exception
        Close this version manager. After having closed a persistence manager, further operations on this object are treated as illegal and throw
        Specified by:
        close in interface InternalVersionManager
        Throws:
        Exception - if an error occurs
      • isVirtualRoot

        public boolean isVirtualRoot​(ItemId id)
        Checks if the id refers to the root of a virtual tree.
        Specified by:
        isVirtualRoot in interface VirtualItemStateProvider
        Returns:
        true if it is the root
      • getVirtualRootId

        public NodeId getVirtualRootId()
        Returns the id of the root node of the virtual tree.
        Specified by:
        getVirtualRootId in interface VirtualItemStateProvider
        Returns:
        the id of the root node of the virtual tree.
      • setNodeReferences

        public boolean setNodeReferences​(ChangeLog references)
        Informs this provider that the node references to some of its states have changed.
        Specified by:
        setNodeReferences in interface VirtualItemStateProvider
        Parameters:
        references - collection of NodeReferences instances
        Returns:
        true if the reference target is one of its items.
      • hasItemState

        public boolean hasItemState​(ItemId id)
        Return a flag indicating whether an item state for a given item id exists.
        Specified by:
        hasItemState in interface ItemStateManager
        Parameters:
        id - item id
        Returns:
        true if an item state exists, otherwise false
      • hasNodeReferences

        public boolean hasNodeReferences​(NodeId id)
        Return a flag indicating whether a node references object for a given target id exists.
        Specified by:
        hasNodeReferences in interface ItemStateManager
        Parameters:
        id - target id
        Returns:
        true if a node reference object exists for the given id, otherwise false.
      • getHistoryRoot

        protected NodeStateEx getHistoryRoot()
        returns the id of the version history root node
        Returns:
        the id of the version history root node
      • getActivitiesRoot

        protected NodeStateEx getActivitiesRoot()
        returns the id of the activities root node
        Returns:
        the id of the activities root node
      • getItem

        protected InternalVersionItem getItem​(NodeId id)
                                       throws RepositoryException
        Returns the item with the given persistent id. Subclass responsibility.

        Please note, that the overridden method must acquire the readlock before reading the state manager.

        Parameters:
        id - the id of the item
        Returns:
        version item
        Throws:
        RepositoryException - if an error occurs
      • hasItem

        protected boolean hasItem​(NodeId id)
        Return a flag indicating if the item specified exists. Subclass responsibility.
        Parameters:
        id - the id of the item
        Returns:
        true if the item exists; false otherwise
      • hasItemReferences

        protected boolean hasItemReferences​(NodeId id)
                                     throws RepositoryException
        Checks if there are item references (from outside the version storage) that reference the given node. Subclass responsibility.

        Please note, that the overridden method must acquire the readlock before reading the state manager.

        Parameters:
        id - the id of the node
        Returns:
        true if there are item references from outside the version storage; false otherwise.
        Throws:
        RepositoryException - if an error occurs while reading from the repository.
      • getNodeStateEx

        protected NodeStateEx getNodeStateEx​(NodeId parentNodeId)
                                      throws RepositoryException
        Returns the node with the given persistent id. Subclass responsibility.

        Please note, that the overridden method must acquire the readlock before reading the state manager.

        Parameters:
        parentNodeId - the id of the node
        Returns:
        the nodestate for the given id.
        Throws:
        RepositoryException - if an error occurs while reading from the repository.
      • internalCheckin

        protected InternalVersion internalCheckin​(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
                                                  NodeStateEx node,
                                                  boolean simple,
                                                  Calendar created)
                                           throws RepositoryException
        Checks in a node

        Before modifying version history given, make a local copy of it.

        Parameters:
        history - the version history
        node - node to checkin
        simple - flag indicates simple versioning
        created - optional created date.
        Returns:
        internal version
        Throws:
        RepositoryException - if an error occurs
        See Also:
        Node.checkin()
      • internalRemoveVersion

        protected void internalRemoveVersion​(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
                                             org.apache.jackrabbit.spi.Name name)
                                      throws VersionException,
                                             RepositoryException
        Removes the specified version from the history

        Before modifying version history given, make a local copy of it.

        Parameters:
        history - the version history from where to remove the version.
        name - the name of the version to remove.
        Throws:
        VersionException - if the version history does not have a version with name.
        RepositoryException - if any other error occurs.
      • setVersionLabel

        protected InternalVersion setVersionLabel​(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
                                                  org.apache.jackrabbit.spi.Name version,
                                                  org.apache.jackrabbit.spi.Name label,
                                                  boolean move)
                                           throws RepositoryException
        Set version label on the specified version.

        Before modifying version history given, make a local copy of it.

        Parameters:
        history - version history
        version - version name
        label - version label
        move - true to move from existing version; false otherwise.
        Returns:
        The internal version.
        Throws:
        RepositoryException - if an error occurs
      • versionCreated

        protected void versionCreated​(InternalVersion version)
        Invoked when a new internal item has been created.

        Put the version object into our cache.

        Parameters:
        version - internal version item
      • versionDestroyed

        protected void versionDestroyed​(InternalVersion version)
        Invoked when a new internal item has been destroyed.

        Remove the version object from our cache.

        Parameters:
        version - internal version item
      • associate

        public void associate​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        associate in interface org.apache.jackrabbit.data.core.InternalXAResource
      • beforeOperation

        public void beforeOperation​(org.apache.jackrabbit.data.core.TransactionContext tx)

        Delegate the call to our XA item state manager.

        Specified by:
        beforeOperation in interface org.apache.jackrabbit.data.core.InternalXAResource
      • prepare

        public void prepare​(org.apache.jackrabbit.data.core.TransactionContext tx)
                     throws org.apache.jackrabbit.data.core.TransactionException

        Delegate the call to our XA item state manager.

        Specified by:
        prepare in interface org.apache.jackrabbit.data.core.InternalXAResource
        Throws:
        org.apache.jackrabbit.data.core.TransactionException
      • commit

        public void commit​(org.apache.jackrabbit.data.core.TransactionContext tx)
                    throws org.apache.jackrabbit.data.core.TransactionException

        Delegate the call to our XA item state manager. If successful, inform global repository manager to update its caches.

        Specified by:
        commit in interface org.apache.jackrabbit.data.core.InternalXAResource
        Throws:
        org.apache.jackrabbit.data.core.TransactionException
      • rollback

        public void rollback​(org.apache.jackrabbit.data.core.TransactionContext tx)

        Delegate the call to our XA item state manager.

        Specified by:
        rollback in interface org.apache.jackrabbit.data.core.InternalXAResource
      • afterOperation

        public void afterOperation​(org.apache.jackrabbit.data.core.TransactionContext tx)

        Delegate the call to our XA item state manager.

        Specified by:
        afterOperation in interface org.apache.jackrabbit.data.core.InternalXAResource
      • getXAResourceBegin

        public org.apache.jackrabbit.data.core.InternalXAResource getXAResourceBegin()
        Returns an InternalXAResource that acquires a write lock on the version manager in InternalXAResource.prepare(TransactionContext).
        Returns:
        an internal XA resource.
      • getXAResourceEnd

        public org.apache.jackrabbit.data.core.InternalXAResource getXAResourceEnd()
        Returns an InternalXAResource that releases the write lock on the version manager in InternalXAResource.commit(TransactionContext) or InternalXAResource.rollback(TransactionContext).
        Returns:
        an internal XA resource.
      • getHeadVersionOfNode

        public InternalVersion getHeadVersionOfNode​(NodeId id)
                                             throws RepositoryException
        Returns the head version of the node with the given id. this is always the last of all versions. this only works correctly for liner version graphs (i.e. simple versioning) Assumes that all versions are stored chronologically below the version history and just returns the last one. i.e. currently only works for simple versioning.
        Specified by:
        getHeadVersionOfNode in interface InternalVersionManager
        Parameters:
        id - id of the node to retrieve the version for
        Returns:
        the version.
        Throws:
        RepositoryException - if an error occurs
      • acquireWriteLock

        protected VersioningLock.WriteLock acquireWriteLock()
        Acquires the write lock on this version manager.
        Returns:
        returns the write lock
      • acquireReadLock

        public VersioningLock.ReadLock acquireReadLock()
        acquires the read lock on this version manager.
        Returns:
        returns the read lock
      • getVersionHistoryInfoForNode

        public VersionHistoryInfo getVersionHistoryInfoForNode​(NodeState node)
                                                        throws RepositoryException
        Returns information about the version history of the specified node or null when unavailable.
        Parameters:
        node - node whose version history should be returned
        Returns:
        identifiers of the version history and root version nodes
        Throws:
        RepositoryException - if an error occurs
      • getVersionHistory

        public VersionHistoryInfo getVersionHistory​(Session session,
                                                    NodeState node,
                                                    NodeId copiedFrom)
                                             throws RepositoryException
        Returns information about the version history of the specified node. If the given node does not already have an associated version history, then an empty history is automatically created. This method should only be called by code that already knows that the specified node is versionable.
        Specified by:
        getVersionHistory in interface InternalVersionManager
        Parameters:
        session - workspace session
        node - node whose version history should be returned
        copiedFrom - the node id for the jcr:copiedFrom property use for copied nodes
        Returns:
        identifiers of the version history and root version nodes
        Throws:
        RepositoryException - if an error occurs
      • getName

        protected static org.apache.jackrabbit.spi.Name getName​(String name)
        Utility method that returns the given string as a name in the default namespace.
        Parameters:
        name - string name
        Returns:
        A Name object.
      • getParentNode

        protected static NodeStateEx getParentNode​(NodeStateEx parent,
                                                   String uuid,
                                                   org.apache.jackrabbit.spi.Name interNT)
                                            throws RepositoryException
        Utility method that returns the parent node under which the version history of the identified versionable node is or will be stored. If the interNT is not null then the returned parent node and any ancestor nodes are automatically created if they do not already exist. Otherwise null is returned if the parent node does not exist.
        Parameters:
        parent - the parent node
        uuid - UUID of a versionable node
        interNT - intermediate nodetype.
        Returns:
        parent node of the version history, or null
        Throws:
        RepositoryException - if an error occurs
      • calculateCheckinVersionName

        protected String calculateCheckinVersionName​(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
                                                     NodeStateEx node,
                                                     boolean simple)
                                              throws RepositoryException
        Calculates the name of the new version that will be created by a checkin call. The name is determined as follows:
        • first the predecessor version with the shortest name is searched.
        • if that predecessor version is the root version, the new version gets the name "{number of successors}+1" + ".0"
        • if that predecessor version has no successor, the last digit of it's version number is incremented.
        • if that predecessor version has successors but the incremented name does not exist, that name is used.
        • otherwise a ".0" is added to the name until a non conflicting name is found.
        Example Graph:
         jcr:rootVersion
          |     |
         1.0   2.0
          |
         1.1
          |
         1.2 ---\  ------\
          |      \        \
         1.3   1.2.0   1.2.0.0
          |      |
         1.4   1.2.1 ----\
          |      |        \
         1.5   1.2.2   1.2.1.0
          |      |        |
         1.6     |     1.2.1.1
          |-----/
         1.7
         
        Parameters:
        history - the version history
        node - the node to checkin
        simple - if true indicates simple versioning
        Returns:
        the new version name
        Throws:
        RepositoryException - if an error occurs.
      • itemDiscarded

        protected void itemDiscarded​(InternalVersionItem item)
        Invoked by the internal version item itself, when it's underlying persistence state was discarded.
        Parameters:
        item - item that was discarded