chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r880876 - /incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/
Date Mon, 16 Nov 2009 17:53:47 GMT
Author: fguillaume
Date: Mon Nov 16 17:53:47 2009
New Revision: 880876

URL: http://svn.apache.org/viewvc?rev=880876&view=rev
Log:
CMIS-58, CMIS-61: AtomPub proper parameter parsing for children and descendants, fix descendants
collection

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCheckedOutCollection.java
  (with props)
Modified:
    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/CMISCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCheckedOutCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCheckedOutCollection.java?rev=880876&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCheckedOutCollection.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCheckedOutCollection.java
Mon Nov 16 17:53:47 2009
@@ -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:
+ *     Florent Guillaume, Nuxeo
+ *     Amélie Avramo
+ */
+package org.apache.chemistry.atompub.server;
+
+import java.util.Collection;
+
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.context.ResponseContextException;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.ObjectId;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.SPI;
+import org.apache.chemistry.atompub.AtomPub;
+
+/**
+ * CMIS Collection for the checked out documents.
+ */
+public class CMISCheckedOutCollection extends CMISObjectsCollection {
+
+    public CMISCheckedOutCollection(Repository repository) {
+        super("checkedout", null, null, repository);
+    }
+
+    /*
+     * ----- AbstractCollectionAdapter -----
+     */
+
+    @Override
+    protected Feed createFeedBase(RequestContext request)
+            throws ResponseContextException {
+        Feed feed = super.createFeedBase(request);
+        feed.addLink(getCheckedOutLink(request), AtomPub.LINK_SELF,
+                AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
+        // RFC 5005 paging
+        return feed;
+    }
+
+    /*
+     * ----- AbstractEntityCollectionAdapter -----
+     */
+
+    @Override
+    public Iterable<ObjectEntry> getEntries(RequestContext request)
+            throws ResponseContextException {
+        SPI spi = repository.getSPI(); // TODO XXX connection leak
+        Target target = request.getTarget();
+        ObjectId folderId = target.getParameter(PARAM_FOLDER_ID) == null ? null
+                : spi.newObjectId(target.getParameter(PARAM_FOLDER_ID));
+        String filter = target.getParameter(PARAM_FILTER);
+        int maxItems = target.getParameter(PARAM_MAX_ITEMS) == null ? 0
+                : Integer.parseInt(target.getParameter(PARAM_MAX_ITEMS));
+        int skipCount = target.getParameter(PARAM_SKIP_COUNT) == null ? 0
+                : Integer.parseInt(target.getParameter(PARAM_SKIP_COUNT));
+        boolean includeAllowableActions = target.getParameter(PARAM_ALLOWABLE_ACTIONS) ==
null ? false
+                : Boolean.parseBoolean(target.getParameter(PARAM_ALLOWABLE_ACTIONS));
+        boolean includeRelationships = target.getParameter(PARAM_RELATIONSHIPS) == null ?
false
+                : Boolean.parseBoolean(target.getParameter(PARAM_RELATIONSHIPS));
+        boolean[] hasMoreItems = new boolean[1];
+        Collection<ObjectEntry> objectEntries = spi.getCheckedOutDocuments(
+                folderId, filter, includeAllowableActions,
+                includeRelationships, maxItems, skipCount, hasMoreItems);
+        return objectEntries;
+    }
+
+}

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

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCheckedOutCollection.java
------------------------------------------------------------------------------
    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=880876&r1=880875&r2=880876&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
Mon Nov 16 17:53:47 2009
@@ -13,6 +13,7 @@
  *
  * Authors:
  *     Florent Guillaume, Nuxeo
+ *     Amélie Avramo
  */
 package org.apache.chemistry.atompub.server;
 
@@ -20,6 +21,7 @@
 
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.protocol.server.context.ResponseContextException;
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.ObjectId;
@@ -75,11 +77,36 @@
     public Iterable<ObjectEntry> getEntries(RequestContext request)
             throws ResponseContextException {
         SPI spi = repository.getSPI(); // TODO XXX connection leak
-        boolean[] hasMoreItems = new boolean[1];
         ObjectId objectId = spi.newObjectId(id);
-        List<ObjectEntry> children = spi.getChildren(objectId, null, false,
-                false, false, 0, 0, null, hasMoreItems);
-        return children;
+        Target target = request.getTarget();
+        String filter = target.getParameter(PARAM_FILTER);
+        boolean includeAllowableActions = target.getParameter(PARAM_ALLOWABLE_ACTIONS) ==
null ? false
+                : Boolean.parseBoolean(target.getParameter(PARAM_ALLOWABLE_ACTIONS));
+        boolean includeRelationships = target.getParameter(PARAM_RELATIONSHIPS) == null ?
false
+                : Boolean.parseBoolean(target.getParameter(PARAM_RELATIONSHIPS));
+        // TODO proper renditionFilter use
+        boolean includeRenditions = target.getParameter(PARAM_RENDITION_FILTER) == null ?
false
+                : true;
+        String orderBy = target.getParameter(PARAM_ORDER_BY);
+        if ("descendants".equals(getType())) {
+            int depth = target.getParameter(PARAM_DEPTH) == null ? 1
+                    : Integer.parseInt(target.getParameter(PARAM_DEPTH));
+            List<ObjectEntry> descendants = spi.getDescendants(objectId, depth,
+                    filter, includeAllowableActions, includeRelationships,
+                    includeRenditions, orderBy);
+            return descendants;
+        } else {
+            int maxItems = target.getParameter(PARAM_MAX_ITEMS) == null ? 0
+                    : Integer.parseInt(target.getParameter(PARAM_MAX_ITEMS));
+            int skipCount = target.getParameter(PARAM_SKIP_COUNT) == null ? 0
+                    : Integer.parseInt(target.getParameter(PARAM_SKIP_COUNT));
+            boolean[] hasMoreItems = new boolean[1];
+            List<ObjectEntry> children = spi.getChildren(objectId, filter,
+                    includeAllowableActions, includeRelationships,
+                    includeRenditions, maxItems, skipCount, orderBy,
+                    hasMoreItems);
+            return children;
+        }
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java?rev=880876&r1=880875&r2=880876&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
Mon Nov 16 17:53:47 2009
@@ -13,6 +13,7 @@
  *
  * Authors:
  *     Florent Guillaume, Nuxeo
+ *     Amélie Avramo
  */
 package org.apache.chemistry.atompub.server;
 
@@ -35,6 +36,26 @@
 public abstract class CMISCollection<T> extends
         AbstractEntityCollectionAdapter<T> {
 
+    protected static final String PARAM_FILTER = "filter";
+
+    protected static final String PARAM_MAX_ITEMS = "maxItems";
+
+    protected static final String PARAM_SKIP_COUNT = "skipCount";
+
+    protected static final String PARAM_ALLOWABLE_ACTIONS = "includeAllowableActions";
+
+    protected static final String PARAM_RELATIONSHIPS = "includeRelationships";
+
+    protected static final String PARAM_RENDITION_FILTER = "renditionFilter";
+
+    protected static final String PARAM_ORDER_BY = "orderBy";
+
+    protected static final String PARAM_DEPTH = "depth";
+
+    protected static final String PARAM_INCLUDE_PATH_SEGMENT = "includePathSegment";
+
+    protected final static String PARAM_FOLDER_ID = "folderId";
+
     protected final String type;
 
     protected final String name;
@@ -120,9 +141,9 @@
 
     public String getChildrenLink(String fid, RequestContext request) {
         Map<String, String> params = new HashMap<String, String>();
-        params.put("entrytype", "children");
+        params.put("collection", "children");
         params.put("id", fid);
-        return request.absoluteUrlFor(TargetType.TYPE_ENTRY, params);
+        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
     }
 
     public String getDescendantsLink(String fid, RequestContext request) {
@@ -134,9 +155,15 @@
 
     public String getParentsLink(String fid, RequestContext request) {
         Map<String, String> params = new HashMap<String, String>();
-        params.put("entrytype", "parents");
+        params.put("collection", "parents");
         params.put("id", fid);
-        return request.absoluteUrlFor(TargetType.TYPE_ENTRY, params);
+        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    }
+
+    public String getCheckedOutLink(RequestContext request) {
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("collection", "checkedout");
+        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
     }
 
     public String getObjectLink(String id, RequestContext request) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java?rev=880876&r1=880875&r2=880876&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
Mon Nov 16 17:53:47 2009
@@ -23,7 +23,6 @@
 import org.apache.abdera.parser.stax.StaxStreamWriter;
 import org.apache.abdera.protocol.server.CollectionInfo;
 import org.apache.abdera.protocol.server.RequestContext;
-import org.apache.abdera.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.WorkspaceInfo;
 import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera.writer.StreamWriter;
@@ -32,7 +31,6 @@
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.RepositoryCapabilities;
 import org.apache.chemistry.RepositoryInfo;
-import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.URITemplate;
 import org.w3c.dom.Document;

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java?rev=880876&r1=880875&r2=880876&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
Mon Nov 16 17:53:47 2009
@@ -13,6 +13,7 @@
  *
  * Authors:
  *     Florent Guillaume, Nuxeo
+ *     Amélie Avramo
  */
 package org.apache.chemistry.atompub.server;
 
@@ -43,12 +44,13 @@
         String spath = request.getTargetBasePath();
         String path = spath == null ? uri : uri.substring(spath.length());
         String paths = path + '/';
+
         if (paths.startsWith("/types/")) {
             return new CMISTypesCollection(null, null, repository);
         }
         if (paths.startsWith("/type/")) {
-            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES,
-                    null, repository);
+            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES, null,
+                    repository);
         }
         if (paths.startsWith("/children/")) {
             String id = request.getTarget().getParameter("objectid");
@@ -56,7 +58,7 @@
         }
         if (paths.startsWith("/descendants/")) {
             String id = request.getTarget().getParameter("objectid");
-            return new CMISChildrenCollection(null, id, repository);
+            return new CMISChildrenCollection("descendants", id, repository);
         }
         if (paths.startsWith("/parents/")) {
             String id = request.getTarget().getParameter("objectid");
@@ -75,6 +77,9 @@
         if (paths.startsWith("/unfiled/")) {
             return new CMISCollectionForOther(null, "unfiled", null, repository);
         }
+        if (paths.startsWith("/checkedout/")) {
+            return new CMISCheckedOutCollection(repository);
+        }
         if (paths.startsWith("/query/") || paths.startsWith("/query?")) {
             return new CMISQueryFeed(repository);
         }



Mime
View raw message