import org.collectionspace.services.vocabulary.VocabularyResource;
import org.collectionspace.services.organization.OrgAuthorityResource;
import org.collectionspace.services.person.PersonAuthorityResource;
-import org.collectionspace.services.article.ArticleResource;
//import org.collectionspace.services.query.QueryResource;
import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.common.ResourceMapHolder;
import org.collectionspace.services.common.ResourceMapImpl;
+import org.collectionspace.services.common.article.ArticleResource;
import org.collectionspace.services.common.relation.RelationResource;
import org.collectionspace.services.common.security.SecurityInterceptor;
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.article.client</artifactId>
<name>services.article.client</name>
<artifactId>org.collectionspace.services.jaxb</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.common</artifactId>
- <optional>true</optional>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.client</artifactId>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
</dependency>
</dependencies>
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+ public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
/* (non-Javadoc)
* @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
<xs:complexType>
<xs:sequence>
<xs:element name="articleNumber" type="xs:string" /> <!-- An ID for the article (different than the CSID) -->
- <xs:element name="articleContentUrl" type="xs:string" /> <!-- The URL of the article's content -->
+ <xs:element name="articleContentCsid" type="xs:string" /> <!-- The URL of the article's content -->
<xs:element name="articleJobId" type="xs:string" /> <!-- The asynch job ID -if any -->
<xs:element name="articleSource" type="xs:string" /> <!-- The name of the service/resource that was used to create the article. -->
<xs:element name="articlePublisher" type="xs:string" /> <!-- The user who published the article -->
<artifactId>org.collectionspace.services.blob.client</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.article.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- External dependencies -->
<dependency>
*/
package org.collectionspace.services.blob;
+import org.collectionspace.services.article.ArticlesCommon;
+import org.collectionspace.services.client.ArticleClient;
import org.collectionspace.services.client.BlobClient;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.FileUtils;
import org.collectionspace.services.common.ResourceBase;
import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.common.article.ArticleResource;
+import org.collectionspace.services.common.article.ArticleUtil;
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.imaging.nuxeo.NuxeoBlobUtils;
import org.collectionspace.services.nuxeo.client.java.CommonList;
+import org.collectionspace.services.workflow.WorkflowCommon;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentRef;
+import org.nuxeo.ecm.core.api.IdRef;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
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;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.UriInfo;
+
+import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
//FIXME: REM - We should not have Nuxeo dependencies in our resource classes.
return result;
}
- private InputStream getBlobContent(String csid, String derivativeTerm, StringBuffer outMimeType) throws WebApplicationException {
+ private InputStream getBlobContent(ServiceContext ctx,
+ String csid,
+ String derivativeTerm,
+ StringBuffer outMimeType) throws WebApplicationException {
InputStream result = null;
try {
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
BlobInput blobInput = BlobUtil.getBlobInput(ctx);
blobInput.setDerivativeTerm(derivativeTerm);
blobInput.setContentRequested(true);
@Path("{csid}/content")
public Response getBlobContent( @PathParam("csid") String csid) {
Response result = null;
-
- StringBuffer mimeType = new StringBuffer();
- InputStream contentStream = getBlobContent(csid, null /*derivative term*/, mimeType /*will get set*/);
- Response.ResponseBuilder responseBuilder = Response.ok(contentStream, mimeType.toString());
-
- result = responseBuilder.build();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
+
+ try {
+ ctx = createServiceContext();
+
+ StringBuffer mimeType = new StringBuffer();
+ InputStream contentStream = getBlobContent(ctx, csid, null /*derivative term*/, mimeType /*will get set*/);
+
+ Response.ResponseBuilder responseBuilder = Response.ok(contentStream, mimeType.toString());
+ result = responseBuilder.build();
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+
return result;
}
+
+ /*
+ * Publish the blob content.
+ */
+ @GET
+ @Path("{csid}/content/publish")
+ public Response publishBlobContent(
+ @Context ResourceMap resourceMap,
+ @Context UriInfo uriInfo,
+ @PathParam("csid") String csid) {
+ Response result = null;
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
+
+ try {
+ ctx = createServiceContext();
+ StringBuffer mimeType = new StringBuffer();
+ InputStream contentStream = getBlobContent(ctx, csid, null /*derivative term*/, mimeType /*will get set*/);
+ result = ArticleUtil.publishToRepository(resourceMap, uriInfo, this.getRepositoryClient(ctx), ctx, contentStream, csid);
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.PUT_FAILED);
+ }
+
+ return result;
+ }
@GET
@Path("{csid}/derivatives/{derivativeTerm}/content")
@PathParam("csid") String csid,
@PathParam("derivativeTerm") String derivativeTerm) {
Response result = null;
+ ServiceContext ctx = null;
- StringBuffer mimeType = new StringBuffer();
- InputStream contentStream = getBlobContent(csid, derivativeTerm, mimeType);
- Response.ResponseBuilder responseBuilder = Response.ok(contentStream, mimeType.toString());
-
- result = responseBuilder.build();
- return result;
+ try {
+ ctx = createServiceContext();
+
+ StringBuffer mimeType = new StringBuffer();
+ InputStream contentStream = getBlobContent(ctx, csid, derivativeTerm, mimeType);
+ Response.ResponseBuilder responseBuilder = Response.ok(contentStream, mimeType.toString());
+
+ result = responseBuilder.build();
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+
+ return result;
}
@GET
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentUtils;
import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils;
+import org.collectionspace.services.common.imaging.nuxeo.NuxeoBlobUtils;
import org.collectionspace.services.config.service.ListResultField;
import org.collectionspace.services.config.service.ObjectPartType;
import org.collectionspace.services.jaxb.BlobJAXBSchema;
//
if (blobInput.isDerivativeListRequested() == true) {
List<ListResultField> resultsFields = getListItemsArray();
- CommonList blobsCommonList = NuxeoImageUtils.getBlobDerivatives( //FIXME: REM - Need to replace "NuxeoImageUtils" with something more general like "BlobUtils" since we may support other blob types.
+ CommonList blobsCommonList = NuxeoBlobUtils.getBlobDerivatives( //FIXME: REM - Need to replace "NuxeoImageUtils" with something more general like "BlobUtils" since we may support other blob types.
repoSession, blobRepositoryId, resultsFields, getDerivativePathBase(docModel));
// ctx.setProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY, blobsCommonList);
blobInput.setDerivativeList(blobsCommonList);
//
if (derivativeTerm != null || getContentFlag == true) {
StringBuffer mimeTypeBuffer = new StringBuffer();
- BlobOutput blobOutput = NuxeoImageUtils.getBlobOutput(ctx, repoSession,
+ BlobOutput blobOutput = NuxeoBlobUtils.getBlobOutput(ctx, repoSession,
blobRepositoryId, derivativeTerm, getContentFlag, mimeTypeBuffer);
if (getContentFlag == true) {
if (blobOutput != null) {
blobInput.setContentStream(blobOutput.getBlobInputStream());
} else {
// If we can't find the blob's content, we'll return a "missing document" image
- blobInput.setContentStream(NuxeoImageUtils.getResource(NuxeoImageUtils.DOCUMENT_MISSING_PLACEHOLDER_IMAGE));
- mimeTypeBuffer.append(NuxeoImageUtils.MIME_JPEG);
+ blobInput.setContentStream(NuxeoBlobUtils.getResource(NuxeoBlobUtils.DOCUMENT_MISSING_PLACEHOLDER_IMAGE));
+ mimeTypeBuffer.append(NuxeoBlobUtils.MIME_JPEG);
}
}
this.setCommonPartProperties(docModel, blobsCommon);
// finish extracting the other parts by calling the parent
} else {
- extractMetadata(blobRepositoryId, NuxeoImageUtils.SCHEMA_IMAGE_METADATA);
- extractMetadata(blobRepositoryId, NuxeoImageUtils.SCHEMA_IPTC);
+ extractMetadata(blobRepositoryId, NuxeoBlobUtils.SCHEMA_IMAGE_METADATA);
+ extractMetadata(blobRepositoryId, NuxeoBlobUtils.SCHEMA_IPTC);
}
//
DocumentModel documentModel = wrapDoc.getWrappedObject();
RepositoryInstance repoSession = this.getRepositorySession();
- BlobsCommon blobsCommon = NuxeoImageUtils.createBlobInRepository(ctx, repoSession, blobInput, purgeOriginal);
+ BlobsCommon blobsCommon = NuxeoBlobUtils.createBlobInRepository(ctx, repoSession, blobInput, purgeOriginal);
blobInput.setBlobCsid(documentModel.getName()); //Assumption here is that the documentModel "name" field is storing a CSID
PoxPayloadIn input = ctx.getInput();
import org.dom4j.DocumentException;\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
<artifactId>org.collectionspace.services.relation.client</artifactId>\r
<version>${project.version}</version>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.article.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.article.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
<!-- \r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.collectionspace.services.article;
+package org.collectionspace.services.common.article;
+import java.io.InputStream;
+
+import org.collectionspace.services.article.ArticlesCommon;
import org.collectionspace.services.client.ArticleClient;
+import org.collectionspace.services.client.PayloadOutputPart;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.ResourceBase;
+import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.common.blob.BlobOutput;
+import org.collectionspace.services.common.context.RemoteServiceContext;
+import org.collectionspace.services.common.imaging.nuxeo.NuxeoBlobUtils;
import org.jboss.resteasy.core.ResourceMethod;
import org.jboss.resteasy.spi.HttpRequest;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@Path(ArticleClient.SERVICE_PATH)
@GET
@Path("/published/{csid}")
- @Produces("text/plain")
- public byte[] getPublishedResource(
- @Context Request request,
+ public Response getPublishedResource(
+ @Context Request request,
@Context UriInfo uriInfo,
@PathParam("csid") String csid) {
- return get(request, uriInfo, csid);
+ Response result = null;
+
+ try {
+ //
+ // First, extract the ArticlesCommon instance.
+ //
+ RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(uriInfo);
+ PoxPayloadOut poxPayloadOut = get(csid, ctx);
+ ArticlesCommon articlesCommon = (ArticlesCommon)poxPayloadOut.getPart(ArticleClient.SERVICE_COMMON_PART_NAME).getBody();
+ //
+ // Get the repository blob ID and retrieve the content as a stream
+ //
+ String blobContentCsid = articlesCommon.getArticleContentCsid();
+ StringBuffer outMimeType = new StringBuffer();
+ BlobOutput blobOutput = NuxeoBlobUtils.getBlobOutput(ctx, getRepositoryClient(ctx), blobContentCsid, outMimeType);
+ InputStream contentStream = blobOutput.getBlobInputStream();
+ //
+ // Return the content stream in the response
+ //
+ Response.ResponseBuilder responseBuilder = Response.ok(contentStream, outMimeType.toString());
+ result = responseBuilder.build();
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.READ_FAILED, csid);
+ }
+
+ return result;
}
}
--- /dev/null
+package org.collectionspace.services.common.article;
+
+import java.io.InputStream;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.collectionspace.services.article.ArticlesCommon;
+import org.collectionspace.services.blob.BlobsCommon;
+import org.collectionspace.services.client.ArticleClient;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.TransactionException;
+import org.collectionspace.services.common.imaging.nuxeo.NuxeoBlobUtils;
+import org.collectionspace.services.common.repository.RepositoryClient;
+
+public class ArticleUtil {
+
+ public static Response publishToRepository(ResourceMap resourceMap,
+ UriInfo uriInfo,
+ ServiceContext parentCtx,
+ PoxPayloadOut poxPayloadOut) {
+ Response result = null;
+
+ ArticlesCommon articlesCommon = new ArticlesCommon();
+ articlesCommon.setArticlePublisher("Hello, this is a test.");
+ PoxPayloadIn input = new PoxPayloadIn(ArticleClient.SERVICE_PAYLOAD_NAME, articlesCommon,
+ ArticleClient.SERVICE_COMMON_PART_NAME);
+
+ ArticleResource articleResource = new ArticleResource();
+ result = articleResource.create(parentCtx, resourceMap, uriInfo, input.getXmlPayload());
+
+ return result;
+ }
+
+ public static Response publishToRepository(ResourceMap resourceMap,
+ UriInfo uriInfo,
+ RepositoryClient repositoryClient,
+ ServiceContext parentCtx,
+ InputStream inputStream,
+ String streamName) throws TransactionException {
+ Response result = null;
+
+ BlobsCommon blobsCommon = NuxeoBlobUtils.createBlobInRepository(parentCtx, repositoryClient, inputStream, streamName);
+
+ ArticlesCommon articlesCommon = new ArticlesCommon();
+ articlesCommon.setArticlePublisher(parentCtx.getUserId());
+ articlesCommon.setArticleContentCsid(blobsCommon.getRepositoryId());
+ PoxPayloadOut poxPayloadOut = new PoxPayloadOut(ArticleClient.SERVICE_PAYLOAD_NAME);
+ poxPayloadOut.addPart(ArticleClient.SERVICE_COMMON_PART_NAME, articlesCommon);
+
+ ArticleResource articleResource = new ArticleResource();
+ result = articleResource.create(parentCtx, resourceMap, uriInfo, poxPayloadOut.toXML());
+
+ return result;
+ }
+
+}
import org.nuxeo.ecm.core.api.blobholder.DocumentBlobHolder;\r
import org.nuxeo.ecm.core.api.impl.DocumentModelImpl;\r
import org.nuxeo.ecm.core.api.impl.blob.FileBlob;\r
+import org.nuxeo.ecm.core.api.impl.blob.InputStreamBlob;\r
import org.nuxeo.ecm.core.api.impl.blob.StreamingBlob;\r
import org.nuxeo.ecm.core.api.impl.blob.ByteArrayBlob;\r
import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
import org.collectionspace.services.common.ServiceMain;\r
import org.collectionspace.services.common.blob.BlobInput;\r
import org.collectionspace.services.common.context.ServiceContext;\r
+import org.collectionspace.services.common.document.DocumentException;\r
+import org.collectionspace.services.common.document.TransactionException;\r
+import org.collectionspace.services.common.repository.RepositoryClient;\r
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.blob.BlobsCommon;\r
import org.collectionspace.services.blob.DimensionSubGroup;\r
//import org.collectionspace.services.blob.BlobsCommonList.BlobListItem;\r
import org.collectionspace.services.jaxb.BlobJAXBSchema;\r
import org.collectionspace.services.nuxeo.client.java.CommonList;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
import org.collectionspace.services.nuxeo.extension.thumbnail.ThumbnailConstants;\r
import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
import org.collectionspace.services.common.blob.BlobOutput;\r
\r
\r
/**\r
- * The Class NuxeoImageUtils.\r
+ * The Class NuxeoBlobUtils.\r
*/\r
-public class NuxeoImageUtils {\r
+public class NuxeoBlobUtils {\r
\r
/** The Constant logger. */\r
private static final Logger logger = LoggerFactory\r
- .getLogger(NuxeoImageUtils.class);\r
+ .getLogger(NuxeoBlobUtils.class);\r
\r
public static final String DOCUMENT_PLACEHOLDER_IMAGE = "documentImage.jpg";\r
public static final String DOCUMENT_MISSING_PLACEHOLDER_IMAGE = "documentImageMissing.jpg";\r
/**\r
* Instantiates a new nuxeo image utils.\r
*/\r
- NuxeoImageUtils() {\r
+ NuxeoBlobUtils() {\r
// empty constructor\r
}\r
\r
static private boolean isImageMedia(Blob nuxeoBlob) {\r
boolean result = false;\r
\r
- String mimeType = nuxeoBlob.getMimeType().toLowerCase().trim();\r
- String[] parts = mimeType.split("/"); // split strings like "application/xml" into an array of two strings\r
- if (parts.length == 2) {\r
- for (String type : imageTypes) {\r
- if (parts[1].equalsIgnoreCase(type)) {\r
- result = true;\r
- break;\r
+ String mimeType = nuxeoBlob.getMimeType();\r
+ if (mimeType != null) {\r
+ mimeType = mimeType.toLowerCase().trim();\r
+ String[] parts = mimeType.split("/"); // split strings like "application/xml" into an array of two strings\r
+ if (parts.length == 2) {\r
+ for (String type : imageTypes) {\r
+ if (parts[1].equalsIgnoreCase(type)) {\r
+ result = true;\r
+ break;\r
+ }\r
}\r
}\r
}\r
return result;\r
}\r
\r
+ static private RepositoryInstance getRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient) {\r
+ RepositoryInstance result = null; \r
+ RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;\r
+ \r
+ try {\r
+ result = nuxeoClient.getRepositorySession(ctx);\r
+ } catch (Exception e) {\r
+ logger.error("Could not get a repository session to the Nuxeo repository", e);\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
+ static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstance repoSession) throws TransactionException {\r
+ RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;\r
+ nuxeoClient.releaseRepositorySession(ctx, repoSession);\r
+ }\r
+ \r
+ static public BlobsCommon createBlobInRepository(\r
+ ServiceContext ctx,\r
+ RepositoryClient repositoryClient,\r
+ InputStream inputStream,\r
+ String blobName) throws TransactionException {\r
+ BlobsCommon result = null;\r
+\r
+ boolean repoSessionCleanup = false;\r
+ RepositoryInstance repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();\r
+ if (repoSession == null) {\r
+ repoSession = getRepositorySession(ctx, repositoryClient);\r
+ repoSessionCleanup = true;\r
+ }\r
+ \r
+ String nuxeoWspaceId = ctx.getRepositoryWorkspaceId();\r
+ DocumentRef nuxeoWspace = new IdRef(nuxeoWspaceId);\r
+ \r
+ try {\r
+ DocumentModel blobLocation = repoSession.getDocument(nuxeoWspace);\r
+ Blob inputStreamBlob = new InputStreamBlob(inputStream);\r
+ String digestAlgorithm = getFileManagerService()\r
+ .getDigestAlgorithm(); // Only call this because we seem to need some way of initializing Nuxeo's FileManager with a call.\r
+ \r
+ logger.debug("Start --> Starting call to Nuxeo to create the blob document."); // For example, see Nuxeo's DefaultPictureAdapter class for details\r
+ DocumentModel documentModel = getFileManagerService()\r
+ .createDocumentFromBlob(repoSession, inputStreamBlob,\r
+ blobLocation.getPathAsString(), true,\r
+ blobName);\r
+ logger.debug("Stop --> Finished calling Nuxeo to create the blob document.");\r
+\r
+ result = createBlobsCommon(documentModel, inputStreamBlob); // Now create our metadata resource document\r
\r
+ } catch (Exception e) {\r
+ result = null;\r
+ logger.error("Could not create new Nuxeo blob document.", e); //FIXME: REM - This should probably be re-throwing the exception?\r
+ } finally {\r
+ if (repoSessionCleanup == true) {\r
+ releaseRepositorySession(ctx, repositoryClient, repoSession);\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
/**\r
* Creates the picture.\r
* \r
\r
return result;\r
}\r
-\r
+ \r
/**\r
* Creates the image blob.\r
* \r
return result;\r
}\r
\r
+ static public BlobOutput getBlobOutput(ServiceContext ctx,\r
+ RepositoryClient repositoryClient,\r
+ String repositoryId,\r
+ StringBuffer outMimeType) throws TransactionException {\r
+ BlobOutput result = null;\r
+ \r
+ boolean repoSessionCleanup = false;\r
+ RepositoryInstance repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();\r
+ if (repoSession == null) {\r
+ repoSession = getRepositorySession(ctx, repositoryClient);\r
+ repoSessionCleanup = true;\r
+ }\r
+ \r
+ try {\r
+ result = getBlobOutput(ctx, repoSession, repositoryId, null, true, outMimeType);\r
+ }\r
+ \r
+ finally {\r
+ if (repoSessionCleanup == true) {\r
+ releaseRepositorySession(ctx, repositoryClient, repoSession);\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
/**\r
* Gets the image.\r
* \r
//
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
-import org.apache.chemistry.opencmis.server.support.query.CmisQlExtParser_CmisBaseGrammar.boolean_factor_return;
import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService;
import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoRepository;