import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.jboss.resteasy.plugins.providers.multipart.InputPart;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
+
+
/**
* BlobClient.java
*
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+ //HTTP query param string for specifying a URI source to blob bits.
+ public static final String BLOB_URI_PARAM = "blobUri";
+
+
@Override
public String getServiceName() {
return SERVICE_NAME;
/**
* allow to reset proxy as per security needs
*/
- public void setProxy() {
+ @Override
+ public void setProxy() {
if (useAuth()) {
blobProxy = ProxyFactory.create(BlobProxy.class,
getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
*/
public ClientResponse<Response> create(PoxPayloadOut xmlPayload) {
return blobProxy.create(xmlPayload.getBytes());
+ }
+
+ public ClientResponse<Response> createBlobFromFormData(MultipartFormDataOutput formDataOutput) {
+ return blobProxy.createBlobFromFormData(formDataOutput);
}
-
+
+ public ClientResponse<Response> createBlobFromURI(String blobUri) {
+ return blobProxy.createBlobFromURI("".getBytes(), blobUri);
+ }
+
/**
* @param csid
* @param blob
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.InputPart;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
+
+
/**
* @version $Revision: 2108 $
*/
@Path(BlobClient.SERVICE_PATH + "/")
-@Produces({"application/xml"})
-@Consumes({"application/xml"})
+@Produces("application/xml")
+@Consumes("application/xml")
public interface BlobProxy extends CollectionSpaceProxy {
//(C)reate
@POST
ClientResponse<Response> create(byte[] xmlPayload);
+ //(C)reate
+ @POST
+ ClientResponse<Response> createBlobFromURI(byte[] xmlPayload,
+ @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri);
+
+ //(C)reate
+ @POST
+ @Consumes("multipart/form-data")
+ ClientResponse<Response> createBlobFromFormData(MultipartFormDataOutput formDataOutput);
+
//(R)ead
@GET
@Path("/{csid}")
*/
package org.collectionspace.services.client.test;
+import java.io.File;
import java.util.List;
+
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.BlobClient;
-import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.blob.BlobsCommon;
-import org.jboss.resteasy.client.ClientResponse;
-
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+
/**
* BlobServiceTest, carries out tests against a deployed and running Blob Service. <p/>
* $LastChangedRevision: $
private final String CLASS_NAME = BlobServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
private String knownResourceId = null;
+ private static final String BLOBS_DIR = "blobs";
+
+ private boolean blobCleanup = true;
@Override
public String getServicePathComponent() {
return response.getEntity(AbstractCommonList.class);
}
+ /**
+ * Sets up create tests.
+ */
+ @Override
+ protected void setupCreate() {
+ super.setupCreate();
+ String noBlobCleanup = System.getProperty(NO_BLOB_CLEANUP);
+ if(Boolean.TRUE.toString().equalsIgnoreCase(noBlobCleanup)) {
+ //
+ // Don't delete the blobs that we created during the test cycle
+ //
+ this.blobCleanup = false;
+ }
+ }
+
+ private boolean blobCleanup() {
+ return blobCleanup;
+ }
+
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
}
allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
}
+
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
+ public void createBlobFromURI(String testName) throws Exception {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ setupCreate();
+ BlobClient client = new BlobClient();
+
+ String currentDir = this.getResourceDir();
+ String blobsDirPath = currentDir + File.separator + BLOBS_DIR;
+ File blobsDir = new File(blobsDirPath);
+ if (blobsDir != null && blobsDir.exists()) {
+ File[] children = blobsDir.listFiles();
+ if (children != null && children.length > 0) {
+ for (File child : children) {
+ String mimeType = this.getMimeType(child);
+ logger.debug("Processing file URI: " + child.getAbsolutePath());
+ logger.debug("MIME type is: " + mimeType);
+ ClientResponse<Response> res = client.createBlobFromURI(child.getAbsolutePath());
+ assertStatusCode(res, testName);
+ if (blobCleanup == true) {
+ allResourceIdsCreated.add(extractId(res));
+ }
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath + " is empty or cannot be read.");
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath + " is missing or cannot be read.");
+ }
+ }
+
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"createBlobFromURI"})
+ public void createBlobwithPost(String testName) throws Exception {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ setupCreate();
+ BlobClient client = new BlobClient();
+
+ String currentDir = this.getResourceDir();
+ String blobsDirPath = currentDir + File.separator + BLOBS_DIR;
+ File blobsDir = new File(blobsDirPath);
+ if (blobsDir != null && blobsDir.exists()) {
+ File[] children = blobsDir.listFiles();
+ if (children != null && children.length > 0) {
+ for (File child : children) {
+ String mimeType = this.getMimeType(child);
+ logger.debug("Posting file: " + child.getAbsolutePath());
+ logger.debug("MIME type is: " + mimeType);
+ MultipartFormDataOutput form = new MultipartFormDataOutput();
+ OutputPart outputPart = form.addFormData("file", child, MediaType.valueOf(mimeType));
+ ClientResponse<Response> res = client.createBlobFromFormData(form);
+ assertStatusCode(res, testName);
+ if (blobCleanup == true) {
+ allResourceIdsCreated.add(extractId(res));
+ }
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath + " is empty or cannot be read.");
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath + " is missing or cannot be read.");
+ }
+ }
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
//FIXME: REM - We should not have Nuxeo dependencies in our resource classes.
import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils;
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 javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.MediaType;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
import java.io.File;
import java.io.InputStream;
import java.util.List;
@Path(BlobClient.SERVICE_PATH)
-@Consumes({"multipart/mixed", "application/xml"})
-@Produces({"multipart/mixed", "application/xml"})
+@Consumes("application/xml")
+@Produces("application/xml")
public class BlobResource extends ResourceBase {
@Override
@Consumes("multipart/form-data")
@Produces("application/xml")
public Response createBlob(@Context HttpServletRequest req,
- @QueryParam("blobUri") String blobUri) {
+ @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri) {
Response response = null;
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
}
+ return response;
+ }
+
+ @POST
+ @Override
+ public Response create(@Context UriInfo ui,
+ String xmlPayload) {
+ Response response = null;
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ String blobUri = queryParams.getFirst(BlobClient.BLOB_URI_PARAM);
+
+ try {
+ if (blobUri != null) {
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
+ BlobInput blobInput = BlobUtil.getBlobInput(ctx);
+ blobInput.createBlobFile(blobUri);
+ response = this.create(null, ctx);
+ } else {
+ response = super.create(ui, xmlPayload);
+ }
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+
return response;
}
@GET
@Path("{csid}/derivatives")
- @Produces("application/xml")
public CommonList getDerivatives(
@PathParam("csid") String csid) {
CommonList result = null;
BlobInput blobInput = BlobUtil.getBlobInput(ctx);
if (blobInput.getBlobFile() != null) {
//
- // If blobInput has a file then we just received a multipart/form-data file post
+ // If blobInput has a file then we just received a multipart/form-data file post or a URI query parameter
//
DocumentModel documentModel = wrapDoc.getWrappedObject();
RepositoryInstance repoSession = this.getRepositorySession();
//import org.dom4j.Namespace;\r
//import org.dom4j.io.SAXReader;\r
//import org.xml.sax.InputSource;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
\r
public class PoxPayloadIn extends PoxPayload<PayloadInputPart> {\r
\r
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());\r
+\r
/*\r
* Parse the POX 'xmlPayload' into individual parts. Each part is saved\r
* as a DOM4j Element and, if possible, a JAXB object instance as well.\r
*/\r
public PoxPayloadIn(String xmlPayload) throws DocumentException {\r
super(xmlPayload);\r
+ if (logger.isTraceEnabled() == true) {\r
+ logger.trace("\n\n>>>> Payload In : BEGIN >>>>\n" +\r
+ xmlPayload +\r
+ "\n>>>> Payload In : END >>>>\n");\r
+ }\r
}\r
\r
/* (non-Javadoc)\r
import org.dom4j.DocumentHelper;\r
import org.dom4j.Element;\r
import org.dom4j.io.SAXReader;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
\r
import java.io.File;\r
import java.io.IOException;\r
*/\r
public class PoxPayloadOut extends PoxPayload<PayloadOutputPart> {\r
\r
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());\r
+ \r
/**\r
* Instantiates a new pox payload out.\r
*\r
}\r
}\r
result = document.asXML();\r
+ \r
+ if (logger.isTraceEnabled() == true) {\r
+ logger.trace("\n\n<<<< Payload Out : BEGIN <<<<\n" +\r
+ result +\r
+ "\n<<<< Payload Out : END <<<<\n");\r
+ }\r
+ \r
return result;\r
}\r
\r
*/
package org.collectionspace.services.client.test;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.jboss.resteasy.client.ClientResponse;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
+import javax.activation.MimetypesFileTypeMap;
+
+
/**
* AbstractServiceTestImpl
*
/** The Constant DEFAULT_LIST_SIZE. */
static protected final int DEFAULT_LIST_SIZE = 10;
static protected final int DEFAULT_PAGINATEDLIST_SIZE = 10;
+ static protected final String RESOURCE_PATH = "src" + File.separator +
+ "test" + File.separator +
+ "resources";
+ static protected final String DEFAULT_MIME = "application/octet-stream; charset=ISO-8859-1";
+ static private final String NO_TEST_CLEANUP = "noTestCleanup";
+ static protected final String NO_BLOB_CLEANUP = "noBlobCleanup";
+
+ protected String getMimeType(File theFile) {
+ String result = null;
+ result = new MimetypesFileTypeMap().getContentType(theFile);
+ if (result == null) {
+ logger.debug("Could not get MIME type for file at: " + theFile.getAbsolutePath());
+ result = DEFAULT_MIME;
+ }
+
+ return result;
+ }
/* Use this to keep track of resources to delete */
protected List<String> allResourceIdsCreated = new ArrayList<String>();
private String EMPTY_SORT_BY_ORDER = "";
return this.logger;
}
+ protected String getResourceDir() {
+ String result = null;
+ String currentDirectory = System.getProperty("user.dir");
+ result = currentDirectory + File.separator + RESOURCE_PATH;
+ return result;
+ }
+
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
//
*/
@AfterClass(alwaysRun=true)
public void cleanUp() {
- String noTest = System.getProperty("noTestCleanup");
- if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+ String noTestCleanup = System.getProperty(NO_TEST_CLEANUP);
+ if(Boolean.TRUE.toString().equalsIgnoreCase(noTestCleanup)) {
if (logger.isDebugEnabled()) {
logger.debug("Skipping Cleanup phase ...");
}
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
\r
+// TODO: Auto-generated Javadoc\r
+/**\r
+ * The Class FileUtils.\r
+ */\r
public class FileUtils {\r
/** The Constant logger. */\r
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);\r
\r
- private static final String TMP_FILE_PREFIX = "cspace_blob_";\r
+ /** The Constant TMP_FILE_PREFIX. */\r
+ public static final String TMP_BLOB_PREFIX = "cspace_blob_";\r
+ public static final String DEFAULT_BLOB_NAME = "blob";\r
+ private static final String FILE_FORM_FIELD = "file";\r
\r
+ /**\r
+ * Creates the tmp file.\r
+ *\r
+ * @param streamIn the stream in\r
+ * @param filePrefix the file prefix\r
+ * @return the file\r
+ */\r
static public File createTmpFile(InputStream streamIn,\r
String filePrefix) {\r
File result = null;\r
return result;\r
}\r
\r
+ /**\r
+ * Look for an uploaded file from the HTTP request of type "multipart/form-data".\r
+ *\r
+ * @param request the request\r
+ * @return the file\r
+ */\r
static public File createTmpFile(HttpServletRequest request) {\r
File result = null;\r
\r
ServletFileUpload upload = new ServletFileUpload(factory);\r
\r
try {\r
- List items = upload.parseRequest(request);\r
- Iterator iter = items.iterator();\r
+ List<FileItem> items = upload.parseRequest(request);\r
+ Iterator<FileItem> iter = items.iterator();\r
\r
while (iter.hasNext()) {\r
- FileItem item = (FileItem) iter.next();\r
-\r
- if (item.isFormField()) {\r
- if (logger.isDebugEnabled() == true) {\r
- String formFieldName = item.getFieldName();\r
- logger.debug("FORM FIELD:" + formFieldName);\r
+ FileItem item = iter.next();\r
+ String formFieldName = item.getFieldName();\r
+ if (logger.isTraceEnabled() == true) {\r
+ logger.trace("HTTP Request form field:" + formFieldName);\r
+ }\r
+ if (formFieldName.equalsIgnoreCase(FILE_FORM_FIELD)) {\r
+ if (item.isFormField() == true) {\r
+ logger.warn(FILE_FORM_FIELD + ": part is marked as a form field.");\r
}\r
- } else {\r
- if (!item.isFormField()) {\r
-\r
- String fileName = item.getName();\r
- System.out.println("File Name:" + fileName);\r
-\r
- File fullFile = new File(item.getName());\r
- String tmpDir = System.getProperty("java.io.tmpdir");\r
- File savedFile = new File(tmpDir, fullFile.getName());\r
-\r
- item.write(savedFile);\r
-// item.getInputStream();//FIXME: We should make a version of this method that returns the input stream\r
- result = savedFile;\r
+ String fileName = item.getName();\r
+ if (logger.isTraceEnabled() == true) {\r
+ logger.trace("Uploaded File Name:" + (fileName != null ? fileName : "<empty>"));\r
}\r
+ if (fileName == null) {\r
+ fileName = DEFAULT_BLOB_NAME; //if there's no file name then set it to an empty string\r
+ logger.warn("File was posted to the services without a file name.");\r
+ } \r
+ File tmpDir = new File(System.getProperty("java.io.tmpdir"));\r
+ File savedFile = File.createTempFile(TMP_BLOB_PREFIX, fileName, tmpDir);\r
+\r
+ item.write(savedFile);\r
+// item.getInputStream();//FIXME: REM - We should make a version of this method that returns the input stream\r
+ result = savedFile;\r
}\r
}\r
} catch (Exception e) {\r
\r
import javax.ws.rs.*;\r
import javax.ws.rs.core.*;\r
+\r
import java.util.List;\r
\r
/**\r
//======================= CREATE ====================================================\r
\r
@POST\r
- public Response create(String xmlPayload) {\r
+ public Response create(@Context UriInfo ui,\r
+ String xmlPayload) {\r
try {\r
PoxPayloadIn input = new PoxPayloadIn(xmlPayload);\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input);\r
File tmpFile = FileUtils.createTmpFile(req);\r
this.setBlobFile(tmpFile);\r
this.setBlobUri(blobUri);\r
+ }\r
+ \r
+ public void createBlobFile(String theBlobUri) {\r
+ File theBlobFile = new File(theBlobUri);\r
+ this.setBlobFile(theBlobFile);\r
+ this.setBlobUri(blobUri);\r
} \r
+ \r
}\r
\r
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.client</artifactId>
<version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.blob.client</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+//import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+//import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
/**
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
-
+
@Override
public String getServiceName() {
return SERVICE_NAME;
public ClientResponse<Response> create(PoxPayloadOut xmlPayload) {
return mediaProxy.create(xmlPayload.getBytes());
}
+
+ /**
+ * @param media
+ * @return
+ *
+ */
+ public ClientResponse<Response> createBlob(String csid, String blobUri) {
+ return mediaProxy.createBlob(csid, blobUri);
+ }
/**
* @param csid
return mediaProxy.update(csid, xmlPayload.getBytes());
}
+
+ /**
+ * @param csid
+ * @param media
+ * @return
+ */
+ public ClientResponse<String> update(String csid, PoxPayloadOut xmlPayload, String URI) {
+ return mediaProxy.update(csid, xmlPayload.getBytes());
+
+ }
+
/**
* @param csid
package org.collectionspace.services.client;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.client.BlobClient;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
/**
* @version $Revision: 2108 $
//(C)reate
@POST
ClientResponse<Response> create(byte[] xmlPayload);
+
+ @POST
+ @Path("{csid}")
+ @Produces("multipart/form-data")
+ ClientResponse<Response>createBlob(@PathParam("csid") String csid,
+ @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri);
//(R)ead
@GET
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.MediaClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.Test;
public class MediaServiceTest extends AbstractServiceTestImpl {
private final String CLASS_NAME = MediaServiceTest.class.getName();
- private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+ private final Logger logger = LoggerFactory.getLogger(MediaServiceTest.class);
private String knownResourceId = null;
@Override
}
allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
}
+
+// String noTest = System.getProperty("noTestCleanup");
+// if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("Skipping Cleanup phase ...");
+// }
+// return;
+// }
+
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update"})
+// public void updateWithBlob(String testName) throws Exception {
+// logger.debug(testBanner(testName, CLASS_NAME));
+// setupCreate();
+// MediaClient client = new MediaClient();
+// PoxPayloadOut multipart = createMediaInstance(createIdentifier());
+// ClientResponse<Response> res = client.create(multipart);
+// assertStatusCode(res, testName);
+// String csid = extractId(res);
+//
+//
+// allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
+// }
+
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
*/
package org.collectionspace.services.media;
+import org.collectionspace.services.client.BlobClient;
import org.collectionspace.services.client.MediaClient;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.blob.BlobInput;
import org.collectionspace.services.common.blob.BlobUtil;
import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.DocumentHandler;
-import org.collectionspace.services.blob.BlobsCommon;
-import org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler;
import org.collectionspace.services.blob.BlobResource;
import org.collectionspace.services.nuxeo.client.java.CommonList;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Consumes("multipart/form-data")
@Produces("application/xml")
public Response createBlob(@Context HttpServletRequest req,
- @QueryParam("blobUri") String blobUri,
+ @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri,
@PathParam("csid") String csid) {
PoxPayloadIn input = null;
Response response = null;