Class VersionManagerImplBase

  • Direct Known Subclasses:
    VersionManagerImplRestore

    public abstract class VersionManagerImplBase
    extends Object
    The JCR Version Manager implementation is split in several classes in order to group related methods together.

    This class provides basic routines for all operations and the methods related to checkin and checkout.

    • Field Detail

      • context

        protected final SessionContext context
        Component context of the current session
      • session

        protected final SessionImpl session
        workspace session
      • hierMgr

        protected final HierarchyManager hierMgr
        hierarchy manager that operates on the locale state manager
      • currentActivity

        protected NodeId currentActivity
        the node id of the current activity
    • Constructor Detail

      • VersionManagerImplBase

        protected VersionManagerImplBase​(SessionContext context,
                                         UpdatableItemStateManager stateMgr,
                                         HierarchyManager hierMgr)
        Creates a new version manager base for the given session
        Parameters:
        context - component context of the current session
        stateMgr - the underlying state manager
        hierMgr - local hierarchy manager
    • Method Detail

      • checkoutCheckin

        protected NodeId checkoutCheckin​(NodeStateEx state,
                                         boolean checkin,
                                         boolean checkout,
                                         Calendar created)
                                  throws RepositoryException
        Performs a checkin or checkout operation. if checkin is true the node is checked in. if checkout is true the node is checked out. if both flags are true the checkin is performed prior to the checkout and the operation is equivalent to a checkpoint operation.
        Parameters:
        state - node state
        checkin - if true the node is checked in.
        checkout - if true the node is checked out.
        created - create time of the new version (if any), or null for the current time
        Returns:
        the node id of the base version or null for a pure checkout.
        Throws:
        RepositoryException - if an error occurs
      • safeGetJCRPath

        protected String safeGetJCRPath​(NodeStateEx state)
        Returns the JCR path for the given node state without throwing an exception.
        Parameters:
        state - node state
        Returns:
        a JCR path string
      • isCheckedOut

        protected boolean isCheckedOut​(NodeStateEx state)
                                throws RepositoryException
        Determines the checked-out status of the given node state.

        A node is considered checked-out if it is versionable and checked-out, or is non-versionable but its nearest versionable ancestor is checked-out, or is non-versionable and there are no versionable ancestors.

        Parameters:
        state - node state
        Returns:
        a boolean
        Throws:
        RepositoryException - if an error occurs
        See Also:
        VersionManager.isCheckedOut(String), Node.isCheckedOut()
      • getBaseVersionId

        protected NodeId getBaseVersionId​(NodeStateEx state)
        Returns the node id of the base version, retrieved from the node state
        Parameters:
        state - node state
        Returns:
        the node id of the base version or null if not defined
      • checkModify

        protected void checkModify​(NodeStateEx state,
                                   int options,
                                   int permissions)
                            throws RepositoryException
        Checks modify and permissions
        Parameters:
        state - state to check
        options - options to check
        permissions - permissions to check
        Throws:
        RepositoryException - if an error occurs
      • checkModify

        protected void checkModify​(NodeImpl node,
                                   int options,
                                   int permissions)
                            throws RepositoryException
        Checks modify and permissions
        Parameters:
        node - node to check
        options - options to check
        permissions - permissions to check
        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

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

        public VersionManagerImplBase.WriteOperation startWriteOperation()
                                                                  throws RepositoryException
        Starts a write operation by acquiring the write lock and setting the item state manager to the "edit" state. If something goes wrong, the write lock is released and an exception is thrown.

        The pattern for using this method and the returned helper instance is:

             WriteOperation operation = startWriteOperation();
             try {
                 ...
                 operation.save(); // if everything is OK
                 ...
             } catch (...) {
                 ...
             } finally {
                 operation.close();
             }
         
        Returns:
        write operation helper
        Throws:
        RepositoryException - if the write operation could not be started