Package ro.sync.net.protocol.http
Class WebdavLockHelper
java.lang.Object
ro.sync.net.protocol.http.WebdavLockHelper
Helper class that allows one to implement locking for a WebDAV server in a multi-user scenario.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLockHeader(String sessionId, HttpURLConnection conn) Adds the lock header so that we can perform write operations on a resource that we locked ourselves.longbooleanChecks if locking is enabled.booleanisSaveAllowed(String sessionId, URL url, int timeoutSeconds) Checks if save is allowed for a resource identified by its URL.voidsetLockOwner(String sessionId, String lockOwnerName) Sets the lock owner for the specified session Id.voidUnlock a given resource.voidUnlock a given resource.voidupdateLock(String sessionId, URL resource, int lockTimeoutSeconds) Lock a given resource.voidupdateLock(String sessionId, URL resource, int lockTimeoutSeconds, List<String> headerKeys, List<String> headerValues) Lock a given resource.
-
Constructor Details
-
WebdavLockHelper
public WebdavLockHelper()Constructor.
-
-
Method Details
-
updateLock
Lock a given resource.- Parameters:
sessionId- The session ID.resource- The resource to locklockTimeoutSeconds- 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 locklockTimeoutSeconds- The timeout in seconds.headerKeys- The header keys.headerValues- The header values.- Throws:
LockException
-
setLockOwner
Sets the lock owner for the specified session Id.- Parameters:
sessionId- The session Id.lockOwnerName- The lock owner.
-
unlock
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 unlockheaderKeys- the header keys.headerValues- the header values.- Throws:
LockException
-
isLockEnabled
public boolean isLockEnabled()Checks if locking is enabled.- Returns:
trueif locking is enabled
-
getServerPreferredTimeout
public long getServerPreferredTimeout()- Returns:
- The server preferred timeout.
-
isSaveAllowed
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:
trueif saving is allowed.
-
addLockHeader
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.
-