juergen 02/04/08 05:43:00
Modified: src/webdav/server/org/apache/slide/webdav/method
WebdavMethod.java
Log:
Added method getPreconditionViolationError() and sendPreconditionViolation().
(ralf)
Revision Changes Path
1.47 +44 -5
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
Index: WebdavMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- WebdavMethod.java 3 Apr 2002 11:52:40 -0000 1.46
+++ WebdavMethod.java 8 Apr 2002 12:43:00 -0000 1.47
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.46 2002/04/03 11:52:40 juergen Exp $
- * $Revision: 1.46 $
- * $Date: 2002/04/03 11:52:40 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.47 2002/04/08 12:43:00 juergen Exp $
+ * $Revision: 1.47 $
+ * $Date: 2002/04/08 12:43:00 $
*
* ====================================================================
*
@@ -93,6 +93,10 @@
import org.apache.slide.security.*;
import org.apache.slide.webdav.*;
import org.apache.slide.webdav.util.WebdavUtils;
+import org.apache.slide.webdav.util.PreconditionViolationException;
+import org.apache.slide.webdav.util.ViolatedPrecondition;
+import org.apache.slide.webdav.util.WebdavConstants;
+import org.apache.slide.webdav.util.DeltavConstants;
import org.apache.slide.util.logger.Logger;
@@ -152,7 +156,7 @@
/**
* Configuration.
*/
- private WebdavServletConfig config;
+ protected WebdavServletConfig config;
/**
@@ -266,7 +270,6 @@
this.requestUri = WebdavUtils.getRelativePath(req, config);
parseHeaders();
-
}
@@ -553,6 +556,42 @@
if (document != null) {
requestContentDocument = new
org.jdom.input.DOMBuilder().build(document);
}
+ }
+ }
+
+ /**
+ * Generate <error> for the given precondition violation.
+ *
+ * @param pve the ProconditionViolationException that describes the violated
+ * precondition.
+ *
+ * @return the <error> for the given precondition violation.
+ */
+ protected org.jdom.Element
getPreconditionViolationError(PreconditionViolationException pve) {
+
+ org.jdom.Element error = new org.jdom.Element(WebdavConstants.E_ERROR,
+
org.jdom.Namespace.getNamespace(WebdavConstants.DEFAULT_NAMESPACE));
+ org.jdom.Element violatedPrecondition = new
org.jdom.Element(pve.getViolatedPrecondition().getPrecondition(),
+
org.jdom.Namespace.getNamespace(WebdavConstants.DEFAULT_NAMESPACE));
+ error.addContent(violatedPrecondition);
+ return error;
+ }
+
+ /**
+ * Sends a precondition vilolation response.
+ *
+ * @param pve the ProconditionViolationException that describes the violated
+ * precondition.
+ */
+ protected void sendPreconditionViolation(PreconditionViolationException pve)
throws IOException {
+
+ if (pve != null) {
+
+ ViolatedPrecondition violatedPrecondition =
pve.getViolatedPrecondition();
+ resp.setStatus(violatedPrecondition.getStatusCode());
+ resp.setContentType(TEXT_XML);
+
+ new
org.jdom.output.XMLOutputter().output(getPreconditionViolationError(pve),
resp.getWriter());
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>