You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2009/07/29 18:26:11 UTC

svn commit: r798970 - in /incubator/chemistry/trunk/chemistry: chemistry-api/src/main/java/org/apache/chemistry/ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-commons/src/main/java/org/apache/chemistry/impl/simpl...

Author: fguillaume
Date: Wed Jul 29 16:26:10 2009
New Revision: 798970

URL: http://svn.apache.org/viewvc?rev=798970&view=rev
Log:
CMIS-44: removed type argument from Folder#getChildren

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Folder.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Folder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Folder.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Folder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Folder.java Wed Jul 29 16:26:10 2009
@@ -106,15 +106,11 @@
     /**
      * Gets the direct children of this folder.
      * <p>
-     * Only children of the given type ({@link BaseType#FOLDER},
-     * {@link BaseType#DOCUMENT}, or {@code null} for all) are returned.
-     * <p>
      * The order of returned children is implementation-dependant.
      *
-     * @param type the base type of children, or {@code null} for all children
      * @return the list of children
      */
-    List<CMISObject> getChildren(BaseType type);
+    List<CMISObject> getChildren();
 
     // getDescendants kept on the SPI
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java Wed Jul 29 16:26:10 2009
@@ -20,7 +20,6 @@
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.Document;
 import org.apache.chemistry.Folder;
