chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1183313 - /chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
Date Fri, 14 Oct 2011 11:36:34 GMT
Author: fmui
Date: Fri Oct 14 11:36:33 2011
New Revision: 1183313

URL: http://svn.apache.org/viewvc?rev=1183313&view=rev
Log:
adjusted DeleteTree() to return the same result as OpenCMIS

Modified:
    chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs

Modified: chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
URL: http://svn.apache.org/viewvc/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs?rev=1183313&r1=1183312&r2=1183313&view=diff
==============================================================================
--- chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs (original)
+++ chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs Fri Oct 14 11:36:33 2011
@@ -1917,6 +1917,45 @@ namespace DotCMIS.Binding.AtomPub
                 return new FailedToDeleteData();
             }
 
+            // 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.StatusCode == HttpStatusCode.InternalServerError)
+            {
+                link = LoadLink(repositoryId, folderId, AtomPubConstants.RelDown, AtomPubConstants.MediatypeChildren);
+
+                if (link != null)
+                {
+                    url = new UrlBuilder(link);
+                    // we only want the object ids
+                    url.AddParameter(AtomPubConstants.ParamFilter, "cmis:objectId");
+                    url.AddParameter(AtomPubConstants.ParamAllowableActions, false);
+                    url.AddParameter(AtomPubConstants.ParamRelationships, IncludeRelationshipsFlag.None);
+                    url.AddParameter(AtomPubConstants.ParamRenditionFilter, "cmis:none");
+                    url.AddParameter(AtomPubConstants.ParamPathSegment, false);
+                    // 1000 children should be enough to indicate a problem
+                    url.AddParameter(AtomPubConstants.ParamMaxItems, 1000);
+                    url.AddParameter(AtomPubConstants.ParamSkipCount, 0);
+
+                    // read and parse
+                    resp = Read(url);
+                    AtomFeed feed = Parse<AtomFeed>(resp.Stream);
+
+                    // prepare result
+                    FailedToDeleteData result = new FailedToDeleteData();
+                    List<string> ids = new List<string>();
+                    result.Ids = ids;
+
+                    // get the children ids
+                    foreach (AtomEntry entry in feed.GetEntries())
+                    {
+                        ids.Add(entry.Id);
+                    }
+
+                    return result;
+                }
+            }
+
             throw ConvertStatusCode(resp.StatusCode, resp.Message, resp.ErrorContent, null);
         }
 



Mime
View raw message