From 5087c7035020df16e36ab1344efcfb2010b1cb5f Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Thu, 9 Dec 2010 08:52:24 +0000 Subject: [PATCH] CSPACE-3245: Additional functionality to the blob service for the v1.2 sprint. --- .../services/blob/BlobResource.java | 80 +++++++++++- .../blob/nuxeo/BlobDocumentModelHandler.java | 54 +++++--- .../CollectionObjectResource.java | 101 --------------- .../services/common/ResourceBase.java | 24 ++-- .../services/common/blob/BlobInput.java | 9 +- .../common/imaging/nuxeo/NuxeoImageUtils.java | 116 +++++++++++++----- 6 files changed, 215 insertions(+), 169 deletions(-) diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java index 8c2001d83..56fd5187d 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java @@ -30,6 +30,7 @@ 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.common.document.DocumentHandler; import org.collectionspace.services.blob.BlobsCommon; import org.collectionspace.services.blob.BlobsCommonList; @@ -38,6 +39,7 @@ 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.collectionspace.services.jaxb.AbstractCommonList; import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import javax.servlet.http.HttpServletRequest; @@ -79,7 +81,9 @@ public class BlobResource extends ResourceBase { return BlobsCommon.class; } - public BlobsCommonList getBlobList(MultivaluedMap queryParams) { + //FIXME: Is this method used/needed? + @Deprecated + private BlobsCommonList getBlobList(MultivaluedMap queryParams) { return (BlobsCommonList)getList(queryParams); } @@ -88,21 +92,37 @@ public class BlobResource extends ResourceBase { return (BlobsCommonList) getList(csidList); } + @Deprecated protected BlobsCommonList search(MultivaluedMap queryParams,String keywords) { return (BlobsCommonList) super.search(queryParams, keywords); } + private BlobsCommonList getDerivativeList(String csid) throws Exception { + BlobsCommonList result = null; + + ServiceContext ctx = createServiceContext(); + ctx.setProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY, Boolean.TRUE); + MultipartOutput response = this.get(csid, ctx); + if (logger.isDebugEnabled() == true) { + logger.debug(response.toString()); + } + result = (BlobsCommonList)ctx.getProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY); + + return result; + } + private InputStream getBlobContent(String csid, String derivativeTerm) throws WebApplicationException { InputStream result = null; try { ServiceContext ctx = createServiceContext(); - ctx.setProperty(BlobInput.DERIVATIVE_TERM_KEY, derivativeTerm); + ctx.setProperty(BlobInput.BLOB_DERIVATIVE_TERM_KEY, derivativeTerm); + ctx.setProperty(BlobInput.BLOB_CONTENT_KEY, Boolean.TRUE); MultipartOutput response = this.get(csid, ctx); if (logger.isDebugEnabled() == true) { logger.debug(response.toString()); } - result = (InputStream)ctx.getProperty(BlobInput.DERIVATIVE_CONTENT_KEY); + result = (InputStream)ctx.getProperty(BlobInput.BLOB_CONTENT_KEY); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.CREATE_FAILED); } @@ -146,10 +166,10 @@ public class BlobResource extends ResourceBase { @GET @Path("{csid}/content") @Produces({"image/jpeg", "image/png", "image/tiff"}) - public InputStream getPicture( + public InputStream getBlobContent( @PathParam("csid") String csid) { InputStream result = null; - result = getBlobContent(csid, BlobInput.DERIVATIVE_ORIGINAL_VALUE); + result = getBlobContent(csid, null /*derivative term*/); return result; } @@ -160,7 +180,55 @@ public class BlobResource extends ResourceBase { @PathParam("csid") String csid, @PathParam("derivative_term") String derivative_term) { InputStream result = null; - result = getBlobContent(csid, derivative_term); + result = getBlobContent(csid, derivative_term); + + return result; + } + + @GET + @Path("{csid}/derivatives/{derivative_term}") + public MultipartOutput getDerivative(@PathParam("csid") String csid, + @PathParam("derivative_term") String derivative_term) { + MultipartOutput result = null; + + ensureCSID(csid, READ); + try { + ServiceContext ctx = createServiceContext(); + ctx.setProperty(BlobInput.BLOB_DERIVATIVE_TERM_KEY, derivative_term); + result = get(csid, ctx); + if (result == null) { + Response response = Response.status(Response.Status.NOT_FOUND).entity( + ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build(); + throw new WebApplicationException(response); + } + } catch (Exception e) { + throw bigReThrow(e, ServiceMessages.READ_FAILED, csid); + } + + return result; + } + + @GET + @Path("{csid}/derivatives") + @Produces("application/xml") + public BlobsCommonList getDerivatives( + @PathParam("csid") String csid) { + BlobsCommonList result = null; + + ensureCSID(csid, READ); + try { + ServiceContext ctx = createServiceContext(); + ctx.setProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY, true); + result = this.getDerivativeList(csid); + if (result == null) { + Response response = Response.status(Response.Status.NOT_FOUND).entity( + ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build(); + throw new WebApplicationException(response); + } + } catch (Exception e) { + throw bigReThrow(e, ServiceMessages.READ_FAILED, csid); + } + return result; } diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java index f3b250a66..13f1498a5 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java @@ -31,6 +31,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.jaxb.BlobJAXBSchema; import org.collectionspace.services.common.blob.BlobInput; +import org.collectionspace.services.common.blob.BlobOutput; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.document.DocumentHandler.Action; @@ -78,6 +79,11 @@ extends DocHandlerBase { List list = ((BlobsCommonList)commonList).getBlobListItem(); return list; } + + private String getDerivativePathBase(DocumentModel docModel) { + return getServiceContextPath() + docModel.getName() + "/" + + BlobInput.URI_DERIVATIVES_PATH + "/"; + } public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception { BlobListItem item = new BlobListItem(); @@ -114,7 +120,8 @@ extends DocHandlerBase { docModel.getProperty(label, BlobJAXBSchema.name)); result.setRepositoryId((String) docModel.getProperty(label, BlobJAXBSchema.repositoryId)); - result.setUri(getServiceContextPath() + docModel.getName() + "/content"); + result.setUri(getServiceContextPath() + docModel.getName() + "/" + + BlobInput.URI_CONTENT_PATH); return result; } @@ -139,28 +146,37 @@ extends DocHandlerBase { public void extractAllParts(DocumentWrapper wrapDoc) throws Exception { ServiceContext ctx = this.getServiceContext(); + RepositoryInstance repoSession = this.getRepositorySession(); 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); + BlobsCommon blobsCommon = this.getCommonPartProperties(docModel); + String blobRepositoryId = blobsCommon.getRepositoryId(); //cache the value to pass to the blob retriever - super.extractAllParts(wrapDoc); - // - // If the derivativeTerm is set then we need to get the blob stream - // + if (ctx.getProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY) != null) { + BlobsCommonList blobsCommonList = NuxeoImageUtils.getBlobDerivatives( + repoSession, blobRepositoryId, getDerivativePathBase(docModel)); + ctx.setProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY, blobsCommonList); + return; //FIXME: Don't like this exit point. Perhaps derivatives should be a sub-resource? + } + + String derivativeTerm = (String)ctx.getProperty(BlobInput.BLOB_DERIVATIVE_TERM_KEY); + Boolean getContentFlag = ctx.getProperty(BlobInput.BLOB_CONTENT_KEY) != null ? true : false; + BlobOutput blobOutput = NuxeoImageUtils.getBlobOutput(ctx, repoSession, + blobRepositoryId, derivativeTerm, getContentFlag); + if (getContentFlag == true) { + ctx.setProperty(BlobInput.BLOB_CONTENT_KEY, blobOutput.getBlobInputStream()); + } + if (derivativeTerm != null) { - RepositoryInstance repoSession = this.getRepositorySession(); - InputStream blobStream = NuxeoImageUtils.getPicture(ctx, repoSession, blobsCommon.getRepositoryId(), derivativeTerm); - ctx.setProperty(BlobInput.DERIVATIVE_CONTENT_KEY, blobStream); + // reset 'blobsCommon' if we have a derivative request + blobsCommon = blobOutput.getBlobsCommon(); + blobsCommon.setUri(getDerivativePathBase(docModel) + + derivativeTerm + "/" + BlobInput.URI_CONTENT_PATH); } + + blobsCommon.setRepositoryId(null); //hide the repository id from the GET results payload since it is private + this.setCommonPartProperties(docModel, blobsCommon); + // finish extracting the other parts by calling the parent + super.extractAllParts(wrapDoc); } @Override diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java index 2847aa9f1..3377d479a 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java @@ -514,107 +514,6 @@ public class CollectionObjectResource return result; } - - @GET - @Path("{csid}/getpicture/{blobId}") - @Produces({"image/jpeg", "image/png", "image/tiff"}) - public InputStream getPicture( - @PathParam("csid") String csid, - @PathParam("blobId") String blobId) { - InputStream result = null; - RepositoryInstance repoSession = null; - try { - repoSession = ServiceMain.getInstance().getNuxeoConnector().getRepositorySession(); - ServiceContext ctx = createServiceContext(); - result = NuxeoImageUtils.getPicture(ctx, repoSession, blobId, null); - } catch (Exception e) { - logger.error("Could not get image blob: " + blobId, e); - } finally { - try { - ServiceMain.getInstance().getNuxeoConnector().releaseRepositorySession(repoSession); - } catch (Exception e) { - logger.error("Could not release Nuxeo repository session", e); - } - } - - if (result == null) { - Response response = Response.status( - Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed.").type("text/plain").build(); - throw new WebApplicationException(response); - } - - return result; - } - - @GET - @Path("{csid}/getpicture/{blobId}/{derivativeTerm}") - @Produces({"image/jpeg", "image/png", "image/tiff"}) - public InputStream getPicture( - @PathParam("csid") String csid, - @PathParam("blobId") String blobId, - @PathParam("derivativeTerm") String derivativeTerm) { - InputStream result = null; - RepositoryInstance repoSession = null; - try { - repoSession = ServiceMain.getInstance().getNuxeoConnector().getRepositorySession(); - ServiceContext ctx = createServiceContext(); - result = NuxeoImageUtils.getPicture(ctx, repoSession, blobId, derivativeTerm); - } catch (Exception e) { - logger.error("Could not get image blob: " + blobId, e); - } finally { - try { - ServiceMain.getInstance().getNuxeoConnector().releaseRepositorySession(repoSession); - } catch (Exception e) { - logger.error("Could not release Nuxeo repository session", e); - } - } - - if (result == null) { - Response response = Response.status( - Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed.").type("text/plain").build(); - throw new WebApplicationException(response); - } - - return result; - } - - @POST - @Path("{csid}/postpicture") - @Consumes("multipart/form-data") - @Produces("application/xml") - public String createPictureDocument(@Context HttpServletRequest req, - @PathParam("csid") String csid, - @QueryParam("blobUri") String blobUri) { - String result = null; - - RepositoryInstance repoSession = null; - try { - repoSession = ServiceMain.getInstance().getNuxeoConnector().getRepositorySession(); - ServiceContext ctx = createServiceContext(); - File tmpFile = FileUtils.createTmpFile(req); - BlobInput blobInput = new BlobInput(tmpFile, blobUri); - BlobsCommon blobCommon = NuxeoImageUtils.createPicture(ctx, repoSession, blobInput); - if (blobCommon != null) { - result = blobCommon.getRepositoryId(); - } - } catch (Exception e) { - logger.error("Could not create the new image file", e); - } finally { - try { - ServiceMain.getInstance().getNuxeoConnector().releaseRepositorySession(repoSession); - } catch (Exception e) { - logger.error("Could not release Nuxeo repository session", e); - } - } - - if (result == null) { - Response response = Response.status( - Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed.").type("text/plain").build(); - throw new WebApplicationException(response); - } - - return result; - } /** * This method is deprecated. Use kwSearchCollectionObjects() method instead. diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index 35e569b90..b3222b2bb 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@ -218,17 +218,17 @@ extends AbstractMultiPartCollectionSpaceResourceImpl { //======================= GET without csid. List, search, etc. ===================================== - @GET - @Produces("application/xml") - public AbstractCommonList getList (@Context UriInfo ui, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { - MultivaluedMap queryParams = ui.getQueryParameters(); - if (keywords != null) { - return search(queryParams, keywords); - } else { - return getList(queryParams); - } - } + @GET + @Produces("application/xml") + public AbstractCommonList getList(@Context UriInfo ui, + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { + MultivaluedMap queryParams = ui.getQueryParameters(); + if (keywords != null) { + return search(queryParams, keywords); + } else { + return getList(queryParams); + } + } protected AbstractCommonList getList(MultivaluedMap queryParams) { try { @@ -241,7 +241,6 @@ extends AbstractMultiPartCollectionSpaceResourceImpl { } } - protected AbstractCommonList search(MultivaluedMap queryParams, String keywords) { try { ServiceContext ctx = createServiceContext(queryParams); @@ -262,6 +261,7 @@ extends AbstractMultiPartCollectionSpaceResourceImpl { } } + //FIXME: REM - This should not be @Deprecated since we may want to implement this -it has been on the wish list. @Deprecated public AbstractCommonList getList(List csidList) { try { diff --git a/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java b/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java index b103eeda9..c76c06b84 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java +++ b/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java @@ -7,9 +7,12 @@ public class BlobInput { private File blobFile; private String blobUri; - public static final String DERIVATIVE_TERM_KEY = "Derivative"; - public static final String DERIVATIVE_ORIGINAL_VALUE = "Original"; - public static final String DERIVATIVE_CONTENT_KEY = "Derivative_Content_Stream"; + public static final String URI_CONTENT_PATH = "content"; + public static final String URI_DERIVATIVES_PATH = "derivatives"; + + public static final String BLOB_DERIVATIVE_TERM_KEY = "derivative"; + public static final String BLOB_DERIVATIVE_LIST_KEY = "derivative.list"; + public static final String BLOB_CONTENT_KEY = "derivative.content.stream"; public BlobInput(File blobFile, String blobUri) { this.blobFile = blobFile; diff --git a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java index ddb776e3b..91c56e477 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java @@ -105,6 +105,9 @@ import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.FileUtils; import org.collectionspace.services.blob.BlobsCommon; +import org.collectionspace.services.blob.BlobsCommonList; +import org.collectionspace.services.blob.BlobsCommonList.BlobListItem; +import org.collectionspace.services.common.blob.BlobOutput; // TODO: Auto-generated Javadoc /** @@ -113,6 +116,23 @@ import org.collectionspace.services.blob.BlobsCommon; public class NuxeoImageUtils { /** The Constant logger. */ private static final Logger logger = LoggerFactory.getLogger(NuxeoImageUtils.class); + + /* + * FIXME: REM - These constants should be coming from configuration and NOT hard coded. + */ + public static final String DERIVATIVE_ORIGINAL = "Original"; + public static final String DERIVATIVE_ORIGINAL_TAG = DERIVATIVE_ORIGINAL + "_"; + + public static final String DERIVATIVE_ORIGINAL_JPEG = "OriginalJpeg"; + public static final String DERIVATIVE_ORIGINAL_JPEG_TAG = DERIVATIVE_ORIGINAL_JPEG + "_"; + + public static final String DERIVATIVE_MEDIUM = "Medium"; + public static final String DERIVATIVE_MEDIUM_TAG = DERIVATIVE_MEDIUM + "_"; + + public static final String DERIVATIVE_THUMBNAIL = "Thumbnail"; + public static final String DERIVATIVE_THUMBNAIL_TAG = DERIVATIVE_THUMBNAIL + "_"; + + public static final String DERIVATIVE_UNKNOWN = "_UNKNOWN_DERIVATIVE_NAME_"; // static DefaultBinaryManager binaryManager = new DefaultBinaryManager(); //can we get this from Nuxeo? i.e., Framework.getService(BinaryManger.class) @@ -139,7 +159,55 @@ public class NuxeoImageUtils { //empty method } - static private BlobsCommon createBlobCommon(DocumentModel documentModel, Blob nuxeoBlob) { + //FIXME: This needs to be configuration-bases and NOT hard coded! + static private String getDerivativeUri(String uri, String derivativeName) { + String result = DERIVATIVE_UNKNOWN; + + if (derivativeName.startsWith(DERIVATIVE_ORIGINAL_TAG) == true) { + result = DERIVATIVE_ORIGINAL; + } else if (derivativeName.startsWith(DERIVATIVE_ORIGINAL_JPEG_TAG) == true) { + result = DERIVATIVE_ORIGINAL_JPEG; + } else if (derivativeName.startsWith(DERIVATIVE_MEDIUM_TAG) == true) { + result = DERIVATIVE_MEDIUM; + } else if (derivativeName.startsWith(DERIVATIVE_THUMBNAIL_TAG) == true) { + result = DERIVATIVE_THUMBNAIL; + } + + return uri + result + "/" + BlobInput.URI_CONTENT_PATH; + } + + static private BlobListItem createBlobListItem(Blob blob, String uri) { + BlobListItem result = new BlobListItem(); + + result.setEncoding(blob.getEncoding()); + result.setLength(Long.toString(blob.getLength())); + result.setMimeType(blob.getMimeType()); + result.setName(blob.getFilename()); + result.setUri(getDerivativeUri(uri, blob.getFilename())); + + return result; + } + + static public BlobsCommonList getBlobDerivatives(RepositoryInstance repoSession, + String repositoryId, + String uri) throws Exception { + BlobsCommonList result = new BlobsCommonList(); + + IdRef documentRef = new IdRef(repositoryId); + DocumentModel documentModel = repoSession.getDocument(documentRef); + DocumentBlobHolder docBlobHolder = (DocumentBlobHolder)documentModel.getAdapter(BlobHolder.class); + List docBlobs = docBlobHolder.getBlobs(); + List blobListItems = result.getBlobListItem(); + BlobListItem blobListItem = null; + for (Blob blob : docBlobs) { + blobListItem = createBlobListItem(blob, uri); + blobListItems.add(blobListItem); + } + + return result; + } + + static private BlobsCommon createBlobsCommon(DocumentModel documentModel, Blob nuxeoBlob) { BlobsCommon result = new BlobsCommon(); if (documentModel != null) { result.setMimeType(nuxeoBlob.getMimeType()); @@ -153,8 +221,7 @@ public class NuxeoImageUtils { static private File getBlobFile(RepositoryInstance ri, DocumentModel documentModel, Blob blob) { DefaultBinaryManager binaryManager = null; RepositoryDescriptor descriptor = null; - - + try { ServiceManager sm = (ServiceManager) Framework.getService(ServiceManager.class); ServiceDescriptor[] sd = sm.getServiceDescriptors(); @@ -485,7 +552,7 @@ public class NuxeoImageUtils { String digestAlgorithm = getFileManagerService().getDigestAlgorithm(); //Need some way on initializing the FileManager with a call. DocumentModel documentModel = getFileManagerService().createDocumentFromBlob(nuxeoSession, fileBlob, blobLocation.getPathAsString(), true, fileName); - result = createBlobCommon(documentModel, fileBlob); + result = createBlobsCommon(documentModel, fileBlob); } catch (Exception e) { result = null; logger.error("Could not create new image blob", e); @@ -493,22 +560,7 @@ public class NuxeoImageUtils { return result; } - - - /** - * Gets the picture. - * - * @param ctx the ctx - * @param repoSession the repo session - * @param blobId the blob id - * @param derivativeTerm the derivative term - * @return the picture - */ - public static InputStream getPicture(ServiceContext ctx, RepositoryInstance repoSession, - String blobId, String derivativeTerm) { - return getImage(repoSession, blobId, derivativeTerm); - } - + /** * Gets the image. * @@ -517,9 +569,12 @@ public class NuxeoImageUtils { * @param derivativeTerm the derivative term * @return the image */ - static public InputStream getImage(RepositoryInstance repoSession, - String repositoryId, String derivativeTerm) { - InputStream result = null; + static public BlobOutput getBlobOutput(ServiceContext ctx, + RepositoryInstance repoSession, + String repositoryId, + String derivativeTerm, + Boolean getContentFlag) { + BlobOutput result = new BlobOutput(); try { IdRef documentRef = new IdRef(repositoryId); @@ -540,12 +595,17 @@ public class NuxeoImageUtils { } else { pictureBlob = pictureBlobHolder.getBlob(); } + // + // Create the result instance + // + BlobsCommon blobsCommon = createBlobsCommon(documentModel, pictureBlob); + result.setBlobsCommon(blobsCommon); // the blob metadata + if (getContentFlag == true) { + InputStream remoteStream = pictureBlob.getStream(); + BufferedInputStream bufferedInputStream = new BufferedInputStream(remoteStream); + result.setBlobInputStream(bufferedInputStream); // the blob stream + } - InputStream remoteStream = pictureBlob.getStream(); - BufferedInputStream bufferedInputStream = new BufferedInputStream(remoteStream); - result = bufferedInputStream; -// File tmpFile = FileUtils.createTmpFile(remoteStream); -// result = new FileInputStream(tmpFile); } catch (Exception e) { logger.error(e.getMessage(), e); } -- 2.47.3