@Context UriInfo uriInfo,\r
@PathParam("csid") String csid,\r
String xmlPayload) {\r
+ return this.update(null, resourceMap, uriInfo, csid, xmlPayload); \r
+ }\r
+\r
+ public byte[] update(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx, // REM: 8/13/2012 - Some sub-classes will override this method -e.g., MediaResource does.\r
+ @Context ResourceMap resourceMap,\r
+ @Context UriInfo uriInfo,\r
+ @PathParam("csid") String csid,\r
+ String xmlPayload) {\r
PoxPayloadOut result = null;\r
ensureCSID(csid, UPDATE);\r
try {\r
PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(theUpdate, uriInfo);\r
ctx.setResourceMap(resourceMap);\r
+ if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) {\r
+ ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists\r
+ } \r
result = update(csid, theUpdate, ctx); //==> CALL implementation method, which subclasses may override.\r
} catch (Exception e) {\r
throw bigReThrow(e, ServiceMessages.UPDATE_FAILED, csid);\r
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
return result;
}
-
+ @Override
+ public byte[] update(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,
+ @Context ResourceMap resourceMap,
+ @Context UriInfo ui,
+ @PathParam("csid") String csid,
+ String xmlPayload) {
+ //
+ // If we find a "blobUri" query param, then we need to create a blob resource/record first and then the media resource/record
+ //
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ String blobUri = queryParams.getFirst(BlobClient.BLOB_URI_PARAM);
+ if (blobUri != null && blobUri.isEmpty() == false) {
+ Response blobresult = createBlobWithUri(resourceMap, ui, xmlPayload, blobUri); // uses the blob resource and doc handler to create the blob
+ String blobCsid = CollectionSpaceClientUtils.extractId(blobresult);
+ queryParams.add(BlobClient.BLOB_CSID_PARAM, blobCsid); // Add the new blob's csid as an artificial query param -the media doc handler will look for this
+ }
+ return super.update(parentCtx, resourceMap, ui, csid, xmlPayload); // Now call the parent to finish the media resource POST request
+ }
+
/*
* Creates a new blob (using a URL pointing to a media file/resource) and associates it with an existing media record/resource.
*/