Package org.alfresco.repo.webdav
Class LockInfoImpl
- java.lang.Object
-
- org.alfresco.repo.webdav.LockInfoImpl
-
- All Implemented Interfaces:
Serializable
,org.alfresco.repo.webdav.LockInfo
public class LockInfoImpl extends Object implements Serializable, org.alfresco.repo.webdav.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 org.alfresco.repo.webdav.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- Specified by:
isLocked
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- boolean
-
setExclusiveLockToken
public void setExclusiveLockToken(String token)
Setter for exclusive lock token- Specified by:
setExclusiveLockToken
in interfaceorg.alfresco.repo.webdav.LockInfo
- Parameters:
token
- Lock token
-
getExclusiveLockToken
public String getExclusiveLockToken()
Getter for exclusive lock token.- Specified by:
getExclusiveLockToken
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- String
-
setScope
public void setScope(String scope)
Setter for lock scope.- Specified by:
setScope
in interfaceorg.alfresco.repo.webdav.LockInfo
- Parameters:
scope
- String
-
getScope
public String getScope()
Returns lock scope- Specified by:
getScope
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- lock scope
-
setDepth
public void setDepth(String depth)
Setter for lock depth- Specified by:
setDepth
in interfaceorg.alfresco.repo.webdav.LockInfo
- Parameters:
depth
- lock depth
-
getDepth
public String getDepth()
Returns lock depth- Specified by:
getDepth
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- lock depth
-
getSharedLockTokens
public Set<String> getSharedLockTokens()
Getter for sharedLockTokens list.- Specified by:
getSharedLockTokens
in interfaceorg.alfresco.repo.webdav.LockInfo
-
setSharedLockTokens
public void setSharedLockTokens(Set<String> sharedLockTokens)
Setter for sharedLockTokens list.- Specified by:
setSharedLockTokens
in interfaceorg.alfresco.repo.webdav.LockInfo
-
addSharedLockToken
public void addSharedLockToken(String token)
Adds new shared lock token to sharedLockTokens list.- Specified by:
addSharedLockToken
in interfaceorg.alfresco.repo.webdav.LockInfo
- Parameters:
token
- The token to add.
-
isShared
public boolean isShared()
Is it a shared lock?- Specified by:
isShared
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- true if shared.
-
toString
public String toString()
Return the lock info as a string
-
toJSON
public String toJSON()
- Specified by:
toJSON
in interfaceorg.alfresco.repo.webdav.LockInfo
-
fromJSON
public static org.alfresco.repo.webdav.LockInfo fromJSON(String json)
-
isExpired
public boolean isExpired()
Whether this lock has expired. If no expiry is set (i.e. expires is null) then false is always returned.- Specified by:
isExpired
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- true if expired.
-
isExclusive
public boolean isExclusive()
Is it an exclusive lock?- Specified by:
isExclusive
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- true if exclusive.
-
getOwner
public String getOwner()
Who owns the lock?- Specified by:
getOwner
in interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- the owner
-
setOwner
public void setOwner(String owner)
Set the username of who owns the lock.- Specified by:
setOwner
in interfaceorg.alfresco.repo.webdav.LockInfo
- Parameters:
owner
- Owner's username
-
setExpires
public void setExpires(Date expires)
Set the expiry date/time for this lock. Set to null for never expires.- Specified by:
setExpires
in interfaceorg.alfresco.repo.webdav.LockInfo
- 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 interfaceorg.alfresco.repo.webdav.LockInfo
- Returns:
- the expires
-
getRemainingTimeoutSeconds
public long getRemainingTimeoutSeconds()
Remaining time before lock expires, in seconds.- Specified by:
getRemainingTimeoutSeconds
in interfaceorg.alfresco.repo.webdav.LockInfo
-
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 interfaceorg.alfresco.repo.webdav.LockInfo
- 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 interfaceorg.alfresco.repo.webdav.LockInfo
- Parameters:
lockTimeoutMins
- int
-
dateNow
protected Date dateNow()
Hook to allow unit testing - gets the current date/time.- Returns:
- Date
-
-