]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3598: Media and Blob tests needed to create example media data in the "Nightly...
authorRichard Millet <richard.millet@berkeley.edu>
Wed, 23 Feb 2011 22:19:47 +0000 (22:19 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Wed, 23 Feb 2011 22:19:47 +0000 (22:19 +0000)
services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java

index 4cf0d66070b94b546077378caa2d2c16b315abd3..068b1e66c80fd58c69824d0fb407b3444137112c 100644 (file)
@@ -52,13 +52,14 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import java.io.InputStream;
 import java.util.List;
 
 @Path(MediaClient.SERVICE_PATH)
-@Produces({"application/xml", "multipart/mixed"})
-@Consumes({"application/xml", "multipart/mixed"})
+@Consumes("application/xml")
+@Produces("application/xml")
 public class MediaResource extends ResourceBase {
     final Logger logger = LoggerFactory.getLogger(MediaResource.class);
 
@@ -114,6 +115,31 @@ public class MediaResource extends ResourceBase {
        return MediaCommon.class;
     }
 
+    @POST
+    @Override
+    public Response create(@Context UriInfo ui,
+               String xmlPayload) {
+       Response response = null;
+       PoxPayloadIn input = null;
+       MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+       String blobUri = queryParams.getFirst(BlobClient.BLOB_URI_PARAM);
+       
+       try {
+               if (blobUri != null) {
+                       ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME, input);
+                       BlobInput blobInput = BlobUtil.getBlobInput(ctx);
+                       blobInput.createBlobFile(blobUri);
+                       response = this.create(input, ctx);
+               } else {
+                       response = super.create(ui, xmlPayload);
+               }
+       } catch (Exception e) {
+               throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+       }
+                       
+               return response;
+    }    
+    
     @POST
     @Path("{csid}")
     @Consumes("multipart/form-data")