Class VersionManagerImplBase
- java.lang.Object
-
- org.apache.jackrabbit.core.version.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
VersionManagerImplBase.WriteOperation
Helper for managing write operations.
-
Field Summary
Fields Modifier and Type Field Description protected SessionContext
context
Component context of the current sessionprotected NodeId
currentActivity
the node id of the current activityprotected HierarchyManager
hierMgr
hierarchy manager that operates on the locale state managerprotected NodeTypeRegistry
ntReg
node type registryprotected SessionImpl
session
workspace sessionprotected UpdatableItemStateManager
stateMgr
item state manager for all workspace operationsprotected InternalVersionManager
vMgr
the session version manager.
-
Constructor Summary
Constructors Modifier Constructor Description protected
VersionManagerImplBase(SessionContext context, UpdatableItemStateManager stateMgr, HierarchyManager hierMgr)
Creates a new version manager base for the given session
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected VersioningLock.ReadLock
acquireReadLock()
acquires the read lock on this version manager.protected VersioningLock.WriteLock
acquireWriteLock()
Acquires the write lock on this version manager.protected void
checkModify(NodeImpl node, int options, int permissions)
Checks modify and permissionsprotected void
checkModify(NodeStateEx state, int options, int permissions)
Checks modify and permissionsprotected NodeId
checkoutCheckin(NodeStateEx state, boolean checkin, boolean checkout, Calendar created)
Performs a checkin or checkout operation.protected boolean
checkVersionable(NodeStateEx state)
Checks if the underlying node is versionable, i.e.protected InternalVersion
getBaseVersion(NodeStateEx state)
Returns the internal base version for the underlying node.protected NodeId
getBaseVersionId(NodeStateEx state)
Returns the node id of the base version, retrieved from the node stateprotected NodeStateEx
getNodeStateEx(NodeId nodeId)
returns the node state for the given node idprotected InternalVersion
getVersion(Version v)
helper class that returns the internal version for a JCR one.protected InternalVersionHistory
getVersionHistory(NodeStateEx state)
Returns the internal version history for the underlying node.protected boolean
isCheckedOut(NodeStateEx state)
Determines the checked-out status of the given node state.protected String
safeGetJCRPath(NodeStateEx state)
Returns the JCR path for the given node state without throwing an exception.VersionManagerImplBase.WriteOperation
startWriteOperation()
Starts a write operation by acquiring the write lock and setting the item state manager to the "edit" state.
-
-
-
Field Detail
-
context
protected final SessionContext context
Component context of the current session
-
session
protected final SessionImpl session
workspace session
-
stateMgr
protected final UpdatableItemStateManager stateMgr
item state manager for all workspace operations
-
hierMgr
protected final HierarchyManager hierMgr
hierarchy manager that operates on the locale state manager
-
ntReg
protected final NodeTypeRegistry ntReg
node type registry
-
vMgr
protected final InternalVersionManager vMgr
the session version 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 sessionstateMgr
- the underlying state managerhierMgr
- 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. ifcheckin
istrue
the node is checked in. ifcheckout
istrue
the node is checked out. if both flags aretrue
the checkin is performed prior to the checkout and the operation is equivalent to a checkpoint operation.- Parameters:
state
- node statecheckin
- iftrue
the node is checked in.checkout
- iftrue
the node is checked out.created
- create time of the new version (if any), ornull
for the current time- Returns:
- the node id of the base version or
null
for a pure checkout. - Throws:
RepositoryException
- if an error occurs
-
checkVersionable
protected boolean checkVersionable(NodeStateEx state) throws UnsupportedRepositoryOperationException, RepositoryException
Checks if the underlying node is versionable, i.e. has 'mix:versionable' or a 'mix:simpleVersionable'.- Parameters:
state
- node state- Returns:
true
if this node is full versionable, i.e. is of nodetype mix:versionable- Throws:
UnsupportedRepositoryOperationException
- if this node is not versionable at allRepositoryException
-
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
-
getVersionHistory
protected InternalVersionHistory getVersionHistory(NodeStateEx state) throws RepositoryException
Returns the internal version history for the underlying node.- Parameters:
state
- node state- Returns:
- internal version history
- Throws:
RepositoryException
- if an error occurs
-
getVersion
protected InternalVersion getVersion(Version v) throws RepositoryException
helper class that returns the internal version for a JCR one.- Parameters:
v
- the jcr version- Returns:
- the internal version
- Throws:
RepositoryException
- if an error occurs
-
getBaseVersion
protected InternalVersion getBaseVersion(NodeStateEx state) throws RepositoryException
Returns the internal base version for the underlying node.- Parameters:
state
- node state- Returns:
- internal base version
- Throws:
RepositoryException
- if an error occurs
-
getNodeStateEx
protected NodeStateEx getNodeStateEx(NodeId nodeId) throws RepositoryException
returns the node state for the given node id- Parameters:
nodeId
- the node id- Returns:
- the node state or null if not found
- Throws:
RepositoryException
- if an error occurs
-
checkModify
protected void checkModify(NodeStateEx state, int options, int permissions) throws RepositoryException
Checks modify and permissions- Parameters:
state
- state to checkoptions
- options to checkpermissions
- 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 checkoptions
- options to checkpermissions
- 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
-
-