chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1164862 - /chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
Date Sat, 03 Sep 2011 13:18:11 GMT
Author: fmui
Date: Sat Sep  3 13:18:11 2011
New Revision: 1164862

URL: http://svn.apache.org/viewvc?rev=1164862&view=rev
Log:
CMIS-428: AtomPub deleteTree() returns object ids when the operation fails

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java?rev=1164862&r1=1164861&r2=1164862&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
Sat Sep  3 13:18:11 2011
@@ -24,6 +24,7 @@ import static org.apache.chemistry.openc
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigInteger;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +33,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomAllowableActions;
 import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
 import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
 import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Acl;
@@ -367,10 +369,46 @@ public class ObjectServiceImpl extends A
         HttpUtils.Response resp = HttpUtils.invokeDELETE(url, getSession());
 
         // check response code
-        if ((resp.getResponseCode() == 200) || (resp.getResponseCode() == 202) || (resp.getResponseCode()
== 204)) {
+        if (resp.getResponseCode() == 200 || resp.getResponseCode() == 202 || resp.getResponseCode()
== 204) {
             return new FailedToDeleteDataImpl();
         }
 
+        // If the server returned an internal server error, get the remaining
+        // children of the folder. We only retrieve the first level, since
+        // getDescendants() is not supported by all repositories.
+        if (resp.getResponseCode() == 500) {
+            link = loadLink(repositoryId, folderId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);
+
+            if (link != null) {
+                url = new UrlBuilder(link);
+                // we only want the object ids
+                url.addParameter(Constants.PARAM_FILTER, "cmis:objectId");
+                url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, false);
+                url.addParameter(Constants.PARAM_RELATIONSHIPS, IncludeRelationships.NONE);
+                url.addParameter(Constants.PARAM_RENDITION_FILTER, "cmis:none");
+                url.addParameter(Constants.PARAM_PATH_SEGMENT, false);
+                // 1000 children should be enough to indicate a problem
+                url.addParameter(Constants.PARAM_MAX_ITEMS, 1000);
+                url.addParameter(Constants.PARAM_SKIP_COUNT, 0);
+
+                // read and parse
+                resp = read(url);
+                AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+
+                // prepare result
+                FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
+                List<String> ids = new ArrayList<String>();
+                result.setIds(ids);
+
+                // get the children ids
+                for (AtomEntry entry : feed.getEntries()) {
+                    ids.add(entry.getId());
+                }
+
+                return result;
+            }
+        }
+
         throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(),
null);
     }
 



Mime
View raw message