jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1461064 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/
Date Tue, 26 Mar 2013 11:53:02 GMT
Author: reschke
Date: Tue Mar 26 11:53:02 2013
New Revision: 1461064

URL: http://svn.apache.org/r1461064
Log:
JCR-3545: fix error handling for unknown WebDAV REPORTs

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DeltaVResourceImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavException.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=1461064&r1=1461063&r2=1461064&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
Tue Mar 26 11:53:02 2013
@@ -66,8 +66,10 @@ import org.apache.jackrabbit.webdav.vers
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
@@ -75,6 +77,9 @@ import javax.jcr.Session;
 import javax.jcr.observation.EventListener;
 import javax.jcr.observation.Event;
 import javax.jcr.observation.EventIterator;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
@@ -468,12 +473,18 @@ abstract class AbstractResource implemen
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
 
-        if (supportedReports.isSupportedReport(reportInfo)) {
-            Report report = ReportType.getType(reportInfo).createReport(this, reportInfo);
-            return report;
-        } else {
-            throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Unknown report
"+ reportInfo.getReportName() +"requested.");
+        if (!supportedReports.isSupportedReport(reportInfo)) {
+            Element condition = null;
+            try {
+                condition = DomUtil.createDocument().createElementNS("DAV:", "supported-report");
+            } catch (ParserConfigurationException ex) {
+                // we don't care THAT much
+            }
+            throw new DavException(DavServletResponse.SC_CONFLICT,
+                    "Unknown report '" + reportInfo.getReportName() + "' requested.", null,
condition);
         }
+
+        return ReportType.getType(reportInfo).createReport(this, reportInfo);
     }
 
     /**
@@ -500,7 +511,7 @@ abstract class AbstractResource implemen
     public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName) throws DavException
{
         DavProperty<?> prop = getProperty(hrefPropertyName);
         if (prop == null || !(prop instanceof HrefProperty)) {
-            throw new DavException(DavServletResponse.SC_CONFLICT, "Unknown Href-Property
'"+hrefPropertyName+"' on resource "+getResourcePath());
+            throw new DavException(DavServletResponse.SC_CONFLICT, "Unknown Href-Property
'" + hrefPropertyName + "' on resource " + getResourcePath());
         }
 
         List<String> hrefs = ((HrefProperty)prop).getHrefs();

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DeltaVResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DeltaVResourceImpl.java?rev=1461064&r1=1461063&r2=1461064&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DeltaVResourceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DeltaVResourceImpl.java
Tue Mar 26 11:53:02 2013
@@ -22,6 +22,7 @@ import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Property;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.webdav.DavCompliance;
@@ -44,8 +45,10 @@ import org.apache.jackrabbit.webdav.vers
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
 
 /**
  * The <code>DeltaVResourceImpl</code> encapsulates the functionality common
to all
@@ -117,12 +120,17 @@ public class DeltaVResourceImpl extends 
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
 
-        if (supportedReports.isSupportedReport(reportInfo)) {
-            Report report = ReportType.getType(reportInfo).createReport(this, reportInfo);
-            return report;
-        } else {
-            throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Unknown report
"+ reportInfo.getReportName() +"requested.");
+        if (!supportedReports.isSupportedReport(reportInfo)) {
+            Element condition = null;
+            try {
+                condition = DomUtil.createDocument().createElementNS("DAV:", "supported-report");
+            } catch (ParserConfigurationException ex) {
+                // we don't care THAT much
+            }
+            throw new DavException(DavServletResponse.SC_CONFLICT,
+                    "Unknown report '" + reportInfo.getReportName() + "' requested.", null,
condition);
         }
+        return ReportType.getType(reportInfo).createReport(this, reportInfo);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavException.java?rev=1461064&r1=1461063&r2=1461064&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavException.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/DavException.java
Tue Mar 26 11:53:02 2013
@@ -40,7 +40,7 @@ public class DavException extends Except
         try {
             statusPhrases.load(DavException.class.getResourceAsStream("statuscode.properties"));
         } catch (IOException e) {
-            log.error("Failed to load status properties: "+ e.getMessage());
+            log.error("Failed to load status properties: " + e.getMessage());
         }
     }
 
@@ -128,7 +128,7 @@ public class DavException extends Except
      * @return status phrase corresponding to the given error code.
      */
     public static String getStatusPhrase(int errorCode) {
-        return statusPhrases.getProperty(errorCode+"");
+        return statusPhrases.getProperty(errorCode + "");
     }
 
     /**



Mime
View raw message