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/01/06 15:30:27 UTC

svn commit: r896452 - 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/chemistry/ato...

Author: fguillaume
Date: Wed Jan  6 14:30:27 2010
New Revision: 896452

URL: http://svn.apache.org/viewvc?rev=896452&view=rev
Log:
Proper use of URI templates; allow queries using GET

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/TypeManager.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/APPRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java
    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/CMISProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.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-atompub/src/main/java/org/apache/chemistry/atompub/abdera/QueryElement.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMIS.java Wed Jan  6 14:30:27 2010
@@ -209,6 +209,10 @@
 
     public static final QName INCLUDE_RELATIONSHIPS = CMISName("includeRelationships");
 
+    public static final QName INCLUDE_POLICY_IDS = CMISName("includePolicyIds");
+
+    public static final QName INCLUDE_ACL = CMISName("includeACL");
+
     public static final QName RENDITION_FILTER = CMISName("renditionFilter");
 
     public static final QName MAX_ITEMS = CMISName("maxItems");

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/TypeManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/TypeManager.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/TypeManager.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/TypeManager.java Wed Jan  6 14:30:27 2010
@@ -65,19 +65,19 @@
      * <li>1: only children of the type,</li>
      * <li>more than 1: grand-children up to that depth,</li>
      * </ul>
-     * If returnPropertyDefinitions is {@code false}, then the
+     * If includePropertyDefinitions is {@code false}, then the
      * {@link PropertyDefinition}s will not be returned in each {@link Type}.
      *
      * @param typeId the base type ID, or {@code null}
      * @param depth the number of levels of depth in the type hierarchy from
      *            which to return results
-     * @param returnPropertyDefinitions {@code false} to skip property
+     * @param includePropertyDefinitions {@code false} to skip property
      *            definitions
      * @return the types, or a subset of them
      *
      * @throws IllegalArgumentException if the depth is invalid
      */
     Collection<Type> getTypes(String typeId, int depth,
-            boolean returnPropertyDefinitions);
+            boolean includePropertyDefinitions);
 
 }

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=896452&r1=896451&r2=896452&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 Wed Jan  6 14:30:27 2010
@@ -51,6 +51,7 @@
 import org.apache.chemistry.Policy;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.Relationship;
+import org.apache.chemistry.RelationshipDirection;
 import org.apache.chemistry.Rendition;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
@@ -213,12 +214,33 @@
 
     public List<ObjectEntry> getDescendants(ObjectId folder, int depth,
             String orderBy, Inclusion inclusion) {
-        // TODO includeRelationship, includeAllowableActions, orderBy
-        // TODO filter, includeRenditions
         String href = getObjectEntry(folder).getLink(AtomPub.LINK_DOWN,
                 AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
         Request req = new Request(href);
         req.setParameter(AtomPubCMIS.PARAM_DEPTH, Integer.toString(depth));
+        if (orderBy != null) {
+            req.setParameter(AtomPubCMIS.PARAM_ORDER_BY, orderBy);
+        }
+        if (inclusion != null) {
+            if (inclusion.properties != null) {
+                req.setParameter(AtomPubCMIS.PARAM_FILTER, inclusion.properties);
+            }
+            if (inclusion.renditions != null) {
+                req.setParameter(AtomPubCMIS.PARAM_RENDITION_FILTER,
+                        inclusion.renditions);
+            }
+            if (inclusion.relationships != null) {
+                req.setParameter(
+                        AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
+                        RelationshipDirection.toInclusion(inclusion.relationships));
+            }
+            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
+                    Boolean.toString(inclusion.allowableActions));
+            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
+                    Boolean.toString(inclusion.policies));
+            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_ACL,
+                    Boolean.toString(inclusion.acls));
+        }
         Response resp = connector.get(req);
         if (!resp.isOk()) {
             throw new ContentManagerException(
@@ -305,8 +327,13 @@
         }
         URITemplate uriTemplate = repository.getURITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_ID);
         String href = uriTemplate.template;
-        // TODO proper URI template syntax
-        href = href.replace("{id}", objectId.getId());
+        href = replace(href, AtomPubCMIS.PARAM_ID, objectId.getId());
+        href = replace(href, AtomPubCMIS.PARAM_FILTER, "");
+        href = replace(href, AtomPubCMIS.PARAM_RENDITION_FILTER, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL, "");
         Response resp = connector.get(new Request(href));
         if (resp.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
             throw new ObjectNotFoundException(objectId.getId());
@@ -319,6 +346,10 @@
         return (APPObjectEntry) resp.getObject(new ReadContext(this));
     }
 
