chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r898858 - in /incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src: main/java/org/apache/chemistry/atompub/server/ main/java/org/apache/chemistry/atompub/server/jaxrs/ test/java/org/apache/chemistry/atompub/server/
Date Wed, 13 Jan 2010 17:49:38 GMT
Author: fguillaume
Date: Wed Jan 13 17:49:37 2010
New Revision: 898858

URL: http://svn.apache.org/viewvc?rev=898858&view=rev
Log:
CMIS-97: deal with Tomcat and encoded paths in URI templates

Modified:
    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/main/java/org/apache/chemistry/atompub/server/CMISProvider.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

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=898858&r1=898857&r2=898858&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
Wed Jan 13 17:49:37 2010
@@ -792,8 +792,17 @@
         RelationshipDirection relationships = RelationshipDirection.fromInclusion(incl);
         Inclusion inclusion = new Inclusion(properties, null, relationships,
                 allowableActions, false, false);
-        if (COLTYPE_PATH.equals(getType())) {
-            String path = resourceName;
+        if (COLTYPE_PATH.equals(getType()) || "".equals(resourceName)) {
+            String path;
+            if (COLTYPE_PATH.equals(getType())) {
+                path = resourceName;
+            } else {
+                path = target.getParameter(AtomPubCMIS.PARAM_PATH);
+                if (path == null) {
+                    throw new ResponseContextException("Missing id and path",
+                            500);
+                }
+            }
             if (!path.startsWith("/")) {
                 path = "/" + path;
             }

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=898858&r1=898857&r2=898858&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 13 17:49:37 2010
@@ -66,7 +66,7 @@
         // entry
         targetBuilder.setTemplate(TargetType.TYPE_ENTRY,
                 "{target_base}/{entrytype}/{id}");
-        targetResolver.setPattern("/object/([^/?]+)(\\?.*)?",
+        targetResolver.setPattern("/object(?:/?)([^/?]*)(\\?.*)?",
                 TargetType.TYPE_ENTRY, "objectid");
         targetResolver.setPattern("/allowableactions/([^/?]+)",
                 TargetType.TYPE_ENTRY, "objectid"); // XXX entry?
@@ -160,7 +160,8 @@
                         AtomPubCMIS.PARAM_INCLUDE_ACL)));
         list.add(new URITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_PATH,
                 AtomPub.MEDIA_TYPE_ATOM_ENTRY, addURITemplateParameters(
-                        base + "/path/{path}", //
+                        base + "/object", //
+                        AtomPubCMIS.PARAM_PATH, //
                         AtomPubCMIS.PARAM_FILTER,
                         AtomPubCMIS.PARAM_RENDITION_FILTER,
                         AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,

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=898858&r1=898857&r2=898858&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 13 17:49:37 2010
@@ -298,6 +298,13 @@
 
     @GET
     @Produces(AtomPub.MEDIA_TYPE_ATOM_ENTRY)
+    @Path("object")
+    public Response doGetObjectNoId() {
+        return getAbderaEntry(1);
+    }
+
+    @GET
+    @Produces(AtomPub.MEDIA_TYPE_ATOM_ENTRY)
     @Path("object/{objectid}")
     public Response doGetObject() {
         // objectid decoded by Abdera getCollectionAdapter

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=898858&r1=898857&r2=898858&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 13 17:49:37 2010
@@ -290,7 +290,7 @@
         String path = "/folder1/folder2/doc3";
 
         // URL-encoded (what a compliant client using the URI template does)
-        ClientResponse resp = client.get(base + "/path/"
+        ClientResponse resp = client.get(base + "/object?path="
                 + path.replace("/", "%2F"));
         assertEquals(HttpStatus.SC_OK, resp.getStatus());
         Element ob = resp.getDocument().getRoot();
@@ -299,6 +299,26 @@
         assertEquals("urn:uuid:" + doc3id, id.getText());
         resp.release();
 
+        // unencoded
+        resp = client.get(base + "/object?path=" + path);
+        assertEquals(HttpStatus.SC_OK, resp.getStatus());
+        ob = resp.getDocument().getRoot();
+        assertNotNull(ob);
+        id = ob.getFirstChild(new QName(AtomPub.ATOM_NS, "id"));
+        assertEquals("urn:uuid:" + doc3id, id.getText());
+        resp.release();
+
+        // non-URI-template version using /path
+
+        // URL-encoded
+        resp = client.get(base + "/path/" + path.replace("/", "%2F"));
+        assertEquals(HttpStatus.SC_OK, resp.getStatus());
+        ob = resp.getDocument().getRoot();
+        assertNotNull(ob);
+        id = ob.getFirstChild(new QName(AtomPub.ATOM_NS, "id"));
+        assertEquals("urn:uuid:" + doc3id, id.getText());
+        resp.release();
+
         // unencoded, single slash
         resp = client.get(base + "/path" + path);
         assertEquals(HttpStatus.SC_OK, resp.getStatus());



Mime
View raw message