jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1777627 - in /jackrabbit/branches/2.10: ./ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/me...
Date Fri, 06 Jan 2017 15:13:32 GMT
Author: reschke
Date: Fri Jan  6 15:13:32 2017
New Revision: 1777627

URL: http://svn.apache.org/viewvc?rev=1777627&view=rev
Log:
JCR-4079: incorrect PROPPATCH response error handling (ported to 2.10)

Modified:
    jackrabbit/branches/2.10/   (props changed)
    jackrabbit/branches/2.10/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java
    jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PropPatchMethod.java

Propchange: jackrabbit/branches/2.10/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan  6 15:13:32 2017
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1709811,1717599,1729382,1732436,1740814-1740815,1751279,1752165,1753226,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772444,1772457,1772530,1772544,1773591,1773745,1774443,1775657
+/jackrabbit/trunk:1709811,1717599,1729382,1732436,1740814-1740815,1751279,1752165,1753226,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772444,1772457,1772530,1772544,1773579,1773591,1773745,1774443,1775657

Modified: jackrabbit/branches/2.10/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1777627&r1=1777626&r2=1777627&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Fri Jan  6 15:13:32 2017
@@ -1915,8 +1915,11 @@ public class RepositoryServiceImpl imple
 
             PropPatchMethod method = new PropPatchMethod(getItemUri(nodeId, sessionInfo),
changeList);
             execute(method, sessionInfo);
+            method.checkSuccess();
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (DavException e) {
+            throw ExceptionConverter.generate(e);
         }
     }
 

Modified: jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java?rev=1777627&r1=1777626&r2=1777627&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java
Fri Jan  6 15:13:32 2017
@@ -268,6 +268,13 @@ public class MultiStatusResponse impleme
     }
 
     /**
+     * @return {@code true} if the response is of type "propstat" (containing information
about individual properties)
+     */
+    public boolean isPropStat() {
+        return this.type == TYPE_PROPSTAT;
+    }
+
+    /**
      * @param document
      * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(org.w3c.dom.Document)
      */

Modified: jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PropPatchMethod.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PropPatchMethod.java?rev=1777627&r1=1777626&r2=1777627&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PropPatchMethod.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/PropPatchMethod.java
Fri Jan  6 15:13:32 2017
@@ -102,33 +102,46 @@ public class PropPatchMethod extends Dav
         // check of OK response contains all set/remove properties
         MultiStatusResponse[] resp = multiStatus.getResponses();
         if (resp.length != 1) {
-            log.warn("Expected a single multi-status response in PROPPATCH.");
+            log.warn("Expected a single multi-status response in PROPPATCH, but got " + resp.length
+ " elements.");
         }
         boolean success = true;
+
         // only check the first ms-response
-        for (int i = 0; i < 1; i++) {
-            DavPropertyNameSet okSet = resp[i].getPropertyNames(DavServletResponse.SC_OK);
-            if (okSet.isEmpty()) {
-                log.debug("PROPPATCH failed: No 'OK' response found for resource " + resp[i].getHref());
-                success = false;
-            } else {
-                DavPropertyNameIterator it = propertyNames.iterator();
-                while (it.hasNext()) {
-                    DavPropertyName pn = it.nextPropertyName();
-                    success = okSet.remove(pn);
+        if (resp.length == 1) {
+            MultiStatusResponse r = resp[0];
+
+            if (r.isPropStat()) {
+                DavPropertyNameSet okSet = r.getPropertyNames(DavServletResponse.SC_OK);
+                if (okSet.isEmpty()) {
+                    log.debug("PROPPATCH failed: No 'OK' response found for resource " +
r.getHref());
+                    success = false;
+                } else {
+                    DavPropertyNameIterator it = propertyNames.iterator();
+                    while (it.hasNext()) {
+                        DavPropertyName pn = it.nextPropertyName();
+                        success = okSet.remove(pn);
+                    }
+                }
+                if (!okSet.isEmpty()) {
+                    StringBuffer b = new StringBuffer("The following properties outside of
the original request where set or removed: ");
+                    DavPropertyNameIterator it = okSet.iterator();
+                    while (it.hasNext()) {
+                        b.append(it.nextPropertyName().toString()).append("; ");
+                    }
+                    log.warn(b.toString());
                 }
             }
-            if (!okSet.isEmpty()) {
-                StringBuffer b = new StringBuffer("The following properties outside of the
original request where set or removed: ");
-                DavPropertyNameIterator it = okSet.iterator();
-                while (it.hasNext()) {
-                    b.append(it.nextPropertyName().toString()).append("; ");
+            else {
+                int status = r.getStatus()[0].getStatusCode();
+                success = status == DavServletResponse.SC_OK;
+                if (!success) {
+                    log.warn("PROPPATCH failed: overall status of " + status);
                 }
-                log.warn(b.toString());
             }
         }
         // if  build the error message
         if (!success) {
+            // TODO: array might be empty, no?
             Status[] st = resp[0].getStatus();
             // TODO: respect multiple error reasons (not only the first one)
             for (int i = 0; i < st.length && responseException == null; i ++)
{



Mime
View raw message