use of org.ambraproject.rhino.model.Syndication 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);
}
use of org.ambraproject.rhino.model.Syndication in project rhino by PLOS.
the class ArticleCrudController method patchSyndication.
@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "SyndicationInputView", value = "example: {\"targetQueue\": \"activemq:plos.pmc\", \"status\": \"FAILURE\", \"errorMessage\": \"failed\"}")
public ResponseEntity<?> patchSyndication(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 patched = syndicationCrudService.updateSyndication(revisionId, input.getTargetQueue(), input.getStatus(), input.getErrorMessage());
return ServiceResponse.serveView(new SyndicationView(patched)).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.model.Syndication in project rhino by PLOS.
the class SyndicationCrudServiceImpl method getSyndication.
@Override
@SuppressWarnings("unchecked")
public Syndication getSyndication(final ArticleRevisionIdentifier revisionId, final String syndicationTargetQueue) {
ArticleRevision articleRevision = articleCrudService.readRevision(revisionId);
return hibernateTemplate.execute(session -> {
Query query = session.createQuery("" + "FROM Syndication s " + "WHERE s.targetQueue = :targetQueue " + "AND s.articleRevision = :articleRevision");
query.setParameter(ArticleJsonNames.SYNDICATION_TARGET, syndicationTargetQueue);
query.setParameter("articleRevision", articleRevision);
return (Syndication) query.uniqueResult();
});
}
Aggregations