chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r891306 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/ chemistry-atompub-server/src/te...
Date Wed, 16 Dec 2009 16:51:33 GMT
Author: fguillaume
Date: Wed Dec 16 16:51:32 2009
New Revision: 891306

URL: http://svn.apache.org/viewvc?rev=891306&view=rev
Log:
CMIS-81: Implement AtomPub entry PUT

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml
  (with props)
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/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/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=891306&r1=891305&r2=891306&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 Dec 16 16:51:32 2009
@@ -17,6 +17,8 @@
  */
 package org.apache.chemistry.atompub.server;
 
+import static org.apache.abdera.protocol.server.ProviderHelper.calculateEntityTag;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -442,8 +444,7 @@
             } else {
                 addContent(entry, object, request);
             }
-            String mediaLink = getMediaLink(object.getId(), request);
-            return buildCreateMediaResponse(mediaLink, entry);
+            return buildGetEntryResponse(request, entry);
 
         } catch (ResponseContextException e) {
             return createErrorResponse(e);

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=891306&r1=891305&r2=891306&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 Dec 16 16:51:32 2009
@@ -24,6 +24,7 @@
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
@@ -209,7 +210,7 @@
         return getResponse(adapter.getEntry(requestContext));
     }
 
-    protected Response getAbderaPostEntry(int skipSegments) {
+    protected Response postAbderaEntry(int skipSegments) {
         RequestContext requestContext = getRequestContext(skipSegments);
         CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
         if (adapter == null) {
@@ -218,6 +219,15 @@
         return getResponse(adapter.postEntry(requestContext));
     }
 
+    protected Response putAbderaEntry(int skipSegments) {
+        RequestContext requestContext = getRequestContext(skipSegments);
+        CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
+        if (adapter == null) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
+        return getResponse(adapter.putEntry(requestContext));
+    }
+
     @GET
     @Produces(AtomPub.MEDIA_TYPE_ATOM_SERVICE)
     @Path("repository")
@@ -268,7 +278,7 @@
     @Path("children/{objectid}")
     public Response doPostChildren() {
         // objectid decoded by Abdera getCollectionAdapter
-        return getAbderaPostEntry(2);
+        return postAbderaEntry(2);
     }
 
     @GET
@@ -279,6 +289,15 @@
         return getAbderaEntry(2);
     }
 
+    @PUT
+    @Consumes(AtomPub.MEDIA_TYPE_ATOM_ENTRY)
+    @Produces(AtomPub.MEDIA_TYPE_ATOM_ENTRY)
+    @Path("object/{objectid}")
+    public Response doPutObject() {
+        // objectid decoded by Abdera getCollectionAdapter
+        return putAbderaEntry(2);
+    }
+
     @GET
     @Path("file/{objectid}")
     public Response doGetFile() {
@@ -293,7 +312,7 @@
     @Produces(AtomPub.MEDIA_TYPE_ATOM_FEED)
     @Path("query")
     public Response doPostQuery() {
-        return getAbderaPostEntry(1);
+        return postAbderaEntry(1);
     }
 
 }

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=891306&r1=891305&r2=891306&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 Dec 16 16:51:32 2009
@@ -31,6 +31,7 @@
 import org.apache.abdera.protocol.EntityProvider;
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
 import org.apache.abdera.protocol.util.AbstractEntityProvider;
 import org.apache.abdera.writer.StreamWriter;
 import org.apache.chemistry.BaseType;
@@ -232,6 +233,15 @@
         assertEquals(HttpStatus.SC_OK, resp.getStatus());
         ob = resp.getDocument().getRoot();
         assertNotNull(ob);
+
+        // update
+        RequestOptions options = new RequestOptions();
+        options.setContentType(AtomPub.MEDIA_TYPE_ATOM_ENTRY);
+        resp = client.put(base + "/object/" + doc3id,
+                load("templates/updatedocument.atomentry.xml"), options);
+        assertEquals(HttpStatus.SC_OK, resp.getStatus());
+        ob = resp.getDocument().getRoot();
+        assertNotNull(ob);
     }
 
     public void testFile() throws Exception {

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml?rev=891306&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml
Wed Dec 16 16:51:32 2009
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
+  <id>urn:uuid:00000000-0000-0000-0000-000000000000</id>
+  <title>Updated Title ${NAME}</title>
+  <updated>2009-01-01T00:00:00Z</updated>
+  <content>this content must be ignored ${NAME}</content>   <!--  must be
overridden by cmisra:content -->
+  <cmisra:content>
+    <cmisra:mediatype>text/plain</cmisra:mediatype>
+    <cmisra:base64>${CMISCONTENT}</cmisra:base64>
+  </cmisra:content>
+</entry>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument.atomentry.xml
------------------------------------------------------------------------------
    svn:keywords = Id

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=891306&r1=891305&r2=891306&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 Dec 16 16:51:32 2009
@@ -405,7 +405,7 @@
             // use a default type, useful for pure AtomPub POST
             typeId = BaseType.DOCUMENT.getId();
             properties.put(Property.TYPE_ID, typeId);
-            // throw new IllegalArgumentException("Missing obejct type id");
+            // throw new IllegalArgumentException("Missing object type id");
         }
         Type type = repository.getType(typeId);
         if (type == null || type.getBaseType() != BaseType.DOCUMENT) {
@@ -443,7 +443,7 @@
             ObjectId folder) {
         String typeId = (String) properties.get(Property.TYPE_ID);
         if (typeId == null) {
-            throw new IllegalArgumentException("Missing obejct type id");
+            throw new IllegalArgumentException("Missing object type id");
         }
         Type type = repository.getType(typeId);
         if (type == null || type.getBaseType() != BaseType.FOLDER) {



Mime
View raw message