is SC_CREATED (patch)
I've removed the extra check of the status. It seemed redundant since
all of those response (with the possible exception of 201) should be
valid. I couldn't tell from the spec what a server is supposed to return
when locking a null resource, but 201 seems reasonable. In either case
the second check didn't seem to be doing any good.
Thanks for tracking this down.
-James
Michael H�usler wrote:
Hello,
Problem:
My code always tries to acquire a lock before invoking the PUT method.
This works well, when overwriting existing resources. It does not
work, when creating new resources on Xythos WFS and (according to user
reports) on Microsoft IIS. With these servers the PUT method fails and
a
locked empty file (0 bytes) remains on the server. For details see the
attached conversation.
Cause:
Xythos WFS returns a "201 Created" when requesting a LOCK on a
non-existing resource, but in org.apache.webdav.lib.methods.LockMethod
the method parseResponse ignores the response, if the status is not
SC_OK.
Solution:
The following change seems to do the trick:
Index:
clientlib/src/java/org/apache/webdav/lib/methods/LockMethod.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/webdavclient/clientlib/src/java/org/apac
he/web
dav/lib/methods/LockMethod.java,v
retrieving revision 1.6
diff -u -r1.6 LockMethod.java
--- clientlib/src/java/org/apache/webdav/lib/methods/LockMethod.java
2 Aug 2004 15:45:48 -0000 1.6
+++ clientlib/src/java/org/apache/webdav/lib/methods/LockMethod.java
16 Aug 2004 14:40:56 -0000
@@ -523,7 +523,8 @@
parseXMLResponse(input);
- if (status == HttpStatus.SC_OK) {
+ if (status == HttpStatus.SC_OK ||
+ status == HttpStatus.SC_CREATED) {
NodeList list =
getResponseDocument().getDocumentElement()
.getElementsByTagNameNS("DAV:", "locktoken");
Disclaimer:
I do not have the slightest idea, why this second check on the status
is
in the code anyway.
Best regards,
Michael
----------------------------------------------------------------------
--
### Locking the resource...
LOCK /akatose/test.xml HTTP/1.1
Authorization: Basic YWthdG9zZTpka3cxcHZrcw==
Content-Type: text/xml; charset=utf-8
User-Agent: Jakarta Commons-HttpClient/2.0final
Host: www.sharemation.com
Cookie: $Version=0; [EMAIL PROTECTED]; $Path=/
Content-Length: 253
Depth: infinity
Timeout: Second-14400
<?xml version="1.0" encoding="UTF-8"?>
<DAV:lockinfo
xmlns:DAV="DAV:"><DAV:lockscope><DAV:exclusive></DAV:exclusive></DAV:l
ockscope><DAV:locktype><DAV:write></DAV:write></DAV:locktype><DAV:owne
r>akatose ([EMAIL PROTECTED])</DAV:owner></DAV:lockinfo>
HTTP/1.1 201 Created
Lock-Token:
<opaquelocktoken:www.sharemation.com-LockTokenfiles:170777>
Date: Sun, 15 Aug 2004 13:55:05 GMT
Content-Type: text/xml;charset=UTF-8
Content-Length: 422
Server: Apache-Coyote/1.1
<?xml version="1.0" encoding="utf-8" ?>
<D:prop xmlns:D="DAV:">
<D:lockdiscovery>
<D:activelock><D:locktype><D:write/></D:locktype><D:lockscope><D:exclu
sive/></D:lockscope><D:depth>0</D:depth><D:owner>akatose
([EMAIL PROTECTED])</D:owner><D:timeout>Second-14400</D:timeout><D:
lockto
ken><D:href>opaquelocktoken:www.sharemation.com-LockTokenfiles:170777<
ken>/D:hre
f></D:locktoken></D:activelock>
</D:lockdiscovery>
</D:prop>
### PUT fails ...
PUT /akatose/test.xml HTTP/1.1
Content-Length: 5041
Authorization: Basic YWthdG9zZTpka3cxcHZrcw==
User-Agent: Jakarta Commons-HttpClient/2.0final
Host: www.sharemation.com
Cookie: $Version=0; [EMAIL PROTECTED]; $Path=/
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
</project>
HTTP/1.1 423 Locked
Cache-Control: no-cache
Pragma: no-cache
Date: Sun, 15 Aug 2004 13:55:06 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 170
Server: Apache-Coyote/1.1
<html><title>Error 423</title><body>
Error: 423
<p><p>Resource locked. If header expected with lock token. Resource
name = /akatose/test.xml</p></p> </body></html>
----------------------------------------------------------------------
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]