Search in sources :

Example 1 with ArticleFileIdentifier

use of org.ambraproject.rhino.identity.ArticleFileIdentifier in project rhino by PLOS.

the class ArticleCrudServiceImpl method getManuscriptMetadata.

@Override
public RepoObjectMetadata getManuscriptMetadata(ArticleIngestion ingestion) {
    Doi articleDoi = Doi.create(ingestion.getArticle().getDoi());
    ArticleIngestionIdentifier ingestionId = ArticleIngestionIdentifier.create(articleDoi, ingestion.getIngestionNumber());
    ArticleItemIdentifier articleItemId = ingestionId.getItemFor();
    ArticleFileIdentifier manuscriptId = ArticleFileIdentifier.create(articleItemId, "manuscript");
    RepoObjectMetadata objectMetadata = assetCrudService.getArticleItemFile(manuscriptId);
    return objectMetadata;
}
Also used : ArticleIngestionIdentifier(org.ambraproject.rhino.identity.ArticleIngestionIdentifier) RepoObjectMetadata(org.plos.crepo.model.metadata.RepoObjectMetadata) ArticleItemIdentifier(org.ambraproject.rhino.identity.ArticleItemIdentifier) ArticleFileIdentifier(org.ambraproject.rhino.identity.ArticleFileIdentifier) Doi(org.ambraproject.rhino.identity.Doi)

Example 2 with ArticleFileIdentifier

use of org.ambraproject.rhino.identity.ArticleFileIdentifier in project rhino by PLOS.

the class AssetFileCrudController method serveFile.

@Transactional(readOnly = true)
@RequestMapping(value = "/articles/{articleDoi}/ingestions/{number}/items/{itemDoi}/files/{filetype}", params = "download", method = RequestMethod.GET)
public void serveFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("articleDoi") String articleDoi, @PathVariable("number") int ingestionNumber, @PathVariable("itemDoi") String itemDoi, @PathVariable("filetype") String fileType) throws IOException {
    ArticleFileIdentifier fileId = ArticleFileIdentifier.create(DoiEscaping.unescape(itemDoi), ingestionNumber, fileType);
    // TODO: Validate that articleDoi belongs to item's parent
    RepoObjectMetadata objectMetadata = assetCrudService.getArticleItemFile(fileId);
    serve(request, response, objectMetadata);
}
Also used : RepoObjectMetadata(org.plos.crepo.model.metadata.RepoObjectMetadata) ArticleFileIdentifier(org.ambraproject.rhino.identity.ArticleFileIdentifier) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ArticleFileIdentifier (org.ambraproject.rhino.identity.ArticleFileIdentifier)2 RepoObjectMetadata (org.plos.crepo.model.metadata.RepoObjectMetadata)2 ArticleIngestionIdentifier (org.ambraproject.rhino.identity.ArticleIngestionIdentifier)1 ArticleItemIdentifier (org.ambraproject.rhino.identity.ArticleItemIdentifier)1 Doi (org.ambraproject.rhino.identity.Doi)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1