I am experimenting with the sample code WebdavFileStore. When I use Internet 
Explorer to open a location (i.e. File -> Open -> (check) Open as Web Folder), 
I see my file collection. I click on a document, test.doc, and I see the 
following output on the Tomcat (5.0.28) console. As you can see, an UNLOCK is 
followed by a LOCK.  

I observed that Word opens the document in Read-only mode (in the application 
title it displays this mode); therefore, I cannot save back to the server any 
changes I make. Since I was using Word 2003, I applied the modifications 
suggested by http://wiki.apache.org/jakarta-slide/WebFolderIssues to my 
registry. This registry change did not help as an UNLOCK always follow a LOCK. 

I noticed that the sample WebdavFileStore did not use a static Map as suggested 
by http://wiki.apache.org/jakarta-slide/WebDavConstructionKit (Correct way to 
interoperate with Slide locks). I decided to give it a shot, however, this did 
not stop the UNLOCK command from following the LOCK command. I also included 
the revised implementation below. 

Any help is appreciated.

//command sequence when opening a Word document

http-8080-Processor25, 05-Dec-2005 21:32:24, a, PROPFIND, 207 "Multi-Status", 
20 ms, /files/test.doc
http-8080-Processor25, 05-Dec-2005 21:32:24, a, LOCK, 200 "OK", 50 ms, 
/files/test.doc
http-8080-Processor25, 05-Dec-2005 21:32:24, a, GET, 200 "OK", 30 ms, 
/files/test.doc
http-8080-Processor25, 05-Dec-2005 21:32:24, a, UNLOCK, 204 "No Content", 20 
ms, /files/test.doc
http-8080-Processor25, 05-Dec-2005 21:32:24, a, GET, 200 "OK", 10 ms, 
/files/test.doc

//revised code of implementing WebdavStoreLockExtension interface

public void lockObject(String uri, String lockId, String subject, Date 
expiration, boolean exclusive,
            boolean inheritable) throws ServiceAccessException, 
AccessDeniedException {
     SimpleLock simpleLock = new 
SimpleLock(lockId,exclusive,inheritable,expiration,subject);
     Map lockMap = getLockMap();
     synchronized (lockMap) {
      if(!lockMap.containsKey(uri)) {
       lockMap.put(uri,simpleLock);
      }
  }
    }

    public void unlockObject(String uri, String lockId) throws 
ServiceAccessException, AccessDeniedException {
     Map lockMap = getLockMap();
     synchronized (lockMap) {
      if(lockMap.containsKey(uri)) {
       lockMap.remove(uri);
      }
  }
    }

    public Lock[] getLockInfo(String uri) throws ServiceAccessException, 
AccessDeniedException {
     Lock[] locks = null;
     Map lockMap = getLockMap();
     synchronized (lockMap) {
      if(lockMap.containsKey(uri)) {
       SimpleLock simpleLock = (SimpleLock)lockMap.get(uri);
       locks = new Lock[] { simpleLock };
      } else {
       locks = new SimpleLock[0];
      }
  }
     return locks;
    }

public static Map getLockMap() {
  if(null == lockMap) {
   lockMap = Collections.synchronizedMap(new HashMap());
  }
  return lockMap;
 }

Reply via email to