Class WebdavLockHelper


  • @API(src=PRIVATE,
         type=NOT_EXTENDABLE)
    public class WebdavLockHelper
    extends java.lang.Object
    Helper class that allows one to implement locking for a WebDAV server in a multi-user scenario.
    • Constructor Summary

      Constructors 
      Constructor Description
      WebdavLockHelper()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLockHeader​(java.lang.String sessionId, java.net.HttpURLConnection conn)
      Adds the lock header so that we can perform write operations on a resource that we locked ourselves.
      long getServerPreferredTimeout()  
      boolean isLockEnabled()
      Checks if locking is enabled.
      boolean isSaveAllowed​(java.lang.String sessionId, java.net.URL url, int timeoutSeconds)
      Checks if save is allowed for a resource identified by its URL.
      void setLockOwner​(java.lang.String sessionId, java.lang.String lockOwnerName)
      Sets the lock owner for the specified session Id.
      void unlock​(java.lang.String sessionId, java.net.URL resource)
      Unlock a given resource.
      void unlock​(java.lang.String sessionId, java.net.URL resource, java.util.List<java.lang.String> headerKeys, java.util.List<java.lang.String> headerValues)
      Unlock a given resource.
      void updateLock​(java.lang.String sessionId, java.net.URL resource, int lockTimeoutSeconds)
      Lock a given resource.
      void updateLock​(java.lang.String sessionId, java.net.URL resource, int lockTimeoutSeconds, java.util.List<java.lang.String> headerKeys, java.util.List<java.lang.String> headerValues)
      Lock a given resource.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebdavLockHelper

        public WebdavLockHelper()
        Constructor.
    • Method Detail

      • updateLock

        public void updateLock​(java.lang.String sessionId,
                               java.net.URL resource,
                               int lockTimeoutSeconds)
                        throws LockException
        Lock a given resource.
        Parameters:
        sessionId - The session ID.
        resource - The resource to lock
        lockTimeoutSeconds - The timeout in seconds.
        Throws:
        LockException
      • updateLock

        public void updateLock​(java.lang.String sessionId,
                               java.net.URL resource,
                               int lockTimeoutSeconds,
                               java.util.List<java.lang.String> headerKeys,
                               java.util.List<java.lang.String> headerValues)
                        throws LockException
        Lock a given resource.
        Parameters:
        sessionId - The session ID.
        resource - The resource to lock
        lockTimeoutSeconds - The timeout in seconds.
        headerKeys - The header keys.
        headerValues - The header values.
        Throws:
        LockException
      • setLockOwner

        public void setLockOwner​(java.lang.String sessionId,
                                 java.lang.String lockOwnerName)
        Sets the lock owner for the specified session Id.
        Parameters:
        sessionId - The session Id.
        lockOwnerName - The lock owner.
      • unlock

        public void unlock​(java.lang.String sessionId,
                           java.net.URL resource)
                    throws LockException
        Unlock a given resource.
        Parameters:
        sessionId - The session Id.
        resource - The resource to unlock
        Throws:
        LockException
      • unlock

        public void unlock​(java.lang.String sessionId,
                           java.net.URL resource,
                           java.util.List<java.lang.String> headerKeys,
                           java.util.List<java.lang.String> headerValues)
                    throws LockException
        Unlock a given resource.
        Parameters:
        sessionId - The session Id.
        resource - The resource to unlock
        headerKeys - the header keys.
        headerValues - the header values.
        Throws:
        LockException
      • isLockEnabled

        public boolean isLockEnabled()
        Checks if locking is enabled.
        Returns:
        true if locking is enabled
      • getServerPreferredTimeout

        public long getServerPreferredTimeout()
        Returns:
        The server preferred timeout.
      • isSaveAllowed

        public boolean isSaveAllowed​(java.lang.String sessionId,
                                     java.net.URL url,
                                     int timeoutSeconds)
        Checks if save is allowed for a resource identified by its URL.
        Parameters:
        sessionId - The session ID.
        url - The URL for which the check is performed.
        timeoutSeconds - The timeout in seconds to set for the lock .
        Returns:
        true if saving is allowed.
      • addLockHeader

        public void addLockHeader​(java.lang.String sessionId,
                                  java.net.HttpURLConnection conn)
        Adds the lock header so that we can perform write operations on a resource that we locked ourselves.
        Parameters:
        sessionId - The session ID.
        conn - The connection to enrich with the lock header.