chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1358140 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ main/java/org...
Date Fri, 06 Jul 2012 11:45:38 GMT
Author: jens
Date: Fri Jul  6 11:45:38 2012
New Revision: 1358140

URL: http://svn.apache.org/viewvc?rev=1358140&view=rev
Log:
fix bug wrong numItems returned in getChildren when paging is used [CMIS-539]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java?rev=1358140&r1=1358139&r2=1358140&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
Fri Jul  6 11:45:38 2012
@@ -49,6 +49,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
 import org.apache.chemistry.opencmis.inmemory.DataObjectCreator;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Children;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
@@ -293,10 +294,10 @@ public class InMemoryNavigationServiceIm
             return null; // it is a document and has no children
         }
 
-        List<? extends StoredObject> children = folderOnly ? folder.getFolderChildren(maxItems,
skipCount, user) : folder
+        Children.ChildrenResult children = folderOnly ? folder.getFolderChildren(maxItems,
skipCount, user) : folder
                 .getChildren(maxItems, skipCount, user);
 
-        for (StoredObject spo : children) {
+        for (StoredObject spo : children.getChildren()) {
             ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
             if (includePathSegments != null && includePathSegments) {
                 oifd.setPathSegment(spo.getName());
@@ -317,7 +318,7 @@ public class InMemoryNavigationServiceIm
 
         }
         result.setObjects(folderList);
-        result.setNumItems(BigInteger.valueOf(folderList.size()));
+        result.setNumItems(BigInteger.valueOf(children.getNoItems()));
         if (objectInfos != null) {
             ObjectInfoImpl objectInfo = new ObjectInfoImpl();
             fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1358140&r1=1358139&r2=1358140&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
Fri Jul  6 11:45:38 2012
@@ -63,6 +63,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
 import org.apache.chemistry.opencmis.inmemory.NameValidator;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Children.ChildrenResult;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Content;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
@@ -961,7 +962,8 @@ public class InMemoryObjectServiceImpl e
      */
     private boolean deleteRecursive(ObjectStore folderStore, Folder parentFolder, boolean
continueOnFailure,
             boolean allVersions, List<String> failedToDeleteIds, String user) {
-        List<StoredObject> children = parentFolder.getChildren(-1, -1, "Admin");
+        ChildrenResult childrenResult = parentFolder.getChildren(-1, -1, "Admin");
+        List<? extends StoredObject> children = childrenResult.getChildren();
 
         if (null == children) {
             return true;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java?rev=1358140&r1=1358139&r2=1358140&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
Fri Jul  6 11:45:38 2012
@@ -27,6 +27,24 @@ import java.util.List;
  * @author Jens
  */
 public interface Children {
+    
+    public class ChildrenResult {
+        private int noItems;
+        private List<? extends StoredObject> children;
+                
+        public ChildrenResult(List<? extends StoredObject> children, int noItems) {
+            this.children = children;
+            this.noItems = noItems;
+        }
+        
+        public int getNoItems() {
+            return noItems;
+        }
+        
+        public List<? extends StoredObject> getChildren() {
+            return children;
+        }
+    }
 
     /**
      * get all the children of this folder. To support paging an initial offset
@@ -39,7 +57,7 @@ public interface Children {
      * @param user 
      * @return list of children objects
      */
-    List<StoredObject> getChildren(int maxItems, int skipCount, String user );
+    ChildrenResult getChildren(int maxItems, int skipCount, String user );
 
     /**
      * get all the children of this folder which are folders. To support paging
@@ -53,7 +71,7 @@ public interface Children {
      * @param user 
      * @return list of children folders
      */
-    List<Folder> getFolderChildren(int maxItems, int skipCount, String user);
+    ChildrenResult getFolderChildren(int maxItems, int skipCount, String user);
 
     /**
      * indicate if a child with the given name exists in this folder

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java?rev=1358140&r1=1358139&r2=1358140&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
Fri Jul  6 11:45:38 2012
@@ -112,7 +112,7 @@ public class FolderImpl extends Abstract
         }
     }
 
-    public List<StoredObject> getChildren(int maxItems, int skipCount, String user)
{
+    public ChildrenResult getChildren(int maxItems, int skipCount, String user) {
         List<StoredObject> result = new ArrayList<StoredObject>();
         for (String id : fObjStore.getIds()) {
             StoredObject obj = fObjStore.getObject(id);
@@ -136,13 +136,16 @@ public class FolderImpl extends Abstract
         if (skipCount < 0) {
             skipCount = 0;
         }
+        
         int from = Math.min(skipCount, result.size());
         int to = Math.min(maxItems + from, result.size());
+        int noItems = result.size();
+        
         result = result.subList(from, to);
-        return result;
+        return new ChildrenResult(result, noItems);
     }
 
-    public List<Folder> getFolderChildren(int maxItems, int skipCount, String user)
{
+    public ChildrenResult getFolderChildren(int maxItems, int skipCount, String user) {
         List<Folder> result = new ArrayList<Folder>();
         for (String id : fObjStore.getIds()) {
             StoredObject obj = fObjStore.getObject(id);
@@ -156,8 +159,10 @@ public class FolderImpl extends Abstract
         sortFolderList(result);
         int from = Math.min(skipCount, result.size());
         int to = Math.min(maxItems + from, result.size());
+        int noItems = result.size();
+
         result = result.subList(from, to);
-        return result;
+        return new ChildrenResult(result, noItems);
     }
 
     public boolean hasChild(String name) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java?rev=1358140&r1=1358139&r2=1358140&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
Fri Jul  6 11:45:38 2012
@@ -430,7 +430,7 @@ public class ObjectStoreImpl implements 
         }
 
         // check if children exist
-        List<StoredObject> children = ((Folder) folder).getChildren(-1, -1, user);
+        List<? extends StoredObject> children = ((Folder) folder).getChildren(-1, -1,
user).getChildren();
         if (children != null && !children.isEmpty()) {
             throw new CmisConstraintException("Cannot delete folder with id:  " + folderId
+ ". Folder is not empty.");
         }
@@ -545,7 +545,7 @@ public class ObjectStoreImpl implements 
     }
 
     private Acl applyAclRecursive(Folder folder, Acl addAces, Acl removeAces, String principalId)
{
-        List<StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID);
+        List<? extends StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID).getChildren();
         
         Acl result = applyAcl(folder, addAces, removeAces);  
 
@@ -567,7 +567,7 @@ public class ObjectStoreImpl implements 
     }
     
     private Acl applyAclRecursive(Folder folder, Acl acl, String principalId) {
-        List<StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID);
+        List<? extends StoredObject> children = folder.getChildren(-1, -1, ADMIN_PRINCIPAL_ID).getChildren();
 
         Acl result = applyAcl(folder, acl);  
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java?rev=1358140&r1=1358139&r2=1358140&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/FolderTest.java
Fri Jul  6 11:45:38 2012
@@ -79,11 +79,11 @@ public class FolderTest extends TestCase
         assertEquals(f1, fTest);
         fTest = fStore.getObjectByPath("/Folder 1/Folder 1.1", USER);
         assertEquals(f11, fTest);
-        List<StoredObject> subFolders = fRoot.getChildren(-1, -1, "user");
+        List<? extends StoredObject> subFolders = fRoot.getChildren(-1, -1, "user").getChildren();
         assertEquals(4, subFolders.size());
-        subFolders = f2.getChildren(-1, -1, "user");
+        subFolders = f2.getChildren(-1, -1, "user").getChildren();
         assertEquals(0, subFolders.size());
-        subFolders = f1.getChildren(-1, -1, "user");
+        subFolders = f1.getChildren(-1, -1, "user").getChildren();
         assertEquals(1, subFolders.size());
     }
 



Mime
View raw message