Class LockManagerImpl
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.lock.LockManagerImpl
-
- All Implemented Interfaces:
LockStateManager
,SessionListener
public class LockManagerImpl extends Object implements LockStateManager, SessionListener
LockManagerImpl
... TODO: TOBEFIXED. Lock objects obtained through this mgr are not informed if another session is or becomes lock-holder and removes the lock again.
-
-
Constructor Summary
Constructors Constructor Description LockManagerImpl(WorkspaceManager wspManager, ItemManager itemManager, CacheBehaviour cacheBehaviour)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLockToken(String lt)
Delegates this call toWorkspaceManager.addLockToken(String)
.void
checkLock(NodeState nodeState)
Check whether the given node state is locked by somebody else than the current session.Lock
getLock(NodeState nodeState)
If the session created a lock on the node with the given state, we already know the lock.String[]
getLockTokens()
Returns the lock tokens present on theSessionInfo
this manager has been created with.boolean
isLocked(NodeState nodeState)
Returnstrue
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 returnsfalse
.Lock
lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped)
Lock a node.Lock
lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint)
Lock a node.void
loggedOut(Session session)
Called when aSession
has been 'closed' by calling
.Session.logout()
void
loggingOut(Session session)
Called when aSession
is about to be 'closed' by calling
.Session.logout()
void
removeLockToken(String lt)
If the lock addressed by the token is session-scoped, this method will throw a LockException, such as defined by JSR170 v.1.0.1 forSession.removeLockToken(String)
.
Otherwise the call is delegated toWorkspaceManager.removeLockToken(String)
.void
unlock(NodeState nodeState)
Removes the lock on a node.
-
-
-
Constructor Detail
-
LockManagerImpl
public LockManagerImpl(WorkspaceManager wspManager, ItemManager itemManager, CacheBehaviour cacheBehaviour)
-
-
Method Detail
-
lock
public Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped) throws LockException, RepositoryException
Description copied from interface:LockStateManager
Lock a node. Checks whether the node is not locked and then returns a lock object for this node.- Specified by:
lock
in interfaceLockStateManager
isDeep
- whether the lock applies to this node onlyisSessionScoped
- whether the lock is session scoped- Returns:
- lock object
- Throws:
LockException
- if this node already is locked, or some descendant node is locked andisDeep
istrue
RepositoryException
- See Also:
LockStateManager.lock(NodeState,boolean,boolean)
-
lock
public Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint) throws RepositoryException
Description copied from interface:LockStateManager
Lock a node. Checks whether the node is not locked and then returns a lock object for this node.- Specified by:
lock
in interfaceLockStateManager
isDeep
- whether the lock applies to this node onlyisSessionScoped
- whether the lock is session scopedtimeoutHint
- optional timeout hint.ownerHint
- optional String defining the lock owner info to be displayed.- Returns:
- lock object
- Throws:
LockException
- if this node already is locked, or some descendant node is locked andisDeep
istrue
RepositoryException
- See Also:
LockStateManager.lock(NodeState,boolean,boolean,long,String)
-
unlock
public void unlock(NodeState nodeState) throws LockException, RepositoryException
Description copied from interface:LockStateManager
Removes the lock on a node.- Specified by:
unlock
in interfaceLockStateManager
- Throws:
LockException
- if this node is not locked or the session does not have the correct lock tokenRepositoryException
- See Also:
LockStateManager.unlock(NodeState)
-
getLock
public Lock getLock(NodeState nodeState) throws LockException, RepositoryException
If the session created a lock on the node with the given state, we already know the lock. Otherwise, the node state and its ancestors are searched for properties indicating a lock.
Note, that the flag indicating session-scoped lock cannot be retrieved unless the current session is the lock holder.- Specified by:
getLock
in interfaceLockStateManager
- Parameters:
nodeState
-- Returns:
- lock object
- Throws:
LockException
- if this node is not lockedRepositoryException
- See Also:
LockStateManager.getLock(NodeState)
-
isLocked
public boolean isLocked(NodeState nodeState) throws RepositoryException
Description copied from interface:LockStateManager
Returnstrue
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 returnsfalse
.- Specified by:
isLocked
in interfaceLockStateManager
- 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 returnsfalse
- Throws:
RepositoryException
- If an error occurs.- See Also:
LockStateManager.isLocked(NodeState)
-
checkLock
public void checkLock(NodeState nodeState) throws LockException, RepositoryException
Description copied from interface:LockStateManager
Check whether the given node state is locked by somebody else than the current session. Access is allowed if the node is not locked or if the session itself holds the lock to this node, i.e. the session contains the lock token for the lock. If the node is not locked at all this method returns silently.- Specified by:
checkLock
in interfaceLockStateManager
- Throws:
LockException
- if write access to the specified node is not allowedRepositoryException
- if some other error occurs- See Also:
LockStateManager.checkLock(NodeState)
-
getLockTokens
public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException
Returns the lock tokens present on theSessionInfo
this manager has been created with.- Specified by:
getLockTokens
in interfaceLockStateManager
- Returns:
- The lock tokens associated with the
Session
this lock manager has been created for. - Throws:
UnsupportedRepositoryOperationException
RepositoryException
- See Also:
LockStateManager.getLockTokens()
-
addLockToken
public void addLockToken(String lt) throws LockException, RepositoryException
Delegates this call toWorkspaceManager.addLockToken(String)
. If this succeeds this method will inform all locks stored in the local map in order to give them the chance to update their lock information.- Specified by:
addLockToken
in interfaceLockStateManager
- Parameters:
lt
- added lock token- Throws:
LockException
RepositoryException
- See Also:
LockStateManager.addLockToken(String)
-
removeLockToken
public void removeLockToken(String lt) throws LockException, RepositoryException
If the lock addressed by the token is session-scoped, this method will throw a LockException, such as defined by JSR170 v.1.0.1 forSession.removeLockToken(String)
.
Otherwise the call is delegated toWorkspaceManager.removeLockToken(String)
. All locks stored in the local lock map are notified by the removed token in order have them updated their lock information.- Specified by:
removeLockToken
in interfaceLockStateManager
- Parameters:
lt
- removed lock token- Throws:
LockException
RepositoryException
- See Also:
LockStateManager.removeLockToken(String)
-
loggingOut
public void loggingOut(Session session)
Description copied from interface:SessionListener
Called when aSession
is about to be 'closed' by calling
. At this moment the session is still valid.Session.logout()
- Specified by:
loggingOut
in interfaceSessionListener
- Parameters:
session
- theSession
that is about to be 'closed'- See Also:
SessionListener.loggingOut(Session)
-
loggedOut
public void loggedOut(Session session)
Description copied from interface:SessionListener
Called when aSession
has been 'closed' by calling
.Session.logout()
- Specified by:
loggedOut
in interfaceSessionListener
- Parameters:
session
- theSession
that has been 'closed'- See Also:
SessionListener.loggedOut(Session)
-
-