+    protected String replace(String template, String param, String value) {
+        return template.replace('{' + param + '}', value);
+    }
+
     public CMISObject getObject(ObjectId object) {
         APPObjectEntry entry = getObjectEntry(object);
         Type type = getRepository().getType(entry.getTypeId());
@@ -462,10 +493,16 @@
         if (uriTemplate == null) {
             throw new UnsupportedOperationException("Cannot get object by path");
         }
-        // TODO proper URI template syntax and encoding
+        // TODO proper encoding
         String encodedPath = path.replace(" ", "%20");
-        String href = uriTemplate.template.replace("{path}", encodedPath);
-
+        String href = uriTemplate.template;
+        href = replace(href, AtomPubCMIS.PARAM_PATH, encodedPath);
+        href = replace(href, AtomPubCMIS.PARAM_FILTER, "");
+        href = replace(href, AtomPubCMIS.PARAM_RENDITION_FILTER, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, "");
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL, "");
         Response resp = connector.get(new Request(href));
         if (!resp.isOk()) {
             if (resp.getStatusCode() == 404) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java Wed Jan  6 14:30:27 2010
@@ -123,9 +123,9 @@
     }
 
     public Collection<Type> getTypes(String typeId, int depth,
-            boolean returnPropertyDefinitions) {
+            boolean includePropertyDefinitions) {
         loadTypes();
-        return typeManager.getTypes(typeId, depth, returnPropertyDefinitions);
+        return typeManager.getTypes(typeId, depth, includePropertyDefinitions);
     }
 
     public String getCollectionHref(String type) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java Wed Jan  6 14:30:27 2010
@@ -62,13 +62,17 @@
         xw.element(CMIS.STATEMENT).econtent(statement);
         xw.element(CMIS.SEARCH_ALL_VERSIONS).content(searchAllVersions);
         if (inclusion != null) {
-            xw.element(CMIS.INCLUDE_ALLOWABLE_ACTIONS).content(
-                    inclusion.allowableActions);
-            xw.element(CMIS.INCLUDE_RELATIONSHIPS).content(
-                    RelationshipDirection.toInclusion(inclusion.relationships));
             if (inclusion.renditions != null) {
                 xw.element(CMIS.RENDITION_FILTER).econtent(inclusion.renditions);
             }
+            if (inclusion.relationships != null) {
+                xw.element(CMIS.INCLUDE_RELATIONSHIPS).content(
+                        RelationshipDirection.toInclusion(inclusion.relationships));
+            }
+            xw.element(CMIS.INCLUDE_ALLOWABLE_ACTIONS).content(
+                    inclusion.allowableActions);
+            xw.element(CMIS.INCLUDE_POLICY_IDS).content(inclusion.policies);
+            xw.element(CMIS.INCLUDE_ACL).content(inclusion.acls);
         }
         if (paging != null) {
             if (paging.maxItems > -1) {

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=896452&r1=896451&r2=896452&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 Wed Jan  6 14:30:27 2010
@@ -178,17 +178,21 @@
             throws ResponseContextException {
         ObjectId objectId = spi.newObjectId(id);
         Target target = request.getTarget();
-        String orderBy = target.getParameter(AtomPubCMIS.PARAM_ORDER_BY);
         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, false, false);
+                relationships, allowableActions, policies, acls);
         if (COLTYPE_DESCENDANTS.equals(getType())) {
-            int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, 1);
+            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>(
@@ -197,7 +201,7 @@
             page.setNumItems(page.size());
             return page;
         } else if (COLTYPE_FOLDER_TREE.equals(getType())) {
-            int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, 1);
+            int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, -1);
             List<ObjectEntry> folderTree = spi.getFolderTree(objectId, depth,
                     inclusion);
             SimpleListPage<ObjectEntry> page = new SimpleListPage<ObjectEntry>(
@@ -206,6 +210,7 @@
             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);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java Wed Jan  6 14:30:27 2010
@@ -72,8 +72,8 @@
                 TargetType.TYPE_ENTRY, "objectid"); // XXX entry?
         targetResolver.setPattern("/type/([^/?]+)(\\?.*)?",
                 TargetType.TYPE_ENTRY, "typeid");
