chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r800139 - 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...
Date Sun, 02 Aug 2009 19:38:23 GMT
Author: fguillaume
Date: Sun Aug  2 19:38:23 2009
New Revision: 800139

URL: http://svn.apache.org/viewvc?rev=800139&view=rev
Log:
CMIS-44: removed returnToRoot SPI#getFolderParent, returns a single object

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Folder.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.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/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.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/CMISObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java?rev=800139&r1=800138&r2=800139&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
Sun Aug  2 19:38:23 2009
@@ -106,7 +106,6 @@
      * @return the parent folder, or {@code null}.
      *
      * @see #getParents
-     * @see Folder#getAncestors
      */
     Folder getParent();
 
@@ -118,7 +117,6 @@
      * @return the collection of parent folders
      *
      * @see #getParent
-     * @see Folder#getAncestors
      */
     Collection<Folder> getParents();
 

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=800139&r1=800138&r2=800139&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
Sun Aug  2 19:38:23 2009
@@ -88,22 +88,6 @@
      */
 
     /**
-     * Gets the ancestors of this folder.
-     * <p>
-     * Returns an ordered list of all ancestor folders from this specified
-     * folder to the root folder. The resulting list is ordered by ancestry,
-     * closest this folder first.
-     * <p>
-     * Returns an empty list if this folder is the root folder.
-     *
-     * @return the list of ancestors
-     *
-     * @see CMISObject#getParent
-     * @see CMISObject#getParents
-     */
-    List<Folder> getAncestors();
-
-    /**
      * Gets the direct children of this folder.
      * <p>
      * The order of returned children is implementation-dependant.

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java?rev=800139&r1=800138&r2=800139&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
Sun Aug  2 19:38:23 2009
@@ -162,26 +162,16 @@
      * Returns {@code null} if the specified folder is the root folder.
      * <p>
      * To find the parent of a non-folder, use {@link #getObjectParents}.
-     * <p>
-     * If returnToRoot is {@code false}, returns only the immediate parent of
-     * the folder. If {@code true}, return an ordered list of all ancestor
-     * folders from the specified folder to the root folder. The resulting list
-     * is ordered by ancestry, closest to specified folder first. However, as
-     * XML clients may not always respect ordering, repositories should always
-     * include the parent and the ObjectID property in the filter to allow
-     * re-ordering if necessary.
      *
      * @param folder the folder
      * @param filter the properties filter, or {@code null} for all properties
      * @param includeAllowableActions {@code true} to include allowable actions
      * @param includeRelationships {@code true} if relationships should be
      *            included as well
-     * @param returnToRoot {@code true} if all ancestors must be returned
      * @return the parents and optionally relationships
      */
-    List<ObjectEntry> getFolderParent(ObjectId folder, String filter,
-            boolean includeAllowableActions, boolean includeRelationships,
-            boolean returnToRoot);
+    ObjectEntry getFolderParent(ObjectId folder, String filter,
+            boolean includeAllowableActions, boolean includeRelationships);
 
     /**
      * Gets the direct parents of an object.

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java?rev=800139&r1=800138&r2=800139&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
Sun Aug  2 19:38:23 2009
@@ -274,32 +274,28 @@
         return result;
     }
 
-    public List<ObjectEntry> getFolderParent(ObjectId folder, String filter,
-            boolean includeAllowableActions, boolean includeRelationships,
-            boolean returnToRoot) {
+    public ObjectEntry getFolderParent(ObjectId folder, String filter,
+            boolean includeAllowableActions, boolean includeRelationships) {
         // TODO filter, includeRelationship, includeAllowableActions
-        List<ObjectEntry> result = new LinkedList<ObjectEntry>();
         APPObjectEntry current = getObjectEntry(folder);
         if (!current.getBaseType().equals(BaseType.FOLDER)) {
             throw new IllegalArgumentException("Not a folder: " + folder);
         }
         String rootId = current.connection.getRootFolder().getId();
-        ReadContext ctx = new ReadContext(this);
-        do {
-            if (current.getId().equals(rootId)) {
-                break;
-            }
-            String href = current.getLink(Atom.LINK_UP);
-            Response resp = connector.get(new Request(href));
-            if (!resp.isOk()) {
-                throw new ContentManagerException(
-                        "Remote server returned error code: "
-                                + resp.getStatusCode());
-            }
-            current = (APPObjectEntry) resp.getObject(ctx);
-            result.add(current);
-        } while (returnToRoot);
-        return result;
+        if (current.getId().equals(rootId)) {
+            return null;
+        }
+        String href = current.getLink(Atom.LINK_UP);
+        if (href == null) {
+            return null;
+        }
+        Response resp = connector.get(new Request(href));
+        if (!resp.isOk()) {
+            throw new ContentManagerException(
+                    "Remote server returned error code: "
+                            + resp.getStatusCode());
+        }
+        return (APPObjectEntry) resp.getObject(new ReadContext(this));
     }
 
     public Collection<ObjectEntry> getObjectParents(ObjectId object,

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=800139&r1=800138&r2=800139&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
Sun Aug  2 19:38:23 2009
@@ -56,11 +56,6 @@
         throw new UnsupportedOperationException();
     }
 
-    public List<Folder> getAncestors() {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
-    }
-
     public List<CMISObject> getChildren() {
         String href = entry.getLink(Atom.LINK_DOWN);
         Response resp = entry.connection.getConnector().get(new Request(href));

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=800139&r1=800138&r2=800139&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
Sun Aug  2 19:38:23 2009
@@ -24,7 +24,6 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -248,12 +247,11 @@
         }
     }
 
-    public List<ObjectEntry> getFolderParent(ObjectId folder, String filter,
-            boolean includeAllowableActions, boolean includeRelationships,
-            boolean returnToRoot) {
+    public ObjectEntry getFolderParent(ObjectId folder, String filter,
+            boolean includeAllowableActions, boolean includeRelationships) {
         // TODO filter, includeRelationship, includeAllowableActions
-        List<ObjectEntry> result = new LinkedList<ObjectEntry>();
-        SimpleData data = repository.datas.get(folder.getId());
+        String folderId = folder.getId();
+        SimpleData data = repository.datas.get(folderId);
         if (data == null) {
             throw new RuntimeException("No such folder: " + folder);
         }
@@ -262,21 +260,16 @@
         if (!type.getBaseType().equals(BaseType.FOLDER)) {
             throw new IllegalArgumentException("Not a folder: " + folder);
         }
-        String currentId = (String) data.get(Property.ID);
-        do {
-            Set<String> parents = repository.parents.get(currentId);
-            if (parents == null || parents.isEmpty()) {
-                break;
-            }
-            if (parents.size() > 1) {
-                throw new AssertionError(currentId + " has " + parents.size()
-                        + " parents");
-            }
-            currentId = parents.iterator().next();
-            data = repository.datas.get(currentId);
-            result.add(new SimpleObjectEntry(data, this));
-        } while (returnToRoot);
-        return result;
+        Set<String> parents = repository.parents.get(folderId);
+        if (parents == null || parents.isEmpty()) {
+            return null;
+        }
+        if (parents.size() > 1) {
+            throw new AssertionError(folder + " has " + parents.size()
+                    + " parents");
+        }
+        String parentId = parents.iterator().next();
+        return new SimpleObjectEntry(repository.datas.get(parentId), this);
     }
 
     public Collection<ObjectEntry> getObjectParents(ObjectId object,

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=800139&r1=800138&r2=800139&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
Sun Aug  2 19:38:23 2009
@@ -47,11 +47,6 @@
         return entry.connection.deleteTree(this, unfiling, true);
     }
 
-    public List<Folder> getAncestors() {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
-    }
-
     public List<CMISObject> getChildren() {
         SimpleRepository repository = entry.connection.repository;
         Set<String> ids = repository.children.get(getId());

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java?rev=800139&r1=800138&r2=800139&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
Sun Aug  2 19:38:23 2009
@@ -344,9 +344,8 @@
         throw new UnsupportedOperationException();
     }
 
-    public List<ObjectEntry> getFolderParent(ObjectId folderId, String filter,
-            boolean includeAllowableActions, boolean includeRelationships,
-            boolean returnToRoot) {
+    public ObjectEntry getFolderParent(ObjectId folderId, String filter,
+            boolean includeAllowableActions, boolean includeRelationships) {
         // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }

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=800139&r1=800138&r2=800139&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
Sun Aug  2 19:38:23 2009
@@ -131,11 +131,6 @@
         return Collections.emptySet();
     }
 
-    public List<Folder> getAncestors() {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
-    }
-
     public BaseType getBaseType() {
         return BaseType.FOLDER;
     }

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=800139&r1=800138&r2=800139&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
Sun Aug  2 19:38:23 2009
@@ -113,14 +113,6 @@
     }
 
     @Override
-    public List<Folder> getAncestors() {
-        if (!saved) {
-            throw new UnsupportedOperationException();
-        }
-        return super.getAncestors();
-    }
-
-    @Override
     public void save() {
         if (saved) {
             throw new UnsupportedOperationException();

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=800139&r1=800138&r2=800139&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
Sun Aug  2 19:38:23 2009
@@ -196,13 +196,11 @@
 
     public void testGetFolderParent() {
         Folder root = conn.getRootFolder();
-        assertEquals(0,
-                spi.getFolderParent(root, null, false, false, false).size());
+        assertNull(spi.getFolderParent(root, null, false, false));
         ObjectId folder1 = root.getChildren().get(0);
-        assertEquals(1,
-                spi.getFolderParent(folder1, null, false, false, true).size());
-        assertEquals(root.getId(), spi.getFolderParent(folder1, null, false,
-                false, false).get(0).getId());
+        ObjectEntry p1 = spi.getFolderParent(folder1, null, false, false);
+        assertNotNull(p1);
+        assertEquals(root.getId(), p1.getId());
     }
 
     public void testGetObjectParents() {



Mime
View raw message