Package org.alfresco.repo.webdav
Class LockInfoImpl
- java.lang.Object
-
- org.alfresco.repo.webdav.LockInfoImpl
-
- All Implemented Interfaces:
Serializable
,LockInfo
public class LockInfoImpl extends Object implements Serializable, LockInfo
Class to represent a WebDAV lock info. Instances of this class are accessible my multiple threads as they are kept in theLockStore
. Clients of this class are expected to synchronise externally using the provided ReentrantReadWriteLock.- Author:
- Ivan Rybnikov
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ADDINFO_WEBDAV_MARKER
-
Constructor Summary
Constructors Constructor Description LockInfoImpl()
Default constructorLockInfoImpl(String token, String scope, String depth)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
fromJSON(String json)
String
getDepth()
Returns lock depthString
getExclusiveLockToken()
Getter for exclusive lock token.Date
getExpires()
Retrieve the expiry date/time for this lock, or null if it never expires.String
getOwner()
Who owns the lock?long
getRemainingTimeoutSeconds()
Remaining time before lock expires, in seconds.String
getScope()
Returns lock scopeSet<String>
getSharedLockTokens()
Getter for sharedLockTokens list.boolean
isExclusive()
Is it an exclusive lock?boolean
isExpired()
Whether this lock has expired.boolean
isLocked()
Returns true if node has shared or exclusive locksboolean
isShared()
Is it a shared lock?void
setDepth(String depth)
Setter for lock depthvoid
setExclusiveLockToken(String token)
Setter for exclusive lock tokenvoid
setExpires(Date expires)
Set the expiry date/time for this lock.void
setOwner(String owner)
Set the username of who owns the lock.void
setScope(String scope)
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.String
toJSON()
String
toString()
Return the lock info as a string
-
-
-
Field Detail
-
ADDINFO_WEBDAV_MARKER
public static final String ADDINFO_WEBDAV_MARKER
- See Also:
- Constant Field Values
-
-
Method Detail
-
isLocked
public boolean isLocked()
Returns true if node has shared or exclusive locks
-
setExclusiveLockToken
public void setExclusiveLockToken(String token)
Setter for exclusive lock token- Specified by:
setExclusiveLockToken
in interfaceLockInfo
- Parameters:
token
- Lock token
-
getExclusiveLockToken
public String getExclusiveLockToken()
Getter for exclusive lock token.- Specified by:
getExclusiveLockToken
in interfaceLockInfo
- Returns:
- String
-
setScope
public void setScope(String scope)
Setter for lock scope.
-
getScope
public String getScope()
Returns lock scope
-
setDepth
public void setDepth(String depth)
Setter for lock depth
-
getDepth
public String getDepth()
Returns lock depth
-
getSharedLockTokens
public Set<String> getSharedLockTokens()
Getter for sharedLockTokens list.- Specified by:
getSharedLockTokens
in interfaceLockInfo
-
setSharedLockTokens
public void setSharedLockTokens(Set<String> sharedLockTokens)
Setter for sharedLockTokens list.- Specified by:
setSharedLockTokens
in interfaceLockInfo
-
addSharedLockToken
public void addSharedLockToken(String token)
Adds new shared lock token to sharedLockTokens list.- Specified by:
addSharedLockToken
in interfaceLockInfo
- Parameters:
token
- The token to add.
-
isShared
public boolean isShared()
Is it a shared lock?
-
toString
public String toString()
Return the lock info as a string
-
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
public String getOwner()
Who owns the lock?
-
setOwner
public void setOwner(String owner)
Set the username of who owns the lock.
-
setExpires
public void setExpires(Date expires)
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
public Date 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
protected Date dateNow()
Hook to allow unit testing - gets the current date/time.- Returns:
- Date
-
-