Locking an already locked resource (which RFC2518 mentions is illegal, but
might happen accidentally) causes unlocking to fail. I believe this is
because a null lock value is added to the locks and presented in the HTTP If
header for subsequent requests. Here is an example using the Slide command
line client

[ Slide ] $ open http://localhost:8080/webdav/davtests
[LOCALHOST] /webdav/davtests/ $ lock Document
Locking '/webdav/davtests/Document': succeeded.
[LOCALHOST] /webdav/davtests/ $ lock Document
Locking '/webdav/davtests/Document': failed.
Precondition Failed (412)
[LOCALHOST] /webdav/davtests/ $ unlock Document
Unlocking '/webdav/davtests/Document': failed.
Precondition Failed (412)
[LOCALHOST] /webdav/davtests/ $

One workaround is to make sure that if the lock value is null, then don't
add it to the list (as per this patch to the WebdavState class):

--- WebdavState.orig.java       Wed Aug 29 13:45:17 2001
+++ WebdavState.java    Wed Aug 29 13:42:52 2001
@@ -110,6 +110,7 @@
      */
     public void addLock(String uri, String value) {
 
+        if (value == null) return;
         if (lockTokens.contains(value))
             return;


Also the lock method does not produce a valid XML document as the payload
for the LOCK method, although this doesn't seem to stop it working ... I
guess a document fragment is good enough. If the lock method is to produce a
full XML document then this change is needed:

 
--- LockMethod.orig.java        Wed Aug 29 13:46:22 2001
+++ LockMethod.java     Wed Aug 29 12:02:05 2001
@@ -475,7 +475,7 @@
                 owner.appendChild(text);
 
                 StringWriter stringWriter = new StringWriter();
-                DOMWriter domWriter = new DOMWriter(stringWriter, true);
+                DOMWriter domWriter = new DOMWriter(stringWriter, false);
                 domWriter.print(document);
 
                 query = stringWriter.getBuffer().toString(); 

Reply via email to