Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 71050 invoked from network); 12 Feb 2010 15:24:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Feb 2010 15:24:40 -0000 Received: (qmail 15928 invoked by uid 500); 12 Feb 2010 15:24:37 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 15877 invoked by uid 500); 12 Feb 2010 15:24:37 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 15833 invoked by uid 99); 12 Feb 2010 15:24:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Feb 2010 15:24:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Feb 2010 15:24:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 38D0A2388847; Fri, 12 Feb 2010 15:24:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Fri, 12 Feb 2010 15:23:59 -0000 To: chemistry-commits@incubator.apache.org From: fguillaume@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100212152400.38D0A2388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + *

+ * 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. + *

+ * 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. + *

+ * If this is the result of a call to {@link SPI#getObjectParents}, then the + * path segment is inverted, it is the relative path segment of the + * object argument of the method inside this {@link ObjectEntry}. + */ + String getPathSegment(); + + /** * Gets a property value. *

* 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 getFolderTree(ObjectId folder, int depth, + Tree 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. - *

- * 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 getDescendants(ObjectId folder, int depth, + Tree 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 { + + /** + * 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> 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 getFolderTree(ObjectId folder, int depth, + public Tree 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 getDescendants(ObjectId folder, int depth, + public Tree 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 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 links; + protected String pathSegment; + + /** Children while reading the object from a feed, not used otherwise. */ + protected List> children; + public static class Link { public final String rel; @@ -104,8 +110,8 @@ } } - protected APPObjectEntry(APPRepository repository, APPConnection connection, - Map properties, + protected APPObjectEntry(APPRepository repository, + APPConnection connection, Map properties, Map 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 allowableActions) { + protected void setAllowableActions(APPObjectEntry object, + Map allowableActions) { object.allowableActions = Collections.unmodifiableMap(allowableActions); } @Override + protected void setPathSegment(APPObjectEntry object, String pathSegment) { + object.pathSegment = pathSegment; + } + + @Override + protected void setChildren(APPObjectEntry object, + List> 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>, APPObjectEntry> { + + public APPObjectFeedTreeReader() { + super(new APPObjectEntryReader()); + } + + @Override + protected List> createFeed(StaxReader reader) { + return new ArrayList>(5); + } + + @Override + protected void addEntry(List> list, APPObjectEntry entry) { + Tree t = new SimpleTree(entry, entry.children); + entry.children = null; // not used anymore + list.add(t); + } + + @Override + protected void setHasMoreItems(List> feed, + boolean hasMoreItems) { + } + + @Override + protected void setNumItems(List> 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 getEntryFeedTree(String href, NameValuePairs params) { + List> list = getObjectFeed(href, params, + new APPObjectFeedTreeReader()); + return new SimpleTree(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 map = new HashMap(); Map pdefs = new HashMap(); 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 getEntryBuilder() { - return entryBuilder; - } - - public void setEntryBuilder(EntryReader 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 extends AbstractEntryReader { - 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 allowableActions); + protected abstract void setAllowableActions(T object, + Map allowableActions); + + protected abstract void setPathSegment(T object, String pathSegment); + + // TODO better use of generics + protected abstract void setChildren(T object, List> 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> 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 changeLogBaseTypes = new HashSet(); 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 changeLogBaseTypes = new HashSet(); + changeLogBaseTypes.add(BaseType.DOCUMENT); + changeLogBaseTypes.add(BaseType.FOLDER); + APPRepositoryInfo ri = new APPRepositoryInfo( + new APPRepositoryCapabilities(), new HashMap(), + 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 changeLogBaseTypes = new HashSet(); + changeLogBaseTypes.add(BaseType.DOCUMENT); + changeLogBaseTypes.add(BaseType.FOLDER); + APPRepositoryInfo ri = new APPRepositoryInfo( + new APPRepositoryCapabilities(), new HashMap(), + 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 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 changeLogBaseTypes = new HashSet(); + changeLogBaseTypes.add(BaseType.DOCUMENT); + changeLogBaseTypes.add(BaseType.FOLDER); + APPRepositoryInfo ri = new APPRepositoryInfo( + new APPRepositoryCapabilities(), new HashMap(), + 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> list = new APPObjectFeedTreeReader().read( + getReadContext(), is); + assertEquals(2, list.size()); + Tree 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 @@ - - + + + + @@ -21,5 +24,6 @@ - + + seg 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 @@ + + + urn:x-id:tree + Tree + + system + + 2009-07-15T11:22:00.000Z + + urn:x-id:document1 + Document1 + 2009-07-15T11:20:00.000Z + + + + + + string1 + + + + seg1 + + + urn:x-id:tree1 + Tree 1 + + system + + 2009-07-15T11:22:00.000Z + + urn:x-id:document3 + Document3 + 2009-07-15T11:20:00.000Z + + + + + + string3 + + + + seg3 + + + urn:x-id:tree2 + Tree 2 + + system + + 2009-07-15T11:22:00.000Z + + urn:x-id:document4 + Document4 + 2009-07-15T11:20:00.000Z + + + + + + string4 + + + + seg4 + + + + + + + + + urn:x-id:document2 + Document2 + 2009-07-15T11:21:00.000Z + + + + + + string2 + + + + seg2 + + + urn:x-id:tree3 + Tree 3 + + system + + 2009-07-15T11:22:00.000Z + + urn:x-id:document5 + Document5 + 2009-07-15T11:20:00.000Z + + + + + + string5 + + + + seg5 + + + urn:x-id:document6 + Document6 + 2009-07-15T11:20:00.000Z + + + + + + string6 + + + + seg6 + + + + + 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 @@ + + + urn:x-id:children + Children + + system + + 2009-07-15T11:22:00.000Z + + urn:x-id:document1 + Document1 + 2009-07-15T11:20:00.000Z + + + + + + string1 + + + + seg1 + + + urn:x-id:document2 + Document2 + 2009-07-15T11:21:00.000Z + + + + + + string2 + + + + seg2 + + 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 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 tree = getEntriesTree(request, spi); + feed = getFeedTree(tree, request, spi); + } else { + ListPage 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 tree, RequestContext request, + SPI spi) throws ResponseContextException { + // no paging + SimpleListPage page = new SimpleListPage(); + Feed feed = createFeedBase(page, request, spi); + addFeedDetails(feed, tree.getChildren(), request, spi); + return feed; + } + protected Feed createFeedBase(ListPage 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 entries, - RequestContext request) throws ResponseContextException { + // called either with a List of ObjectEntry or a List of Tree + @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 tree; + if (ob instanceof ObjectEntry) { + tree = null; + entryObj = (ObjectEntry) ob; + } else { + tree = (Tree) ob; + entryObj = tree.getNode(); + } + + Entry e = feed.addEntry(); + IRI feedIri = new IRI(getFeedIriForEntry(entryObj, request)); + addEntryDetails(request, e, feedIri, entryObj); + + if (tree != null) { + List> 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 getEntries(RequestContext request) - throws ResponseContextException { - SPI spi = repository.getSPI(); - try { - return getEntries(request, spi); - } finally { - spi.close(); - } + // unused but abstract + public ListPage getEntries(RequestContext request) { + throw new UnsupportedOperationException(); } public ListPage 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 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 tree; if (COLTYPE_DESCENDANTS.equals(getType())) { - int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, -1); - String orderBy = target.getParameter(AtomPubCMIS.PARAM_ORDER_BY); - List descendants = spi.getDescendants(objectId, depth, - orderBy, inclusion); - SimpleListPage page = new SimpleListPage( - 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 folderTree = spi.getFolderTree(objectId, depth, - inclusion); - SimpleListPage page = new SimpleListPage( - 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 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