-        targetResolver.setPattern("/path/([^?]*)", TargetType.TYPE_ENTRY,
-                "path");
+        targetResolver.setPattern("/path/([^?]*)(\\?.*)?",
+                TargetType.TYPE_ENTRY, "path");
 
         // media
         targetBuilder.setTemplate(TargetType.TYPE_MEDIA,
@@ -88,7 +88,7 @@
         targetResolver.setPattern("/checkedout(\\?.*)?",
                 TargetType.TYPE_COLLECTION);
         targetResolver.setPattern("/unfiled", TargetType.TYPE_COLLECTION);
-        targetResolver.setPattern("/query",
+        targetResolver.setPattern("/query(\\?.*)?",
                 CMISQueryFeed.TARGET_TYPE_CMIS_QUERY);
         targetResolver.setPattern("/types(\\?.*)?", //
                 TargetType.TYPE_COLLECTION);
@@ -147,23 +147,52 @@
         base += request.getTargetBasePath().substring(
                 request.getContextPath().length());
         List<URITemplate> list = new ArrayList<URITemplate>(3);
-        list.add(new URITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_ID, //
-                AtomPub.MEDIA_TYPE_ATOM_ENTRY, //
-                base + "/object/{id}"));
-        list.add(new URITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_PATH, //
-                AtomPub.MEDIA_TYPE_ATOM_ENTRY, //
-                base + "/path/{path}"));
+        list.add(new URITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_ID,
+                AtomPub.MEDIA_TYPE_ATOM_ENTRY, addURITemplateParameters(
+                        base + "/object/{id}", //
+                        AtomPubCMIS.PARAM_FILTER,
+                        AtomPubCMIS.PARAM_RENDITION_FILTER,
+                        AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
+                        AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
+                        AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
+                        AtomPubCMIS.PARAM_INCLUDE_ACL)));
+        list.add(new URITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_PATH,
+                AtomPub.MEDIA_TYPE_ATOM_ENTRY, addURITemplateParameters(
+                        base + "/path/{path}", //
+                        AtomPubCMIS.PARAM_FILTER,
+                        AtomPubCMIS.PARAM_RENDITION_FILTER,
+                        AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
+                        AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
+                        AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
+                        AtomPubCMIS.PARAM_INCLUDE_ACL)));
+        list.add(new URITemplate(AtomPubCMIS.URITMPL_QUERY, //
+                AtomPub.MEDIA_TYPE_ATOM_FEED, addURITemplateParameters(
+                        base + "/query",
+                        AtomPubCMIS.PARAM_QUERY, //
+                        AtomPubCMIS.PARAM_SEARCH_ALL_VERSIONS,
+                        AtomPubCMIS.PARAM_MAX_ITEMS,
+                        AtomPubCMIS.PARAM_SKIP_COUNT,
+                        AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
+                        AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS)));
         list.add(new URITemplate(AtomPubCMIS.URITMPL_TYPE_BY_ID, //
                 AtomPub.MEDIA_TYPE_ATOM_FEED, //
                 base + "/type/{id}"));
-        if (false) { // TODO
-            list.add(new URITemplate(AtomPubCMIS.URITMPL_QUERY, //
-                    AtomPub.MEDIA_TYPE_ATOM_FEED, //
-                    base + "/query?q={q}"));
-        }
         return list;
     }
 
