Search in sources :

Example 1 with ArticleIngestionIdentifier

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

the class ArticleCrudController method writeRevision.

@Transactional(readOnly = false)
@RequestMapping(value = "/articles/{doi}/revisions", method = RequestMethod.POST)
public ResponseEntity<?> writeRevision(@PathVariable("doi") String doi, @RequestParam(value = "revision", required = false) Integer revisionNumber, @RequestParam(value = "ingestion", required = true) Integer ingestionNumber) throws IOException {
    ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(doi));
    ArticleIngestionIdentifier ingestionId = ArticleIngestionIdentifier.create(articleId, ingestionNumber);
    final ArticleRevision revision;
    if (revisionNumber == null) {
        revision = articleRevisionWriteService.createRevision(ingestionId);
    } else {
        ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(articleId, revisionNumber);
        revision = articleRevisionWriteService.writeRevision(revisionId, ingestionId);
    }
    return ServiceResponse.reportCreated(ArticleRevisionView.getView(revision)).asJsonResponse(entityGson);
}
Also used : ArticleRevision(org.ambraproject.rhino.model.ArticleRevision) ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) ArticleIngestionIdentifier(org.ambraproject.rhino.identity.ArticleIngestionIdentifier) ArticleRevisionIdentifier(org.ambraproject.rhino.identity.ArticleRevisionIdentifier) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ArticleIngestionIdentifier

use of org.ambraproject.rhino.identity.ArticleIngestionIdentifier 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 3 with ArticleIngestionIdentifier

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

the class IngestibleController method repack.

@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/articles/{doi}/ingestions/{number}/ingestible", method = RequestMethod.GET)
public void repack(HttpServletResponse response, @PathVariable("doi") String doi, @PathVariable("number") int ingestionNumber) throws IOException {
    ArticleIngestionIdentifier ingestionId = ArticleIngestionIdentifier.create(DoiEscaping.unescape(doi), ingestionNumber);
    Archive archive = articleCrudService.repack(ingestionId);
    response.setStatus(HttpStatus.OK.value());
    response.setContentType("application/zip");
    response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "filename=" + archive.getArchiveName());
    try (OutputStream outputStream = response.getOutputStream()) {
        archive.write(outputStream);
    }
}
Also used : Archive(org.ambraproject.rhino.util.Archive) ArticleIngestionIdentifier(org.ambraproject.rhino.identity.ArticleIngestionIdentifier) OutputStream(java.io.OutputStream) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ArticleIngestionIdentifier (org.ambraproject.rhino.identity.ArticleIngestionIdentifier)3 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 OutputStream (java.io.OutputStream)1 ArticleFileIdentifier (org.ambraproject.rhino.identity.ArticleFileIdentifier)1 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)1 ArticleItemIdentifier (org.ambraproject.rhino.identity.ArticleItemIdentifier)1 ArticleRevisionIdentifier (org.ambraproject.rhino.identity.ArticleRevisionIdentifier)1 Doi (org.ambraproject.rhino.identity.Doi)1 ArticleRevision (org.ambraproject.rhino.model.ArticleRevision)1 Archive (org.ambraproject.rhino.util.Archive)1 RepoObjectMetadata (org.plos.crepo.model.metadata.RepoObjectMetadata)1