Package org.alfresco.repo.webdav
Class LockInfoImpl
- java.lang.Object
-
- org.alfresco.repo.webdav.LockInfoImpl
-
- All Implemented Interfaces:
java.io.Serializable,org.alfresco.repo.webdav.LockInfo
public class LockInfoImpl extends java.lang.Object implements java.io.Serializable, org.alfresco.repo.webdav.LockInfoClass 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 java.lang.StringADDINFO_WEBDAV_MARKER
-
Constructor Summary
Constructors Constructor Description LockInfoImpl()Default constructorLockInfoImpl(java.lang.String token, java.lang.String scope, java.lang.String depth)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSharedLockToken(java.lang.String token)Adds new shared lock token to sharedLockTokens list.protected java.util.DatedateNow()Hook to allow unit testing - gets the current date/time.static org.alfresco.repo.webdav.LockInfofromJSON(java.lang.String json)java.lang.StringgetDepth()Returns lock depthjava.lang.StringgetExclusiveLockToken()Getter for exclusive lock token.java.util.DategetExpires()Retrieve the expiry date/time for this lock, or null if it never expires.java.lang.StringgetOwner()Who owns the lock?longgetRemainingTimeoutSeconds()Remaining time before lock expires, in seconds.java.lang.StringgetScope()Returns lock scopejava.util.Set<java.lang.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(java.lang.String depth)Setter for lock depthvoidsetExclusiveLockToken(java.lang.String token)Setter for exclusive lock tokenvoidsetExpires(java.util.Date expires)Set the expiry date/time for this lock.voidsetOwner(java.lang.String owner)Set the username of who owns the lock.voidsetScope(java.lang.String scope)Setter for lock scope.voidsetSharedLockTokens(java.util.Set<java.lang.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.java.lang.StringtoJSON()java.lang.StringtoString()Return the lock info as a string
-
-
-
Field Detail
-
ADDINFO_WEBDAV_MARKER
public static final java.lang.String ADDINFO_WEBDAV_MARKER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LockInfoImpl
public LockInfoImpl()
Default constructor
-
LockInfoImpl
public LockInfoImpl(java.lang.String token, java.lang.String scope, java.lang.String depth)Constructor- Parameters:
token- Exclusive lock tokenscope- Lock scope (shared/exclusive)depth- Lock depth (0/infinity)
-
-
Method Detail
-
isLocked
public boolean isLocked()
Returns true if node has shared or exclusive locks- Specified by:
isLockedin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- boolean
-
setExclusiveLockToken
public void setExclusiveLockToken(java.lang.String token)
Setter for exclusive lock token- Specified by:
setExclusiveLockTokenin interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
token- Lock token
-
getExclusiveLockToken
public java.lang.String getExclusiveLockToken()
Getter for exclusive lock token.- Specified by:
getExclusiveLockTokenin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- String
-
setScope
public void setScope(java.lang.String scope)
Setter for lock scope.- Specified by:
setScopein interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
scope- String
-
getScope
public java.lang.String getScope()
Returns lock scope- Specified by:
getScopein interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- lock scope
-
setDepth
public void setDepth(java.lang.String depth)
Setter for lock depth- Specified by:
setDepthin interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
depth- lock depth
-
getDepth
public java.lang.String getDepth()
Returns lock depth- Specified by:
getDepthin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- lock depth
-
getSharedLockTokens
public java.util.Set<java.lang.String> getSharedLockTokens()
Getter for sharedLockTokens list.- Specified by:
getSharedLockTokensin interfaceorg.alfresco.repo.webdav.LockInfo
-
setSharedLockTokens
public void setSharedLockTokens(java.util.Set<java.lang.String> sharedLockTokens)
Setter for sharedLockTokens list.- Specified by:
setSharedLockTokensin interfaceorg.alfresco.repo.webdav.LockInfo
-
addSharedLockToken
public void addSharedLockToken(java.lang.String token)
Adds new shared lock token to sharedLockTokens list.- Specified by:
addSharedLockTokenin interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
token- The token to add.
-
isShared
public boolean isShared()
Is it a shared lock?- Specified by:
isSharedin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- true if shared.
-
toString
public java.lang.String toString()
Return the lock info as a string- Overrides:
toStringin classjava.lang.Object- Returns:
- String
-
toJSON
public java.lang.String toJSON()
- Specified by:
toJSONin interfaceorg.alfresco.repo.webdav.LockInfo
-
fromJSON
public static org.alfresco.repo.webdav.LockInfo fromJSON(java.lang.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:
isExpiredin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- true if expired.
-
isExclusive
public boolean isExclusive()
Is it an exclusive lock?- Specified by:
isExclusivein interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- true if exclusive.
-
getOwner
public java.lang.String getOwner()
Who owns the lock?- Specified by:
getOwnerin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- the owner
-
setOwner
public void setOwner(java.lang.String owner)
Set the username of who owns the lock.- Specified by:
setOwnerin interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
owner- Owner's username
-
setExpires
public void setExpires(java.util.Date expires)
Set the expiry date/time for this lock. Set to null for never expires.- Specified by:
setExpiresin interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
expires- the expires to set
-
getExpires
public java.util.Date getExpires()
Retrieve the expiry date/time for this lock, or null if it never expires.- Specified by:
getExpiresin interfaceorg.alfresco.repo.webdav.LockInfo- Returns:
- the expires
-
getRemainingTimeoutSeconds
public long getRemainingTimeoutSeconds()
Remaining time before lock expires, in seconds.- Specified by:
getRemainingTimeoutSecondsin 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:
setTimeoutSecondsin 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:
setTimeoutMinutesin interfaceorg.alfresco.repo.webdav.LockInfo- Parameters:
lockTimeoutMins- int
-
dateNow
protected java.util.Date dateNow()
Hook to allow unit testing - gets the current date/time.- Returns:
- Date
-
-