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 NodeId
getId()
Return the ID of the lock holding nodeSessionImpl
getLockHolder()
Return the session currently holding the lockString
getLockOwner()
Return the lock owner.String
getLockToken()
Return the lock token associated with this lock.long
getTimeoutHint()
Returns the timeout hint given when the lock was created.long
getTimeoutTime()
Returns the time when this lock will expire.boolean
isDeep()
Return a flag indicating whether the lock is deep.boolean
isExpired()
boolean
isLive()
Return a flag indicating whether the lock is liveboolean
isLockHolder(Session session)
Return a flag indicating whether the session given is lock holder.boolean
isSessionScoped()
Return a flag indicating whether the lock is session-scopedboolean
mayChange()
Return a flag indicating whether the lock information may still change.static NodeId
parseLockToken(String token)
Parse a lock token string representation and return the lock holder node id.void
setLive(boolean live)
Set the live flagvoid
setLockHolder(SessionImpl lockHolder)
Set the session currently holding the lockvoid
throwLockException(String message, SessionImpl session)
Utility method that throws aLockException
with the "failure node path" set to the path of the node that holds this lock.String
toString()
void
updateTimeoutTime()
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:
true
if the lock is deep;false
otherwise
-
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:
true
if 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:
true
if the lock is still alive.
-
isSessionScoped
public boolean isSessionScoped()
Return a flag indicating whether the lock is session-scoped- Returns:
true
if 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 aLockException
with 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
-
-