<?xml version="1.0"?>
<component name="org.collectionspace.blob.coreTypes">
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
- <schema name="blob_common" prefix="blob_common" src="schemas/blob_common.xsd"/>
+ <schema name="blobs_common" prefix="blobs_common" src="schemas/blobs_common.xsd"/>
</extension>
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
<schema name="common"/>
<schema name="dublincore"/>
<schema name="collectionspace_core"/>
- <schema name="blob_common"/>
+ <schema name="blobs_common"/>
</doctype>
</extension>
</component>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">blobNumber</field>
+ <field schema="blobs_common">blobNumber</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">borrower</field>
+ <field schema="blobs_common">borrower</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">borrowersContact</field>
+ <field schema="blobs_common">borrowersContact</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">lendersAuthorizer</field>
+ <field schema="blobs_common">lendersAuthorizer</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">lendersAuthorizationDate</field>
+ <field schema="blobs_common">lendersAuthorizationDate</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">lendersContact</field>
+ <field schema="blobs_common">lendersContact</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">blobDate</field>
+ <field schema="blobs_common">blobDate</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">loanReturnDate</field>
+ <field schema="blobs_common">loanReturnDate</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">loanRenewalApplicationDate</field>
+ <field schema="blobs_common">loanRenewalApplicationDate</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">specialConditionsOfLoan</field>
+ <field schema="blobs_common">specialConditionsOfLoan</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">blobNote</field>
+ <field schema="blobs_common">blobNote</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</labels>
<translated>true</translated>
<fields>
- <field schema="blob_common">loanPurpose</field>
+ <field schema="blobs_common">loanPurpose</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
\r
<!-- Blob Information Group -->\r
<xs:element name="encoding" type="xs:string" />\r
- <xs:element name="mime-type" type="xs:string" />\r
+ <xs:element name="mimeType" type="xs:string" />\r
<xs:element name="data" type="xs:string" />\r
<xs:element name="name" type="xs:string" />\r
<xs:element name="length" type="xs:string" />\r
<xs:element name="digest" type="xs:string" />\r
<xs:element name="uri" type="xs:string" />\r
+ <xs:element name="repositoryId" type="xs:string" />\r
</xs:schema>\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.jaxb</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
import org.collectionspace.services.common.authorityref.AuthorityRefList;
//import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.blob.BlobCommonList;
+import org.collectionspace.services.blob.BlobsCommonList;
import org.jboss.resteasy.client.ProxyFactory;
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
* @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
*/
public String getServicePathComponent() {
- return "blob"; //Laramie20100824 was blobs, but label was a mismatch.
+ return "blobs"; //Laramie20100824 was blobs, but label was a mismatch.
}
/**
*
* @return
* @see org.collectionspace.services.client.BlobProxy#getBlob()
*/
- public ClientResponse<BlobCommonList> readList() {
+ public ClientResponse<BlobsCommonList> readList() {
return blobProxy.readList();
}
import javax.ws.rs.core.Response;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.blob.BlobCommonList;
+import org.collectionspace.services.blob.BlobsCommonList;
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 $
*/
-@Path("/blob/")
+@Path("/blobs/")
@Produces({"multipart/mixed"})
@Consumes({"multipart/mixed"})
public interface BlobProxy extends CollectionSpaceProxy {
// List
@GET
@Produces({"application/xml"})
- ClientResponse<BlobCommonList> readList();
+ ClientResponse<BlobsCommonList> readList();
// List Authority References
@GET
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.blob.BlobCommon;
+import org.collectionspace.services.blob.BlobsCommon;
import org.jboss.resteasy.client.ClientResponse;
private MultipartOutput createBlobInstance(String depositorRefName) {
this.depositorRefName = depositorRefName;
this.blobName = "testblob-"+createIdentifier();
- BlobCommon blob = new BlobCommon();
+ BlobsCommon blob = new BlobsCommon();
blob.setName(this.blobName);
MultipartOutput multipart = new MultipartOutput();
OutputPart commonPart = multipart.addPart(blob, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", new BlobClient().getCommonPartName());
- logger.debug("to be created, blob common: " + objectAsXmlString(blob, BlobCommon.class));
+ logger.debug("to be created, blob common: " + objectAsXmlString(blob, BlobsCommon.class));
return multipart;
}
ClientResponse<MultipartInput> res = blobClient.read(knownResourceId);
assertStatusCode(res, testName);
MultipartInput input = (MultipartInput) res.getEntity();
- BlobCommon blob = (BlobCommon) extractPart(input, blobClient.getCommonPartName(), BlobCommon.class);
+ BlobsCommon blob = (BlobsCommon) extractPart(input, blobClient.getCommonPartName(), BlobsCommon.class);
Assert.assertNotNull(blob);
- logger.debug(objectAsXmlString(blob, BlobCommon.class));
+ logger.debug(objectAsXmlString(blob, BlobsCommon.class));
// Check a couple of fields
Assert.assertEquals(blob.getName(), blobName);
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.BlobClient;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.blob.BlobCommon;
-import org.collectionspace.services.blob.BlobCommonList;
+import org.collectionspace.services.blob.BlobsCommon;
+import org.collectionspace.services.blob.BlobsCommonList;
import org.jboss.resteasy.client.ClientResponse;
private final String CLASS_NAME = BlobServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
- final String SERVICE_PATH_COMPONENT = "blob";
+ final String SERVICE_PATH_COMPONENT = "blobs";
private String knownResourceId = null;
@Override
@Override
protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(BlobCommonList.class);
+ return response.getEntity(BlobsCommonList.class);
}
@Override
ClientResponse<MultipartInput> res = client.read(knownResourceId);
assertStatusCode(res, testName);
MultipartInput input = (MultipartInput) res.getEntity();
- BlobCommon blob = (BlobCommon) extractPart(input, client.getCommonPartName(), BlobCommon.class);
+ BlobsCommon blob = (BlobsCommon) extractPart(input, client.getCommonPartName(), BlobsCommon.class);
Assert.assertNotNull(blob);
}
logger.debug(testBanner(testName, CLASS_NAME));
setupReadList();
BlobClient client = new BlobClient();
- ClientResponse<BlobCommonList> res = client.readList();
- BlobCommonList list = res.getEntity();
+ ClientResponse<BlobsCommonList> res = client.readList();
+ BlobsCommonList list = res.getEntity();
assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
- List<BlobCommonList.BlobListItem> items = list.getBlobListItem();
+ List<BlobsCommonList.BlobListItem> items = list.getBlobListItem();
int i = 0;
- for (BlobCommonList.BlobListItem item : items) {
+ for (BlobsCommonList.BlobListItem item : items) {
logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid());
logger.debug(testName + ": list-item[" + i + "] blob.name=" + item.getName());
logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri());
assertStatusCode(res, testName);
logger.debug("got object to update with ID: " + knownResourceId);
MultipartInput input = (MultipartInput) res.getEntity();
- BlobCommon blob = (BlobCommon) extractPart(input, client.getCommonPartName(), BlobCommon.class);
+ BlobsCommon blob = (BlobsCommon) extractPart(input, client.getCommonPartName(), BlobsCommon.class);
Assert.assertNotNull(blob);
blob.setName("updated-" + blob.getName());
- logger.debug("Object to be updated:"+objectAsXmlString(blob, BlobCommon.class));
+ logger.debug("Object to be updated:"+objectAsXmlString(blob, BlobsCommon.class));
MultipartOutput output = new MultipartOutput();
OutputPart commonPart = output.addPart(blob, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", client.getCommonPartName());
res = client.update(knownResourceId, output);
assertStatusCode(res, testName);
input = (MultipartInput) res.getEntity();
- BlobCommon updatedBlob = (BlobCommon) extractPart(input, client.getCommonPartName(), BlobCommon.class);
+ BlobsCommon updatedBlob = (BlobsCommon) extractPart(input, client.getCommonPartName(), BlobsCommon.class);
Assert.assertNotNull(updatedBlob);
}
private MultipartOutput createBlobInstance(String exitNumber) {
String identifier = "blobNumber-" + exitNumber;
- BlobCommon blob = new BlobCommon();
+ BlobsCommon blob = new BlobsCommon();
blob.setName(identifier);
MultipartOutput multipart = new MultipartOutput();
OutputPart commonPart = multipart.addPart(blob, MediaType.APPLICATION_XML_TYPE);
if (logger.isDebugEnabled()) {
logger.debug("to be created, blob common");
- logger.debug(objectAsXmlString(blob, BlobCommon.class));
+ logger.debug(objectAsXmlString(blob, BlobsCommon.class));
}
return multipart;
<!-- See http://wiki.collectionspace.org/display/collectionspace/Loans+Out+Schema -->
<!-- blob -->
- <xs:element name="blob_common">
+ <xs:element name="blobs_common_deprecated">
<xs:complexType>
<xs:sequence>
<xs:element name="encoding" type="xs:string" />
<xs:element name="length" type="xs:string" />
<xs:element name="digest" type="xs:string" />
<xs:element name="uri" type="xs:string" />
+ <xs:element name="id" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:complexType>
<!-- blob records, as in nuxeo repository -->
- <xs:element name="blob_common_list">
+ <xs:element name="blobs_common_deprecated_list">
<xs:complexType>
<xs:complexContent>
<xs:extension base="abstractCommonList">
<xs:sequence>
- <xs:element name="blob_list_item" maxOccurs="unbounded">
+ <xs:element name="blobs_common_deprecated_list_item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="1" />
<xs:element name="encoding" type="xs:string" minOccurs="1" />
<xs:element name="length" type="xs:string" minOccurs="1" />
<xs:element name="uri" type="xs:string" />
- <xs:element name="csid" type="xs:string" minOccurs="1" />
+ <xs:element name="csid" type="xs:string" minOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.blob.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.collectionobject.jaxb</artifactId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
<version>${project.version}</version>
</dependency>
<!-- External dependencies -->
*/
package org.collectionspace.services.blob;
+import org.collectionspace.services.common.FileUtils;
import org.collectionspace.services.common.ResourceBase;
-import org.collectionspace.services.common.ClientType;
+//import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.common.blob.BlobInput;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.blob.BlobsCommon;
+import org.collectionspace.services.blob.BlobsCommonList;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+
+//FIXME: REM - We should not have Nuxeo dependencies in our resource classes.
+import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
+
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import java.io.File;
+import java.io.InputStream;
import java.util.List;
-@Path("/blob")
+@Path("/blobs")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
public class BlobResource extends ResourceBase {
@Override
public String getServiceName(){
- return "blob";
+ return "blobs";
};
}
@Override
- public Class<BlobCommon> getCommonPartClass() {
- return BlobCommon.class;
+ public Class<BlobsCommon> getCommonPartClass() {
+ return BlobsCommon.class;
+ }
+
+ public BlobsCommonList getBlobList(MultivaluedMap<String, String> queryParams) {
+ return (BlobsCommonList)getList(queryParams);
+ }
+
+ @Deprecated
+ public BlobsCommonList getBlobList(List<String> csidList) {
+ return (BlobsCommonList) getList(csidList);
+ }
+
+ protected BlobsCommonList search(MultivaluedMap<String,String> queryParams,String keywords) {
+ return (BlobsCommonList) super.search(queryParams, keywords);
+ }
+
+ private InputStream getBlobContent(String csid, String derivativeTerm) throws WebApplicationException {
+ InputStream result = null;
+
+ try {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ ctx.setProperty(BlobInput.DERIVATIVE_TERM_KEY, derivativeTerm);
+ MultipartOutput response = this.get(csid, ctx);
+ if (logger.isDebugEnabled() == true) {
+ logger.debug(response.toString());
+ }
+ result = (InputStream)ctx.getProperty(BlobInput.DERIVATIVE_CONTENT_KEY);
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+
+ if (result == null) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Index failed. Could not get the contents for the Blob.").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+
+ return result;
+ }
+
+ private BlobInput setBlobInput(ServiceContext<MultipartInput, MultipartOutput> ctx,
+ HttpServletRequest req,
+ String blobUri) {
+ File tmpFile = FileUtils.createTmpFile(req);
+ BlobInput blobInput = new BlobInput(tmpFile, blobUri);
+ ctx.setProperty(BlobInput.class.getName(), blobInput);
+ return blobInput;
+ }
+
+ @POST
+ @Consumes("multipart/form-data")
+ @Produces("application/xml")
+ public Response createBlob(@Context HttpServletRequest req,
+ @QueryParam("blobUri") String blobUri) {
+ Response response = null;
+ try {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ setBlobInput(ctx, req, blobUri);
+ response = this.create(null, ctx);
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+
+ return response;
+ }
+
+ @GET
+ @Path("{csid}/content")
+ @Produces({"image/jpeg", "image/png", "image/tiff"})
+ public InputStream getPicture(
+ @PathParam("csid") String csid) {
+ InputStream result = null;
+ result = getBlobContent(csid, BlobInput.DERIVATIVE_ORIGINAL_VALUE);
+ return result;
+ }
+
+ @GET
+ @Path("{csid}/derivatives/{derivative_term}/content")
+ @Produces({"image/jpeg", "image/png", "image/tiff"})
+ public InputStream getDerivativeContent(
+ @PathParam("csid") String csid,
+ @PathParam("derivative_term") String derivative_term) {
+ InputStream result = null;
+ result = getBlobContent(csid, derivative_term);
+ return result;
}
}
*/
package org.collectionspace.services.blob.nuxeo;
+import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
-import org.collectionspace.services.BlobJAXBSchema;
-import org.collectionspace.services.common.DocHandlerBase;
-import org.collectionspace.services.blob.BlobCommon;
-import org.collectionspace.services.blob.BlobCommonList;
-import org.collectionspace.services.blob.BlobCommonList.BlobListItem;
import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.jaxb.BlobJAXBSchema;
+
+import org.collectionspace.services.common.blob.BlobInput;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils;
+import org.collectionspace.services.common.DocHandlerBase;
+
+import org.collectionspace.services.blob.BlobsCommonList;
+import org.collectionspace.services.blob.BlobsCommon;
+import org.collectionspace.services.blob.BlobsCommonList.BlobListItem;
+
+import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+
import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
+import org.nuxeo.ecm.core.api.ClientException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * The Class BlobDocumentModelHandler.
+ */
public class BlobDocumentModelHandler
- extends DocHandlerBase<BlobCommon, AbstractCommonList> {
-
- public final String getNuxeoSchemaName(){
- return "blob";
- }
-
- public String getSummaryFields(AbstractCommonList commonList){
- return "name|mimeType|encoding|length|uri|csid";
- }
-
- public AbstractCommonList createAbstractCommonListImpl(){
- return new BlobCommonList();
- }
-
- public List createItemsList(AbstractCommonList commonList){
- List list = ((BlobCommonList)commonList).getBlobListItem();
- return list;
- }
-
- public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception {
- BlobListItem item = new BlobListItem();
- item.setEncoding((String) docModel.getProperty(label, BlobJAXBSchema.encoding));
- item.setMimeType((String) docModel.getProperty(label, BlobJAXBSchema.mimeType));
- //String theData = (String) docModel.getProperty(label, BlobJAXBSchema.data);
- item.setName((String) docModel.getProperty(label, BlobJAXBSchema.name));
- item.setLength((String) docModel.getProperty(label, BlobJAXBSchema.length));
- item.setUri(getServiceContextPath() + id);
- item.setCsid(id);
- return item;
- }
+extends DocHandlerBase<BlobsCommon, AbstractCommonList> {
+
+ /** The logger. */
+ private final Logger logger = LoggerFactory.getLogger(BlobDocumentModelHandler.class);
+
+ public final String getNuxeoSchemaName(){
+ return "blobs";
+ }
+
+ public String getSummaryFields(AbstractCommonList commonList){
+ return "name|mimeType|encoding|length|uri|csid";
+ }
+
+ public AbstractCommonList createAbstractCommonListImpl(){
+ return new BlobsCommonList();
+ }
+
+ public List createItemsList(AbstractCommonList commonList){
+ List list = ((BlobsCommonList)commonList).getBlobListItem();
+ return list;
+ }
+
+ public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception {
+ BlobListItem item = new BlobListItem();
+ item.setEncoding((String)
+ docModel.getProperty(label, BlobJAXBSchema.encoding));
+ item.setMimeType((String)
+ docModel.getProperty(label, BlobJAXBSchema.mimeType));
+ //String theData = (String)
+ docModel.getProperty(label, BlobJAXBSchema.data);
+ item.setName((String)
+ docModel.getProperty(label, BlobJAXBSchema.name));
+ item.setLength((String)
+ docModel.getProperty(label, BlobJAXBSchema.length));
+ item.setUri(getServiceContextPath() + id);
+ item.setCsid(id);
+ return item;
+ }
+
+ private BlobsCommon getCommonPartProperties(DocumentModel docModel) throws Exception {
+ String label = getServiceContext().getCommonPartLabel();
+ BlobsCommon result = new BlobsCommon();
+
+ result.setData((String)
+ docModel.getProperty(label, BlobJAXBSchema.data));
+ result.setDigest((String)
+ docModel.getProperty(label, BlobJAXBSchema.digest));
+ result.setEncoding((String)
+ docModel.getProperty(label, BlobJAXBSchema.encoding));
+ result.setLength((String)
+ docModel.getProperty(label, BlobJAXBSchema.length));
+ result.setMimeType((String)
+ docModel.getProperty(label, BlobJAXBSchema.mimeType));
+ result.setName((String)
+ docModel.getProperty(label, BlobJAXBSchema.name));
+ result.setRepositoryId((String)
+ docModel.getProperty(label, BlobJAXBSchema.repositoryId));
+ result.setUri(getServiceContextPath() + docModel.getName() + "/content");
+
+ return result;
+ }
+
+ private void setCommonPartProperties(DocumentModel documentModel,
+ BlobsCommon blobsCommon) throws ClientException {
+ String label = getServiceContext().getCommonPartLabel();
+ documentModel.setProperty(label, BlobJAXBSchema.data, blobsCommon.getData());
+ documentModel.setProperty(label, BlobJAXBSchema.digest, blobsCommon.getDigest());
+ documentModel.setProperty(label, BlobJAXBSchema.encoding, blobsCommon.getEncoding());
+ documentModel.setProperty(label, BlobJAXBSchema.length, blobsCommon.getLength());
+ documentModel.setProperty(label, BlobJAXBSchema.mimeType, blobsCommon.getMimeType());
+ documentModel.setProperty(label, BlobJAXBSchema.name, blobsCommon.getName());
+ documentModel.setProperty(label, BlobJAXBSchema.uri, blobsCommon.getUri());
+ documentModel.setProperty(label, BlobJAXBSchema.repositoryId, blobsCommon.getRepositoryId());
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractAllParts(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc)
+ throws Exception {
+ ServiceContext ctx = this.getServiceContext();
+ DocumentModel docModel = wrapDoc.getWrappedObject();
+ //
+ // Setup of the content URL's
+ //
+ BlobsCommon blobsCommon = this.getCommonPartProperties(docModel);
+ String derivativeTerm = (String)ctx.getProperty(BlobInput.DERIVATIVE_TERM_KEY);
+ if (derivativeTerm != null && !derivativeTerm.equalsIgnoreCase(BlobInput.DERIVATIVE_ORIGINAL_VALUE)) {
+ blobsCommon.setUri(getServiceContextPath() + docModel.getName() + "/derivatives/" +
+ derivativeTerm + "/content");
+ }
+ blobsCommon.setRepositoryId(null); //hide the repository id from the GET results since it is private
+ this.setCommonPartProperties(docModel, blobsCommon);
+
+ super.extractAllParts(wrapDoc);
+ //
+ // If the derivativeTerm is set then we need to get the blob stream
+ //
+ if (derivativeTerm != null) {
+ RepositoryInstance repoSession = this.getRepositorySession();
+ InputStream blobStream = NuxeoImageUtils.getPicture(ctx, repoSession, blobsCommon.getRepositoryId(), derivativeTerm);
+ ctx.setProperty(BlobInput.DERIVATIVE_CONTENT_KEY, blobStream);
+ }
+ }
+
+ @Override
+ public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
+ ServiceContext ctx = this.getServiceContext();
+ BlobInput blobInput = (BlobInput)ctx.getProperty(BlobInput.class.getName());
+ if (blobInput == null) {
+ super.fillAllParts(wrapDoc, action);
+ } else {
+ //
+ // If blobInput is set then we just received a multipart/form-data file post
+ //
+ DocumentModel documentModel = wrapDoc.getWrappedObject();
+ RepositoryInstance repoSession = this.getRepositorySession();
+ BlobsCommon blobsCommon = NuxeoImageUtils.createPicture(ctx, repoSession, blobInput);
+ this.setCommonPartProperties(documentModel, blobsCommon);
+ }
+ }
}