From: Richard Millet Date: Thu, 24 Jan 2013 21:45:27 +0000 (-0800) Subject: CSPACE-5564: Updated public access URL that gets a public item's content to conform... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=3580bec0f48450fd3ab5fd1cc335d74a418ef834;p=tmp%2Fjakarta-migration.git CSPACE-5564: Updated public access URL that gets a public item's content to conform to the convention used by both the Blob and Media services. --- diff --git a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml index fba0ae5e3..2e6b6f69a 100644 --- a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -26,12 +26,8 @@ - - - + diff --git a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml index 4515cb1f7..e633882ce 100644 --- a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml +++ b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml @@ -117,16 +117,5 @@ Resteasy /* - - - PublishedResourcesServlet - - org.collectionspace.services.common.servlet.PublishedResourcesServlet - - - - PublishedResourcesServlet - /published/* - diff --git a/services/article/3rdparty/nuxeo-platform-cs-article/src/main/resources/schemas/articles_common.xsd b/services/article/3rdparty/nuxeo-platform-cs-article/src/main/resources/schemas/articles_common.xsd index 8dc4cb416..2f288e46e 100644 --- a/services/article/3rdparty/nuxeo-platform-cs-article/src/main/resources/schemas/articles_common.xsd +++ b/services/article/3rdparty/nuxeo-platform-cs-article/src/main/resources/schemas/articles_common.xsd @@ -16,13 +16,13 @@ targetNamespace="http://collectionspace.org/article/" version="0.1"> - - - - - - - - - + + + + + + + + + diff --git a/services/article/client/src/main/java/org/collectionspace/services/client/ArticleClient.java b/services/article/client/src/main/java/org/collectionspace/services/client/ArticleClient.java index a6c68eeba..fff3669cb 100644 --- a/services/article/client/src/main/java/org/collectionspace/services/client/ArticleClient.java +++ b/services/article/client/src/main/java/org/collectionspace/services/client/ArticleClient.java @@ -30,7 +30,9 @@ public class ArticleClient extends AbstractCommonListPoxServiceClientImpl - - - - - - - - - + + + + + + + + + diff --git a/services/article/service/src/main/java/org/collectionspace/services/article/nuxeo/ArticleDocumentModelHandler.java b/services/article/service/src/main/java/org/collectionspace/services/article/nuxeo/ArticleDocumentModelHandler.java index 45f4ae48c..a6782c31c 100644 --- a/services/article/service/src/main/java/org/collectionspace/services/article/nuxeo/ArticleDocumentModelHandler.java +++ b/services/article/service/src/main/java/org/collectionspace/services/article/nuxeo/ArticleDocumentModelHandler.java @@ -23,8 +23,12 @@ */ package org.collectionspace.services.article.nuxeo; +import org.collectionspace.services.ArticlesCommonJAXBSchema; import org.collectionspace.services.article.ArticlesCommon; +import org.collectionspace.services.client.ArticleClient; +import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.nuxeo.ecm.core.api.DocumentModel; /** ArticleDocumentModelHandler * $LastChangedRevision$ @@ -32,5 +36,24 @@ import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; */ public class ArticleDocumentModelHandler extends DocHandlerBase { + + @Override + public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { + // + // Call our parent's implementation first to fill out most of the document model properties + // + super.fillAllParts(wrapDoc, action); + + // + // Since we didn't know the CSID when we created the publicly accessible URL we need to + // add it now. + // + DocumentModel documentModel = wrapDoc.getWrappedObject(); + String url = (String) documentModel.getProperty(ArticleClient.SERVICE_COMMON_PART_NAME, + ArticlesCommonJAXBSchema.ARTICLE_CONTENT_URL); + url = url.replace(ArticleClient.CSID_PATH_PARAM_VAR, documentModel.getName()); + documentModel.setProperty(ArticleClient.SERVICE_COMMON_PART_NAME, + ArticlesCommonJAXBSchema.ARTICLE_CONTENT_URL, url); + } } diff --git a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java index 19ddf315c..cf960100f 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java +++ b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java @@ -36,6 +36,7 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList; */ public interface CollectionSpaceClient> { + public final static String CSID_PATH_PARAM_VAR = "{csid}"; public final static String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core"; public final static String COLLECTIONSPACE_CORE_TENANTID = "tenantId"; diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml index 594f69c10..a79b5cc82 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml @@ -2926,9 +2926,13 @@ articleNumber - articleContentCsid - articleContentCsid + articleSource + articleSource + + articleContentUrl + articleContentUrl + diff --git a/services/common/src/main/java/org/collectionspace/services/common/article/ArticleResource.java b/services/common/src/main/java/org/collectionspace/services/common/article/ArticleResource.java index aae22da18..b61e736dd 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/article/ArticleResource.java +++ b/services/common/src/main/java/org/collectionspace/services/common/article/ArticleResource.java @@ -81,7 +81,7 @@ public class ArticleResource extends ResourceBase { } @GET - @Path("/{csid}/{tenantId}/published") + @Path("/{csid}/{tenantId}/" + ArticleClient.PUBLICITEMS_CONTENT_SUFFIX) // "content" public Response getPublishedResource( @Context Request request, @Context UriInfo uriInfo, @@ -99,7 +99,7 @@ public class ArticleResource extends ResourceBase { // // Get the repository blob ID and retrieve the content as a stream // - String blobContentCsid = articlesCommon.getArticleContentCsid(); + String blobContentCsid = articlesCommon.getArticleContentRepositoryId(); StringBuffer outMimeType = new StringBuffer(); BlobOutput blobOutput = NuxeoBlobUtils.getBlobOutput(ctx, getRepositoryClient(ctx), blobContentCsid, outMimeType); InputStream contentStream = blobOutput.getBlobInputStream(); diff --git a/services/common/src/main/java/org/collectionspace/services/common/article/ArticleUtil.java b/services/common/src/main/java/org/collectionspace/services/common/article/ArticleUtil.java index ac7b388ca..2f3a84f0e 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/article/ArticleUtil.java +++ b/services/common/src/main/java/org/collectionspace/services/common/article/ArticleUtil.java @@ -31,12 +31,20 @@ public class ArticleUtil { result = new ArticlesCommon(); // If they passed in null, we'll create a new instance } - String publishingService = parentCtx.getServiceName(); // Overrides any existing value - result.setArticleSource(publishingService); + String articleSource = result.getArticleSource(); + if (articleSource == null || articleSource.trim().isEmpty()) { + String publishingService = parentCtx.getServiceName(); // Overrides any existing value + result.setArticleSource(publishingService); + } + + String publicUrl = String.format("%s%s/%s/%s/%s", // e.g., http://{base url}/articles/{csid}/{tenant ID}/content + uriInfo.getBaseUri().toString(), // the base part of the URL + ArticleClient.SERVICE_NAME, // the base service path to the Article service + ArticleClient.CSID_PATH_PARAM_VAR, // the {csid} param part that will be filled in later in ArticleDocumentModelHandler.fillAllParts() method + parentCtx.getTenantId(), // the tenant ID part + ArticleClient.PUBLICITEMS_CONTENT_SUFFIX); // the final "content" suffix + result.setArticleContentUrl(publicUrl); - String articleContentUrl = "the public url goes here"; - result.setArticleContentUrl(articleContentUrl); - return result; } @@ -77,7 +85,7 @@ public class ArticleUtil { BlobsCommon blobsCommon = NuxeoBlobUtils.createBlobInRepository(parentCtx, repositoryClient, inputStream, streamName); articlesCommon = setArticlesCommonMetadata(articlesCommon, uriInfo, parentCtx); - articlesCommon.setArticleContentCsid(blobsCommon.getRepositoryId()); + articlesCommon.setArticleContentRepositoryId(blobsCommon.getRepositoryId()); articlesCommon.setArticleContentName(streamName); PoxPayloadOut poxPayloadOut = new PoxPayloadOut(ArticleClient.SERVICE_PAYLOAD_NAME); diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java index db187cd2e..3657d6c75 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java @@ -154,8 +154,8 @@ public class ReportResource extends ResourceBase { /* * Publishes the report to the Articles service. The response is a URI to the corresponding Article resource instance in * the form of /articles/{csid}. - * To access the contents of the report use a form like /articles/published/{csid}?tid={tenant ID}. For example, - * http://localhost:8180/cspace-services/articles/published/2991da78-6001-4f34-b02c?tid=1 + * To access the contents of the report use a form like /articles/{csid}/{tenantId}/content. For example, + * http://localhost:8180/cspace-services/articles/2991da78-6001-4f34-b02/1/content */ @POST @Path("{csid}/publish")