You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by lu...@apache.org on 2004/10/02 19:33:49 UTC

cvs commit: jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods LockMethod.java

luetzkendorf    2004/10/02 10:33:49

  Modified:    webdavclient/clientlib/src/java/org/apache/webdav/lib/methods
                        Tag: SLIDE_2_1_RELEASE_BRANCH LockMethod.java
  Log:
  patch by Warwick Burrows for bug 30902
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.6.2.2   +28 -27    jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/LockMethod.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/LockMethod.java,v
  retrieving revision 1.6.2.1
  retrieving revision 1.6.2.2
  diff -u -r1.6.2.1 -r1.6.2.2
  --- LockMethod.java	16 Aug 2004 18:26:33 -0000	1.6.2.1
  +++ LockMethod.java	2 Oct 2004 17:33:49 -0000	1.6.2.2
  @@ -33,6 +33,8 @@
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.httpclient.HttpStatus;
  +import org.apache.commons.httpclient.util.URIUtil;
  +
   import org.apache.webdav.lib.WebdavState;
   import org.apache.webdav.lib.properties.LockEntryProperty;
   import org.apache.webdav.lib.util.DOMUtils;
  @@ -514,41 +516,40 @@
       public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
           throws IOException, HttpException {
           int status = getStatusLine().getStatusCode();
  -//      if (status == HttpStatus.SC_OK ||
  -//          status == HttpStatus.SC_MULTI_STATUS ||
  -//          status == HttpStatus.SC_CONFLICT) {
           if (status == HttpStatus.SC_OK      ||
               status == HttpStatus.SC_CREATED ||
               status == HttpStatus.SC_MULTI_STATUS ) {
   
               parseXMLResponse(input);
   
  -            // Not sure why this is here. 200 and 207 are both valid responses
  -            // and some webdav servers return 201 responses for lock-null.
  -            //if (status == HttpStatus.SC_OK) {
  -                NodeList list = getResponseDocument().getDocumentElement()
  -                      .getElementsByTagNameNS("DAV:", "locktoken");
  -
  -                if (list.getLength() == 1) {
  -                    Element locktoken = (Element) list.item(0);
  -                    NodeList list2 = locktoken.getElementsByTagNameNS("DAV:", "href");
  -                    if (list2.getLength() == 1) {
  -                        this.lockToken = DOMUtils.getTextValue(list2.item(0));
  -                        if (state instanceof WebdavState) {
  -                           ((WebdavState) state).addLock(getPath(), this.lockToken);
  -                        }
  +            NodeList list = getResponseDocument().getDocumentElement()
  +                  .getElementsByTagNameNS("DAV:", "locktoken");
  +
  +            if (list.getLength() == 1) {
  +                Element locktoken = (Element) list.item(0);
  +                NodeList list2 = locktoken.getElementsByTagNameNS("DAV:", "href");
  +                if (list2.getLength() == 1) {
  +                    this.lockToken = DOMUtils.getTextValue(list2.item(0));
  +                    if (state instanceof WebdavState) {
  +                       /* 
  +                        * lockMethod/unlockMethod take unescaped URIs but LockMathod.getPath()
  +                        * func returns an escaped URI so searching for the lock by path name in 
  +                        * the state object doesn't work. Convert escaped back to unescaped.
  +                        */
  +                        ((WebdavState) state).addLock(URIUtil.decode(getPath()), 
  +                                this.lockToken);
                       }
                   }
  +            }
   
  -                list = getResponseDocument().getDocumentElement()
  -                      .getElementsByTagNameNS("DAV:", "owner");
  +            list = getResponseDocument().getDocumentElement()
  +                  .getElementsByTagNameNS("DAV:", "owner");
   
  -                if (list.getLength() == 1) {
  -                    Element owner = (Element)list.item(0);
  +            if (list.getLength() == 1) {
  +                Element owner = (Element)list.item(0);
   
  -                    this.owner = DOMUtils.getTextValue(owner);
  -                }
  -            //}
  +                this.owner = DOMUtils.getTextValue(owner);
  +            }
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org