Class 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.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:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      LockInfoImpl()
      Default constructor
      LockInfoImpl​(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
      void addSharedLockToken​(java.lang.String token)
      Adds new shared lock token to sharedLockTokens list.
      protected java.util.Date dateNow()
      Hook to allow unit testing - gets the current date/time.
      static org.alfresco.repo.webdav.LockInfo fromJSON​(java.lang.String json)  
      java.lang.String getDepth()
      Returns lock depth
      java.lang.String getExclusiveLockToken()
      Getter for exclusive lock token.
      java.util.Date getExpires()
      Retrieve the expiry date/time for this lock, or null if it never expires.
      java.lang.String getOwner()
      Who owns the lock?
      long getRemainingTimeoutSeconds()
      Remaining time before lock expires, in seconds.
      java.lang.String getScope()
      Returns lock scope
      java.util.Set<java.lang.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 locks
      boolean isShared()
      Is it a shared lock?
      void setDepth​(java.lang.String depth)
      Setter for lock depth
      void setExclusiveLockToken​(java.lang.String token)
      Setter for exclusive lock token
      void setExpires​(java.util.Date expires)
      Set the expiry date/time for this lock.
      void setOwner​(java.lang.String owner)
      Set the username of who owns the lock.
      void setScope​(java.lang.String scope)
      Setter for lock scope.
      void setSharedLockTokens​(java.util.Set<java.lang.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.
      java.lang.String toJSON()  
      java.lang.String toString()
      Return the lock info as a string
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 token
        scope - 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:
        isLocked in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        boolean
      • setExclusiveLockToken

        public void setExclusiveLockToken​(java.lang.String token)
        Setter for exclusive lock token
        Specified by:
        setExclusiveLockToken in interface org.alfresco.repo.webdav.LockInfo
        Parameters:
        token - Lock token
      • getExclusiveLockToken

        public java.lang.String getExclusiveLockToken()
        Getter for exclusive lock token.
        Specified by:
        getExclusiveLockToken in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        String
      • setScope

        public void setScope​(java.lang.String scope)
        Setter for lock scope.
        Specified by:
        setScope in interface org.alfresco.repo.webdav.LockInfo
        Parameters:
        scope - String
      • getScope

        public java.lang.String getScope()
        Returns lock scope
        Specified by:
        getScope in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        lock scope
      • setDepth

        public void setDepth​(java.lang.String depth)
        Setter for lock depth
        Specified by:
        setDepth in interface org.alfresco.repo.webdav.LockInfo
        Parameters:
        depth - lock depth
      • getDepth

        public java.lang.String getDepth()
        Returns lock depth
        Specified by:
        getDepth in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        lock depth
      • getSharedLockTokens

        public java.util.Set<java.lang.String> getSharedLockTokens()
        Getter for sharedLockTokens list.
        Specified by:
        getSharedLockTokens in interface org.alfresco.repo.webdav.LockInfo
      • setSharedLockTokens

        public void setSharedLockTokens​(java.util.Set<java.lang.String> sharedLockTokens)
        Setter for sharedLockTokens list.
        Specified by:
        setSharedLockTokens in interface org.alfresco.repo.webdav.LockInfo
      • addSharedLockToken

        public void addSharedLockToken​(java.lang.String token)
        Adds new shared lock token to sharedLockTokens list.
        Specified by:
        addSharedLockToken in interface org.alfresco.repo.webdav.LockInfo
        Parameters:
        token - The token to add.
      • isShared

        public boolean isShared()
        Is it a shared lock?
        Specified by:
        isShared in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        true if shared.
      • toString

        public java.lang.String toString()
        Return the lock info as a string
        Overrides:
        toString in class java.lang.Object
        Returns:
        String
      • toJSON

        public java.lang.String toJSON()
        Specified by:
        toJSON in interface org.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:
        isExpired in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        true if expired.
      • isExclusive

        public boolean isExclusive()
        Is it an exclusive lock?
        Specified by:
        isExclusive in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        true if exclusive.
      • getOwner

        public java.lang.String getOwner()
        Who owns the lock?
        Specified by:
        getOwner in interface org.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:
        setOwner in interface org.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:
        setExpires in interface org.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:
        getExpires in interface org.alfresco.repo.webdav.LockInfo
        Returns:
        the expires
      • getRemainingTimeoutSeconds

        public long getRemainingTimeoutSeconds()
        Remaining time before lock expires, in seconds.
        Specified by:
        getRemainingTimeoutSeconds in interface org.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 interface org.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 interface org.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