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);
}
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;
}
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);
}
}
Aggregations