]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5564: Updated public access URL that gets a public item's content to conform...
authorRichard Millet <remillet@berkeley.edu>
Thu, 24 Jan 2013 21:45:27 +0000 (13:45 -0800)
committerRichard Millet <remillet@berkeley.edu>
Thu, 24 Jan 2013 21:45:27 +0000 (13:45 -0800)
12 files changed:
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
services/article/3rdparty/nuxeo-platform-cs-article/src/main/resources/schemas/articles_common.xsd
services/article/client/src/main/java/org/collectionspace/services/client/ArticleClient.java
services/article/jaxb/src/main/java/org/collectionspace/services/ArticlesCommonJAXBSchema.java
services/article/jaxb/src/main/resources/articles-common.xsd
services/article/service/src/main/java/org/collectionspace/services/article/nuxeo/ArticleDocumentModelHandler.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml
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/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java

index fba0ae5e3838e9dd344a391bfca0eb6ee13afdd3..2e6b6f69a966ffd98bbdc49f15d6e4533bbd2cb6 100644 (file)
     <bean id="springSecurityFilterChain"
           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"
+                       <!-- Exclude the resource path to public items' content from AuthN and AuthZ.  Let's us publish resources with anonymous access. -->
+                       <sec:filter-chain pattern="/articles/*/*/content"
                               filters="none"/>
             <sec:filter-chain pattern="/**"
                               filters="securityContextPersistenceFilter,basicAuthenticationFilter,logoutFilter,exTranslationFilter,filterInvocationInterceptor"/>
index 4515cb1f7c06a280143be090c77be9d2ac632536..e633882ce2baeafc7a57334d78e3e2acab69752f 100644 (file)
         <servlet-name>Resteasy</servlet-name>\r
         <url-pattern>/*</url-pattern>\r
     </servlet-mapping>\r
-    \r
-    <servlet>\r
-            <servlet-name>PublishedResourcesServlet</servlet-name>\r
-            <servlet-class>\r
-                org.collectionspace.services.common.servlet.PublishedResourcesServlet\r
-            </servlet-class>\r
-    </servlet>    \r
-    <servlet-mapping>\r
-        <servlet-name>PublishedResourcesServlet</servlet-name>\r
-        <url-pattern>/published/*</url-pattern>\r
-    </servlet-mapping>\r
 \r
 </web-app>\r
index 8dc4cb416982a32c03eb77b7cfe8c369932553ec..2f288e46eee5efcf36611da3f090f1098234ad0a 100644 (file)
     targetNamespace="http://collectionspace.org/article/"
     version="0.1">
     
-       <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 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="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="accessedCountLimit" type="xs:integer" />              <!-- The maximum times the article can be accessed. -->
+       <xs:element name="articleNumber" type="xs:string" />                            <!-- An identifier for the article (different than the CSID) -->
+       <xs:element name="articleContentName" type="xs:string" />                       <!-- A name for the article's content  -->
+       <xs:element name="articleContentRepositoryId" 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="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="accessedCountLimit" type="xs:integer" />                      <!-- The maximum times the article can be accessed. -->
 </xs:schema>
index a6c68eeba1dd3631966c5f117f48d2349f928b9e..fff3669cbff9b477c71fbaf59a341f25639f5795 100644 (file)
@@ -30,7 +30,9 @@ public class ArticleClient extends AbstractCommonListPoxServiceClientImpl<Articl
     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;    
+    public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+    
+    public static final String PUBLICITEMS_CONTENT_SUFFIX = "content";
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
index a121f7374ac0e2486308e26a884b829912a8c511..c5c3e38445005df2f4e3f2bf849047e865cb7ea8 100644 (file)
@@ -22,11 +22,12 @@ package org.collectionspace.services;
 
 public interface ArticlesCommonJAXBSchema {
     final static String ARTICLE_NUMBER = "articleNumber";
-    final static String ARTICLE_CONTENT_CSID = "articleContentCsid";
+    final static String ARTICLE_CONTENT_NAME = "articleContentName";
+    final static String ARTICLE_CONTENT_REPO_ID = "articleContentRepositoryId";
+    final static String ARTICLE_CONTENT_URL = "articleContentUrl";
     final static String ARTICLE_JOB_ID = "articleJobId";
     final static String ARTICLE_SOURCE = "articleSource";
-    final static String ARTICLE_PUBLISHER = "articlePublisher";
     final static String ARTICLE_ACCESS_EXPIRATION_DATE = "accessExpirationDate";
     final static String ARTICLE_ACCESSED_COUNT = "accessedCount";
-    final static String ARTICLE_ACCESS_COUNT_LIMIT = "accessCountLimit";
+    final static String ARTICLE_ACCESSED_COUNT_LIMIT = "accesseedCountLimit";
 }
\ No newline at end of file
index cd16b5a5f604b10ae5a719f35aa9c3e48c52b27d..d1ad13753e6cc63de5b8409b103d1b3a4a746929 100644 (file)
        <xs:element name="articles_common">
                <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="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="accessedCountLimit" type="xs:integer" />              <!-- The maximum times the article can be accessed. -->
+                               <xs:element name="articleNumber" type="xs:string" />                            <!-- An identifier for the article (different than the CSID) -->
+                               <xs:element name="articleContentName" type="xs:string" />                       <!-- A name for the article's content  -->
+                               <xs:element name="articleContentRepositoryId" 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="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="accessedCountLimit" type="xs:integer" />                      <!-- The maximum times the article can be accessed. -->
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
index 45f4ae48ca1dab57d01938d5b12b59925e47707d..a6782c31cbe1341bc671191852d32865d49badee 100644 (file)
  */
 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<ArticlesCommon> {
+       
+       @Override
+       public void fillAllParts(DocumentWrapper<DocumentModel> 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);
+       }
 }
 
index 19ddf315c6aa80babfeba535792ce4f78d71512a..cf960100fee6e5dcf5edbb25a794f8626409671b 100644 (file)
@@ -36,6 +36,7 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList;
  */
 public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P extends CollectionSpaceProxy<CLT>> {
 
+       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";
index 594f69c105078c350614e7f0c76567cbb512711d..a79b5cc8238976a8c85531afc8d690ad27c5af60 100644 (file)
                             <service:xpath>articleNumber</service:xpath>
                         </service:ListResultField>
                         <service:ListResultField>
-                            <service:element>articleContentCsid</service:element>
-                            <service:xpath>articleContentCsid</service:xpath>
+                            <service:element>articleSource</service:element>
+                            <service:xpath>articleSource</service:xpath>
                         </service:ListResultField>
+                        <service:ListResultField>
+                            <service:element>articleContentUrl</service:element>
+                            <service:xpath>articleContentUrl</service:xpath>
+                        </service:ListResultField>                  
                     </service:ListResultsFields>
                 </service:params>
             </service:DocHandlerParams>
index aae22da18e58a77dd4e0be80dabdf7be80090d46..b61e736ddce352ffcdab0775f788d675af695a1d 100644 (file)
@@ -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();
index ac7b388caabdbf8c58f67a7b38db10393d4ce425..2f3a84f0e6e566b5de3c3c5107c3b209c665b7ed 100644 (file)
@@ -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);
index db187cd2e30e1a0c173e7ef84746acef7481f67b..3657d6c750dec3f788c29b3aeebcf3b9a5f849b5 100644 (file)
@@ -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")