|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.jcr2spi.lock.LockManagerImpl
public class LockManagerImpl
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 | |
---|---|
LockManagerImpl(WorkspaceManager wspManager,
ItemManager itemManager,
CacheBehaviour cacheBehaviour,
PathResolver pathResolver)
|
Method Summary | |
---|---|
void |
addLockToken(String lt)
Delegates this call to WorkspaceManager.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. |
Lock |
getLock(String absPath)
Returns the Lock object that applies to the node at the
specified absPath . |
String[] |
getLockTokens()
Returns the lock tokens present on the SessionInfo this
manager has been created with. |
boolean |
holdsLock(String absPath)
Returns true if the node at absPath holds a
lock; otherwise returns false . |
boolean |
isLocked(NodeState nodeState)
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 returns false . |
boolean |
isLocked(String absPath)
Returns true if the node at absPath is locked
either as a result of a lock held by that node or by a deep
lock on a node above that node; otherwise returns false . |
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. |
Lock |
lock(String absPath,
boolean isDeep,
boolean isSessionScoped,
long timeoutHint,
String ownerInfo)
Places a lock on the node at absPath . |
void |
loggedOut(Session session)
Called when a Session has been 'closed' by
calling
|
void |
loggingOut(Session session)
Called when a Session is about to be 'closed' by
calling
|
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 for Session.removeLockToken(String) . |
void |
unlock(NodeState nodeState)
Removes the lock on a node. |
void |
unlock(String absPath)
Removes the lock on the node at absPath . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LockManagerImpl(WorkspaceManager wspManager, ItemManager itemManager, CacheBehaviour cacheBehaviour, PathResolver pathResolver)
Method Detail |
---|
public Lock getLock(String absPath) throws LockException, RepositoryException
LockManager
Lock
object that applies to the node at the
specified absPath
. This may be either a lock on that node
itself or a deep lock on a node above that node.
If the node is not locked (no lock applies to this node), a
LockException
is thrown.
If the current session does not have sufficient privileges to get the
lock, an AccessDeniedException
is thrown.
An UnsupportedRepositoryOperationException
is thrown if
this implementation does not support locking.
A RepositoryException
is thrown if another error occurs.
getLock
in interface LockManager
absPath
- absolute path of node for which to obtain the lock
Lock
object.
LockException
- if no lock applies to this node.
UnsupportedRepositoryOperationException
- if this implementation does not support locking.
AccessDeniedException
- if the current session does not have permission to get the lock.
RepositoryException
- if another error occurs.LockManager.getLock(String)
public boolean isLocked(String absPath) throws RepositoryException
LockManager
true
if the node at absPath
is locked
either as a result of a lock held by that node or by a deep
lock on a node above that node; otherwise returns false
.
isLocked
in interface LockManager
absPath
- absolute path of node
boolean
.
RepositoryException
- if an error occurs.LockManager.isLocked(String)
public boolean holdsLock(String absPath) throws RepositoryException
LockManager
true
if the node at absPath
holds a
lock; otherwise returns false
. To hold a lock means
that this node has actually had a lock placed on it specifically, as
opposed to just having a lock apply to it due to a deep lock held
by a node above.
holdsLock
in interface LockManager
absPath
- absolute path of node
boolean
.
RepositoryException
- if an error occurs.LockManager.holdsLock(String)
public Lock lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo) throws RepositoryException
LockManager
Places a lock on the node at absPath
.
If successful, the node is said to hold the lock.
If isDeep
is true
then the lock
applies to the specified node and all its descendant nodes;
if false
, the lock applies only to the specified node.
On a successful lock, the jcr:isDeep
property of the
locked node is set to this value.
If isSessionScoped
is true
then this lock
will expire upon the expiration of the current session (either
through an automatic or explicit Session.logout
);
if false, this lock does not expire until it is explicitly unlocked,
it times out, or it is automatically unlocked due to a
implementation-specific limitation.
The timeout parameter specifies the number of seconds until the lock times out
(if it is not refreshed with Lock.refresh
in the meantime).
An implementation may use this information as a hint or ignore it altogether.
Clients can discover the actual timeout by inspecting the returned Lock
object.
The ownerInfo
parameter can be used to pass a string holding
owner information relevant to the client. An implementation may either use
or ignore this parameter. If it uses the parameter it must set the
jcr:lockOwner
property of the locked node to this value and
return this value on Lock.getLockOwner
. If it ignores this
parameter the jcr:lockOwner
property (and the value returned
by Lock.getLockOwner
) is set to either the value returned by
Session.getUserID
of the owning session or an
implementation-specific string identifying the owner.
The method returns a Lock
object representing the new lock.
If the lock is open-scoped the returned lock will include a lock token.
The lock token is also automatically added to the set of lock tokens held
by the current session.
The addition or change of the properties jcr:isDeep
and jcr:lockOwner
are persisted immediately; there is no
need to call save
.
It is possible to lock a node even if it is checked-in.
If this node is not of mixin node type mix:lockable
then an
LockException
is thrown.
If this node is already locked (either because it holds a lock or a
lock above it applies to it), a LockException
is thrown.
If isDeep
is true
and a descendant node of
this node already holds a lock, then a LockException
is
thrown.
If this node does not have a persistent state (has never been saved
or otherwise persisted), a LockException
is thrown.
If the current session does not have sufficient privileges to place the
lock, an AccessDeniedException
is thrown.
An UnsupportedRepositoryOperationException
is thrown if
this implementation does not support locking.
An InvalidItemStateException is thrown if this node has pending unsaved changes.
A RepositoryException
is thrown if another error occurs.
lock
in interface LockManager
absPath
- absolute path of node to be lockedisDeep
- if true
this lock will apply to this node and all its descendants; if
false
, it applies only to this node.isSessionScoped
- if true
, this lock expires with the current session; if false
it
expires when explicitly or automatically unlocked for some other reason.timeoutHint
- desired lock timeout in seconds (servers are free to
ignore this value); specify Long.MAX_VALUE
for no timeout.ownerInfo
- a string containing owner information
supplied by the client; servers are free to ignore this value.
Lock
object containing a lock token.
UnsupportedRepositoryOperationException
- if this implementation does not support locking.
LockException
- if this node is not mix:lockable
or this node is already locked or
isDeep
is true
and a descendant node of this node already holds a lock.
AccessDeniedException
- if this session does not have permission to lock this node.
InvalidItemStateException
- if this node has pending unsaved changes.
RepositoryException
- if another error occurs.LockManager.lock(String, boolean, boolean, long, String)
public void unlock(String absPath) throws LockException, RepositoryException
LockManager
absPath
. Also removes
the properties jcr:lockOwner
and jcr:lockIsDeep
from that node. As well, the corresponding lock token is removed from
the set of lock tokens held by the current Session
.
If the node does not currently hold a lock or holds a lock for which
this Session
is not the owner, then a
LockException
is thrown. Note however that the system
may give permission to a non-owning session to unlock a lock. Typically
such "lock-superuser" capability is intended to facilitate
administrational clean-up of orphaned open-scoped locks.
Note that it is possible to unlock a node even if it is checked-in (the lock-related properties will be changed despite the checked-in status).
If the current session does not have sufficient privileges to remove the
lock, an AccessDeniedException
is thrown.
An InvalidItemStateException
is thrown if this node has
pending unsaved changes.
An UnsupportedRepositoryOperationException
is thrown if
this implementation does not support locking.
A RepositoryException
is thrown if another error occurs.
unlock
in interface LockManager
absPath
- absolute path of node to be unlocked
LockException
- if this node does not currently hold a lock or holds a lock for which this Session does not have the correct lock token
UnsupportedRepositoryOperationException
- if this implementation does not support locking.
AccessDeniedException
- if the current session does not have permission to unlock this node.
InvalidItemStateException
- if this node has pending unsaved changes.
RepositoryException
- if another error occurs.LockManager.unlock(String)
public Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped) throws LockException, RepositoryException
LockManager
isDeep
- whether the lock applies to this node onlyisSessionScoped
- whether the lock is session scoped
LockException
- if this node already is locked, or some descendant
node is locked and isDeep
is true
RepositoryException
LockManager.lock(NodeState,boolean,boolean)
public Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint) throws RepositoryException
LockManager
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.
LockException
- if this node already is locked, or some descendant
node is locked and isDeep
is true
RepositoryException
LockManager.lock(NodeState,boolean,boolean,long,String)
public void unlock(NodeState nodeState) throws LockException, RepositoryException
LockManager
nodeState
-
LockException
- if this node is not locked or the session does not
have the correct lock token
RepositoryException
LockManager.unlock(NodeState)
public Lock getLock(NodeState nodeState) throws LockException, RepositoryException
nodeState
-
LockException
- if this node is not locked
RepositoryException
LockManager.getLock(NodeState)
public boolean isLocked(NodeState nodeState) throws RepositoryException
LockManager
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 returns false
.
nodeState
-
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 returns false
RepositoryException
- If an error occurs.LockManager.isLocked(NodeState)
public void checkLock(NodeState nodeState) throws LockException, RepositoryException
LockManager
nodeState
-
LockException
- if write access to the specified node is not allowed
RepositoryException
- if some other error occursLockManager.checkLock(NodeState)
public String[] getLockTokens()
SessionInfo
this
manager has been created with.
getLockTokens
in interface LockManager
Session
this
lock manager has been created for.LockManager.getLockTokens()
public void addLockToken(String lt) throws LockException, RepositoryException
WorkspaceManager.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.
addLockToken
in interface LockManager
lt
- added lock token
LockException
- if the specified lock token is already held by
another Session
and the implementation
does not support simultaneous ownership of open-scoped
locks.
RepositoryException
- if another error occurs.LockManager.addLockToken(String)
public void removeLockToken(String lt) throws LockException, RepositoryException
Session.removeLockToken(String)
.WorkspaceManager.removeLockToken(String)
.
All locks stored in the local lock map are notified by the removed
token in order have them updated their lock information.
removeLockToken
in interface LockManager
lt
- removed lock token
LockException
- if the current Session
does not hold
the specified lock token.
RepositoryException
- if another error occurs.LockManager.removeLockToken(String)
public void loggingOut(Session session)
SessionListener
Session
is about to be 'closed' by
calling Session.logout()
- Specified by:
loggingOut
in interface SessionListener
- Parameters:
session
- - See Also:
SessionListener.loggingOut(Session)
public void loggedOut(Session session)
SessionListener
Session
has been 'closed' by
calling Session.logout()
- Specified by:
loggedOut
in interface SessionListener
- Parameters:
session
- - See Also:
SessionListener.loggedOut(Session)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |