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 2010/02/12 16:23:59 UTC

svn commit: r909458 [1/2] - 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-atompub-client/src/main/java/org/apache/chemist...

Author: fguillaume
Date: Fri Feb 12 15:23:54 2010
New Revision: 909458

URL: http://svn.apache.org/viewvc?rev=909458&view=rev
Log:
CMIS-110: implement proper nested datastructures and AtomPub feeds for descendants and folder tree

Added:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestLink.java
      - copied, changed from r908544, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/LinkTest.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestServiceDocumentReader.java
      - copied, changed from r908544, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestTypeFeedReader.java
      - copied, changed from r908544, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PathSegmentElement.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleTree.java   (with props)
Removed:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/LinkTest.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.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/APPObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractFeedReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ServiceDocumentReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ValueIterator.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/entry.xml
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.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/SimpleObjectEntry.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/JcrObjectEntry.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/ObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java Fri Feb 12 15:23:54 2010
@@ -56,6 +56,24 @@
     ChangeInfo getChangeInfo();
 
     /**
+     * The path segment of the object relative to the (implicit) containing
+     * folder.
+     * <p>
+     * If this is the result of a call to {@link SPI#getChildren}, then the path
+     * segment is relative to the folder argument of the method.
+     * <p>
+     * If this is a tree node from the result of a call to
+     * {@link SPI#getFolderTree} or {@link SPI#getDescendants}, then the path
+     * segment of the tree root node is relative to the folder argument of the
+     * method, and the segment of other nodes is relative to the parent node.
+     * <p>
+     * If this is the result of a call to {@link SPI#getObjectParents}, then the
+     * path segment is <em>inverted</em>, it is the relative path segment of the
+     * object argument of the method inside this {@link ObjectEntry}.
+     */
+    String getPathSegment();
+
+    /**
      * Gets a property value.
      * <p>
      * Returns {@code null} is the property is not set, not fetched or unknown.

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=909458&r1=909457&r2=909458&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 Fri Feb 12 15:23:54 2010
@@ -68,19 +68,20 @@
      */
 
     /**
-     * Gets the set of descendant folders contained in the specified folder.
+     * Gets the tree of descendant folders contained in the specified folder.
      *
      * @param folder the folder
      * @param depth the depth, or {@code -1} for all levels
      * @param inclusion the {@link Inclusion#properties properties} and
      *            {@link Inclusion#allowableActions allowable actions} to
      *            include in the result
+     * @return a tree of folder entries (a forest)
      *
      * @throws FilterNotValidException if the filter is not valid
      * @throws IllegalArgumentException if the object is not a folder or the
      *             depth is invalid
      */
-    List<ObjectEntry> getFolderTree(ObjectId folder, int depth,
+    Tree<ObjectEntry> getFolderTree(ObjectId folder, int depth,
             Inclusion inclusion);
 
     /**
@@ -104,8 +105,6 @@
      * {@link Inclusion#relationships} is {@code true} then relationships are
      * also returned for each returned object, according to the value of the
      * parameter.
-     * <p>
-     * When returning more than one level, the objects are nested.
      *
      * @param folder the folder
      * @param depth the depth, or {@code -1} for all levels
@@ -115,12 +114,13 @@
      *            {@link Inclusion#relationships relationships} and
      *            {@link Inclusion#renditions renditions} to include in the
      *            result
+     * @return a tree of folder entries (a forest)
+     *
      * @throws FilterNotValidException if the filter is not valid
      * @throws IllegalArgumentException if the object is not a folder or the
      *             depth is invalid
      */
-    // TODO return type for a tree
-    List<ObjectEntry> getDescendants(ObjectId folder, int depth,
+    Tree<ObjectEntry> getDescendants(ObjectId folder, int depth,
             String orderBy, Inclusion inclusion);
 
     /**

Added: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java Fri Feb 12 15:23:54 2010
@@ -0,0 +1,42 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry;
+
+import java.util.List;
+
+/**
+ * A tree of objects of type T, where the children of a node are a {@link List}.
+ */
+public interface Tree<T> {
+
+    /**
+     * The root node of this tree. This is may be {@code null} to represent a
+     * forest.
+     */
+    T getNode();
+
+    /**
+     * The children of this tree. This is never {@code null}.
+     */
+    List<Tree<T>> getChildren();
+
+    /**
+     * The number of nodes in this tree. {@code null} nodes are not counted.
+     */
+    int size();
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Tree.java
------------------------------------------------------------------------------
    svn:keywords = Id

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=909458&r1=909457&r2=909458&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 Fri Feb 12 15:23:54 2010
@@ -53,6 +53,7 @@
 import org.apache.chemistry.Rendition;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.Type;
 import org.apache.chemistry.Unfiling;
 import org.apache.chemistry.VersioningState;
@@ -178,7 +179,7 @@
     // TODO check capabilityGetDescendants / capabilityGetFolderTree
     // and folder fall back on recursion based on getChildren
 
-    public List<ObjectEntry> getFolderTree(ObjectId folder, int depth,
+    public Tree<ObjectEntry> getFolderTree(ObjectId folder, int depth,
             Inclusion inclusion) {
         String href = getFolderEntry(folder).getLink(
                 AtomPubCMIS.LINK_FOLDER_TREE, AtomPub.MEDIA_TYPE_ATOM_FEED);
@@ -203,10 +204,10 @@
             params.add(AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
                     Boolean.toString(inclusion.allowableActions));
         }
-        return connector.getEntryFeed(href, params);
+        return connector.getEntryFeedTree(href, params);
     }
 
-    public List<ObjectEntry> getDescendants(ObjectId folder, int depth,
+    public Tree<ObjectEntry> getDescendants(ObjectId folder, int depth,
             String orderBy, Inclusion inclusion) {
         String href = getFolderEntry(folder).getLink(AtomPub.LINK_DOWN,
                 AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
@@ -238,7 +239,7 @@
             params.add(AtomPubCMIS.PARAM_INCLUDE_ACL,
                     Boolean.toString(inclusion.acls));
         }
-        return connector.getEntryFeed(href, params);
+        return connector.getEntryFeedTree(href, params);
     }
 
     public ListPage<ObjectEntry> getChildren(ObjectId folder,

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java Fri Feb 12 15:23:54 2010
@@ -38,6 +38,7 @@
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.ValueAdapter;
 import org.apache.chemistry.atompub.client.stax.XmlProperty;
@@ -69,6 +70,11 @@
 
     protected final List<Link> links;
 
+    protected String pathSegment;
+
+    /** Children while reading the object from a feed, not used otherwise. */
+    protected List<Tree<ObjectEntry>> children;
+
     public static class Link {
         public final String rel;
 
@@ -104,8 +110,8 @@
         }
     }
 
-    protected APPObjectEntry(APPRepository repository, APPConnection connection,
-            Map<String, XmlProperty> properties,
+    protected APPObjectEntry(APPRepository repository,
+            APPConnection connection, Map<String, XmlProperty> properties,
             Map<QName, Boolean> allowableActions) {
         this.repository = repository;
         this.connection = connection;
@@ -143,8 +149,8 @@
         links.add(new Link(rel, href, type));
     }
 
-    public String[] getLinks() {
-        return links.toArray(new String[links.size()]);
+    public Link[] getLinks() {
+        return links.toArray(new Link[links.size()]);
     }
 
     public String getLink(String rel) {
@@ -175,6 +181,10 @@
         return null;
     }
 
+    public String getPathSegment() {
+        return pathSegment;
+    }
+
     // -----
 
     protected boolean isCreation() {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java Fri Feb 12 15:23:54 2010
@@ -19,11 +19,14 @@
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.client.stax.AbstractObjectReader;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
@@ -43,18 +46,28 @@
     }
 
     @Override
-    protected void readProperty(ReadContext ctx, StaxReader reader,
-            APPObjectEntry object, XmlProperty p) {
+    protected void setProperty(APPObjectEntry object, XmlProperty p) {
         object.properties.put(p.getId(), p);
     }
 
     @Override
-    protected void readAllowableActions(ReadContext ctx, StaxReader reader,
-            APPObjectEntry object, Map<QName, Boolean> allowableActions) {
+    protected void setAllowableActions(APPObjectEntry object,
+            Map<QName, Boolean> allowableActions) {
         object.allowableActions = Collections.unmodifiableMap(allowableActions);
     }
 
     @Override
+    protected void setPathSegment(APPObjectEntry object, String pathSegment) {
+        object.pathSegment = pathSegment;
+    }
+
+    @Override
+    protected void setChildren(APPObjectEntry object,
+            List<Tree<ObjectEntry>> list) {
+        object.children = list;
+    }
+
+    @Override
     protected void readAtomElement(ReadContext ctx, StaxReader reader,
             APPObjectEntry object) throws XMLStreamException {
         QName name = reader.getName();

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java Fri Feb 12 15:23:54 2010
@@ -0,0 +1,59 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Tree;
+import org.apache.chemistry.atompub.client.stax.AbstractFeedReader;
+import org.apache.chemistry.impl.simple.SimpleTree;
+import org.apache.chemistry.xml.stax.StaxReader;
+
+/**
+ * A reader of {@link List} of {@link Tree} of {@link ObjectEntry}.
+ */
+public class APPObjectFeedTreeReader extends
+        AbstractFeedReader<List<Tree<ObjectEntry>>, APPObjectEntry> {
+
+    public APPObjectFeedTreeReader() {
+        super(new APPObjectEntryReader());
+    }
+
+    @Override
+    protected List<Tree<ObjectEntry>> createFeed(StaxReader reader) {
+        return new ArrayList<Tree<ObjectEntry>>(5);
+    }
+
+    @Override
+    protected void addEntry(List<Tree<ObjectEntry>> list, APPObjectEntry entry) {
+        Tree<ObjectEntry> t = new SimpleTree<ObjectEntry>(entry, entry.children);
+        entry.children = null; // not used anymore
+        list.add(t);
+    }
+
+    @Override
+    protected void setHasMoreItems(List<Tree<ObjectEntry>> feed,
+            boolean hasMoreItems) {
+    }
+
+    @Override
+    protected void setNumItems(List<Tree<ObjectEntry>> feed, int numItems) {
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedTreeReader.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java Fri Feb 12 15:23:54 2010
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.List;
 
 import javax.xml.stream.XMLStreamException;
 
@@ -31,6 +32,7 @@
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.ObjectNotFoundException;
 import org.apache.chemistry.Paging;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.TypeManager;
 import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.client.APPObjectEntry;
@@ -49,6 +51,7 @@
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.atompub.client.stax.XmlObjectWriter;
 import org.apache.chemistry.impl.simple.SimpleContentStream;
+import org.apache.chemistry.impl.simple.SimpleTree;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
@@ -125,6 +128,12 @@
         }
     }
 
+    public Tree<ObjectEntry> getEntryFeedTree(String href, NameValuePairs params) {
+        List<Tree<ObjectEntry>> list = getObjectFeed(href, params,
+                new APPObjectFeedTreeReader());
+        return new SimpleTree<ObjectEntry>(null, list);
+    }
+
     public APPObjectEntry getEntry(String href, String msg) {
         return getObject(href, msg, new APPObjectEntryReader());
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java Fri Feb 12 15:23:54 2010
@@ -58,8 +58,7 @@
     @Override
     protected void readAtomElement(ReadContext ctx, StaxReader reader,
             APPType object) throws XMLStreamException {
-        // read only links - optimization to avoid useless operations
-        if ("link".equals(reader.getLocalName())) {
+        if (AtomPub.ATOM_LINK.equals(reader.getName())) {
             String rel = reader.getAttributeValue(AtomPub.ATOM_NS, "rel");
             String href = reader.getAttributeValue(AtomPub.ATOM_NS, "href");
             String type = reader.getAttributeValue(AtomPub.ATOM_NS, "type");
@@ -70,7 +69,7 @@
     @Override
     protected void readCmisElement(ReadContext context, StaxReader reader,
             APPType entry) throws XMLStreamException {
-        if (AtomPubCMIS.TYPE.getLocalPart().equals(reader.getLocalName())) {
+        if (AtomPubCMIS.TYPE.equals(reader.getName())) {
             ChildrenNavigator children = reader.getChildren();
             Map<String, String> map = new HashMap<String, String>();
             Map<String, PropertyDefinition> pdefs = new HashMap<String, PropertyDefinition>();

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractFeedReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractFeedReader.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractFeedReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractFeedReader.java Fri Feb 12 15:23:54 2010
@@ -49,14 +49,6 @@
         this.entryBuilder = entryBuilder;
     }
 
-    public EntryReader<E> getEntryBuilder() {
-        return entryBuilder;
-    }
-
-    public void setEntryBuilder(EntryReader<E> entryBuilder) {
-        this.entryBuilder = entryBuilder;
-    }
-
     public T read(ReadContext ctx, File file) throws XMLStreamException,
             IOException {
         InputStream in = new FileInputStream(file);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java Fri Feb 12 15:23:54 2010
@@ -19,14 +19,18 @@
 package org.apache.chemistry.atompub.client.stax;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 
 import org.apache.chemistry.CMIS;
+import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.atompub.AtomPubCMIS;
+import org.apache.chemistry.atompub.client.APPObjectFeedTreeReader;
 import org.apache.chemistry.xml.stax.ChildrenNavigator;
 import org.apache.chemistry.xml.stax.ParseException;
 import org.apache.chemistry.xml.stax.StaxReader;
@@ -36,17 +40,29 @@
  */
 public abstract class AbstractObjectReader<T> extends AbstractEntryReader<T> {
 
-    protected abstract void readProperty(ReadContext ctx, StaxReader reader,
-            T object, XmlProperty p);
+    protected abstract void setProperty(T object, XmlProperty p);
 
-    protected abstract void readAllowableActions(ReadContext ctx,
-            StaxReader reader, T object, Map<QName, Boolean> allowableActions);
+    protected abstract void setAllowableActions(T object,
+            Map<QName, Boolean> allowableActions);
+
+    protected abstract void setPathSegment(T object, String pathSegment);
+
+    // TODO better use of generics
+    protected abstract void setChildren(T object, List<Tree<ObjectEntry>> tree);
 
     @Override
     protected void readCmisElement(ReadContext ctx, StaxReader reader, T object)
             throws XMLStreamException {
-        if (reader.getLocalName().equals(AtomPubCMIS.OBJECT.getLocalPart())) {
+        QName name = reader.getName();
+        if (AtomPubCMIS.OBJECT.equals(name)) {
             readCmisObject(ctx, reader, object);
+        } else if (AtomPubCMIS.PATH_SEGMENT.equals(name)) {
+            readPathSegment(ctx, reader, object);
+        } else if (AtomPubCMIS.RELATIVE_PATH_SEGMENT.equals(name)) {
+            // stored in the same property as PATH_SEGMENT
+            readPathSegment(ctx, reader, object);
+        } else if (AtomPubCMIS.CHILDREN.equals(name)) {
+            readChildren(ctx, reader, object);
         }
     }
 
@@ -61,12 +77,12 @@
     protected void readObjectChildElement(ReadContext ctx, StaxReader reader,
             T object) throws XMLStreamException {
         if (reader.getNamespaceURI().equals(CMIS.CMIS_NS)) {
-            String localName = reader.getLocalName();
-            if (localName.equals(CMIS.PROPERTIES.getLocalPart())) {
+            QName name = reader.getName();
+            if (CMIS.PROPERTIES.equals(name)) {
                 readProperties(ctx, reader, object);
-            } else if (localName.equals(CMIS.ALLOWABLE_ACTIONS.getLocalPart())) {
+            } else if (CMIS.ALLOWABLE_ACTIONS.equals(name)) {
                 readAllowableActions(ctx, reader, object);
-            } else if (localName.equals(CMIS.CHANGE_EVENT_INFO.getLocalPart())) {
+            } else if (CMIS.CHANGE_EVENT_INFO.equals(name)) {
                 readChangeEventInfo(ctx, reader, object);
             } else { // unknown tag
                 readOtherCmisElement(ctx, reader, object);
@@ -92,7 +108,7 @@
             throw new ParseException("No such property definition: " + id);
         }
         p.setDefinition(def);
-        readProperty(ctx, reader, object, p);
+        setProperty(object, p);
     }
 
     protected void readAllowableActions(ReadContext ctx, StaxReader reader,
@@ -104,7 +120,7 @@
             Boolean bool = Boolean.valueOf(reader.getElementText());
             allowableActions.put(qname, bool);
         }
-        readAllowableActions(ctx, reader, object, allowableActions);
+        setAllowableActions(object, allowableActions);
     }
 
     protected void readChangeEventInfo(ReadContext ctx, StaxReader reader,
@@ -117,4 +133,16 @@
         // do nothing
     }
 
+    protected void readPathSegment(ReadContext ctx, StaxReader reader, T object)
+            throws XMLStreamException {
+        setPathSegment(object, reader.getElementText());
+    }
+
+    protected void readChildren(ReadContext ctx, StaxReader reader, T object)
+            throws XMLStreamException {
+        // TODO better use of generics
+        List<Tree<ObjectEntry>> list = new APPObjectFeedTreeReader().read(ctx, reader);
+        setChildren(object, list);
+    }
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ServiceDocumentReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ServiceDocumentReader.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ServiceDocumentReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ServiceDocumentReader.java Fri Feb 12 15:23:54 2010
@@ -13,6 +13,7 @@
  *
  * Authors:
  *     Bogdan Stefanescu, Nuxeo
+ *     Florent Guillaume, Nuxeo
  */
 package org.apache.chemistry.atompub.client.stax;
 
@@ -73,22 +74,22 @@
                 ChildrenNavigator children = reader.getChildren();
                 while (children.next()) {
                     QName name = reader.getName();
-                    if (name.equals(AtomPub.APP_COLLECTION)) {
+                    if (AtomPub.APP_COLLECTION.equals(name)) {
                         String href = reader.getAttributeValue("href");
                         String type = "";
                         ChildrenNavigator nav = reader.getChildren();
                         while (nav.next()) {
                             QName n = reader.getName();
-                            if (n.equals(AtomPubCMIS.COLLECTION_TYPE)) {
+                            if (AtomPubCMIS.COLLECTION_TYPE.equals(n)) {
                                 type = reader.getElementText();
                             }
                         }
                         addCollection(repo, href, type);
-                    } else if (name.equals(AtomPubCMIS.REPOSITORY_INFO)) {
+                    } else if (AtomPubCMIS.REPOSITORY_INFO.equals(name)) {
                         RepositoryInfo info = readRepositoryInfo(context,
                                 reader);
                         setInfo(repo, info);
-                    } else if (name.equals(AtomPubCMIS.URI_TEMPLATE)) {
+                    } else if (AtomPubCMIS.URI_TEMPLATE.equals(name)) {
                         URITemplate uriTemplate = readURITemplate(context,
                                 reader);
                         addURITemplate(repo, uriTemplate);
@@ -111,54 +112,54 @@
         Set<BaseType> changeLogBaseTypes = new HashSet<BaseType>();
         ChildrenNavigator nav = reader.getChildren();
         while (nav.next()) {
-            String localName = reader.getLocalName();
-            if (localName.equals(CMIS.CAPABILITIES.getLocalPart())) {
+            QName name = reader.getName();
+            if (CMIS.CAPABILITIES.equals(name)) {
                 caps = new APPRepositoryCapabilities();
                 ChildrenNavigator capElems = reader.getChildren();
                 while (capElems.next()) {
-                    localName = reader.getLocalName();
-                    if (localName.equals(CMIS.CAPABILITY_ALL_VERSIONS_SEARCHABLE.getLocalPart())) {
+                    name = reader.getName();
+                    if (CMIS.CAPABILITY_ALL_VERSIONS_SEARCHABLE.equals(name)) {
                         caps.setAllVersionsSearchable(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_CAN_GET_DESCENDANTS.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_CAN_GET_DESCENDANTS.equals(name)) {
                         caps.setHasGetDescendants(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_CAN_GET_FOLDER_TREE.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_CAN_GET_FOLDER_TREE.equals(name)) {
                         caps.setHasGetFolderTree(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_CONTENT_STREAM_UPDATABILITY.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_CONTENT_STREAM_UPDATABILITY.equals(name)) {
                         caps.setContentStreamUpdatableAnytime("anytime".equals(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_MULTIFILING.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_MULTIFILING.equals(name)) {
                         caps.setHasMultifiling(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_PWC_SEARCHABLE.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_PWC_SEARCHABLE.equals(name)) {
                         caps.setPWCSearchable(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_PWC_UPDATABLE.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_PWC_UPDATABLE.equals(name)) {
                         caps.setPWCUpdatable(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_UNFILING.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_UNFILING.equals(name)) {
                         caps.setHasUnfiling(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_VERSION_SPECIFIC_FILING.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_VERSION_SPECIFIC_FILING.equals(name)) {
                         caps.setHasVersionSpecificFiling(Boolean.parseBoolean(reader.getElementText()));
-                    } else if (localName.equals(CMIS.CAPABILITY_QUERY.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_QUERY.equals(name)) {
                         caps.setQueryCapability(CapabilityQuery.get(
                                 reader.getElementText(), CapabilityQuery.NONE));
-                    } else if (localName.equals(CMIS.CAPABILITY_JOIN.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_JOIN.equals(name)) {
                         caps.setJoinCapability(CapabilityJoin.get(
                                 reader.getElementText(), CapabilityJoin.NONE));
-                    } else if (localName.equals(CMIS.CAPABILITY_RENDITIONS.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_RENDITIONS.equals(name)) {
                         caps.setRenditionCapability(CapabilityRendition.get(
                                 reader.getElementText(),
                                 CapabilityRendition.NONE));
-                    } else if (localName.equals(CMIS.CAPABILITY_CHANGES.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_CHANGES.equals(name)) {
                         caps.setChangeCapability(CapabilityChange.get(
                                 reader.getElementText(), CapabilityChange.NONE));
-                    } else if (localName.equals(CMIS.CAPABILITY_ACL.getLocalPart())) {
+                    } else if (CMIS.CAPABILITY_ACL.equals(name)) {
                         caps.setACLCapability(CapabilityACL.get(
                                 reader.getElementText(), CapabilityACL.NONE));
                     }
                 }
-            } else if (localName.equals(CMIS.REPOSITORY_SPECIFIC_INFORMATION.getLocalPart())) {
+            } else if (CMIS.REPOSITORY_SPECIFIC_INFORMATION.equals(name)) {
                 readRepositorySpecificInformation(context, reader);
-            } else if (localName.equals(CMIS.CHANGES_ON_TYPE.getLocalPart())) {
+            } else if (CMIS.CHANGES_ON_TYPE.equals(name)) {
                 changeLogBaseTypes.add(BaseType.get(reader.getElementText()));
             } else {
-                map.put(localName, reader.getElementText());
+                map.put(name.getLocalPart(), reader.getElementText());
             }
         }
         if (changeLogBaseTypes.isEmpty()) {
@@ -178,12 +179,12 @@
         String template = null;
         ChildrenNavigator nav = reader.getChildren();
         while (nav.next()) {
-            String localName = reader.getLocalName();
-            if (localName.equals(AtomPubCMIS.TYPE.getLocalPart())) {
+            QName name = reader.getName();
+            if (AtomPubCMIS.TYPE.equals(name)) {
                 type = reader.getElementText();
-            } else if (localName.equals(AtomPubCMIS.MEDIA_TYPE.getLocalPart())) {
+            } else if (AtomPubCMIS.MEDIA_TYPE.equals(name)) {
                 mediaType = reader.getElementText();
-            } else if (localName.equals(AtomPubCMIS.TEMPLATE.getLocalPart())) {
+            } else if (AtomPubCMIS.TEMPLATE.equals(name)) {
                 template = reader.getElementText();
             }
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ValueIterator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ValueIterator.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ValueIterator.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ValueIterator.java Fri Feb 12 15:23:54 2010
@@ -33,8 +33,7 @@
 
     @Override
     protected boolean accept() {
-        return (reader.getLocalName().equals(CMIS.VALUE.getLocalPart()) && reader.getNamespaceURI().equals(
-                CMIS.VALUE.getNamespaceURI()));
+        return reader.getName().equals(CMIS.VALUE);
     }
 
     @Override

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java Fri Feb 12 15:23:54 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.ContentStreamPresence;
+import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.PropertyType;
+import org.apache.chemistry.Updatability;
+import org.apache.chemistry.atompub.client.APPObjectEntry.Link;
+import org.apache.chemistry.atompub.client.stax.ReadContext;
+import org.apache.chemistry.impl.simple.SimplePropertyDefinition;
+import org.apache.chemistry.impl.simple.SimpleType;
+import org.apache.chemistry.impl.simple.SimpleTypeManager;
+
+public class TestAPPObjectEntryReader extends TestCase {
+
+    protected ReadContext getReadContext() {
+        Set<BaseType> changeLogBaseTypes = new HashSet<BaseType>();
+        changeLogBaseTypes.add(BaseType.DOCUMENT);
+        changeLogBaseTypes.add(BaseType.FOLDER);
+        APPRepositoryInfo ri = new APPRepositoryInfo(
+                new APPRepositoryCapabilities(), new HashMap<String, Object>(),
+                changeLogBaseTypes);
+        APPRepository repo = new APPRepository(new APPContentManager(null), ri);
+
+        SimpleTypeManager tm = new SimpleTypeManager();
+        PropertyDefinition psn = new SimplePropertyDefinition("string_null",
+                "def:string_null", null, "string_null", "string_null", "",
+                false, PropertyType.STRING, false, null, false, false, null,
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        PropertyDefinition ps = new SimplePropertyDefinition("string",
+                "def:string", null, "string", "string", "", false,
+                PropertyType.STRING, false, null, false, false, "",
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        PropertyDefinition psa = new SimplePropertyDefinition("string_array",
+                "def:string_array", null, "string_array", "string_array", "",
+                false, PropertyType.STRING, true, null, false, false, null,
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        PropertyDefinition pd = new SimplePropertyDefinition("date",
+                "def:date", null, "date", "date", "", false,
+                PropertyType.DATETIME, false, null, false, false, null,
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        PropertyDefinition pda = new SimplePropertyDefinition("date_array",
+                "def:date_array", null, "date_array", "date_array", "", false,
+                PropertyType.DATETIME, true, null, false, false, null,
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        SimpleType t = new SimpleType("doc", BaseType.DOCUMENT.getId(), "doc",
+                null, "Doc", "My Doc Type", BaseType.DOCUMENT, "", true, true,
+                true, true, true, true, true, true,
+                ContentStreamPresence.ALLOWED, null, null, Arrays.asList(psn,
+                        ps, psa, pd, pda));
+        tm.addType(t);
+        repo.typeManager = tm;
+
+        return new ReadContext(new APPConnection(repo));
+    }
+
+    public void testReadObjectEntry() throws Exception {
+        InputStream is = getClass().getResourceAsStream("/entry.xml");
+        APPObjectEntry entry = new APPObjectEntryReader().read(
+                getReadContext(), is);
+        Link[] links = entry.getLinks();
+        assertEquals(2, links.length);
+        Link link = links[0];
+        assertEquals("self", link.rel);
+        assertEquals("http://host/self", link.href);
+        link = links[1];
+        assertEquals("up", link.rel);
+        assertEquals("http://host/parents", link.href);
+        assertEquals("application/atom+xml;type=feed", link.type);
+        assertEquals("seg", entry.getPathSegment());
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectEntryReader.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java Fri Feb 12 15:23:54 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Ugo Cei, Sourcesense
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.ContentStreamPresence;
+import org.apache.chemistry.ListPage;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.PropertyType;
+import org.apache.chemistry.Updatability;
+import org.apache.chemistry.atompub.client.stax.ReadContext;
+import org.apache.chemistry.impl.simple.SimplePropertyDefinition;
+import org.apache.chemistry.impl.simple.SimpleType;
+import org.apache.chemistry.impl.simple.SimpleTypeManager;
+
+public class TestAPPObjectFeedReader extends TestCase {
+
+    protected ReadContext getReadContext() {
+        Set<BaseType> changeLogBaseTypes = new HashSet<BaseType>();
+        changeLogBaseTypes.add(BaseType.DOCUMENT);
+        changeLogBaseTypes.add(BaseType.FOLDER);
+        APPRepositoryInfo ri = new APPRepositoryInfo(
+                new APPRepositoryCapabilities(), new HashMap<String, Object>(),
+                changeLogBaseTypes);
+        APPRepository repo = new APPRepository(new APPContentManager(null), ri);
+
+        SimpleTypeManager tm = new SimpleTypeManager();
+        PropertyDefinition ps = new SimplePropertyDefinition("string",
+                "def:string", null, "string", "string", "", false,
+                PropertyType.STRING, false, null, false, false, "",
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        SimpleType t = new SimpleType("doc", BaseType.DOCUMENT.getId(), "doc",
+                null, "Doc", "My Doc Type", BaseType.DOCUMENT, "", true, true,
+                true, true, true, true, true, true,
+                ContentStreamPresence.ALLOWED, null, null, Arrays.asList(ps));
+        tm.addType(t);
+        repo.typeManager = tm;
+
+        return new ReadContext(new APPConnection(repo));
+    }
+
+    public void testReadAPPObjectFeed() throws Exception {
+        InputStream is = getClass().getResourceAsStream("/feed.xml");
+        ListPage<ObjectEntry> list = new APPObjectFeedReader().read(
+                getReadContext(), is);
+        assertEquals(2, list.size());
+        assertEquals("string1", list.get(0).getValue("string"));
+        assertEquals("string2", list.get(1).getValue("string"));
+    }
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedReader.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java Fri Feb 12 15:23:54 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Ugo Cei, Sourcesense
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.ContentStreamPresence;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.PropertyType;
+import org.apache.chemistry.Tree;
+import org.apache.chemistry.Updatability;
+import org.apache.chemistry.atompub.client.stax.ReadContext;
+import org.apache.chemistry.impl.simple.SimplePropertyDefinition;
+import org.apache.chemistry.impl.simple.SimpleType;
+import org.apache.chemistry.impl.simple.SimpleTypeManager;
+
+public class TestAPPObjectFeedTreeReader extends TestCase {
+
+    protected ReadContext getReadContext() {
+        Set<BaseType> changeLogBaseTypes = new HashSet<BaseType>();
+        changeLogBaseTypes.add(BaseType.DOCUMENT);
+        changeLogBaseTypes.add(BaseType.FOLDER);
+        APPRepositoryInfo ri = new APPRepositoryInfo(
+                new APPRepositoryCapabilities(), new HashMap<String, Object>(),
+                changeLogBaseTypes);
+        APPRepository repo = new APPRepository(new APPContentManager(null), ri);
+
+        SimpleTypeManager tm = new SimpleTypeManager();
+        PropertyDefinition ps = new SimplePropertyDefinition("string",
+                "def:string", null, "string", "string", "", false,
+                PropertyType.STRING, false, null, false, false, "",
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
+        SimpleType t = new SimpleType("doc", BaseType.DOCUMENT.getId(), "doc",
+                null, "Doc", "My Doc Type", BaseType.DOCUMENT, "", true, true,
+                true, true, true, true, true, true,
+                ContentStreamPresence.ALLOWED, null, null, Arrays.asList(ps));
+        tm.addType(t);
+        repo.typeManager = tm;
+
+        return new ReadContext(new APPConnection(repo));
+    }
+
+    public void testReadAPPObjectFeed() throws Exception {
+        InputStream is = getClass().getResourceAsStream("/feed-nested.xml");
+        List<Tree<ObjectEntry>> list = new APPObjectFeedTreeReader().read(
+                getReadContext(), is);
+        assertEquals(2, list.size());
+        Tree<ObjectEntry> tree = list.get(0);
+        assertEquals(3, tree.size());
+        assertEquals(1, tree.getChildren().size());
+        assertEquals(2, tree.getChildren().get(0).size());
+        assertEquals(1, tree.getChildren().get(0).getChildren().size());
+        tree = list.get(1);
+        assertEquals(3, tree.size());
+        assertEquals(2, tree.getChildren().size());
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestAPPObjectFeedTreeReader.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestLink.java (from r908544, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/LinkTest.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestLink.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestLink.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/LinkTest.java&r1=908544&r2=909458&rev=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/LinkTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestLink.java Fri Feb 12 15:23:54 2010
@@ -20,7 +20,7 @@
 
 import org.apache.chemistry.atompub.client.APPObjectEntry.Link;
 
-public class LinkTest extends TestCase {
+public class TestLink extends TestCase {
 
     public void testLink() throws Exception {
         assertNull(Link.canonicalType(null));

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestServiceDocumentReader.java (from r908544, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestServiceDocumentReader.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestServiceDocumentReader.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java&r1=908544&r2=909458&rev=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestServiceDocumentReader.java Fri Feb 12 15:23:54 2010
@@ -36,7 +36,7 @@
 import org.apache.chemistry.atompub.client.stax.ServiceDocumentReader;
 import org.apache.chemistry.impl.simple.SimpleObjectId;
 
-public class ServiceDocumentReaderTest extends TestCase {
+public class TestServiceDocumentReader extends TestCase {
 
     public void testReadServiceDocument() throws Exception {
         InputStream is = getClass().getResourceAsStream("/service-document.xml");

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestTypeFeedReader.java (from r908544, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestTypeFeedReader.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestTypeFeedReader.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java&r1=908544&r2=909458&rev=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TestTypeFeedReader.java Fri Feb 12 15:23:54 2010
@@ -25,7 +25,7 @@
 import org.apache.chemistry.TypeManager;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 
-public class TypeFeedReaderTest extends TestCase {
+public class TestTypeFeedReader extends TestCase {
 
     public void testReadTypesFeed() throws Exception {
         InputStream is = getClass().getResourceAsStream("/types-feed.xml");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/entry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/entry.xml?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/entry.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/entry.xml Fri Feb 12 15:23:54 2010
@@ -1,6 +1,9 @@
 <?xml version="1.0"?>
-<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">
-  <cmis:object>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"
+  xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
+  <link rel="self" href="http://host/self" />
+  <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents" />
+  <cmisra:object>
     <cmis:properties>
       <cmis:propertyString propertyDefinitionId="string_null" />
       <cmis:propertyString propertyDefinitionId="string">
@@ -21,5 +24,6 @@
         </cmis:value>
       </cmis:propertyDateTime>
     </cmis:properties>
-  </cmis:object>
+  </cmisra:object>
+  <cmisra:pathSegment>seg</cmisra:pathSegment>
 </entry>

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml Fri Feb 12 15:23:54 2010
@@ -0,0 +1,130 @@
+<?xml version='1.0' encoding='utf-8'?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"
+  xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
+  <id>urn:x-id:tree</id>
+  <title type="text">Tree</title>
+  <author>
+    <name>system</name>
+  </author>
+  <updated>2009-07-15T11:22:00.000Z</updated>
+  <entry>
+    <id>urn:x-id:document1</id>
+    <title type="text">Document1</title>
+    <updated>2009-07-15T11:20:00.000Z</updated>
+    <link rel="self" href="http://host/self1" />
+    <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents1" />
+    <cmisra:object>
+      <cmis:properties>
+        <cmis:propertyString propertyDefinitionId="string">
+          <cmis:value>string1</cmis:value>
+        </cmis:propertyString>
+      </cmis:properties>
+    </cmisra:object>
+    <cmisra:pathSegment>seg1</cmisra:pathSegment>
+    <cmisra:children>
+      <feed>
+        <id>urn:x-id:tree1</id>
+        <title type="text">Tree 1</title>
+        <author>
+          <name>system</name>
+        </author>
+        <updated>2009-07-15T11:22:00.000Z</updated>
+        <entry>
+          <id>urn:x-id:document3</id>
+          <title type="text">Document3</title>
+          <updated>2009-07-15T11:20:00.000Z</updated>
+          <link rel="self" href="http://host/self3" />
+          <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents3" />
+          <cmisra:object>
+            <cmis:properties>
+              <cmis:propertyString propertyDefinitionId="string">
+                <cmis:value>string3</cmis:value>
+              </cmis:propertyString>
+            </cmis:properties>
+          </cmisra:object>
+          <cmisra:pathSegment>seg3</cmisra:pathSegment>
+          <cmisra:children>
+            <feed>
+              <id>urn:x-id:tree2</id>
+              <title type="text">Tree 2</title>
+              <author>
+                <name>system</name>
+              </author>
+              <updated>2009-07-15T11:22:00.000Z</updated>
+              <entry>
+                <id>urn:x-id:document4</id>
+                <title type="text">Document4</title>
+                <updated>2009-07-15T11:20:00.000Z</updated>
+                <link rel="self" href="http://host/self4" />
+                <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents4" />
+                <cmisra:object>
+                  <cmis:properties>
+                    <cmis:propertyString propertyDefinitionId="string">
+                      <cmis:value>string4</cmis:value>
+                    </cmis:propertyString>
+                  </cmis:properties>
+                </cmisra:object>
+                <cmisra:pathSegment>seg4</cmisra:pathSegment>
+              </entry>
+            </feed>
+          </cmisra:children>
+        </entry>
+      </feed>
+    </cmisra:children>
+  </entry>
+  <entry>
+    <id>urn:x-id:document2</id>
+    <title type="text">Document2</title>
+    <updated>2009-07-15T11:21:00.000Z</updated>
+    <link rel="self" href="http://host/self2" />
+    <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents2" />
+    <cmisra:object>
+      <cmis:properties>
+        <cmis:propertyString propertyDefinitionId="string">
+          <cmis:value>string2</cmis:value>
+        </cmis:propertyString>
+      </cmis:properties>
+    </cmisra:object>
+    <cmisra:pathSegment>seg2</cmisra:pathSegment>
+    <cmisra:children>
+      <feed>
+        <id>urn:x-id:tree3</id>
+        <title type="text">Tree 3</title>
+        <author>
+          <name>system</name>
+        </author>
+        <updated>2009-07-15T11:22:00.000Z</updated>
+        <entry>
+          <id>urn:x-id:document5</id>
+          <title type="text">Document5</title>
+          <updated>2009-07-15T11:20:00.000Z</updated>
+          <link rel="self" href="http://host/self5" />
+          <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents5" />
+          <cmisra:object>
+            <cmis:properties>
+              <cmis:propertyString propertyDefinitionId="string">
+                <cmis:value>string5</cmis:value>
+              </cmis:propertyString>
+            </cmis:properties>
+          </cmisra:object>
+          <cmisra:pathSegment>seg5</cmisra:pathSegment>
+        </entry>
+        <entry>
+          <id>urn:x-id:document6</id>
+          <title type="text">Document6</title>
+          <updated>2009-07-15T11:20:00.000Z</updated>
+          <link rel="self" href="http://host/self6" />
+          <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents6" />
+          <cmisra:object>
+            <cmis:properties>
+              <cmis:propertyString propertyDefinitionId="string">
+                <cmis:value>string6</cmis:value>
+              </cmis:propertyString>
+            </cmis:properties>
+          </cmisra:object>
+          <cmisra:pathSegment>seg6</cmisra:pathSegment>
+        </entry>
+      </feed>
+    </cmisra:children>
+  </entry>
+</feed>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-nested.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml Fri Feb 12 15:23:54 2010
@@ -0,0 +1,40 @@
+<?xml version='1.0' encoding='utf-8'?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"
+  xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
+  <id>urn:x-id:children</id>
+  <title type="text">Children</title>
+  <author>
+    <name>system</name>
+  </author>
+  <updated>2009-07-15T11:22:00.000Z</updated>
+  <entry>
+    <id>urn:x-id:document1</id>
+    <title type="text">Document1</title>
+    <updated>2009-07-15T11:20:00.000Z</updated>
+    <link rel="self" href="http://host/self1" />
+    <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents1" />
+    <cmisra:object>
+      <cmis:properties>
+        <cmis:propertyString propertyDefinitionId="string">
+          <cmis:value>string1</cmis:value>
+        </cmis:propertyString>
+      </cmis:properties>
+    </cmisra:object>
+    <cmisra:pathSegment>seg1</cmisra:pathSegment>
+  </entry>
+  <entry>
+    <id>urn:x-id:document2</id>
+    <title type="text">Document2</title>
+    <updated>2009-07-15T11:21:00.000Z</updated>
+    <link rel="self" href="http://host/self2" />
+    <link rel="up" type="application/atom+xml;type=feed" href="http://host/parents2" />
+    <cmisra:object>
+      <cmis:properties>
+        <cmis:propertyString propertyDefinitionId="string">
+          <cmis:value>string2</cmis:value>
+        </cmis:propertyString>
+      </cmis:properties>
+    </cmisra:object>
+    <cmisra:pathSegment>seg2</cmisra:pathSegment>
+  </entry>
+</feed>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISChildrenCollection.java Fri Feb 12 15:23:54 2010
@@ -47,9 +47,11 @@
 import org.apache.chemistry.RelationshipDirection;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
+import org.apache.chemistry.Tree;
 import org.apache.chemistry.UpdateConflictException;
 import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
+import org.apache.chemistry.atompub.abdera.ChildrenElement;
 import org.apache.chemistry.impl.simple.SimpleContentStream;
 import org.apache.chemistry.impl.simple.SimpleListPage;
 import org.apache.chemistry.impl.simple.SimpleObjectId;
@@ -74,9 +76,16 @@
     public ResponseContext getFeed(RequestContext request) {
         SPI spi = repository.getSPI();
         try {
-            ListPage<ObjectEntry> entries = getEntries(request, spi);
-            Feed feed = createFeedBase(entries, request, spi);
-            addFeedDetails(feed, entries, request);
+            Feed feed;
+            if (COLTYPE_DESCENDANTS.equals(getType())
+                    || COLTYPE_FOLDER_TREE.equals(getType())) {
+                Tree<ObjectEntry> tree = getEntriesTree(request, spi);
+                feed = getFeedTree(tree, request, spi);
+            } else {
+                ListPage<ObjectEntry> entries = getEntries(request, spi);
+                feed = createFeedBase(entries, request, spi);
+                addFeedDetails(feed, entries, request, spi);
+            }
             return buildGetFeedResponse(feed);
         } catch (ResponseContextException e) {
             return createErrorResponse(e);
@@ -85,6 +94,15 @@
         }
     }
 
+    public Feed getFeedTree(Tree<ObjectEntry> tree, RequestContext request,
+            SPI spi) throws ResponseContextException {
+        // no paging
+        SimpleListPage<ObjectEntry> page = new SimpleListPage<ObjectEntry>();
+        Feed feed = createFeedBase(page, request, spi);
+        addFeedDetails(feed, tree.getChildren(), request, spi);
+        return feed;
+    }
+
     protected Feed createFeedBase(ListPage<ObjectEntry> entries,
             RequestContext request, SPI spi) throws ResponseContextException {
         Feed feed = super.createFeedBase(request);
@@ -92,6 +110,7 @@
         feed.addLink(getChildrenLink(id, request), AtomPub.LINK_SELF,
                 AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
 
+        // TODO passe known parent id when for a tree, avoid SPI use
         // link to parent children feed, needs parent id
         ObjectEntry entry;
         entry = spi.getProperties(spi.newObjectId(id), null);
@@ -103,6 +122,7 @@
             feed.addLink(getChildrenLink(pid, request), AtomPub.LINK_UP,
                     AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
         }
+
         // TODO don't add descendants links if no children
         feed.addLink(getDescendantsLink(pid, request), AtomPub.LINK_DOWN,
                 AtomPubCMIS.MEDIA_TYPE_CMIS_TREE, null, null, -1);
@@ -145,33 +165,52 @@
         return feed;
     }
 
-    protected void addFeedDetails(Feed feed, ListPage<ObjectEntry> entries,
-            RequestContext request) throws ResponseContextException {
+    // called either with a List of ObjectEntry or a List of Tree<ObjectEntry>
+    @SuppressWarnings("unchecked")
+    protected void addFeedDetails(Feed feed, List<?> entries,
+            RequestContext request, SPI spi) throws ResponseContextException {
         feed.setUpdated(new Date()); // TODO
-        if (entries != null) {
-            for (ObjectEntry entryObj : entries) {
-                Entry e = feed.addEntry();
-                IRI feedIri = new IRI(getFeedIriForEntry(entryObj, request));
-                addEntryDetails(request, e, feedIri, entryObj);
-
-                if (isMediaEntry(entryObj)) {
-                    addMediaContent(feedIri, e, entryObj, request);
-                } else {
-                    addContent(e, entryObj, request);
+        if (entries == null) {
+            return;
+        }
+        for (Object ob : entries) {
+            ObjectEntry entryObj;
+            Tree<ObjectEntry> tree;
+            if (ob instanceof ObjectEntry) {
+                tree = null;
+                entryObj = (ObjectEntry) ob;
+            } else {
+                tree = (Tree<ObjectEntry>) ob;
+                entryObj = tree.getNode();
+            }
+
+            Entry e = feed.addEntry();
+            IRI feedIri = new IRI(getFeedIriForEntry(entryObj, request));
+            addEntryDetails(request, e, feedIri, entryObj);
+
+            if (tree != null) {
+                List<Tree<ObjectEntry>> children = tree.getChildren();
+                if (children != null && !children.isEmpty()) {
+                    CMISChildrenCollection adapter = new CMISChildrenCollection(
+                            getType(), entryObj.getId(), repository);
+                    Feed subFeed = adapter.getFeedTree(tree, request, spi);
+                    e.addExtension(new ChildrenElement(
+                            request.getAbdera().getFactory(), subFeed));
                 }
             }
+
+            if (isMediaEntry(entryObj)) {
+                addMediaContent(feedIri, e, entryObj, request);
+            } else {
+                addContent(e, entryObj, request);
+            }
         }
     }
 
     @Override
-    public ListPage<ObjectEntry> getEntries(RequestContext request)
-            throws ResponseContextException {
-        SPI spi = repository.getSPI();
-        try {
-            return getEntries(request, spi);
-        } finally {
-            spi.close();
-        }
+    // unused but abstract
+    public ListPage<ObjectEntry> getEntries(RequestContext request) {
+        throw new UnsupportedOperationException();
     }
 
     public ListPage<ObjectEntry> getEntries(RequestContext request, SPI spi)
@@ -190,34 +229,38 @@
                 false);
         Inclusion inclusion = new Inclusion(properties, renditions,
                 relationships, allowableActions, policies, acls);
+        String orderBy = target.getParameter(AtomPubCMIS.PARAM_ORDER_BY);
+        int maxItems = getParameter(request, AtomPubCMIS.PARAM_MAX_ITEMS, 0);
+        int skipCount = getParameter(request, AtomPubCMIS.PARAM_SKIP_COUNT, 0);
+        Paging paging = new Paging(maxItems, skipCount);
+        return spi.getChildren(objectId, inclusion, orderBy, paging);
+    }
+
+    public Tree<ObjectEntry> getEntriesTree(RequestContext request, SPI spi)
+            throws ResponseContextException {
+        ObjectId objectId = spi.newObjectId(id);
+        Target target = request.getTarget();
+        String properties = target.getParameter(AtomPubCMIS.PARAM_FILTER);
+        String renditions = target.getParameter(AtomPubCMIS.PARAM_RENDITION_FILTER);
+        String rel = target.getParameter(AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS);
+        RelationshipDirection relationships = RelationshipDirection.fromInclusion(rel);
+        boolean allowableActions = getParameter(request,
+                AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, false);
+        boolean policies = getParameter(request,
+                AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, false);
+        boolean acls = getParameter(request, AtomPubCMIS.PARAM_INCLUDE_ACL,
+                false);
+        Inclusion inclusion = new Inclusion(properties, renditions,
+                relationships, allowableActions, policies, acls);
+        int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, -1);
+        Tree<ObjectEntry> tree;
         if (COLTYPE_DESCENDANTS.equals(getType())) {
-            int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, -1);
-            String orderBy = target.getParameter(AtomPubCMIS.PARAM_ORDER_BY);
-            List<ObjectEntry> descendants = spi.getDescendants(objectId, depth,
-                    orderBy, inclusion);
-            SimpleListPage<ObjectEntry> page = new SimpleListPage<ObjectEntry>(
-                    descendants);
-            page.setHasMoreItems(false);
-            page.setNumItems(page.size());
-            return page;
-        } else if (COLTYPE_FOLDER_TREE.equals(getType())) {
-            int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, -1);
-            List<ObjectEntry> folderTree = spi.getFolderTree(objectId, depth,
-                    inclusion);
-            SimpleListPage<ObjectEntry> page = new SimpleListPage<ObjectEntry>(
-                    folderTree);
-            page.setHasMoreItems(false);
-            page.setNumItems(page.size());
-            return page;
-        } else {
             String orderBy = target.getParameter(AtomPubCMIS.PARAM_ORDER_BY);
-            int maxItems = getParameter(request, AtomPubCMIS.PARAM_MAX_ITEMS, 0);
-            int skipCount = getParameter(request, AtomPubCMIS.PARAM_SKIP_COUNT,
-                    0);
-            ListPage<ObjectEntry> children = spi.getChildren(objectId,
-                    inclusion, orderBy, new Paging(maxItems, skipCount));
-            return children;
+            tree = spi.getDescendants(objectId, depth, orderBy, inclusion);
+        } else { // COLTYPE_FOLDER_TREE
+            tree = spi.getFolderTree(objectId, depth, inclusion);
         }
+        return tree;
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java Fri Feb 12 15:23:54 2010
@@ -79,6 +79,7 @@
 import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.abdera.ObjectElement;
+import org.apache.chemistry.atompub.abdera.PathSegmentElement;
 import org.apache.chemistry.impl.simple.SimpleContentStream;
 import org.apache.chemistry.util.GregorianCalendar;
 import org.apache.commons.codec.binary.Base64;
@@ -300,6 +301,11 @@
         Type objectType = repository.getType(typeId);
         entry.addExtension(new ObjectElement(factory, object, objectType));
 
+        String pathSegment = object.getPathSegment();
+        if (pathSegment != null) {
+            entry.addExtension(new PathSegmentElement(factory, pathSegment));
+        }
+
         return link;
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java Fri Feb 12 15:23:54 2010
@@ -383,10 +383,18 @@
 
     public void testFolderTree() {
         ClientResponse resp = client.get(base + "/descendants/" + rootFolderId
-                + "?" + AtomPubCMIS.PARAM_DEPTH + "=1");
+                + "?" + AtomPubCMIS.PARAM_DEPTH + "=-1");
         assertEquals(HttpStatus.SC_OK, resp.getStatus());
-        Element ch = resp.getDocument().getRoot();
+        Element f = resp.getDocument().getRoot();
+        Element e = f.getFirstChild(AtomPub.ATOM_ENTRY);
+        assertNotNull(e);
+        Element ch = e.getFirstChild(AtomPubCMIS.CHILDREN);
         assertNotNull(ch);
+        f = ch.getFirstChild(AtomPub.ATOM_FEED);
+        e = f.getFirstChild(AtomPub.ATOM_ENTRY);
+        assertNotNull(e);
+        e = e.getNextSibling(AtomPub.ATOM_ENTRY);
+        assertNotNull(e);
         resp.release();
 
         resp = client.delete(base + "/foldertree/" + folder1id);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java?rev=909458&r1=909457&r2=909458&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java Fri Feb 12 15:23:54 2010
@@ -71,6 +71,10 @@
 
     public static final QName BASE64 = CMISRAName("base64");
 
+    public static final QName PATH_SEGMENT = CMISRAName("pathSegment");
+
+    public static final QName RELATIVE_PATH_SEGMENT = CMISRAName("relativePathSegment");
+
     /*
      * ----- AtomPub Collection Types -----
      */

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java?rev=909458&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java Fri Feb 12 15:23:54 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.abdera;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+import org.apache.abdera.model.Feed;
+import org.apache.chemistry.atompub.AtomPubCMIS;
+
+/**
+ * Element wrapping for a cmisra:children that itself just wraps an atom:feed.
+ */
+public class ChildrenElement extends ExtensibleElementWrapper {
+
+    /**
+     * Constructor used when parsing XML.
+     */
+    public ChildrenElement(Element internal) {
+        super(internal);
+    }
+
+    /**
+     * Constructor used when generating XML.
+     */
+    public ChildrenElement(Factory factory, Feed feed) {
+        super(factory, AtomPubCMIS.CHILDREN);
+        addExtension(feed);
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ChildrenElement.java
------------------------------------------------------------------------------
    svn:keywords = Id