Package org.apache.jackrabbit.core.lock
Class LockInfo
- java.lang.Object
-
- org.apache.jackrabbit.core.lock.LockInfo
-
public abstract class LockInfo extends Object
Internal lock information.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeIdgetId()Return the ID of the lock holding nodeSessionImplgetLockHolder()Return the session currently holding the lockStringgetLockOwner()Return the lock owner.StringgetLockToken()Return the lock token associated with this lock.longgetTimeoutHint()Returns the timeout hint given when the lock was created.longgetTimeoutTime()Returns the time when this lock will expire.booleanisDeep()Return a flag indicating whether the lock is deep.booleanisExpired()booleanisLive()Return a flag indicating whether the lock is livebooleanisLockHolder(Session session)Return a flag indicating whether the session given is lock holder.booleanisSessionScoped()Return a flag indicating whether the lock is session-scopedbooleanmayChange()Return a flag indicating whether the lock information may still change.static NodeIdparseLockToken(String token)Parse a lock token string representation and return the lock holder node id.voidsetLive(boolean live)Set the live flagvoidsetLockHolder(SessionImpl lockHolder)Set the session currently holding the lockvoidthrowLockException(String message, SessionImpl session)Utility method that throws aLockExceptionwith the "failure node path" set to the path of the node that holds this lock.StringtoString()voidupdateTimeoutTime()Updates the timeout time of this lock based on current time and the timeout hint specified for this lock.
-
-
-
Constructor Detail
-
LockInfo
protected LockInfo(NodeId id, boolean sessionScoped, boolean deep, String lockOwner, long timeoutHint)
Create a new instance of this class.- Parameters:
id- lock holder node idsessionScoped- whether lock token is session scopeddeep- whether lock is deeplockOwner- owner of locktimeoutHint- lock timeout hint in seconds
-
LockInfo
protected LockInfo(LockInfo that)
-
-
Method Detail
-
getLockToken
public String getLockToken()
Return the lock token associated with this lock.- Returns:
- lock token
-
getId
public NodeId getId()
Return the ID of the lock holding node- Returns:
- the id
-
getLockOwner
public String getLockOwner()
Return the lock owner.- Returns:
- lock owner
-
isDeep
public boolean isDeep()
Return a flag indicating whether the lock is deep.- Returns:
trueif the lock is deep;falseotherwise
-
isLockHolder
public boolean isLockHolder(Session session)
Return a flag indicating whether the session given is lock holder.- Parameters:
session- session to compare with
-
getLockHolder
public SessionImpl getLockHolder()
Return the session currently holding the lock- Returns:
- session currently holding the lock
-
setLockHolder
public void setLockHolder(SessionImpl lockHolder)
Set the session currently holding the lock- Parameters:
lockHolder- session currently holding the lock
-
isLive
public boolean isLive()
Return a flag indicating whether the lock is live- Returns:
trueif the lock is live; otherwisefalse
-
setLive
public void setLive(boolean live)
Set the live flag- Parameters:
live- live flag
-
mayChange
public boolean mayChange()
Return a flag indicating whether the lock information may still change.- Returns:
trueif the lock is still alive.
-
isSessionScoped
public boolean isSessionScoped()
Return a flag indicating whether the lock is session-scoped- Returns:
trueif the lock is session-scoped; otherwisefalse
-
getTimeoutHint
public long getTimeoutHint()
Returns the timeout hint given when the lock was created.- Returns:
- timeout hint (in seconds)
-
getTimeoutTime
public long getTimeoutTime()
Returns the time when this lock will expire.- Returns:
- timeout time in milliseconds since the epoch
-
isExpired
public boolean isExpired()
-
updateTimeoutTime
public void updateTimeoutTime()
Updates the timeout time of this lock based on current time and the timeout hint specified for this lock. The timeout time is always rounded up.
-
throwLockException
public void throwLockException(String message, SessionImpl session) throws LockException, RepositoryException
Utility method that throws aLockExceptionwith the "failure node path" set to the path of the node that holds this lock. The given session is used to resolve the path of the lock holder node.- Parameters:
message- exception messagesession- session that the user was using for the failing operation- Throws:
LockException- always thrown, unless another error occursRepositoryException- if the path of this lock can not be resolved
-
parseLockToken
public static NodeId parseLockToken(String token) throws IllegalArgumentException
Parse a lock token string representation and return the lock holder node id.- Parameters:
token- string representation of lock token- Returns:
- lock holder node id
- Throws:
IllegalArgumentException- if some field is illegal
-
-