From: markt Date: Fri, 3 Apr 2009 10:28:40 +0000 (+0000) Subject: Fix a handful of failures when using the litmus WebDAV testsuite. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=188779e42f4448ab2b2264aee3055ddefb138cac;p=tomcat7.0 Fix a handful of failures when using the litmus WebDAV testsuite. Still other failures but these appear to relate to the lack of PROPPATCH support. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@761601 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java index cfa012538..94b0b1212 100644 --- a/java/org/apache/catalina/servlets/WebdavServlet.java +++ b/java/org/apache/catalina/servlets/WebdavServlet.java @@ -19,6 +19,7 @@ package org.apache.catalina.servlets; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; @@ -463,7 +464,7 @@ public class WebdavServlet Node propNode = null; - if (req.getInputStream().available() > 0) { + if (req.getContentLength() > 0) { DocumentBuilder documentBuilder = getDocumentBuilder(); try { @@ -494,9 +495,11 @@ public class WebdavServlet } } } catch (SAXException e) { - // Something went wrong - use the defaults. + // Something went wrong - bad request + resp.sendError(WebdavStatus.SC_BAD_REQUEST); } catch (IOException e) { - // Something went wrong - use the defaults. + // Something went wrong - bad request + resp.sendError(WebdavStatus.SC_BAD_REQUEST); } } @@ -1662,14 +1665,20 @@ public class WebdavServlet path, destinationPath); if ((!result) || (!errorList.isEmpty())) { - - sendReport(req, resp, errorList); + if (errorList.size() == 1) { + resp.sendError(errorList.elements().nextElement().intValue()); + } else { + sendReport(req, resp, errorList); + } return false; - } // Copy was successful - resp.setStatus(WebdavStatus.SC_CREATED); + if (exists) { + resp.setStatus(WebdavStatus.SC_NO_CONTENT); + } else { + resp.setStatus(WebdavStatus.SC_CREATED); + } // Removing any lock-null resource which would be present at // the destination path @@ -1739,9 +1748,15 @@ public class WebdavServlet try { resources.bind(dest, object); } catch (NamingException e) { - errorList.put - (source, - new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR)); + if (e.getCause() instanceof FileNotFoundException) { + // We know the source exists so it must be the + // destination dir that can't be found + errorList.put(source, + new Integer(WebdavStatus.SC_CONFLICT)); + } else { + errorList.put(source, + new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR)); + } return false; } } else { diff --git a/java/org/apache/naming/resources/FileDirContext.java b/java/org/apache/naming/resources/FileDirContext.java index 1bdd9dbe6..f42c367e2 100644 --- a/java/org/apache/naming/resources/FileDirContext.java +++ b/java/org/apache/naming/resources/FileDirContext.java @@ -578,8 +578,10 @@ public class FileDirContext extends BaseDirContext { is.close(); } } catch (IOException e) { - throw new NamingException - (sm.getString("resources.bindFailed", e)); + NamingException ne = new NamingException + (sm.getString("resources.bindFailed", e)); + ne.initCause(e); + throw ne; } }