Class 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 the LockStore. Clients of this class are expected to synchronise externally using the provided ReentrantReadWriteLock.
    Author:
    Ivan Rybnikov
    See Also:
    Serialized Form
    • Constructor Detail

      • LockInfoImpl

        public LockInfoImpl()
        Default constructor
      • LockInfoImpl

        public LockInfoImpl​(String token,
                            String scope,
                            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 LockInfo
        Returns:
        boolean
      • setExclusiveLockToken

        public void setExclusiveLockToken​(String token)
        Setter for exclusive lock token
        Specified by:
        setExclusiveLockToken in interface LockInfo
        Parameters:
        token - Lock token
      • setScope

        public void setScope​(String scope)
        Setter for lock scope.
        Specified by:
        setScope in interface LockInfo
        Parameters:
        scope - String
      • getScope

        public String getScope()
        Returns lock scope
        Specified by:
        getScope in interface LockInfo
        Returns:
        lock scope
      • setDepth

        public void setDepth​(String depth)
        Setter for lock depth
        Specified by:
        setDepth in interface LockInfo
        Parameters:
        depth - lock depth
      • getDepth

        public String getDepth()
        Returns lock depth
        Specified by:
        getDepth in interface LockInfo
        Returns:
        lock depth
      • setSharedLockTokens

        public void setSharedLockTokens​(Set<String> sharedLockTokens)
        Setter for sharedLockTokens list.
        Specified by:
        setSharedLockTokens in interface LockInfo
      • addSharedLockToken

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

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

        public String toString()
        Return the lock info as a string
        Overrides:
        toString in class Object
        Returns:
        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.
        Specified by:
        isExpired in interface LockInfo
        Returns:
        true if expired.
      • isExclusive

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

        public String getOwner()
        Who owns the lock?
        Specified by:
        getOwner in interface LockInfo
        Returns:
        the owner
      • setOwner

        public void setOwner​(String owner)
        Set the username of who owns the lock.
        Specified by:
        setOwner in interface 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 interface 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 interface LockInfo
        Returns:
        the expires
      • getRemainingTimeoutSeconds

        public long getRemainingTimeoutSeconds()
        Remaining time before lock expires, in seconds.
        Specified by:
        getRemainingTimeoutSeconds in interface 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 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 LockInfo
        Parameters:
        lockTimeoutMins - int
      • dateNow

        protected Date dateNow()
        Hook to allow unit testing - gets the current date/time.
        Returns:
        Date