jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r374610 - in /incubator/jackrabbit/trunk/contrib/jcr-server: server/src/java/org/apache/jackrabbit/server/ webdav/src/java/org/apache/jackrabbit/webdav/ webdav/src/java/org/apache/jackrabbit/webdav/lock/ webdav/src/java/org/apache/jackrabbi...
Date Fri, 03 Feb 2006 09:09:42 GMT
Author: angela
Date: Fri Feb  3 01:09:28 2006
New Revision: 374610

URL: http://svn.apache.org/viewcvs?rev=374610&view=rev
Log:
methods parsing the request body xml may throw DavException if the parsing fails.

Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletRequest.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionDavServletRequest.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ReportInfo.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
Fri Feb  3 01:09:28 2006
@@ -313,7 +313,7 @@
      * @param resource
      */
     protected void doOptions(WebdavRequest request, WebdavResponse response,
-                             DavResource resource) throws IOException {
+                             DavResource resource) throws IOException, DavException {
         response.addHeader(DavConstants.HEADER_DAV, resource.getComplianceClass());
         response.addHeader("Allow", resource.getSupportedMethods());
         response.addHeader("MS-Author-Via", DavConstants.HEADER_DAV);
@@ -1022,7 +1022,6 @@
             response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
             return;
         }
-        try {
             Document doc = request.getRequestDocument();
             if (doc != null) {
                 SearchInfo sR = SearchInfo.createFromXml(doc.getDocumentElement());
@@ -1031,10 +1030,6 @@
                 // request without request body is valid if requested resource
                 // is a 'query' resource.
                 response.sendMultiStatus(((SearchResource) resource).search(null));
-            }
-        } catch (IllegalArgumentException e) {
-            response.sendError(DavServletResponse.SC_BAD_REQUEST);
-            return;
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletRequest.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletRequest.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletRequest.java
Fri Feb  3 01:09:28 2006
@@ -130,6 +130,8 @@
      * @see DavConstants#PROPFIND_ALL_PROP
      * @see DavConstants#PROPFIND_BY_PROPERTY
      * @see DavConstants#PROPFIND_PROPERTY_NAMES
+     * @throws DavException If the propfind type could not be determined due to
+     * an invalid request body.
      */
     public int getPropFindType() throws DavException;
 
@@ -139,6 +141,7 @@
      * or {@link DavConstants#PROPFIND_PROPERTY_NAMES}.
      *
      * @return set of properties the client requested with a PROPFIND request
+     * @throws DavException In case of invalid request body
      */
     public DavPropertyNameSet getPropFindProperties() throws DavException;
 
@@ -149,6 +152,7 @@
      *
      * @return set of properties the client wanted to modify / create with a
      * PROPPATCH request.
+     * @throws DavException In case of invalid request body
      */
     public DavPropertySet getPropPatchSetProperties() throws DavException;
 
@@ -163,6 +167,7 @@
      *
      * @return set of property names the client wanted to remove with a
      * PROPPATCH request.
+     * @throws DavException In case of invalid request body
      */
     public DavPropertyNameSet getPropPatchRemoveProperties() throws DavException;
 
@@ -176,8 +181,9 @@
      * @see DavConstants#HEADER_TIMEOUT
      * @see DavConstants#HEADER_DEPTH
      * @see DavConstants#XML_LOCKINFO
+     * @throws DavException
      */
-    public LockInfo getLockInfo();
+    public LockInfo getLockInfo() throws DavException;
 
     /**
      * Returns true, if the {@link DavConstants#HEADER_IF If header} present

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Fri Feb  3 01:09:28 2006
@@ -420,10 +420,14 @@
      *
      * @return lock info object or <code>null</code> if an error occured while
      *         parsing the request body.
+     * @throws DavException throws a 400 (Bad Request) DavException if a request
+     * body is present but does not start with a DAV:lockinfo element. Note however,
+     * that a non-existing request body is a valid request used to refresh
+     * an existing lock.
      * @see DavServletRequest#getLockInfo()
      */
-    public LockInfo getLockInfo() {
-        LockInfo lockInfo = null;
+    public LockInfo getLockInfo() throws DavException {
+        LockInfo lockInfo;
         boolean isDeep = (getDepth(DEPTH_INFINITY) == DEPTH_INFINITY);
         Document requestDocument = getRequestDocument();
         // check if XML request body is present. It SHOULD have one for
@@ -433,7 +437,8 @@
             if (root.getLocalName().equals(XML_LOCKINFO)) {
                 lockInfo = new LockInfo(root, getTimeout(), isDeep);
             } else {
-                log.debug("Lock-Request has no <lockinfo> tag.");
+                log.debug("Lock request body must start with a DAV:lockinfo element.");
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
             }
         } else {
             lockInfo = new LockInfo(null, getTimeout(), isDeep);
@@ -524,14 +529,10 @@
     /**
      * @see org.apache.jackrabbit.webdav.transaction.TransactionDavServletRequest#getTransactionInfo()
      */
-    public TransactionInfo getTransactionInfo() {
+    public TransactionInfo getTransactionInfo() throws DavException {
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
-            try {
                 return new TransactionInfo(requestDocument.getDocumentElement());
-            } catch (IllegalArgumentException e) {
-                log.error(e.getMessage());
-            }
         }
         return null;
     }
@@ -547,7 +548,7 @@
     /**
      * @see org.apache.jackrabbit.webdav.observation.ObservationDavServletRequest#getSubscriptionInfo()
      */
-    public SubscriptionInfo getSubscriptionInfo() {
+    public SubscriptionInfo getSubscriptionInfo() throws DavException {
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
             Element root = requestDocument.getDocumentElement();
@@ -596,12 +597,7 @@
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
             Element root = requestDocument.getDocumentElement();
-            try {
                 op = OrderPatch.createFromXml(root);
-            } catch (IllegalArgumentException e) {
-                log.error(e.getMessage());
-                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
-            }
         } else {
             log.error("Error while building xml document from ORDERPATH request body.");
         }
@@ -623,17 +619,13 @@
     /**
      * @see org.apache.jackrabbit.webdav.version.DeltaVServletRequest#getLabelInfo()
      */
-    public LabelInfo getLabelInfo() {
+    public LabelInfo getLabelInfo() throws DavException {
         LabelInfo lInfo = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
             Element root = requestDocument.getDocumentElement();
             int depth = getDepth(DEPTH_0);
-            try {
                 lInfo = new LabelInfo(root, depth);
-            } catch (IllegalArgumentException e) {
-                log.error(e.getMessage());
-            }
         }
         return lInfo;
     }
@@ -641,15 +633,11 @@
     /**
      * @see org.apache.jackrabbit.webdav.version.DeltaVServletRequest#getMergeInfo()
      */
-    public MergeInfo getMergeInfo() {
+    public MergeInfo getMergeInfo()  throws DavException {
         MergeInfo mInfo = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
-            try {
                 mInfo = new MergeInfo(requestDocument.getDocumentElement());
-            } catch (IllegalArgumentException e) {
-                log.error(e.getMessage());
-            }
         }
         return mInfo;
     }
@@ -657,15 +645,11 @@
     /**
      * @see org.apache.jackrabbit.webdav.version.DeltaVServletRequest#getUpdateInfo()
      */
-    public UpdateInfo getUpdateInfo() {
+    public UpdateInfo getUpdateInfo() throws DavException  {
         UpdateInfo uInfo = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
-            try {
                 uInfo = new UpdateInfo(requestDocument.getDocumentElement());
-            } catch (IllegalArgumentException e) {
-                log.error(e.getMessage());
-            }
         }
         return uInfo;
     }
@@ -673,7 +657,7 @@
     /**
      * @see org.apache.jackrabbit.webdav.version.DeltaVServletRequest#getReportInfo()
      */
-    public ReportInfo getReportInfo() {
+    public ReportInfo getReportInfo() throws DavException  {
         ReportInfo rInfo = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {
@@ -685,7 +669,7 @@
     /**
      * @see org.apache.jackrabbit.webdav.version.DeltaVServletRequest#getOptionsInfo()
      */
-    public OptionsInfo getOptionsInfo() {
+    public OptionsInfo getOptionsInfo() throws DavException {
         OptionsInfo info = null;
         Document requestDocument = getRequestDocument();
         if (requestDocument != null) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/lock/LockInfo.java
Fri Feb  3 01:09:28 2006
@@ -16,9 +16,12 @@
 package org.apache.jackrabbit.webdav.lock;
 
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.log4j.Logger;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -34,6 +37,8 @@
  */
 public class LockInfo implements DavConstants, XmlSerializable {
 
+    private static Logger log = Logger.getLogger(LockInfo.class);
+
     private Type type;
     private Scope scope;
     private String owner;
@@ -86,16 +91,17 @@
      * according to RFC 2518.
      * @param isDeep boolean value indicating whether the lock should be applied
      * with depth infinity or only to the requested resource.
-     * @throws IllegalArgumentException if the <code>liElement</code> is not
+     * @throws DavException if the <code>liElement</code> is not
      * <code>null</null> but does not start with an 'lockinfo' element.
      */
-    public LockInfo(Element liElement, long timeout, boolean isDeep) {
+    public LockInfo(Element liElement, long timeout, boolean isDeep) throws DavException
{
         this.timeout = (timeout > 0) ? timeout : INFINITE_TIMEOUT;
         this.isDeep = isDeep;
 
         if (liElement != null) {
             if (!DomUtil.matches(liElement, XML_LOCKINFO, NAMESPACE)) {
-                throw new IllegalArgumentException("'DAV:lockinfo' element expected.");
+                log.warn("'DAV:lockinfo' element expected.");
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
             }
 
             ElementIterator it = DomUtil.getChildren(liElement);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationDavServletRequest.java
Fri Feb  3 01:09:28 2006
@@ -16,6 +16,7 @@
 package org.apache.jackrabbit.webdav.observation;
 
 import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavException;
 
 /**
  * <code>ObservationDavServletRequest</code> provides extensions to the
@@ -38,6 +39,7 @@
      *
      * @return subscription info object encapsulating the SUBSCRIBE request body
      * or <code>null</code> if the subscription info cannot be built.
+     * @throws DavException if an invalid request body was encountered.
      */
-    public SubscriptionInfo getSubscriptionInfo();
+    public SubscriptionInfo getSubscriptionInfo() throws DavException;
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java
Fri Feb  3 01:09:28 2006
@@ -20,6 +20,8 @@
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.xml.Namespace;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -101,9 +103,10 @@
      * @param isDeep as defined by the {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_DEPTH
depth header}.
      * @throws IllegalArgumentException if the reqInfo element does not contain the mandatory
elements.
      */
-    public SubscriptionInfo(Element reqInfo, long timeout, boolean isDeep) {
+    public SubscriptionInfo(Element reqInfo, long timeout, boolean isDeep) throws DavException
{
         if (!DomUtil.matches(reqInfo, XML_SUBSCRIPTIONINFO, NAMESPACE)) {
-            throw new IllegalArgumentException("Element with name 'subscriptioninfo' expected");
+            log.warn("Element with name 'subscriptioninfo' expected");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         List typeList = new ArrayList();
         Element el = DomUtil.getChildElement(reqInfo, XML_EVENTTYPE, NAMESPACE);
@@ -115,11 +118,13 @@
                 typeList.add(et);
             }
         } else {
-            throw new IllegalArgumentException("'subscriptioninfo' must contain an 'eventtype'
child element.");
+            log.warn("'subscriptioninfo' must contain an 'eventtype' child element.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         if (typeList.isEmpty()) {
-            throw new IllegalArgumentException("'subscriptioninfo' must at least indicate
a single event type.");
+            log.warn("'subscriptioninfo' must at least indicate a single event type.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         eventTypes = (EventType[]) typeList.toArray(new EventType[typeList.size()]);
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java
Fri Feb  3 01:09:28 2006
@@ -17,6 +17,8 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
@@ -115,9 +117,10 @@
      * @param orderPatchElement
      * @throws IllegalArgumentException if the specified Xml element was not valid.
      */
-    public static OrderPatch createFromXml(Element orderPatchElement) {
+    public static OrderPatch createFromXml(Element orderPatchElement) throws DavException
{
         if (!DomUtil.matches(orderPatchElement, XML_ORDERPATCH, NAMESPACE)) {
-            throw new IllegalArgumentException("ORDERPATH request body must start with an
'orderpatch' element.");
+            log.warn("ORDERPATH request body must start with an 'orderpatch' element.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         // retrieve the href of the orderingtype element
@@ -126,7 +129,8 @@
         if (otype != null) {
             orderingType = DomUtil.getChildText(otype, DavConstants.XML_HREF, DavConstants.NAMESPACE);
         } else {
-            throw new IllegalArgumentException("ORDERPATH request body must contain an 'ordering-type'
child element.");
+            log.warn("ORDERPATH request body must contain an 'ordering-type' child element.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         // set build the list of ordering instructions
@@ -142,7 +146,8 @@
                 Member om = new Member(segment, pos);
                 tmpList.add(om);
             } catch (IllegalArgumentException e) {
-                log.error("Invalid element in 'orderpatch' request body: " + e.getMessage());
+                log.warn("Invalid element in 'orderpatch' request body: " + e.getMessage());
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
             }
         }
         Member[] instructions = (Member[]) tmpList.toArray(new Member[tmpList.size()]);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/search/SearchInfo.java
Fri Feb  3 01:09:28 2006
@@ -19,6 +19,8 @@
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -110,19 +112,21 @@
      * retrieved from the request body.
      *
      * @param searchRequest
-     * @throws IllegalArgumentException if the root element's name is other than
+     * @throws DavException if the root element's name is other than
      * 'searchrequest' or if it does not contain a single child element specifying
      * the query language to be used.
      */
-    public static SearchInfo createFromXml(Element searchRequest) {
+    public static SearchInfo createFromXml(Element searchRequest) throws DavException {
         if (searchRequest == null || !XML_SEARCHREQUEST.equals(searchRequest.getLocalName()))
 {
-            throw new IllegalArgumentException("The root element must be 'searchrequest'.");
+            log.warn("The root element must be 'searchrequest'.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         Element first = DomUtil.getFirstChildElement(searchRequest);
         if (first != null) {
             return new SearchInfo(first.getLocalName(), DomUtil.getNamespace(first), DomUtil.getText(first));
         } else {
-            throw new IllegalArgumentException("A single child element is expected with the
'DAV:searchrequest'.");
+            log.warn("A single child element is expected with the 'DAV:searchrequest'.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionDavServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionDavServletRequest.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionDavServletRequest.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionDavServletRequest.java
Fri Feb  3 01:09:28 2006
@@ -16,6 +16,7 @@
 package org.apache.jackrabbit.webdav.transaction;
 
 import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavException;
 
 /**
  * <code>TransactionDavServletRequest</code> provides extensions to the
@@ -33,8 +34,9 @@
      * @return <code>TransactionInfo</code> object encapsulating the 'transactioninfo'
      * Xml element present in the request body or <code>null</null> if no
      * body is present or if it could not be parsed.
+     * @throws DavException if an invalid request body is present.
      */
-    public TransactionInfo getTransactionInfo();
+    public TransactionInfo getTransactionInfo() throws DavException;
 
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionInfo.java
Fri Feb  3 01:09:28 2006
@@ -18,6 +18,8 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -58,16 +60,18 @@
      * @throws IllegalArgumentException if the given transactionInfo element
      * is not valid.
      */
-    public TransactionInfo(Element transactionInfo) {
+    public TransactionInfo(Element transactionInfo) throws DavException {
         if (transactionInfo == null || !XML_TRANSACTIONINFO.equals(transactionInfo.getLocalName()))
{
-            throw new IllegalArgumentException("transactionInfo element expected.");
+            log.warn("'transactionInfo' element expected.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         Element txStatus = DomUtil.getChildElement(transactionInfo, XML_TRANSACTIONSTATUS,
NAMESPACE);
         if (txStatus != null) {
             // retrieve status: commit or rollback
             isCommit = DomUtil.hasChildElement(txStatus, XML_COMMIT, NAMESPACE);
         } else {
-            throw new IllegalArgumentException("transactionInfo must contain a single 'transactionstatus'
element.");
+            log.warn("transactionInfo must contain a single 'transactionstatus' element.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java
Fri Feb  3 01:09:28 2006
@@ -16,6 +16,7 @@
 package org.apache.jackrabbit.webdav.version;
 
 import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 
 /**
@@ -37,16 +38,18 @@
      * if parsing the request body or the creation of the label info failed.
      *
      * @return <code>LabelInfo</code> object or <code>null</code>
+     * @throws DavException in case of an invalid request body
      */
-    public LabelInfo getLabelInfo();
+    public LabelInfo getLabelInfo() throws DavException;
 
     /**
      * Return the request body as <code>MergeInfo</code> object or <code>null</code>
      * if the creation failed due to invalid format.
      *
      * @return <code>MergeInfo</code> object or <code>null</code>
+     * @throws DavException in case of an invalid request body
      */
-    public MergeInfo getMergeInfo();
+    public MergeInfo getMergeInfo() throws DavException;
 
     /**
      * Parses the UPDATE request body a build the corresponding <code>UpdateInfo</code>
@@ -54,8 +57,9 @@
      * <code>null</code> is returned.
      *
      * @return the parsed update request body or <code>null</code>
+     * @throws DavException in case of an invalid request body
      */
-    public UpdateInfo getUpdateInfo();
+    public UpdateInfo getUpdateInfo() throws DavException;
 
     /**
      * Returns the request body and the Depth header as <code>ReportInfo</code>
@@ -65,13 +69,15 @@
      * <code>null</code> is returned.
      *
      * @return <code>ReportInfo</code> or <code>null</code>
+     * @throws DavException in case of an invalid request body
      */
-    public ReportInfo getReportInfo();
+    public ReportInfo getReportInfo() throws DavException;
 
     /**
      * Returns the {@link OptionsInfo} present with the request or <code>null</code>.
      *
      * @return {@link OptionsInfo} or <code>null</code>
+     * @throws DavException in case of an invalid request body
      */
-    public OptionsInfo getOptionsInfo();
+    public OptionsInfo getOptionsInfo() throws DavException;
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java
Fri Feb  3 01:09:28 2006
@@ -19,6 +19,8 @@
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
 
@@ -101,14 +103,15 @@
      *
      * @param labelElement
      * @param depth
-     * @throws IllegalArgumentException if the specified element does not
+     * @throws DavException if the specified element does not
      * start with a {@link DeltaVConstants#XML_LABEL} element or if the DAV:label
      * element contains illegal instructions e.g. contains multiple DAV:add, DAV:set
      * or DAV:remove elements.
      */
-    public LabelInfo(Element labelElement, int depth) {
+    public LabelInfo(Element labelElement, int depth) throws DavException {
         if (!DomUtil.matches(labelElement, DeltaVConstants.XML_LABEL, DeltaVConstants.NAMESPACE))
{
-            throw new IllegalArgumentException("DAV:label element expected");
+            log.warn("DAV:label element expected");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         String label = null;
@@ -121,7 +124,8 @@
             }
             }
         if (label == null) {
-            throw new IllegalArgumentException("DAV:label element must contain at least one
set, add or remove element defining a label-name.");
+            log.warn("DAV:label element must contain at least one set, add or remove element
defining a label-name.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         this.labelName = label;
         this.type = type;
@@ -133,10 +137,10 @@
      * the default value 0 is assumed.
      *
      * @param labelElement
-     * @throws IllegalArgumentException
+     * @throws DavException
      * @see #LabelInfo(org.w3c.dom.Element;, int)
      */
-    public LabelInfo(Element labelElement) {
+    public LabelInfo(Element labelElement) throws DavException {
         this(labelElement, 0);
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java
Fri Feb  3 01:09:28 2006
@@ -17,6 +17,8 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
@@ -54,12 +56,13 @@
      * Create a new <code>MergeInfo</code>
      *
      * @param mergeElement
-     * @throws IllegalArgumentException if the mergeElement is <code>null</code>
+     * @throws DavException if the mergeElement is <code>null</code>
      * or not a DAV:merge element.
      */
-    public MergeInfo(Element mergeElement) {
+    public MergeInfo(Element mergeElement) throws DavException {
         if (!DomUtil.matches(mergeElement, XML_MERGE, NAMESPACE)) {
-            throw new IllegalArgumentException("'DAV:merge' element expected");
+            log.warn("'DAV:merge' element expected");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         // if property name set if present

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java
Fri Feb  3 01:09:28 2006
@@ -19,6 +19,8 @@
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -107,12 +109,13 @@
      *
      * @param optionsElement
      * @return
-     * @throws IllegalArgumentException if the optionsElement is <code>null</code>
+     * @throws DavException if the optionsElement is <code>null</code>
      * or not a DAV:options element.
      */
-    public static OptionsInfo createFromXml(Element optionsElement) {
+    public static OptionsInfo createFromXml(Element optionsElement) throws DavException {
         if (!DomUtil.matches(optionsElement, DeltaVConstants.XML_OPTIONS, DeltaVConstants.NAMESPACE))
{
-            throw new IllegalArgumentException("DAV:options element expected");
+            log.warn("DAV:options element expected");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         OptionsInfo oInfo = new OptionsInfo();
         ElementIterator it = DomUtil.getChildren(optionsElement);

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java
Fri Feb  3 01:09:28 2006
@@ -18,6 +18,8 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
@@ -63,13 +65,14 @@
      * Create a new <code>UpdateInfo</code> object.
      *
      * @param updateElement
-     * @throws IllegalArgumentException if the updateElement is <code>null</code>
+     * @throws DavException if the updateElement is <code>null</code>
      * or not a DAV:update element or if the element does not match the required
      * structure.
      */
-    public UpdateInfo(Element updateElement) {
+    public UpdateInfo(Element updateElement) throws DavException {
         if (!DomUtil.matches(updateElement, XML_UPDATE, NAMESPACE)) {
-            throw new IllegalArgumentException("DAV:update element expected");
+            log.warn("DAV:update element expected");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         boolean done = false;
@@ -100,7 +103,8 @@
             if (wspElem != null) {
                 workspaceHref = DomUtil.getChildTextTrim(wspElem, DavConstants.XML_HREF,
DavConstants.NAMESPACE);
         } else {
-            throw new IllegalArgumentException("DAV:update element must contain either DAV:version,
DAV:label-name or DAV:workspace child element.");
+                log.warn("DAV:update element must contain either DAV:version, DAV:label-name
or DAV:workspace child element.");
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
         }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ReportInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ReportInfo.java?rev=374610&r1=374609&r2=374610&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ReportInfo.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ReportInfo.java
Fri Feb  3 01:09:28 2006
@@ -18,6 +18,8 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.xml.XmlSerializable;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
@@ -88,10 +90,12 @@
      *
      * @param reportElement
      * @param depth Depth value as retrieved from the {@link DavConstants#HEADER_DEPTH}.
+     * @throws DavException if the report element is <code>null</code>.
      */
-    public ReportInfo(Element reportElement, int depth) {
+    public ReportInfo(Element reportElement, int depth) throws DavException {
         if (reportElement == null) {
-            throw new IllegalArgumentException("Report request body must not be null.");
+            log.warn("Report request body must not be null.");
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
         }
 
         this.typeLocalName = reportElement.getLocalName();



Mime
View raw message