View Javadoc

1   package com.bradmcevoy.http;
2   
3   import com.bradmcevoy.http.exceptions.LockedException;
4   import com.bradmcevoy.http.exceptions.NotAuthorizedException;
5   import com.bradmcevoy.http.exceptions.PreConditionFailedException;
6   
7   /**
8    * webDAV LOCK
9    *
10   * You should also implement LockingCollectionResource on your collections for full
11   * locking support
12   * 
13   * @author brad
14   */
15  public interface LockableResource extends Resource {
16      /**
17       * Lock this resource and return a token
18       * 
19       * @param timeout - in seconds, or null
20       * @param lockInfo
21       * @return - a result containing the token representing the lock if succesful,
22       * otherwise a failure reason code
23       */
24      public LockResult lock(LockTimeout timeout, LockInfo lockInfo) throws NotAuthorizedException, PreConditionFailedException, LockedException;
25      
26      /**
27       * Renew the lock and return new lock info
28       * 
29       * @param token
30       * @return
31       */
32      public LockResult refreshLock(String token) throws NotAuthorizedException, PreConditionFailedException;
33  
34      /**
35       * If the resource is currently locked, and the tokenId  matches the current
36       * one, unlock the resource
37       *
38       * @param tokenId
39       */
40      public void unlock(String tokenId) throws NotAuthorizedException, PreConditionFailedException;
41  
42      /**
43       *
44       * @return - the current lock, if the resource is locked, or null
45       */
46      public LockToken getCurrentLock();
47  }