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>
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>
</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>
<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>
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
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);
}
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;
}
@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 {
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);
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);
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());
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;
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);