juergen 02/05/28 05:39:41
Modified: src/webdav/server/org/apache/slide/webdav/method
AbstractMultistatusResponseMethod.java
AclMethod.java CheckinMethod.java
CheckoutMethod.java CopyMethod.java GetMethod.java
LabelMethod.java LockMethod.java
MkworkspaceMethod.java OptionsMethod.java
PropFindMethod.java PropPatchMethod.java
PutMethod.java ReportMethod.java SearchMethod.java
UncheckoutMethod.java UpdateMethod.java
VersionControlMethod.java WebdavMethod.java
Log:
Finished replacement of org.w3c.dom by JDOM. Whether we should use JDOM or not,
using both DOM and JDOM was ugly and resource consuming.
Also did some minor code clean-up.
(ralf)
Revision Changes Path
1.25 +4 -4
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java
Index: AbstractMultistatusResponseMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- AbstractMultistatusResponseMethod.java 17 May 2002 11:54:32 -0000 1.24
+++ AbstractMultistatusResponseMethod.java 28 May 2002 12:39:40 -0000 1.25
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java,v
1.24 2002/05/17 11:54:32 juergen Exp $
- * $Revision: 1.24 $
- * $Date: 2002/05/17 11:54:32 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java,v
1.25 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.25 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -148,7 +148,7 @@
* @exception WebdavException Does not happen
*/
protected void parseRequest()
- throws WebdavException, IOException {
+ throws WebdavException {
sourceUri = requestUri;
if (sourceUri == null) {
1.21 +22 -34
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java
Index: AclMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- AclMethod.java 28 May 2002 09:16:54 -0000 1.20
+++ AclMethod.java 28 May 2002 12:39:40 -0000 1.21
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v
1.20 2002/05/28 09:16:54 juergen Exp $
- * $Revision: 1.20 $
- * $Date: 2002/05/28 09:16:54 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v
1.21 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.21 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -68,9 +68,6 @@
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
import org.apache.util.WebdavStatus;
import org.apache.slide.authenticate.CredentialsToken;
@@ -179,16 +176,18 @@
resourcePath = "/";
}
- if (requestBody.length() != 0) {
try {
- retrieveRequestContent();
- Document document = getRequestContent();
+ if (requestBody.length() == 0) {
+ throw new JDOMException("Request content must not be empty");
+ }
+
+ Document document = parseRequestContent();
// Get the root element of the document
Element acl = document.getRootElement();
if ( (acl == null) || ( ! E_ACL.equals(acl.getName()) ) ) {
- throw new SAXException("Request content document must start
with an <"+
+ throw new JDOMException("Request content document must start with
an <"+
E_ACL+"> element");
}
@@ -210,7 +209,7 @@
// continue;
}
if (inheritedCount > 1) {
- throw new SAXException("Element <"+E_ACE+"> must
contain at most one <"+E_INHERITED+"> element");
+ throw new JDOMException("Element <"+E_ACE+"> must contain
at most one <"+E_INHERITED+"> element");
}
// Ignore protected (protected <-> inherited for Slide)
@@ -219,13 +218,13 @@
if (protectedCount == 1)
continue;
if (protectedCount > 1) {
- throw new SAXException("Element <"+E_ACE+"> must
contain at most one <"+E_PROTECTED+"> element");
+ throw new JDOMException("Element <"+E_ACE+"> must contain
at most one <"+E_PROTECTED+"> element");
}
List principalList = ace.getChildren(E_PRINCIPAL,
NamespaceCache.DEFAULT_NAMESPACE);
if (principalList.size() != 1) {
- throw new SAXException("Element <"+E_ACE+"> must
contain a <"+E_PRINCIPAL+"> element");
+ throw new JDOMException("Element <"+E_ACE+"> must contain
a <"+E_PRINCIPAL+"> element");
}
Element principalElement = (Element) principalList.get(0);
@@ -238,7 +237,7 @@
// there must be only ONE grant or deny element
if ((grantList.size()+denyList.size())!=1) {
- throw new SAXException("Element <"+E_ACE+"> must
contain either a <"+
+ throw new JDOMException("Element <"+E_ACE+"> must contain
either a <"+
E_GRANT+"> or a <"+
E_DENY+"> element");
}
@@ -356,7 +355,7 @@
e.printStackTrace();
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- } catch (SAXException e) {
+ } catch (JDOMException e) {
System.err.println("Error parsing requestBody:");
System.err.println(requestBody);
e.printStackTrace();
@@ -365,22 +364,11 @@
resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
} catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- } catch (ParserConfigurationException e) {
- System.err.println(e.getMessage());
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException
- (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
} catch (IOException e) {
e.printStackTrace();
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
- } else {
- // requestBody.length() == 0
- System.err.println("Error requestBody is empty");
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
}
@@ -421,7 +409,7 @@
*
* @return the URI of the principal
*/
- protected String parsePrincipal(Element principal) throws SAXException {
+ protected String parsePrincipal(Element principal) throws JDOMException {
// FIXME: make constants and make sure they are used in
// AclMethod:parsePrincipal and PropFindMethod:writePrincipal
@@ -429,7 +417,7 @@
if (href != null) {
String text = href.getText();
if (text.length() == 0) {
- throw new SAXException("<"+E_HREF+"> element of
<"+principal.getName()+
+ throw new JDOMException("<"+E_HREF+"> element of
<"+principal.getName()+
"> must not be emtpy");
}
return getSlidePath(text);
@@ -444,7 +432,7 @@
return token.getNamespaceConfig().getUsersPath() + "/" +
token.getNamespaceConfig().getGuestPath();
}
- throw new SAXException("<"+principal.getName()+"> element must
contain either a "+
+ throw new JDOMException("<"+principal.getName()+"> element must
contain either a "+
"<"+E_HREF+">, "+
"<"+E_ALL+">, "+
"<"+E_SELF+"> or "+
@@ -455,18 +443,18 @@
*
* @return the URI of the inheritence
*/
- protected String parseInheritence(Element inheritence) throws SAXException {
+ protected String parseInheritence(Element inheritence) throws JDOMException {
Element href = getChild(inheritence, NamespaceCache.DEFAULT_NAMESPACE,
E_HREF);
if (href != null) {
String text = href.getText();
if (text.length() == 0) {
- throw new SAXException("<"+E_HREF+"> element of
<"+inheritence.getName()+
+ throw new JDOMException("<"+E_HREF+"> element of
<"+inheritence.getName()+
"> must not be emtpy");
}
return getSlidePath(text);
}
- throw new SAXException("<"+inheritence.getName()+"> element must
contain a <"+
+ throw new JDOMException("<"+inheritence.getName()+"> element must
contain a <"+
E_HREF+"> element");
}
@@ -477,7 +465,7 @@
* @return privilege
*/
protected int parsePrivilege(Element privilege)
- throws SAXException {
+ throws JDOMException {
if (hasChild(privilege, NamespaceCache.DEFAULT_NAMESPACE, "all")) {
return PRIVILEGE_ALL;
@@ -521,7 +509,7 @@
// return PRIVILEGE_REVOKE_PERMISSION;
} else {
System.err.println("Error: Unknown privilege !!!");
- throw new SAXException("Unknown privilege
<"+privilege.getName()+">");
+ throw new JDOMException("Unknown privilege
<"+privilege.getName()+">");
}
}
1.8 +12 -17
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java
Index: CheckinMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CheckinMethod.java 29 Apr 2002 16:49:43 -0000 1.7
+++ CheckinMethod.java 28 May 2002 12:39:40 -0000 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v
1.7 2002/04/29 16:49:43 pnever Exp $
- * $Revision: 1.7 $
- * $Date: 2002/04/29 16:49:43 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v
1.8 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.8 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -68,8 +68,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
@@ -118,19 +116,17 @@
* @throws WebdavException
* @throws IOException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
}
if( req.getContentLength() > 0 ) {
try{
- retrieveRequestContent();
- Element cie = getRequestContent().getRootElement();
+ Element cie = parseRequestContent().getRootElement();
if( cie == null || !cie.getName().equals(E_CHECKIN) ) {
Domain.warn( "Root element must be "+E_CHECKIN );
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("Root element must be
<"+E_CHECKIN+">");
}
Iterator i = cie.getChildren().iterator();
while( i.hasNext() ) {
@@ -139,17 +135,16 @@
forkOk = true;
}
}
- catch (SAXException e){
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch (ParserConfigurationException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ catch (JDOMException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
}
}
1.10 +16 -17
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java
Index: CheckoutMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CheckoutMethod.java 22 May 2002 16:24:27 -0000 1.9
+++ CheckoutMethod.java 28 May 2002 12:39:40 -0000 1.10
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v
1.9 2002/05/22 16:24:27 pnever Exp $
- * $Revision: 1.9 $
- * $Date: 2002/05/22 16:24:27 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v
1.10 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.10 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -68,8 +68,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
@@ -132,7 +130,7 @@
* @throws WebdavException
* @throws IOException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
@@ -148,12 +146,16 @@
ViolatedPrecondition violatedPrecondition =
new
ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
WebdavStatus.SC_CONFLICT);
+ try {
sendPreconditionViolation(new
PreconditionViolationException(violatedPrecondition,
resourcePath));
+ } catch (IOException ioe) {}
throw new WebdavException(getErrorCode((Exception)e));
}
catch (SlideException e) {
+ try {
resp.sendError(getErrorCode((Exception)e));
+ } catch (IOException ioe) {}
throw new WebdavException(getErrorCode((Exception)e));
}
}
@@ -161,12 +163,10 @@
if( req.getContentLength() > 0 ) {
try{
- retrieveRequestContent();
- Element coe = getRequestContent().getRootElement();
+ Element coe = parseRequestContent().getRootElement();
if( coe == null || !coe.getName().equals(E_CHECKOUT) ) {
Domain.warn( "Root element must be "+E_CHECKOUT );
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("Root element must be
<"+E_CHECKOUT+">");
}
Iterator i = coe.getChildren().iterator();
while( i.hasNext() ) {
@@ -187,17 +187,16 @@
}
}
}
- catch (SAXException e){
- resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch (ParserConfigurationException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ catch (JDOMException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
}
}
1.39 +5 -5
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java
Index: CopyMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- CopyMethod.java 21 May 2002 08:57:45 -0000 1.38
+++ CopyMethod.java 28 May 2002 12:39:40 -0000 1.39
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v
1.38 2002/05/21 08:57:45 juergen Exp $
- * $Revision: 1.38 $
- * $Date: 2002/05/21 08:57:45 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v
1.39 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.39 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -153,7 +153,7 @@
*
* @exception WebdavException Does not happen
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
super.parseRequest();
labelHeader = req.getHeader(DeltavConstants.H_LABEL);
}
@@ -364,7 +364,7 @@
else {
// this is not a checked-out VCR so remove all DeltaV properties
Enumeration propertyNamesEnum =
- destinationRevisionDescriptor.getPropertiesNames();
+ destinationRevisionDescriptor.enumeratePropertiesName();
String propertyName = null;
while (propertyNamesEnum.hasMoreElements()) {
propertyName = (String)propertyNamesEnum.nextElement();
1.29 +11 -22
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java
Index: GetMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- GetMethod.java 14 May 2002 15:33:42 -0000 1.28
+++ GetMethod.java 28 May 2002 12:39:40 -0000 1.29
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
1.28 2002/05/14 15:33:42 pnever Exp $
- * $Revision: 1.28 $
- * $Date: 2002/05/14 15:33:42 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
1.29 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.29 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -70,10 +70,9 @@
import java.text.ParseException;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
+
import org.jdom.Document;
-import org.jdom.input.DOMBuilder;
+import org.jdom.JDOMException;
import org.apache.util.WebdavStatus;
import org.apache.slide.common.NamespaceAccessToken;
@@ -182,7 +181,7 @@
* Parse XML request.
*/
protected void parseRequest()
- throws WebdavException, IOException {
+ throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
@@ -198,31 +197,20 @@
ViolatedPrecondition violatedPrecondition =
new
ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
WebdavStatus.SC_CONFLICT);
+ try {
sendPreconditionViolation(new
PreconditionViolationException(violatedPrecondition,
resourcePath));
+ } catch (IOException ioe) {}
throw new WebdavException(getErrorCode((Exception)e));
}
catch (SlideException e) {
+ try {
resp.sendError(getErrorCode((Exception)e));
+ } catch (IOException ioe) {}
throw new WebdavException(getErrorCode((Exception)e));
}
}
- try{
- retrieveRequestContent();
- }
- catch (SAXException e){
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
- catch (IOException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
- catch (ParserConfigurationException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
}
@@ -869,6 +857,7 @@
}
rangeHeader = rangeHeader.substring(6);
+
// Vector which will contain all the ranges which are successfully
// parsed.
1.6 +19 -25
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LabelMethod.java
Index: LabelMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LabelMethod.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LabelMethod.java 17 May 2002 08:38:45 -0000 1.5
+++ LabelMethod.java 28 May 2002 12:39:40 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LabelMethod.java,v
1.5 2002/05/17 08:38:45 juergen Exp $
- * $Revision: 1.5 $
- * $Date: 2002/05/17 08:38:45 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LabelMethod.java,v
1.6 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -73,10 +73,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-
-import org.xml.sax.SAXException;
-
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.NestedSlideException;
@@ -116,7 +112,7 @@
/**
* LABEL method.
*
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ralf Stuckert</a>
*/
@@ -206,7 +202,7 @@
* @throws WebdavException
* @throws IOException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
@@ -214,17 +210,16 @@
labelHeader = req.getHeader(DeltavConstants.H_LABEL);
try{
- retrieveRequestContent();
- Document document = getRequestContent();
+ Document document = parseRequestContent();
if (document == null) {
- throw new SAXException(CONTENT_MISSING);
+ throw new JDOMException(CONTENT_MISSING);
}
Element root = document.getRootElement();
if (root == null) {
- throw new SAXException(CONTENT_MISSING);
+ throw new JDOMException(CONTENT_MISSING);
}
if ( ! DeltavConstants.E_LABEL.equals(root.getName())) {
- throw new SAXException(MUST_START_WITH_LABEL);
+ throw new JDOMException(MUST_START_WITH_LABEL);
}
Element current = root.getChild(DeltavConstants.E_ADD,
NamespaceCache.DEFAULT_NAMESPACE);
@@ -235,19 +230,19 @@
current = root.getChild(DeltavConstants.E_SET,
NamespaceCache.DEFAULT_NAMESPACE);
if ( current != null) {
if (operationElement != null) {
- throw new
SAXException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
+ throw new
JDOMException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
}
operationElement = current;
}
current = root.getChild(DeltavConstants.E_REMOVE,
NamespaceCache.DEFAULT_NAMESPACE);
if ( current != null) {
if (operationElement != null) {
- throw new
SAXException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
+ throw new
JDOMException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
}
operationElement = current;
}
if (operationElement == null) {
- throw new SAXException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
+ throw new
JDOMException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
}
operation = operationElement.getName();
@@ -255,21 +250,20 @@
if ( (labelName == null) ||
(labelName.getText() == null) ||
(labelName.getText().length() == 0) ) {
- throw new SAXException(LABEL_MISSING);
+ throw new JDOMException(LABEL_MISSING);
}
label = labelName.getText();
}
- catch (SAXException e){
- resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
- }
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch (ParserConfigurationException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ catch (JDOMException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
}
1.36 +20 -27
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
Index: LockMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- LockMethod.java 27 May 2002 12:36:17 -0000 1.35
+++ LockMethod.java 28 May 2002 12:39:40 -0000 1.36
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
1.35 2002/05/27 12:36:17 juergen Exp $
- * $Revision: 1.35 $
- * $Date: 2002/05/27 12:36:17 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
1.36 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.36 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -68,9 +68,6 @@
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
import org.apache.util.PropertyWriter;
import org.apache.util.WebdavStatus;
@@ -88,6 +85,7 @@
import org.jdom.Document;
import org.jdom.Element;
+import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
@@ -293,16 +291,15 @@
lockType = LOCK_CREATION;
try {
- retrieveRequestContent();
- Document document = getRequestContent();
+ Document document = parseRequestContent();
if (document == null) {
- throw new SAXException("Request content missing");
+ throw new JDOMException("Request content missing");
}
Element lockInfoElement = document.getRootElement();
if ( (lockInfoElement == null) ||
( ! E_LOCKINFO.equals(lockInfoElement.getName()) ) ) {
- throw new SAXException("Request must start with
<"+E_LOCKINFO+"> element");
+ throw new JDOMException("Request must start with
<"+E_LOCKINFO+"> element");
}
StringWriter strWriter = null;
@@ -331,7 +328,7 @@
parseLockType(lockTypeElement);
parseOwner(lockOwnerElement);
}
- catch (SAXException e) {
+ catch (JDOMException e) {
e.printStackTrace();
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
try {
@@ -343,10 +340,6 @@
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch (ParserConfigurationException e) {
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
}
/**
@@ -355,18 +348,18 @@
*
* @param lockScopeElement the <code><lockscope></code> to parse.
*
- * @throws SAXException if parsing the request failed or if
+ * @throws JDOMException if parsing the request failed or if
* the request is not valid.
*/
- private void parseLockScope(Element lockScopeElement) throws SAXException {
+ private void parseLockScope(Element lockScopeElement) throws JDOMException {
if (lockScopeElement == null) {
- throw new SAXException("Expected <"+E_LOCKSCOPE+"> element");
+ throw new JDOMException("Expected <"+E_LOCKSCOPE+"> element");
}
List children = lockScopeElement.getChildren();
if (children.size() != 1) {
- throw new SAXException("<"+E_LOCKSCOPE+"> must have exactly one
child element");
+ throw new JDOMException("<"+E_LOCKSCOPE+"> must have exactly one
child element");
}
lockInfo_lockScope = ((Element)children.get(0)).getName();
@@ -378,18 +371,18 @@
*
* @param lockTypeElement the <code><locktype></code> to parse.
*
- * @throws SAXException if parsing the request failed or if
+ * @throws JDOMException if parsing the request failed or if
* the request is not valid.
*/
- private void parseLockType(Element lockTypeElement) throws SAXException {
+ private void parseLockType(Element lockTypeElement) throws JDOMException {
if (lockTypeElement == null) {
- throw new SAXException("Expected <"+E_LOCKTYPE+"> element");
+ throw new JDOMException("Expected <"+E_LOCKTYPE+"> element");
}
List children = lockTypeElement.getChildren();
if (children.size() != 1) {
- throw new SAXException("<"+E_LOCKTYPE+"> must have exactly one
child element");
+ throw new JDOMException("<"+E_LOCKTYPE+"> must have exactly one
child element");
}
lockInfo_lockType = ((Element)children.get(0)).getName();
@@ -401,13 +394,13 @@
*
* @param ownerElement the <code><owner></code> to parse.
*
- * @throws SAXException if parsing the request failed or if
+ * @throws JDOMException if parsing the request failed or if
* the request is not valid.
*/
- private void parseOwner(Element ownerElement) throws SAXException {
+ private void parseOwner(Element ownerElement) throws JDOMException {
if (ownerElement == null) {
- throw new SAXException("Expected <"+E_OWNER+"> element");
+ throw new JDOMException("Expected <"+E_OWNER+"> element");
}
StringWriter stringWriter = new StringWriter();
@@ -423,7 +416,7 @@
lockInfo_lockOwner = stringWriter.toString();
if (lockInfo_lockOwner.length() == 0) {
- throw new SAXException("<"+E_OWNER+"> element must not be empty");
+ throw new JDOMException("<"+E_OWNER+"> element must not be
empty");
}
}
1.5 +4 -6
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java
Index: MkworkspaceMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MkworkspaceMethod.java 29 Apr 2002 16:50:20 -0000 1.4
+++ MkworkspaceMethod.java 28 May 2002 12:39:40 -0000 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v
1.4 2002/04/29 16:50:20 pnever Exp $
- * $Revision: 1.4 $
- * $Date: 2002/04/29 16:50:20 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v
1.5 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -66,8 +66,6 @@
import java.io.*;
import java.util.*;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
@@ -135,7 +133,7 @@
*
* @exception WebdavException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
1.26 +9 -13
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java
Index: OptionsMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- OptionsMethod.java 20 May 2002 12:10:14 -0000 1.25
+++ OptionsMethod.java 28 May 2002 12:39:40 -0000 1.26
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v
1.25 2002/05/20 12:10:14 pnever Exp $
- * $Revision: 1.25 $
- * $Date: 2002/05/20 12:10:14 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v
1.26 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.26 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -90,7 +90,6 @@
import org.jdom.Document;
import org.jdom.Namespace;
import org.jdom.JDOMException;
-import org.jdom.input.DOMBuilder;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
@@ -126,12 +125,10 @@
if( req.getContentLength() > 0 ) {
try {
- retrieveRequestContent();
- Element oe = getRequestContent().getRootElement();
+ Element oe = parseRequestContent().getRootElement();
if( oe == null || !oe.getName().equals(E_OPTIONS) ) {
Domain.warn( "Root element must be "+E_OPTIONS );
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("Root element must be
<"+E_OPTIONS+">");
}
Iterator i = oe.getChildren().iterator();
while( i.hasNext() ) {
@@ -144,15 +141,14 @@
if( versionHistoryCollectionSetRequested ||
workspaceCollectionSetRequested )
responseBodyNeeded = true;
}
- catch( org.xml.sax.SAXException x ){
+ catch(JDOMException x ){
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, x.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
catch( IOException x ){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
- catch( javax.xml.parsers.ParserConfigurationException x ){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
1.73 +9 -14
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- PropFindMethod.java 17 May 2002 11:54:32 -0000 1.72
+++ PropFindMethod.java 28 May 2002 12:39:40 -0000 1.73
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.72 2002/05/17 11:54:32 juergen Exp $
- * $Revision: 1.72 $
- * $Date: 2002/05/17 11:54:32 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.73 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.73 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -68,8 +68,6 @@
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.ParserConfigurationException;
-import org.xml.sax.SAXException;
import org.apache.util.WebdavStatus;
import org.apache.slide.authenticate.CredentialsToken;
@@ -101,7 +99,6 @@
import org.jdom.Namespace;
import org.jdom.JDOMException;
-import org.jdom.input.DOMBuilder;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
@@ -220,7 +217,7 @@
*
* @exception WebdavException Bad request
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
@@ -239,9 +236,8 @@
else {
try {
- retrieveRequestContent();
- Element element = getRequestContent().getRootElement();
+ Element element = parseRequestContent().getRootElement();
if ( (element == null) || !
element.getName().equalsIgnoreCase(E_PROPFIND)) {
Domain.warn( "Root element must be "+E_PROPFIND );
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
@@ -274,15 +270,14 @@
}
}
- catch (SAXException e){
+ catch (JDOMException e){
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
catch (IOException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
- catch (ParserConfigurationException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
1.51 +14 -22
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java
Index: PropPatchMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- PropPatchMethod.java 27 May 2002 07:39:18 -0000 1.50
+++ PropPatchMethod.java 28 May 2002 12:39:40 -0000 1.51
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
1.50 2002/05/27 07:39:18 juergen Exp $
- * $Revision: 1.50 $
- * $Date: 2002/05/27 07:39:18 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
1.51 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.51 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -68,9 +68,6 @@
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
import org.apache.util.PropertyWriter;
import org.apache.util.WebdavStatus;
@@ -91,6 +88,7 @@
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
+import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
@@ -184,17 +182,16 @@
if (requestBody.length() != 0) {
try {
- retrieveRequestContent();
Element setNode = null;
Element removeNode = null;
- Document document = getRequestContent();
+ Document document = parseRequestContent();
// Get the root element of the document
Element rootElement = document.getRootElement();
if ( (rootElement == null) || ( !
E_PROPERTYUPDATE.equals(rootElement.getName()) ) ) {
- throw new SAXException("<"+E_PROPERTYUPDATE+"> element
missing");
+ throw new JDOMException("<"+E_PROPERTYUPDATE+"> element
missing");
}
Iterator childrenIterator = rootElement.getChildren().iterator();
Element child = null;
@@ -207,13 +204,13 @@
propertiesToRemove = new
PropPatchProperties(getPropElement(child));
}
else {
- throw new SAXException("Expected <"+E_SET+"> or
<"+E_REMOVE+"> element");
+ throw new JDOMException("Expected <"+E_SET+"> or
<"+E_REMOVE+"> element");
}
}
}
- catch (SAXException e) {
+ catch (JDOMException e) {
try {
resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
}
@@ -226,16 +223,10 @@
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch (ParserConfigurationException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
}
else {
try {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- WebdavStatus.getStatusText
- (WebdavStatus.SC_BAD_REQUEST));
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, "Request content must
not be empty");
}
catch (IOException e) {
e.printStackTrace();
@@ -248,19 +239,19 @@
* Checks if the given Element has exactly one child named
* <code><prop></code>. If the check succeeds the
* <code><prop></code> element is returned, otherwise a
- * SAXException is thrown.
+ * JDOMException is thrown.
*
* @param parent the parent Element of the <code><prop></code>.
*
* @return the <code><prop></code> element.
*
- * @throws SAXException if the check fails.
+ * @throws JDOMException if the check fails.
*/
- private Element getPropElement(Element parent) throws SAXException {
+ private Element getPropElement(Element parent) throws JDOMException {
List childrenList = parent.getChildren();
if ( (childrenList.size() != 1) ||
( ! E_PROP.equals(((Element)childrenList.get(0)).getName()) ) ) {
- throw new SAXException("Expected <"+E_PROP+"> element");
+ throw new JDOMException("Expected <"+E_PROP+"> element");
}
return (Element)childrenList.get(0);
}
@@ -806,3 +797,4 @@
}
}
+
1.51 +3 -5
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java
Index: PutMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- PutMethod.java 20 May 2002 12:10:14 -0000 1.50
+++ PutMethod.java 28 May 2002 12:39:40 -0000 1.51
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
1.50 2002/05/20 12:10:14 pnever Exp $
- * $Revision: 1.50 $
- * $Date: 2002/05/20 12:10:14 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
1.51 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.51 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -70,8 +70,6 @@
import java.text.SimpleDateFormat;
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
1.33 +34 -42
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java
Index: ReportMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- ReportMethod.java 20 May 2002 12:10:14 -0000 1.32
+++ ReportMethod.java 28 May 2002 12:39:40 -0000 1.33
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
1.32 2002/05/20 12:10:14 pnever Exp $
- * $Revision: 1.32 $
- * $Date: 2002/05/20 12:10:14 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
1.33 2002/05/28 12:39:40 juergen Exp $
+ * $Revision: 1.33 $
+ * $Date: 2002/05/28 12:39:40 $
*
* ====================================================================
*
@@ -82,13 +82,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
import org.apache.util.WebdavStatus;
import org.apache.slide.common.SlideException;
@@ -160,7 +153,6 @@
import org.jdom.Namespace;
import org.jdom.JDOMException;
-import org.jdom.input.DOMBuilder;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
@@ -168,7 +160,7 @@
/**
* An implementation of the DeltaV <code>REPORT</code> method.
*
- * @version $Revision: 1.32 $
+ * @version $Revision: 1.33 $
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ralf Stuckert</a>
*/
@@ -297,10 +289,9 @@
}
try{
- retrieveRequestContent();
// check if Report request contains a content
- Document content = getRequestContent();
+ Document content = parseRequestContent();
Element element = content.getRootElement();
if (element == null) {
@@ -340,18 +331,17 @@
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
}
- catch (SAXException e){
+ catch (JDOMException e){
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
catch (IOException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch (ParserConfigurationException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
catch (WebdavException e) {
e.printStackTrace();
String statusText = getStatusText(e);
@@ -562,7 +552,7 @@
* @throws IOException if any I/O problems occur during execution.
* @throws WebdavException if processing the request fails.
*/
- protected void executeRequest() throws IOException, WebdavException {
+ protected void executeRequest() throws WebdavException {
// content type must be set BEFORE calling getWriter()
getResponse().setContentType(TEXT_XML_UTF_8);
@@ -609,11 +599,16 @@
output(new Document(resultElement), getResponse().getWriter());
}
catch (PreconditionViolationException e) {
+ try {
sendPreconditionViolation(e);
+ } catch (IOException ioe) {
+ resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
throw e;
}
catch (Exception e) {
e.printStackTrace();
+ try {
String statusText = getStatusText(e);
if (statusText != null) {
resp.sendError(getErrorCode(e), statusText);
@@ -621,6 +616,10 @@
else {
resp.sendError(getErrorCode(e));
}
+ } catch (IOException ioe) {
+ resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+ throw new WebdavException(getErrorCode(e));
}
}
@@ -969,31 +968,21 @@
* @throws SlideException
* @throws JDOMException
*/
- protected SearchQueryResult searchPrincipal(String searchDocument, int depth)
throws WebdavException, SlideException, JDOMException {
- org.w3c.dom.Element rootElement = null;
- org.w3c.dom.Document parseDoc = null;
- org.w3c.dom.Element queryElement = null;
- org.w3c.dom.NodeList nl = null;
+ protected SearchQueryResult searchPrincipal(String searchDocument, int depth)
throws WebdavException, SlideException, JDOMException, IOException {
+ Element rootElement = null;
+ Document parseDoc = null;
+ Element queryElement = null;
Search searchHelper = null;
String grammarNamespace = null;
SearchQuery searchQuery = null;
SearchQueryResult queryResult = null;
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- try {
- DocumentBuilder builder = factory.newDocumentBuilder();
- parseDoc = builder.parse(new InputSource(new
StringReader(searchDocument)));
- } catch (Exception e) {
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
+ parseDoc = getSAXBuilder().build(new StringReader(searchDocument));
- rootElement = parseDoc.getDocumentElement();
- nl = rootElement.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- if (nl.item (i) instanceof org.w3c.dom.Element)
- queryElement = (org.w3c.dom.Element)nl.item(i);
+ rootElement = parseDoc.getRootElement();
+ List childrenList = rootElement.getChildren();
+ if (childrenList.size() > 0) {
+ queryElement = (Element)childrenList.get(0);
}
// create search query for principals
@@ -1003,8 +992,11 @@
searchQuery = searchHelper.createSearchQuery
(grammarNamespace, queryElement, slideToken, depth,
req.getRequestURI());
} catch (BadQueryException e) {
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
e.printStackTrace();
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
queryResult = searchHelper.search (slideToken, searchQuery);
@@ -1024,7 +1016,7 @@
* @throws SlideException
* @throws JDOMException
*/
- protected void executeAclMatchReport(Element parentElement, int depth) throws
WebdavException, SlideException, JDOMException {
+ protected void executeAclMatchReport(Element parentElement, int depth) throws
WebdavException, SlideException, JDOMException, IOException {
String currentUri = null;
String userID = null;
@@ -1115,7 +1107,7 @@
* @throws SlideException
* @throws JDOMException
*/
- protected Element executePrincipalSearchPropertyReport(int depth) throws
WebdavException, SlideException, JDOMException {
+ protected Element executePrincipalSearchPropertyReport(int depth) throws
WebdavException, SlideException, JDOMException, IOException {
Element parentElement = new Element(E_MULTISTATUS,
NamespaceCache.DEFAULT_NAMESPACE);
SearchQueryResult queryResult = null;
1.22 +9 -17
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java
Index: SearchMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- SearchMethod.java 23 May 2002 05:23:08 -0000 1.21
+++ SearchMethod.java 28 May 2002 12:39:41 -0000 1.22
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v
1.21 2002/05/23 05:23:08 juergen Exp $
- * $Revision: 1.21 $
- * $Date: 2002/05/23 05:23:08 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v
1.22 2002/05/28 12:39:41 juergen Exp $
+ * $Revision: 1.22 $
+ * $Date: 2002/05/28 12:39:41 $
*
* ====================================================================
*
@@ -97,11 +97,9 @@
import org.apache.slide.webdav.util.PropertyRetrieverImpl;
import org.apache.slide.webdav.util.WebdavConstants;
-import org.xml.sax.SAXException;
-import javax.xml.parsers.ParserConfigurationException;
-
import org.jdom.Document;
import org.jdom.Element;
+import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
@@ -164,7 +162,7 @@
requestedProperties = searchQuery.requestedProperties ();
}
- catch (SAXException e) {
+ catch (JDOMException e) {
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
resp.setContentType (TEXT_XML);
createErrorResult (SearchQueryResult.STATUS_BAD_QUERY,
@@ -246,13 +244,11 @@
*
* @version 12/28/2001
*/
- private Element getQueryElement() throws WebdavException, SAXException {
+ private Element getQueryElement() throws WebdavException, JDOMException {
Element queryElement = null;
try
{
- retrieveRequestContent();
-
- Document document = getRequestContent();
+ Document document = parseRequestContent();
Element rootElement = document.getRootElement();
List children = rootElement.getChildren();
if (children.size() > 0) {
@@ -261,12 +257,8 @@
return queryElement;
- } catch (ParserConfigurationException e) {
- System.err.println(e.getMessage());
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException
- (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
System.err.println(e.getMessage());
e.printStackTrace();
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
1.6 +9 -12
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java
Index: UncheckoutMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UncheckoutMethod.java 25 Apr 2002 21:15:15 -0000 1.5
+++ UncheckoutMethod.java 28 May 2002 12:39:41 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java,v
1.5 2002/04/25 21:15:15 jericho Exp $
- * $Revision: 1.5 $
- * $Date: 2002/04/25 21:15:15 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java,v
1.6 2002/05/28 12:39:41 juergen Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/05/28 12:39:41 $
*
* ====================================================================
*
@@ -67,8 +67,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
@@ -120,23 +118,22 @@
* @throws WebdavException
* @throws IOException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
}
try{
- retrieveRequestContent();
+ parseRequestContent();
}
- catch (SAXException e){
+ catch (JDOMException e){
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
catch (IOException e){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
- catch (ParserConfigurationException e){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
1.8 +21 -37
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UpdateMethod.java
Index: UpdateMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UpdateMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- UpdateMethod.java 20 May 2002 12:10:14 -0000 1.7
+++ UpdateMethod.java 28 May 2002 12:39:41 -0000 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UpdateMethod.java,v
1.7 2002/05/20 12:10:14 pnever Exp $
- * $Revision: 1.7 $
- * $Date: 2002/05/20 12:10:14 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UpdateMethod.java,v
1.8 2002/05/28 12:39:41 juergen Exp $
+ * $Revision: 1.8 $
+ * $Date: 2002/05/28 12:39:41 $
*
* ====================================================================
*
@@ -69,8 +69,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
@@ -172,7 +170,7 @@
*
* @exception WebdavException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
@@ -180,56 +178,50 @@
}
if( req.getContentLength() == 0 ) {
+ try {
resp.sendError(WebdavStatus.SC_BAD_REQUEST, "Request body required");
+ } catch (IOException e) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
try{
- retrieveRequestContent();
parseUpdateRequestContent();
}
- catch( org.xml.sax.SAXException x ){
- resp.sendError(WebdavStatus.SC_BAD_REQUEST, x.getMessage());
+ catch (JDOMException e){
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
catch( IOException x ){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
- catch( javax.xml.parsers.ParserConfigurationException x ){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
}
/**
* Parses the expected request content specified for the Update method.
*
- * @throws WebdavException
+ * @throws JDOMException if parsing the request failed for any reason.
* @throws IOException
*/
- private void parseUpdateRequestContent() throws WebdavException, IOException {
+ private void parseUpdateRequestContent() throws IOException, JDOMException {
- Element ue = getRequestContent().getRootElement();
+ Element ue = parseRequestContent().getRootElement();
Element ve = null;
if( ue == null || !ue.getName().equals(E_UPDATE) ) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "Root element must be <"+E_UPDATE+">");
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("Root element must be <"+E_UPDATE+">");
}
Iterator i = ue.getChildren().iterator();
while( i.hasNext() ) {
Element e = (Element)i.next();
if( e.getName().equals(E_VERSION) ) {
if( updateSourcePath != null ) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "At most one <"+E_VERSION+"> element
allowed" );
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("At most one <"+E_VERSION+">
element allowed" );
}
if (updateLabelName != null) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "Either a <"+E_VERSION+"> OR a
<"+E_LABEL_NAME+"> element allowed");
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("Either a <"+E_VERSION+"> OR a
<"+E_LABEL_NAME+"> element allowed");
}
// get the href element
ve = e;
@@ -240,29 +232,21 @@
updateSourcePath = getSlidePath( hre.getText() );
}
catch( Exception x ) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "<"+E_VERSION+"> element must contain
<"+E_HREF+"> element" );
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("<"+E_VERSION+"> element must
contain <"+E_HREF+"> element" );
}
}
if( e.getName().equals(E_PROP) ) {
if( requestedProps != null ) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "At most one "+E_PROP+" element allowed" );
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("At most one "+E_PROP+" element
allowed" );
}
requestedProps = new RequestedPropertiesImpl( e );
}
if( e.getName().equals(E_LABEL_NAME) ) {
if (updateSourcePath != null) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "Either a <"+E_VERSION+"> OR a
<"+E_LABEL_NAME+"> element allowed");
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("Either a <"+E_VERSION+"> OR a
<"+E_LABEL_NAME+"> element allowed");
}
if( updateLabelName != null ) {
- resp.sendError(WebdavStatus.SC_BAD_REQUEST,
- "At most one <"+E_LABEL_NAME+"> element
allowed" );
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ throw new JDOMException("At most one <"+E_LABEL_NAME+">
element allowed" );
}
updateLabelName = e.getText();
}
1.15 +9 -13
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java
Index: VersionControlMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- VersionControlMethod.java 29 Apr 2002 13:21:40 -0000 1.14
+++ VersionControlMethod.java 28 May 2002 12:39:41 -0000 1.15
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java,v
1.14 2002/04/29 13:21:40 pnever Exp $
- * $Revision: 1.14 $
- * $Date: 2002/04/29 13:21:40 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java,v
1.15 2002/05/28 12:39:41 juergen Exp $
+ * $Revision: 1.15 $
+ * $Date: 2002/05/28 12:39:41 $
*
* ====================================================================
*
@@ -69,8 +69,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException ;
-import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
@@ -135,7 +133,7 @@
*
* @exception WebdavException
*/
- protected void parseRequest() throws WebdavException, IOException {
+ protected void parseRequest() throws WebdavException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
@@ -143,8 +141,7 @@
if( req.getContentLength() > 0 ) {
try{
- retrieveRequestContent();
- Element vce = getRequestContent().getRootElement();
+ Element vce = parseRequestContent().getRootElement();
Element ve = null;
if( vce == null || !vce.getName().equals(E_VERSION_CONTROL) ) {
Domain.warn( "Root element must be "+E_VERSION_CONTROL );
@@ -173,15 +170,14 @@
}
}
}
- catch( org.xml.sax.SAXException x ){
+ catch (JDOMException e){
resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ try {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST, e.getMessage());
+ } catch (IOException ioe) {}
throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
catch( IOException x ){
- resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
- catch( javax.xml.parsers.ParserConfigurationException x ){
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}
1.60 +57 -56
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.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- WebdavMethod.java 27 May 2002 12:35:34 -0000 1.59
+++ WebdavMethod.java 28 May 2002 12:39:41 -0000 1.60
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.59 2002/05/27 12:35:34 juergen Exp $
- * $Revision: 1.59 $
- * $Date: 2002/05/27 12:35:34 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.60 2002/05/28 12:39:41 juergen Exp $
+ * $Revision: 1.60 $
+ * $Date: 2002/05/28 12:39:41 $
*
* ====================================================================
*
@@ -72,13 +72,6 @@
import javax.servlet.*;
import javax.servlet.http.*;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
import org.apache.util.URLUtil;
import org.apache.util.MD5Encoder;
@@ -101,6 +94,14 @@
import org.apache.slide.util.logger.Logger;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+import org.jdom.input.SAXBuilder;
+
+import org.jdom.output.XMLOutputter;
+
/**
* WebDAV method.
*
@@ -246,8 +247,12 @@
/**
* The request content (XML) Document.
*/
- private org.jdom.Document requestContentDocument = null;
+ private Document requestContentDocument = null;
+ /**
+ * Indicates if the request content has already been parsed.
+ */
+ private boolean isRequestContentParsed = false;
// -------------------------------------------------- Static Initialization
@@ -502,36 +507,55 @@
* @exception WebdavException
*/
protected abstract void parseRequest()
- throws WebdavException, IOException;
+ throws WebdavException;
+
+ /**
+ * Returns the request content (XML) Document.
+ *
+ * @return the request content (XML) Document.
+ */
+ protected Document getRequestContent() {
+ return requestContentDocument;
+ }
+
/**
- * Parse WebDAV XML request body, and return the DOM representation.
+ * Parses the request content (XML) Document.
+ *
+ * @return the request content (XML) Document.
*
- * @exception ParserConfigurationException If the JAXP factory cannot
- * configure a parser given its current configuration
- * parameters.
- * @exception SAXException If any parse errors occur.
- * @exception IOException If any IO errors occur.
+ * @throws IOException if an I/O error occurred.
+ * @throws JDOMException if parsing the document failed.
*/
- protected Document parseRequestContent()
- throws ParserConfigurationException, SAXException, IOException {
+ protected Document parseRequestContent() throws JDOMException, IOException {
+
+ if (isRequestContentParsed) {
+ return requestContentDocument;
+ }
if (requestBody == null) {
readRequestContent();
if (requestBody == null) {
// there is no request content body, so there's nothing to
// parse
- return null;
+ return requestContentDocument;
+ }
+ }
+ try {
+ requestContentDocument = new SAXBuilder().build(new
StringReader(requestBody));
+ isRequestContentParsed = true;
+ }
+ catch (JDOMException e) {
+ if (e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ else {
+ throw e;
}
}
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- return builder.parse(new InputSource(new StringReader(requestBody)));
-
+ return requestContentDocument;
}
@@ -554,29 +578,6 @@
}
/**
- * Returns the request content (XML) Document.
- *
- * @return the request content (XML) Document.
- */
- protected org.jdom.Document getRequestContent() {
- return requestContentDocument;
- }
-
- /**
- * Retrieves the request content (XML) Document.
- */
- protected void retrieveRequestContent() throws ParserConfigurationException,
IOException, SAXException{
-
- if (req.getContentLength() > 0) {
-
- Document document = parseRequestContent();
- if (document != null) {
- requestContentDocument = new
org.jdom.input.DOMBuilder().build(document);
- }
- }
- }
-
- /**
* Generate <error> for the given precondition violation.
*
* @param violatedPrecondition the ViolatedPrecondition that describes
@@ -584,7 +585,7 @@
*
* @return the <error> for the given precondition violation.
*/
- protected org.jdom.Element getPreconditionViolationError(ViolatedPrecondition
violatedPrecondition) {
+ protected Element getPreconditionViolationError(ViolatedPrecondition
violatedPrecondition) {
return getPreconditionViolationError(violatedPrecondition,
NamespaceCache.DEFAULT_NAMESPACE);
}
@@ -597,11 +598,11 @@
*
* @return the <error> for the given precondition violation.
*/
- protected org.jdom.Element getPreconditionViolationError(ViolatedPrecondition
violatedPrecondition, org.jdom.Namespace namespace) {
+ protected Element getPreconditionViolationError(ViolatedPrecondition
violatedPrecondition, org.jdom.Namespace namespace) {
- org.jdom.Element error = new org.jdom.Element(WebdavConstants.E_ERROR,
+ Element error = new Element(WebdavConstants.E_ERROR,
namespace);
- org.jdom.Element violatedPreconditionElement = new
org.jdom.Element(violatedPrecondition.getPrecondition(),
+ Element violatedPreconditionElement = new
Element(violatedPrecondition.getPrecondition(),
namespace);
error.addContent(violatedPreconditionElement);
return error;
@@ -621,8 +622,8 @@
resp.setStatus(violatedPrecondition.getStatusCode());
resp.setContentType(TEXT_XML_UTF_8);
- new org.jdom.output.XMLOutputter(XML_REPONSE_INDENT, true).
- output(new
org.jdom.Document(getPreconditionViolationError(pve.getViolatedPrecondition())),
resp.getWriter());
+ new XMLOutputter(XML_REPONSE_INDENT, true).
+ output(new
Document(getPreconditionViolationError(pve.getViolatedPrecondition())),
resp.getWriter());
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>