@@ -62,7 +61,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public List<CMISObject> getChildren(BaseType type) {
+    public List<CMISObject> getChildren() {
         String href = entry.getLink(Atom.LINK_DOWN);
         Response resp = entry.connection.getConnector().get(new Request(href));
         if (!resp.isOk()) {
@@ -74,9 +73,6 @@
                 entry.connection));
         List<CMISObject> children = new ArrayList<CMISObject>(feed.size());
         for (ObjectEntry child : feed) {
-            if (type != null && !child.getBaseType().equals(type)) {
-                continue;
-            }
             children.add(APPObject.construct((APPObjectEntry) child));
         }
         return children;

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java Wed Jul 29 16:26:10 2009
@@ -21,12 +21,10 @@
 import java.util.List;
 import java.util.Set;
 
-import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.Document;
 import org.apache.chemistry.Folder;
 import org.apache.chemistry.ObjectId;
-import org.apache.chemistry.Property;
 import org.apache.chemistry.Unfiling;
 
 public class SimpleFolder extends SimpleObject implements Folder {
@@ -54,17 +52,12 @@
         throw new UnsupportedOperationException();
     }
 
-    public List<CMISObject> getChildren(BaseType type) {
+    public List<CMISObject> getChildren() {
         SimpleRepository repository = entry.connection.repository;
         Set<String> ids = repository.children.get(getId());
         List<CMISObject> children = new ArrayList<CMISObject>(ids.size());
         for (String id : ids) {
             SimpleData d = repository.datas.get(id);
-            if (type != null
-                    && !repository.getType((String) d.get(Property.TYPE_ID)).getBaseType().equals(
-                            type)) {
-                continue;
-            }
             children.add(SimpleObject.construct(new SimpleObjectEntry(d,
                     entry.connection)));
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java Wed Jul 29 16:26:10 2009
@@ -132,7 +132,7 @@
         assertNotNull(root);
         assertEquals(repo.getRootFolderId().getId(), root.getId());
         assertEquals("CMIS_Root_Folder", root.getName());
-        assertEquals(0, root.getChildren(null).size());
+        assertEquals(0, root.getChildren().size());
         assertNull(root.getParent());
     }
 
@@ -143,19 +143,19 @@
         assertEquals(SimpleType.PROPS_FOLDER_BASE.size() + 2,
                 f1.getType().getPropertyDefinitions().size());
 
-        List<CMISObject> children = root.getChildren(null);
+        List<CMISObject> children = root.getChildren();
         assertEquals(0, children.size());
 
         f1.save();
         assertEquals(root.getId(), f1.getParent().getId());
 
-        children = root.getChildren(null);
+        children = root.getChildren();
         assertEquals(1, children.size());
         assertTrue(children.get(0) instanceof Folder);
 
         Document d1 = root.newDocument("doc");
         d1.save();
-        children = root.getChildren(null);
+        children = root.getChildren();
         assertEquals(2, children.size());
         assertTrue(children.get(0) instanceof Document
                 || children.get(1) instanceof Document);

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java Wed Jul 29 16:26:10 2009
@@ -48,7 +48,7 @@
     protected JcrFolder() {
     }
 
-    public List<CMISObject> getChildren(BaseType type) {
+    public List<CMISObject> getChildren() {
         try {
             List<CMISObject> result = new ArrayList<CMISObject>();
 
@@ -63,9 +63,7 @@
                 } else {
                     continue;
                 }
-                if (type == null || type == entry.getBaseType()) {
-                    result.add(entry);
-                }
+                result.add(entry);
             }
             return result;
         } catch (RepositoryException e) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java Wed Jul 29 16:26:10 2009
@@ -25,7 +25,6 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.Document;
 import org.apache.chemistry.Folder;
@@ -49,11 +48,11 @@
     }
 
     @Override
-    public List<CMISObject> getChildren(BaseType type) {
+    public List<CMISObject> getChildren() {
         if (!saved) {
             throw new UnsupportedOperationException();
         }
-        return super.getChildren(type);
+        return super.getChildren();
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java?rev=798970&r1=798969&r2=798970&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java Wed Jul 29 16:26:10 2009
@@ -81,6 +81,24 @@
         spi = null;
     }
 
+    public static Folder getFolderChild(Folder folder) {
+        for (CMISObject child : folder.getChildren()) {
+            if (child.getBaseType() == BaseType.FOLDER) {
+                return (Folder) child;
+            }
+        }
+        return null;
+    }
+
+    public static Document getDocumentChild(Folder folder) {
+        for (CMISObject child : folder.getChildren()) {
+            if (child.getBaseType() == BaseType.DOCUMENT) {
+                return (Document) child;
+            }
+        }
+        return null;
+    }
+
     public void testBasic() {
         assertNotNull(repository);
         assertNotNull(conn);
@@ -96,7 +114,7 @@
         assertNotNull(props);
         assertTrue(props.size() > 0);
 
-        List<CMISObject> entries = root.getChildren(null);
+        List<CMISObject> entries = root.getChildren();
         assertEquals(1, entries.size());
         Folder f1 = (Folder) entries.get(0);
         Folder fold = f1.getParent();
@@ -105,9 +123,9 @@
 
     public void testDefaultValues() {
         Folder root = conn.getRootFolder();
-        Folder f1 = (Folder) root.getChildren(BaseType.FOLDER).get(0);
-        Folder f2 = (Folder) f1.getChildren(BaseType.FOLDER).get(0);
-        List<CMISObject> children = f2.getChildren(null);
+        Folder f1 = (Folder) root.getChildren().get(0);
+        Folder f2 = getFolderChild(f1);
+        List<CMISObject> children = f2.getChildren();
         assertEquals(3, children.size());
         // check default values
         for (CMISObject child : children) {
@@ -141,7 +159,7 @@
         assertEquals(1, spi.getChildren(root, null, true, false, 20, 0, null,
                 hasMoreItems).size());
         assertFalse(hasMoreItems[0]);
-        ObjectId folder1 = root.getChildren(null).get(0);
+        ObjectId folder1 = root.getChildren().get(0);
         assertEquals(2, spi.getChildren(folder1, null, false, false, 20, 0,
                 null, hasMoreItems).size());
         assertFalse(hasMoreItems[0]);
@@ -174,7 +192,7 @@
         Folder root = conn.getRootFolder();
         assertEquals(0,
                 spi.getFolderParent(root, null, false, false, false).size());
-        ObjectId folder1 = root.getChildren(null).get(0);
+        ObjectId folder1 = root.getChildren().get(0);
         assertEquals(1,
                 spi.getFolderParent(folder1, null, false, false, true).size());
         assertEquals(root.getId(), spi.getFolderParent(folder1, null, false,
@@ -183,9 +201,9 @@
 
     public void testGetObjectParents() {
         Folder root = conn.getRootFolder();
-        ObjectId folder1Id = root.getChildren(null).get(0);
+        ObjectId folder1Id = root.getChildren().get(0);
         Folder folder1 = (Folder) conn.getObject(folder1Id);
-        Document doc = (Document) folder1.getChildren(BaseType.DOCUMENT).get(0);
+        Document doc = getDocumentChild(folder1);
         Collection<ObjectEntry> parents = spi.getObjectParents(doc, null,
                 false, false);
         assertEquals(1, parents.size());
@@ -193,12 +211,11 @@
 
     @SuppressWarnings("null")
     public void testGetStream() throws Exception {
-        Folder f1 = (Folder) conn.getRootFolder().getChildren(BaseType.FOLDER).get(
-                0);
-        Folder f2 = (Folder) f1.getChildren(BaseType.FOLDER).get(0);
+        Folder f1 = (Folder) conn.getRootFolder().getChildren().get(0);
+        Folder f2 = getFolderChild(f1);
         Document other = null;
         Document dog = null;
-        for (CMISObject child : f2.getChildren(null)) {
+        for (CMISObject child : f2.getChildren()) {
             String name = child.getName();
             if (name.equals("doc 2")) {
                 other = (Document) child;
@@ -225,7 +242,7 @@
 
     public void testNewDocument() {
         Folder root = conn.getRootFolder();
-        assertEquals(0, root.getChildren(BaseType.DOCUMENT).size());
+        assertNull(getDocumentChild(root));
         Document doc = root.newDocument("doc");
         doc.setName("mydoc");
         doc.setValue("title", "mytitle");
@@ -246,9 +263,8 @@
         closeConn();
         openConn();
         root = conn.getRootFolder();
-        List<CMISObject> children = root.getChildren(BaseType.DOCUMENT);
-        assertEquals(1, children.size());
-        doc = (Document) children.get(0);
+        doc = getDocumentChild(root);
+        assertNotNull(doc);
         assertEquals(id, doc.getId());
         assertEquals("mydoc", doc.getName());
         assertEquals("mytitle", doc.getString("title"));