Class WebdavLockHelper

java.lang.Object
ro.sync.net.protocol.http.WebdavLockHelper

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

    • WebdavLockHelper

      public WebdavLockHelper()
      Constructor.
  • Method Details

    • updateLock

      public void updateLock(String sessionId, 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(String sessionId, URL resource, int lockTimeoutSeconds, List<String> headerKeys, List<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(String sessionId, String lockOwnerName)
      Sets the lock owner for the specified session Id.
      Parameters:
      sessionId - The session Id.
      lockOwnerName - The lock owner.
    • unlock

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

      public void unlock(String sessionId, URL resource, List<String> headerKeys, List<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(String sessionId, 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(String sessionId, 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.