chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r899003 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/ chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/ chemistry-commons/src/main/java...
Date Wed, 13 Jan 2010 23:50:39 GMT
Author: fguillaume
Date: Wed Jan 13 23:50:39 2010
New Revision: 899003

URL: http://svn.apache.org/viewvc?rev=899003&view=rev
Log:
Make JAX-RS binding support DELETE on descendants and foldertree

Modified:
    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-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java

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=899003&r1=899002&r2=899003&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 23:50:39 2010
@@ -297,6 +297,20 @@
         return postAbderaEntry(2);
     }
 
+    @DELETE
+    @Path("descendants/{objectid}")
+    public Response deleteDescendants() {
+        // objectid decoded by Abdera getCollectionAdapter
+        return deleteAbderaEntry(2);
+    }
+
+    @DELETE
+    @Path("foldertree/{objectid}")
+    public Response deleteFolderTree() {
+        // objectid decoded by Abdera getCollectionAdapter
+        return deleteAbderaEntry(2);
+    }
+
     @GET
     @Produces(AtomPub.MEDIA_TYPE_ATOM_ENTRY)
     @Path("object")

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=899003&r1=899002&r2=899003&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 23:50:39 2010
@@ -74,6 +74,8 @@
 
     protected static String rootFolderId;
 
+    private static String folder1id;
+
     protected static String doc2id;
 
     protected static String doc3id;
@@ -149,6 +151,7 @@
         folder1.setValue("title", "The folder 1 description");
         folder1.setValue("description", "folder 1 title");
         folder1.save();
+        folder1id = folder1.getId();
 
         Folder folder2 = folder1.newFolder("fold");
         folder2.setName("folder2");
@@ -240,8 +243,7 @@
         assertNotNull(ch);
         resp.release();
 
-        resp = client.get(base + "/children/"
-                + repository.getInfo().getRootFolderId().getId() + "?"
+        resp = client.get(base + "/children/" + rootFolderId + "?"
                 + AtomPubCMIS.PARAM_MAX_ITEMS + "=4");
         assertEquals(HttpStatus.SC_OK, resp.getStatus());
         ch = resp.getDocument().getRoot();
@@ -344,12 +346,35 @@
 
     public void testDelete() {
         RequestOptions options = new RequestOptions();
-        options.setContentType(AtomPub.MEDIA_TYPE_ATOM_ENTRY);
         ClientResponse resp = client.delete(base + "/object/" + doc3id, options);
         assertEquals(HttpStatus.SC_NO_CONTENT, resp.getStatus());
         resp.release();
 
-        resp = client.delete(base + "/object/nosuchid", options);
+        resp = client.delete(base + "/object/no-such-id", options);
+        assertEquals(HttpStatus.SC_NOT_FOUND, resp.getStatus());
+        resp.release();
+    }
+
+    public void testDeleteDescendants() {
+        RequestOptions options = new RequestOptions();
+        ClientResponse resp = client.delete(base + "/descendants/" + folder1id,
+                options);
+        assertEquals(HttpStatus.SC_NO_CONTENT, resp.getStatus());
+        resp.release();
+
+        resp = client.delete(base + "/descendants/no-such-id", options);
+        assertEquals(HttpStatus.SC_NOT_FOUND, resp.getStatus());
+        resp.release();
+    }
+
+    public void testDeleteFolderTree() {
+        RequestOptions options = new RequestOptions();
+        ClientResponse resp = client.delete(base + "/foldertree/" + folder1id,
+                options);
+        assertEquals(HttpStatus.SC_NO_CONTENT, resp.getStatus());
+        resp.release();
+
+        resp = client.delete(base + "/foldertree/no-such-id", options);
         assertEquals(HttpStatus.SC_NOT_FOUND, resp.getStatus());
         resp.release();
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=899003&r1=899002&r2=899003&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
Wed Jan 13 23:50:39 2010
@@ -712,15 +712,17 @@
         boolean allVersions = false; // TODO add in signature?
         String id = folder.getId();
         if (repository.rootId.equals(id)) {
-            throw new RuntimeException("Cannot delete root"); // TODO
+            throw new ConstraintViolationException("Cannot delete root");
         }
         SimpleData data = repository.datas.get(id);
         if (data == null) {
-            throw new RuntimeException("Not found: " + folder); // TODO
+            throw new ObjectNotFoundException("No such folder: "
+                    + folder.getId());
         }
         String typeId = (String) data.get(Property.TYPE_ID);
         if (repository.getType(typeId).getBaseType() != BaseType.FOLDER) {
-            throw new RuntimeException("Not a folder: " + folder); // TODO
+            throw new IllegalArgumentException("Not a folder: "
+                    + folder.getId());
         }
         for (String childId : new ArrayList<String>(repository.children.get(id))) {
             SimpleData childData = repository.datas.get(childId);



Mime
View raw message