]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5564-REM: Tweaked the public url to look like /articles/{csid}/{tenantId}...
authorRichard Millet <remillet@berkeley.edu>
Thu, 24 Jan 2013 17:53:46 +0000 (09:53 -0800)
committerRichard Millet <remillet@berkeley.edu>
Thu, 24 Jan 2013 17:53:46 +0000 (09:53 -0800)
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
services/article/3rdparty/nuxeo-platform-cs-article/src/main/resources/schemas/articles_common.xsd
services/article/3rdparty/pom.xml
services/article/jaxb/src/main/resources/articles-common.xsd
services/authentication/service/src/main/java/org/collectionspace/authentication/spi/AuthNContext.java
services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java
services/common/src/main/java/org/collectionspace/services/common/article/ArticleResource.java
services/common/src/main/java/org/collectionspace/services/common/article/ArticleUtil.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityContextImpl.java
services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java

index c118918de02d6a23afab3e930dbe542f4b7c9315..fba0ae5e3838e9dd344a391bfca0eb6ee13afdd3 100644 (file)
           class="org.springframework.security.web.FilterChainProxy">
         <sec:filter-chain-map path-type="ant">
                        <!-- Exclude the "PublishedResourcesServlet" paths from AuthN and AuthZ.  Let's us publish resources with anonymous access. -->
+                       <!-- 
                        <sec:filter-chain pattern="/articles/published/**"
                               filters="none"/>
+             -->
+                       <sec:filter-chain pattern="/articles/*/*/published"
+                              filters="none"/>
             <sec:filter-chain pattern="/**"
                               filters="securityContextPersistenceFilter,basicAuthenticationFilter,logoutFilter,exTranslationFilter,filterInvocationInterceptor"/>
         </sec:filter-chain-map>
index 05cbf53235539ee6e1bb2cc26dd0154d37dea033..8dc4cb416982a32c03eb77b7cfe8c369932553ec 100644 (file)
     version="0.1">
     
        <xs:element name="articleNumber" type="xs:string" />                    <!-- An ID for the article (different than the CSID) -->
-       <xs:element name="articleContentCsid" type="xs:string" />               <!-- The URL of the article's content -->
+       <xs:element name="articleContentName" type="xs:string" />
+       <xs:element name="articleContentCsid" type="xs:string" />               <!-- The backend repository ID of the article's content -->
+       <xs:element name="articleContentUrl" type="xs:string" />                <!-- The publicly accessible 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 -->
        <xs:element name="accessExpirationDate" type="xs:dateTime" />   <!-- When the article is no longer available for access -->
        <xs:element name="accessedCount" type="xs:integer" />                   <!-- How many times the article has been accessed. -->
-       <xs:element name="accessCountLimit" type="xs:integer" />                <!-- The maximum times the article can be accessed. -->
+       <xs:element name="accessedCountLimit" type="xs:integer" />              <!-- The maximum times the article can be accessed. -->
 </xs:schema>
index d1e47f25df6192d7a3e3e6c04933c46fead338ae..e0622fd67424911142711c674f780f24cd46238b 100644 (file)
@@ -9,7 +9,6 @@
     </parent>
     
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.collectionspace.services</groupId>
     <artifactId>org.collectionspace.services.article.3rdparty</artifactId>
     <name>services.article.3rdparty</name>
     <packaging>pom</packaging>
index 6b277cf988fcd3368f775569e5b58de8e093e0da..cd16b5a5f604b10ae5a719f35aa9c3e48c52b27d 100644 (file)
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="articleNumber" type="xs:string" />                    <!-- An ID for the article (different than the CSID) -->
+                               <xs:element name="articleContentName" type="xs:string" />
                                <xs:element name="articleContentCsid" type="xs:string" />               <!-- The URL of the article's content -->
+                               <xs:element name="articleContentUrl" 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 -->
                                <xs:element name="accessExpirationDate" type="xs:dateTime" />   <!-- When the article is no longer available for access -->
                                <xs:element name="accessedCount" type="xs:integer" />                   <!-- How many times the article has been accessed. -->
-                               <xs:element name="accessCountLimit" type="xs:integer" />                <!-- The maximum times the article can be accessed. -->
+                               <xs:element name="accessedCountLimit" type="xs:integer" />              <!-- The maximum times the article can be accessed. -->
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
index 506c11fac2adabef1717d3a57d2b7caa469d9408..1b7b536a6ca0289a5c7865bf34cf9e6cdaa4b441 100644 (file)
@@ -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
index 7f2fdf48be9b8324060a0e1185a8f178f17e7873..7343a04cc463e16f82a84d48c3b143bdac073241 100644 (file)
@@ -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);
        }
index c83812ccbde1261b1a85591aed807085a87b82e7..aae22da18e58a77dd4e0be80dabdf7be80090d46 100644 (file)
@@ -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 {
index f4af10e8869704909009ce1e8849536b0deaa3e1..ac7b388caabdbf8c58f67a7b38db10393d4ce425 100644 (file)
@@ -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<PoxPayloadIn, PoxPayloadOut> 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<PoxPayloadIn, PoxPayloadOut> 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<PoxPayloadIn, PoxPayloadOut> repositoryClient,
+               ServiceContext<PoxPayloadIn, PoxPayloadOut> 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);
        
index ee1179482d1ca5eec0ae1a8bac9a2d5a3ac6333a..7c6896f8ad3b8dc3c8decdc642182030b49e22b9 100644 (file)
@@ -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());
index ab3d425e02864b4a4c46ee3842e18dabe1dff77b..db187cd2e30e1a0c173e7ef84746acef7481f67b 100644 (file)
@@ -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<PoxPayloadIn, PoxPayloadOut> 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);