dirkv       01/08/24 13:18:04

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        XMLResponseMethodBase.java
  Log:
  The status element for the response can be inside the propstat element
  or directly inside the response element.
  
  Revision  Changes    Path
  1.24      +30 -21    
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
  
  Index: XMLResponseMethodBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XMLResponseMethodBase.java        2001/08/10 20:40:06     1.23
  +++ XMLResponseMethodBase.java        2001/08/24 20:18:04     1.24
  @@ -411,12 +411,39 @@
           }
   
           public int getStatusCode() {
  +            // The status element for the response can be inside the propstat 
element
  +            // or directly inside the response element.
  +
  +            //  <multistatus xmlns=\DAV:\>
  +            //    <response>
  +            //      <href>/slide/files/</href>
  +            //      <propstat>
  +            //        <prop><displayname>files</displayname></prop>
  +            //        <status>HTTP/1.1 200 OK</status>
  +            //      </propstat>
  +            //    </response>
  +            //  </multistatus>
  +            Element propstat = getFirstElement("DAV:", "propstat");
  +            if (propstat != null ) {
  +                Element status = DOMUtils.getFirstElement(propstat,"DAV:", 
"status");
  +                if (status != null) {
  +                    return DOMUtils.parseStatus(DOMUtils.getTextValue(status));
  +                }
  +            }
  +            
  +            //  <multistatus xmlns=\DAV:\>
  +            //    <response>
  +            //      <href>/slide/files/</href>
  +            //      <href>/slide/files/a</href>
  +            //      <status>HTTP/1.1 200 OK</status>
  +            //    </response>
  +            //  </multistatus>
               Element status = getFirstElement("DAV:", "status");
               if (status != null) {
                   return DOMUtils.parseStatus(DOMUtils.getTextValue(status));
  -            } else {
  -                return -1;
               }
  +
  +            return -1;
           }
   
           public String getHref() {
  @@ -429,23 +456,7 @@
           }
   
           protected Element getFirstElement(String namespace, String name) {
  -            NodeList list = this.node.getChildNodes();
  -            Element result = null;
  -            for (int i = 0;
  -                 result == null && list != null && i < list.getLength(); i++) {
  -
  -                try {
  -                    Element child = (Element) list.item(i);
  -                    if (name.equals(DOMUtils.getElementLocalName(child)) &&
  -                        namespace.equals(
  -                            DOMUtils.getElementNamespaceURI(child))) {
  -
  -                        result = child;
  -                    }
  -                } catch (ClassCastException e) {
  -                }
  -            }
  -            return result;
  +            return DOMUtils.getFirstElement(this.node, namespace, name);
           }
       }
   
  @@ -469,6 +480,4 @@
               return this.href;
           }
       }
  -
  -
   }
  
  
  

Reply via email to