Package org.alfresco.repo.webdav
Class LockInfoImpl
java.lang.Object
org.alfresco.repo.webdav.LockInfoImpl
- All Implemented Interfaces:
Serializable
,LockInfo
Class to represent a WebDAV lock info. Instances of this class are accessible
my multiple threads as they are kept in the
LockStore
. Clients of this
class are expected to synchronise externally using the provided
ReentrantReadWriteLock.- Author:
- Ivan Rybnikov
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorLockInfoImpl
(String token, String scope, String depth) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSharedLockToken
(String token) Adds new shared lock token to sharedLockTokens list.protected Date
dateNow()
Hook to allow unit testing - gets the current date/time.static LockInfo
getDepth()
Returns lock depthGetter for exclusive lock token.Retrieve the expiry date/time for this lock, or null if it never expires.getOwner()
Who owns the lock?long
Remaining time before lock expires, in seconds.getScope()
Returns lock scopeGetter for sharedLockTokens list.boolean
Is it an exclusive lock?boolean
Whether this lock has expired.boolean
isLocked()
Returns true if node has shared or exclusive locksboolean
isShared()
Is it a shared lock?void
Setter for lock depthvoid
setExclusiveLockToken
(String token) Setter for exclusive lock tokenvoid
setExpires
(Date expires) Set the expiry date/time for this lock.void
Set the username of who owns the lock.void
Setter for lock scope.void
setSharedLockTokens
(Set<String> sharedLockTokens) Setter for sharedLockTokens list.void
setTimeoutMinutes
(int lockTimeoutMins) Sets the expiry date/time to lockTimeout minutes into the future.void
setTimeoutSeconds
(int lockTimeoutSecs) Sets the expiry date/time to lockTimeout seconds into the future.toJSON()
toString()
Return the lock info as a string
-
Field Details
-
ADDINFO_WEBDAV_MARKER
- See Also:
-
-
Constructor Details
-
LockInfoImpl
public LockInfoImpl()Default constructor -
LockInfoImpl
Constructor- Parameters:
token
- Exclusive lock tokenscope
- Lock scope (shared/exclusive)depth
- Lock depth (0/infinity)
-
-
Method Details
-
isLocked
public boolean isLocked()Returns true if node has shared or exclusive locks -
setExclusiveLockToken
Setter for exclusive lock token- Specified by:
setExclusiveLockToken
in interfaceLockInfo
- Parameters:
token
- Lock token
-
getExclusiveLockToken
Getter for exclusive lock token.- Specified by:
getExclusiveLockToken
in interfaceLockInfo
- Returns:
- String
-
setScope
Setter for lock scope. -
getScope
Returns lock scope -
setDepth
Setter for lock depth -
getDepth
Returns lock depth -
toString
Return the lock info as a string -
toJSON
-
fromJSON
-
isExpired
public boolean isExpired()Whether this lock has expired. If no expiry is set (i.e. expires is null) then false is always returned. -
isExclusive
public boolean isExclusive()Is it an exclusive lock?- Specified by:
isExclusive
in interfaceLockInfo
- Returns:
- true if exclusive.
-
getOwner
Who owns the lock? -
setOwner
Set the username of who owns the lock. -
setExpires
Set the expiry date/time for this lock. Set to null for never expires.- Specified by:
setExpires
in interfaceLockInfo
- Parameters:
expires
- the expires to set
-
getExpires
Retrieve the expiry date/time for this lock, or null if it never expires.- Specified by:
getExpires
in interfaceLockInfo
- Returns:
- the expires
-
getRemainingTimeoutSeconds
public long getRemainingTimeoutSeconds()Remaining time before lock expires, in seconds.- Specified by:
getRemainingTimeoutSeconds
in interfaceLockInfo
-
setTimeoutSeconds
public void setTimeoutSeconds(int lockTimeoutSecs) Sets the expiry date/time to lockTimeout seconds into the future. Provide a lockTimeout of WebDAV.TIMEOUT_INFINITY for never expires.- Specified by:
setTimeoutSeconds
in interfaceLockInfo
- Parameters:
lockTimeoutSecs
- int
-
setTimeoutMinutes
public void setTimeoutMinutes(int lockTimeoutMins) Sets the expiry date/time to lockTimeout minutes into the future. Provide a lockTimeout of WebDAV.TIMEOUT_INFINITY for never expires.- Specified by:
setTimeoutMinutes
in interfaceLockInfo
- Parameters:
lockTimeoutMins
- int
-
dateNow
Hook to allow unit testing - gets the current date/time.- Returns:
- Date
-