+    protected static String addURITemplateParameters(String s, String... params) {
+        StringBuilder buf = new StringBuilder(s);
+        for (int i = 0; i < params.length; i++) {
+            String param = params[i];
+            buf.append(i == 0 ? '?' : '&');
+            buf.append(param);
+            buf.append("={");
+            buf.append(param);
+            buf.append('}');
+        }
+        return buf.toString();
+    }
+
     @Override
     protected TargetBuilder getTargetBuilder(RequestContext request) {
         return targetBuilder;

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java Wed Jan  6 14:30:27 2010
@@ -21,6 +21,7 @@
 import org.apache.abdera.protocol.server.ProviderHelper;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.context.ResponseContextException;
 import org.apache.axiom.om.OMDocument;
@@ -28,6 +29,7 @@
 import org.apache.chemistry.ListPage;
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.Paging;
+import org.apache.chemistry.RelationshipDirection;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
 import org.apache.chemistry.atompub.AtomPubCMIS;
@@ -46,9 +48,19 @@
 
     protected boolean searchAllVersions;
 
-    protected Paging paging;
+    protected int maxItems;
 
-    protected Inclusion inclusion;
+    protected int skipCount;
+
+    protected String renditions;
+
+    protected RelationshipDirection relationships;
+
+    protected boolean allowableActions;
+
+    protected boolean policies;
+
+    protected boolean acls;
 
     public CMISQueryFeed(Repository repository) {
         super(AtomPubCMIS.COL_QUERY, "query", null, repository);
@@ -69,7 +81,9 @@
         if (request.getTarget().getType() != TARGET_TYPE_CMIS_QUERY) {
             return ProviderHelper.notsupported(request);
         }
-        if (request.getMethod().equalsIgnoreCase("POST")) {
+        if (request.getMethod().equalsIgnoreCase("GET")) {
+            return getEntry(request);
+        } else if (request.getMethod().equalsIgnoreCase("POST")) {
             return postEntry(request);
         } else {
             // stupid signature prevents use of varargs...
@@ -96,12 +110,39 @@
         QueryElement q = new QueryElement(element);
         statement = q.getStatement();
         searchAllVersions = q.getSearchAllVersions();
-        paging = new Paging(q.getMaxItems(), q.getSkipCount());
-        inclusion = new Inclusion(null, q.getRenditionFilter(),
-                q.getIncludeRelationships(), q.getIncludeAllowableActions(),
-                false, false);
+        maxItems = q.getMaxItems();
+        skipCount = q.getSkipCount();
+        renditions = q.getRenditionFilter();
+        relationships = q.getIncludeRelationships();
+        allowableActions = q.getIncludeAllowableActions();
+        policies = q.getIncludePolicyIds();
+        acls = q.getIncludeACL();
+        return doSearch(request);
+    }
+
+    @Override
+    public ResponseContext getEntry(RequestContext request) {
+        Target target = request.getTarget();
+        statement = target.getParameter(AtomPubCMIS.PARAM_QUERY);
+        searchAllVersions = getParameter(request,
+                AtomPubCMIS.PARAM_SEARCH_ALL_VERSIONS, false);
+        maxItems = getParameter(request, AtomPubCMIS.PARAM_MAX_ITEMS, -1);
+        skipCount = getParameter(request, AtomPubCMIS.PARAM_SKIP_COUNT, 0);
+        renditions = target.getParameter(AtomPubCMIS.PARAM_RENDITION_FILTER);
+        String rel = target.getParameter(AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS);
+        relationships = RelationshipDirection.fromInclusion(rel);
+        allowableActions = getParameter(request,
+                AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, false);
+        policies = getParameter(request, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
+                false);
+        acls = getParameter(request, AtomPubCMIS.PARAM_INCLUDE_ACL, false);
+        return doSearch(request);
+    }
+
+    protected ResponseContext doSearch(RequestContext request) {
         ResponseContext res = getFeed(request); // calls getEntries
-        if (res.getStatus() == HttpStatus.SC_OK) {
+        if (res.getStatus() == HttpStatus.SC_OK
+                && request.getMethod().equalsIgnoreCase("POST")) {
             res.setStatus(HttpStatus.SC_CREATED);
         }
         return res;
@@ -112,6 +153,9 @@
             throws ResponseContextException {
         SPI spi = repository.getSPI();
         try {
+            Paging paging = new Paging(maxItems, skipCount);
+            Inclusion inclusion = new Inclusion(null, renditions,
+                    relationships, allowableActions, policies, acls);
             ListPage<ObjectEntry> results = spi.query(statement,
                     searchAllVersions, inclusion, paging);
             return results;

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java Wed Jan  6 14:30:27 2010
@@ -135,21 +135,21 @@
         el = factory.newElement(CMIS.DESCRIPTION, te);
         el.setText(type.getDescription());
         el = factory.newElement(CMIS.CREATABLE, te);
-        el.setText(bool(type.isCreatable()));
+        el.setText(Boolean.toString(type.isCreatable()));
         el = factory.newElement(CMIS.FILEABLE, te);
-        el.setText(bool(type.isFileable()));
+        el.setText(Boolean.toString(type.isFileable()));
         el = factory.newElement(CMIS.QUERYABLE, te);
-        el.setText(bool(type.isQueryable()));
+        el.setText(Boolean.toString(type.isQueryable()));
         el = factory.newElement(CMIS.CONTROLLABLE_POLICY, te);
-        el.setText(bool(type.isControllablePolicy()));
+        el.setText(Boolean.toString(type.isControllablePolicy()));
         el = factory.newElement(CMIS.CONTROLLABLE_ACL, te);
-        el.setText(bool(type.isControllableACL()));
+        el.setText(Boolean.toString(type.isControllableACL()));
         el = factory.newElement(CMIS.FULLTEXT_INDEXED, te);
-        el.setText(bool(type.isFulltextIndexed()));
+        el.setText(Boolean.toString(type.isFulltextIndexed()));
         el = factory.newElement(CMIS.INCLUDED_IN_SUPERTYPE_QUERY, te);
-        el.setText(bool(type.isIncludedInSuperTypeQuery()));
+        el.setText(Boolean.toString(type.isIncludedInSuperTypeQuery()));
         el = factory.newElement(CMIS.VERSIONABLE, te); // docs only
-        el.setText(bool(type.isVersionable()));
+        el.setText(Boolean.toString(type.isVersionable()));
         el = factory.newElement(CMIS.CONTENT_STREAM_ALLOWED, te); // docs only
         el.setText(type.getContentStreamAllowed().toString()); // TODO null
         // TODO allowedSourceTypes, allowedTargetTypes
@@ -257,14 +257,13 @@
         return link;
     }
 
-    protected static String bool(boolean bool) {
-        return bool ? "true" : "false";
-    }
-
     @Override
     public Iterable<Type> getEntries(RequestContext request)
             throws ResponseContextException {
-        return repository.getTypes(id);
+        int depth = getParameter(request, AtomPubCMIS.PARAM_DEPTH, -1);
+        boolean includePropertyDefinitions = getParameter(request,
+                AtomPubCMIS.PARAM_INCLUDE_PROPERTY_DEFINITIONS, false);
+        return repository.getTypes(id, depth, includePropertyDefinitions);
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java Wed Jan  6 14:30:27 2010
@@ -351,6 +351,13 @@
         return getResponse(adapter.putMedia(requestContext));
     }
 
+    @GET
+    @Produces(AtomPub.MEDIA_TYPE_ATOM_FEED)
+    @Path("query")
+    public Response doGetQuery() {
+        return getAbderaEntry(1);
+    }
+
     @POST
     @Consumes(AtomPubCMIS.MEDIA_TYPE_CMIS_QUERY)
     @Produces(AtomPub.MEDIA_TYPE_ATOM_FEED)

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=896452&r1=896451&r2=896452&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 Wed Jan  6 14:30:27 2010
@@ -195,7 +195,7 @@
         assertNotNull(uritmpl);
         Element tmpl = uritmpl.getFirstChild(AtomPubCMIS.TEMPLATE);
         assertNotNull(tmpl);
-        assertEquals(base + "/object/{id}", tmpl.getText());
+        assertTrue(tmpl.getText().startsWith(base + "/object/{id}"));
         resp.release();
     }
 
@@ -323,7 +323,7 @@
         method.releaseConnection();
     }
 
-    public void testQuery() throws Exception {
+    public void testQueryPOST() throws Exception {
         EntityProvider provider = new QueryEntityProvider("SELECT * FROM doc",
                 true, null, null);
         ClientResponse resp = client.post(base + "/query", provider);
@@ -333,6 +333,14 @@
         resp.release();
     }
 
+    public void testQueryGET() throws Exception {
+        ClientResponse resp = client.get(base + "/query?q=SELECT+*+FROM+doc");
+        assertEquals(HttpStatus.SC_OK, resp.getStatus());
+        Element res = resp.getDocument().getRoot();
+        assertNotNull(res);
+        resp.release();
+    }
+
     protected InputStream load(String resource) throws Exception {
         return getClass().getClassLoader().getResource(resource).openStream();
     }
@@ -371,14 +379,20 @@
             sw.startElement(CMIS.SEARCH_ALL_VERSIONS).writeElementText(
                     Boolean.toString(searchAllVersions)).endElement();
             if (inclusion != null) {
-                sw.startElement(CMIS.INCLUDE_ALLOWABLE_ACTIONS).writeElementText(
-                        Boolean.toString(inclusion.allowableActions)).endElement();
-                sw.startElement(CMIS.INCLUDE_RELATIONSHIPS).writeElementText(
-                        RelationshipDirection.toInclusion(inclusion.relationships)).endElement();
                 if (inclusion.renditions != null) {
                     sw.startElement(CMIS.RENDITION_FILTER).writeElementText(
                             inclusion.renditions).endElement();
                 }
+                if (inclusion.relationships != null) {
+                    sw.startElement(CMIS.INCLUDE_RELATIONSHIPS).writeElementText(
+                            RelationshipDirection.toInclusion(inclusion.relationships)).endElement();
+                }
+                sw.startElement(CMIS.INCLUDE_ALLOWABLE_ACTIONS).writeElementText(
+                        Boolean.toString(inclusion.allowableActions)).endElement();
+                sw.startElement(CMIS.INCLUDE_POLICY_IDS).writeElementText(
+                        Boolean.toString(inclusion.policies)).endElement();
+                sw.startElement(CMIS.INCLUDE_ACL).writeElementText(
+                        Boolean.toString(inclusion.acls)).endElement();
             }
             if (paging != null) {
                 if (paging.maxItems > -1) {

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=896452&r1=896451&r2=896452&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 Wed Jan  6 14:30:27 2010
@@ -118,6 +118,12 @@
      * ----- AtomPub Link Parameters -----
      */
 
+    public static final String PARAM_ID = "id";
+
+    public static final String PARAM_PATH = "path";
+
+    public static final String PARAM_QUERY = "q";
+
     public static final String PARAM_FILTER = "filter";
 
     public static final String PARAM_MAX_ITEMS = "maxItems";
@@ -128,6 +134,8 @@
 
     public static final String PARAM_DEPTH = "depth";
 
+    public static final String PARAM_INCLUDE_PROPERTY_DEFINITIONS = "includePropertyDefinitions";
+
     public final static String PARAM_FOLDER_ID = "folderId";
 
     public static final String PARAM_RENDITION_FILTER = "renditionFilter";
@@ -136,8 +144,14 @@
 
     public static final String PARAM_INCLUDE_RELATIONSHIPS = "includeRelationships";
 
+    public static final String PARAM_INCLUDE_POLICY_IDS = "includePolicyIds";
+
+    public static final String PARAM_INCLUDE_ACL = "includeACL";
+
     public static final String PARAM_INCLUDE_PATH_SEGMENT = "includePathSegment";
 
+    public static final String PARAM_SEARCH_ALL_VERSIONS = "searchAllVersions";
+
     public static final String PARAM_CONTINUE_ON_FAILURE = "continueOnFailure";
 
     public static final String PARAM_UNFILE_OBJECTS = "unfileObjects";

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/QueryElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/QueryElement.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/QueryElement.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/QueryElement.java Wed Jan  6 14:30:27 2010
@@ -72,6 +72,14 @@
         return RelationshipDirection.fromInclusion(getChildElementText(CMIS.INCLUDE_RELATIONSHIPS));
     }
 
+    public boolean getIncludePolicyIds() {
+        return Boolean.parseBoolean(getChildElementText(CMIS.INCLUDE_POLICY_IDS));
+    }
+
+    public boolean getIncludeACL() {
+        return Boolean.parseBoolean(getChildElementText(CMIS.INCLUDE_ACL));
+    }
+
     public String getRenditionFilter() {
         return getChildElementText(CMIS.RENDITION_FILTER);
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseRepository.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseRepository.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseRepository.java Wed Jan  6 14:30:27 2010
@@ -163,8 +163,8 @@
     }
 
     public Collection<Type> getTypes(String typeId, int depth,
-            boolean returnPropertyDefinitions) {
-        return typeManager.getTypes(typeId, depth, returnPropertyDefinitions);
+            boolean includePropertyDefinitions) {
+        return typeManager.getTypes(typeId, depth, includePropertyDefinitions);
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java?rev=896452&r1=896451&r2=896452&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java Wed Jan  6 14:30:27 2010
@@ -136,9 +136,9 @@
     }
 
     public List<Type> getTypes(String typeId, int depth,
-            boolean returnPropertyDefinitions) {
+            boolean includePropertyDefinitions) {
 
-        // TODO depth, returnPropertyDefinitions
+        // TODO depth, includePropertyDefinitions
 
         try {
             List<Type> result = new ArrayList<Type>();