From: Richard Millet Date: Thu, 24 Jan 2013 17:53:46 +0000 (-0800) Subject: CSPACE-5564-REM: Tweaked the public url to look like /articles/{csid}/{tenantId}... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=4a846ea16e7beda12df1d828ecaea459d5baca0e;p=tmp%2Fjakarta-migration.git CSPACE-5564-REM: Tweaked the public url to look like /articles/{csid}/{tenantId}/published which removed the requirement for supplying the tenant ID as a query param. --- 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 c118918de..fba0ae5e3 100644 --- a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -27,8 +27,12 @@ class="org.springframework.security.web.FilterChainProxy"> + + 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 05cbf5323..8dc4cb416 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 @@ -17,11 +17,12 @@ version="0.1"> - + + + - - + diff --git a/services/article/3rdparty/pom.xml b/services/article/3rdparty/pom.xml index d1e47f25d..e0622fd67 100644 --- a/services/article/3rdparty/pom.xml +++ b/services/article/3rdparty/pom.xml @@ -9,7 +9,6 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.article.3rdparty services.article.3rdparty pom diff --git a/services/article/jaxb/src/main/resources/articles-common.xsd b/services/article/jaxb/src/main/resources/articles-common.xsd index 6b277cf98..cd16b5a5f 100644 --- a/services/article/jaxb/src/main/resources/articles-common.xsd +++ b/services/article/jaxb/src/main/resources/articles-common.xsd @@ -14,13 +14,14 @@ + + - - + diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/spi/AuthNContext.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/spi/AuthNContext.java index 506c11fac..1b7b536a6 100644 --- a/services/authentication/service/src/main/java/org/collectionspace/authentication/spi/AuthNContext.java +++ b/services/authentication/service/src/main/java/org/collectionspace/authentication/spi/AuthNContext.java @@ -38,6 +38,8 @@ public abstract class AuthNContext { public static final String ANONYMOUS_TENANT_NAME = ANONYMOUS_USER; public static final String SPRING_ADMIN_USER = "SPRING_ADMIN"; public static final String TENANT_ID_QUERY_PARAM = "tid"; + public static final String TENANT_ID_PATH_PARAM = "tenantId"; + /** * getUserId returns authenticated user id 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 7f2fdf48b..7343a04cc 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 @@ -287,7 +287,8 @@ public class BlobResource extends ResourceBase { ctx = createServiceContext(); StringBuffer mimeType = new StringBuffer(); InputStream contentStream = getBlobContent(ctx, csid, null /*derivative term*/, mimeType /*will get set*/); - result = ArticleUtil.publishToRepository(resourceMap, uriInfo, getRepositoryClient(ctx), ctx, contentStream, csid); + result = ArticleUtil.publishToRepository((ArticlesCommon)null, resourceMap, uriInfo, + getRepositoryClient(ctx), ctx, contentStream, csid); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.PUT_FAILED); } 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 c83812ccb..aae22da18 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 @@ -25,6 +25,7 @@ package org.collectionspace.services.common.article; import java.io.InputStream; +import org.collectionspace.authentication.spi.AuthNContext; import org.collectionspace.services.article.ArticlesCommon; import org.collectionspace.services.client.ArticleClient; import org.collectionspace.services.client.PoxPayloadIn; @@ -80,11 +81,12 @@ public class ArticleResource extends ResourceBase { } @GET - @Path("/published/{csid}") + @Path("/{csid}/{tenantId}/published") public Response getPublishedResource( @Context Request request, @Context UriInfo uriInfo, - @PathParam("csid") String csid) { + @PathParam("csid") String csid, + @PathParam(AuthNContext.TENANT_ID_PATH_PARAM) String tenantId) { Response result = null; try { 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 f4af10e88..ac7b388ca 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 @@ -18,14 +18,40 @@ import org.collectionspace.services.common.repository.RepositoryClient; public class ArticleUtil { - public static Response publishToRepository(ResourceMap resourceMap, + /* + * Sets common fields for an ArticlesCommon instance + */ + private static ArticlesCommon setArticlesCommonMetadata( + ArticlesCommon articlesCommon, + UriInfo uriInfo, + ServiceContext parentCtx) { + ArticlesCommon result = articlesCommon; + + if (result == null) { + 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 articleContentUrl = "the public url goes here"; + result.setArticleContentUrl(articleContentUrl); + + return result; + } + + /* + * Publishes a PoxPayloadOut instance for public access + */ + public static Response publishToRepository( + ArticlesCommon articlesCommon, + ResourceMap resourceMap, UriInfo uriInfo, - ServiceContext parentCtx, + ServiceContext parentCtx, PoxPayloadOut poxPayloadOut) { Response result = null; - ArticlesCommon articlesCommon = new ArticlesCommon(); - articlesCommon.setArticlePublisher("Hello, this is a test."); + articlesCommon = setArticlesCommonMetadata(articlesCommon, uriInfo, parentCtx); PoxPayloadIn input = new PoxPayloadIn(ArticleClient.SERVICE_PAYLOAD_NAME, articlesCommon, ArticleClient.SERVICE_COMMON_PART_NAME); @@ -35,19 +61,25 @@ public class ArticleUtil { return result; } - public static Response publishToRepository(ResourceMap resourceMap, + /* + * Publishes a a byte stream for public access + */ + public static Response publishToRepository( + ArticlesCommon articlesCommon, + ResourceMap resourceMap, UriInfo uriInfo, - RepositoryClient repositoryClient, - ServiceContext parentCtx, + 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 = setArticlesCommonMetadata(articlesCommon, uriInfo, parentCtx); articlesCommon.setArticleContentCsid(blobsCommon.getRepositoryId()); + articlesCommon.setArticleContentName(streamName); + PoxPayloadOut poxPayloadOut = new PoxPayloadOut(ArticleClient.SERVICE_PAYLOAD_NAME); poxPayloadOut.addPart(ArticleClient.SERVICE_COMMON_PART_NAME, articlesCommon); diff --git a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityContextImpl.java index ee1179482..7c6896f8a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityContextImpl.java @@ -59,7 +59,8 @@ public class SecurityContextImpl implements SecurityContext { throw new UnauthorizedException(errMsg); } - String tenantId = uriInfo.getQueryParameters().getFirst(AuthNContext.TENANT_ID_QUERY_PARAM); +// String tenantId = uriInfo.getQueryParameters().getFirst(AuthNContext.TENANT_ID_QUERY_PARAM); + String tenantId = uriInfo.getPathParameters().getFirst(AuthNContext.TENANT_ID_PATH_PARAM); if (tenantId == null) { String errMsg = String.format("Anonymous access to '%s' attempted without a valid tenant ID query paramter.", uriInfo.getPath()); 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 ab3d425e0..db187cd2e 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 @@ -27,6 +27,7 @@ import java.io.InputStream; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler; +import org.collectionspace.services.article.ArticlesCommon; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; @@ -170,7 +171,7 @@ public class ReportResource extends ResourceBase { StringBuffer outReportFileName = new StringBuffer(); ServiceContext ctx = createServiceContext(); InputStream reportInputStream = invokeReport(ctx, csid, invContext, outMimeType, outReportFileName); - response = ArticleUtil.publishToRepository(resourceMap, uriInfo, getRepositoryClient(ctx), ctx, + response = ArticleUtil.publishToRepository((ArticlesCommon)null, resourceMap, uriInfo, getRepositoryClient(ctx), ctx, reportInputStream, outReportFileName.toString()); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.POST_FAILED);