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 StringADDINFO_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 voidaddSharedLockToken(String token)Adds new shared lock token to sharedLockTokens list.protected DatedateNow()Hook to allow unit testing - gets the current date/time.static LockInfofromJSON(String json)StringgetDepth()Returns lock depthStringgetExclusiveLockToken()Getter for exclusive lock token.DategetExpires()Retrieve the expiry date/time for this lock, or null if it never expires.StringgetOwner()Who owns the lock?longgetRemainingTimeoutSeconds()Remaining time before lock expires, in seconds.StringgetScope()Returns lock scopeSet<String>getSharedLockTokens()Getter for sharedLockTokens list.booleanisExclusive()Is it an exclusive lock?booleanisExpired()Whether this lock has expired.booleanisLocked()Returns true if node has shared or exclusive locksbooleanisShared()Is it a shared lock?voidsetDepth(String depth)Setter for lock depthvoidsetExclusiveLockToken(String token)Setter for exclusive lock tokenvoidsetExpires(Date expires)Set the expiry date/time for this lock.voidsetOwner(String owner)Set the username of who owns the lock.voidsetScope(String scope)Setter for lock scope.voidsetSharedLockTokens(Set<String> sharedLockTokens)Setter for sharedLockTokens list.voidsetTimeoutMinutes(int lockTimeoutMins)Sets the expiry date/time to lockTimeout minutes into the future.voidsetTimeoutSeconds(int lockTimeoutSecs)Sets the expiry date/time to lockTimeout seconds into the future.StringtoJSON()StringtoString()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:
setExclusiveLockTokenin interfaceLockInfo- Parameters:
token- Lock token
-
getExclusiveLockToken
public String getExclusiveLockToken()
Getter for exclusive lock token.- Specified by:
getExclusiveLockTokenin 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:
getSharedLockTokensin interfaceLockInfo
-
setSharedLockTokens
public void setSharedLockTokens(Set<String> sharedLockTokens)
Setter for sharedLockTokens list.- Specified by:
setSharedLockTokensin interfaceLockInfo
-
addSharedLockToken
public void addSharedLockToken(String token)
Adds new shared lock token to sharedLockTokens list.- Specified by:
addSharedLockTokenin 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:
isExclusivein 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:
setExpiresin 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:
getExpiresin interfaceLockInfo- Returns:
- the expires
-
getRemainingTimeoutSeconds
public long getRemainingTimeoutSeconds()
Remaining time before lock expires, in seconds.- Specified by:
getRemainingTimeoutSecondsin 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:
setTimeoutSecondsin 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:
setTimeoutMinutesin interfaceLockInfo- Parameters:
lockTimeoutMins- int
-
dateNow
protected Date dateNow()
Hook to allow unit testing - gets the current date/time.- Returns:
- Date
-
-