use of org.ambraproject.rhino.identity.ArticleRevisionIdentifier in project rhino by PLOS.
the class ArticleCrudController method deleteRevision.
@Transactional(readOnly = false)
@RequestMapping(value = "/articles/{doi}/revisions/{revision}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteRevision(@PathVariable("doi") String doi, @PathVariable("revision") int revisionNumber) {
ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);
articleRevisionWriteService.deleteRevision(revisionId);
return new ResponseEntity<>(HttpStatus.OK);
}
use of org.ambraproject.rhino.identity.ArticleRevisionIdentifier in project rhino by PLOS.
the class ArticleCrudController method readSyndications.
@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", method = RequestMethod.GET)
public ResponseEntity<?> readSyndications(@PathVariable("doi") String doi, @PathVariable("number") int revisionNumber) throws IOException {
ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);
List<Syndication> syndications = syndicationCrudService.getSyndications(revisionId);
// TODO: If revision does not exist, need to respond with 404 instead of empty list?
List<SyndicationView> views = syndications.stream().map(SyndicationView::new).collect(Collectors.toList());
return ServiceResponse.serveView(views).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.identity.ArticleRevisionIdentifier 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.ArticleRevisionIdentifier in project rhino by PLOS.
the class ArticleCrudController method createSyndication.
@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "SyndicationInputView", value = "example: {\"targetQueue\": \"activemq:plos.pmc\"}")
public ResponseEntity<?> createSyndication(HttpServletRequest request, @PathVariable("doi") String doi, @PathVariable("number") int revisionNumber) throws IOException {
ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);
SyndicationInputView input = readJsonFromRequest(request, SyndicationInputView.class);
Syndication syndication = syndicationCrudService.createSyndication(revisionId, input.getTargetQueue());
return ServiceResponse.reportCreated(new SyndicationView(syndication)).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.identity.ArticleRevisionIdentifier in project rhino by PLOS.
the class ArticleCrudController method syndicate.
@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", // Fold into PATCH operation so we can get rid of "?syndicate"?
method = RequestMethod.POST, params = "syndicate")
@ApiOperation(value = "syndicate", notes = "Send a syndication message to the queue for processing. " + "Will create and add a syndication to the database if none exist for current article and target.")
@ApiImplicitParam(name = "body", paramType = "body", dataType = "SyndicationInputView", value = "example: {\"targetQueue\": \"activemq:plos.pmc\"}")
public ResponseEntity<?> syndicate(HttpServletRequest request, @PathVariable("doi") String doi, @PathVariable("number") int revisionNumber) throws IOException {
ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);
SyndicationInputView input = readJsonFromRequest(request, SyndicationInputView.class);
Syndication created = syndicationCrudService.syndicate(revisionId, input.getTargetQueue());
return ServiceResponse.reportCreated(new SyndicationView(created)).asJsonResponse(entityGson);
}
Aggregations