Search in sources :

Example 11 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.

the class CommentCrudController method createFlag.

@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi}/flags", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "CommentFlagInputView", value = "example: {\"creatorUserId\": 10365, \"body\": \"oops\", \"reasonCode\": \"spam\"}")
public ResponseEntity<?> createFlag(HttpServletRequest request, @PathVariable("articleDoi") String articleDoi, @PathVariable("commentDoi") String commentDoi) throws IOException {
    ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(articleDoi));
    CommentIdentifier commentId = CommentIdentifier.create(DoiEscaping.unescape(commentDoi));
    // TODO: Validate articleId
    CommentFlagInputView input = readJsonFromRequest(request, CommentFlagInputView.class);
    Flag commentFlag = commentCrudService.createCommentFlag(commentId, input);
    return ServiceResponse.reportCreated(commentNodeViewFactory.createFlagView(commentFlag)).asJsonResponse(entityGson);
}
Also used : ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) CommentIdentifier(org.ambraproject.rhino.identity.CommentIdentifier) Flag(org.ambraproject.rhino.model.Flag) CommentFlagInputView(org.ambraproject.rhino.view.comment.CommentFlagInputView) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam 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);
}
Also used : SyndicationView(org.ambraproject.rhino.view.article.SyndicationView) ArticleRevisionIdentifier(org.ambraproject.rhino.identity.ArticleRevisionIdentifier) SyndicationInputView(org.ambraproject.rhino.view.article.SyndicationInputView) Syndication(org.ambraproject.rhino.model.Syndication) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam 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);
}
Also used : SyndicationView(org.ambraproject.rhino.view.article.SyndicationView) ArticleRevisionIdentifier(org.ambraproject.rhino.identity.ArticleRevisionIdentifier) SyndicationInputView(org.ambraproject.rhino.view.article.SyndicationInputView) Syndication(org.ambraproject.rhino.model.Syndication) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 Transactional (org.springframework.transaction.annotation.Transactional)7 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)3 ArticleRevisionIdentifier (org.ambraproject.rhino.identity.ArticleRevisionIdentifier)3 Syndication (org.ambraproject.rhino.model.Syndication)3 RestClientException (org.ambraproject.rhino.rest.RestClientException)3 SyndicationInputView (org.ambraproject.rhino.view.article.SyndicationInputView)3 SyndicationView (org.ambraproject.rhino.view.article.SyndicationView)3 ArticleListIdentity (org.ambraproject.rhino.identity.ArticleListIdentity)2 CommentIdentifier (org.ambraproject.rhino.identity.CommentIdentifier)2 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)2 Volume (org.ambraproject.rhino.model.Volume)2 ListInputView (org.ambraproject.rhino.view.article.ListInputView)2 CommentInputView (org.ambraproject.rhino.view.comment.CommentInputView)2 IssueInputView (org.ambraproject.rhino.view.journal.IssueInputView)2 VolumeInputView (org.ambraproject.rhino.view.journal.VolumeInputView)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 IssueIdentifier (org.ambraproject.rhino.identity.IssueIdentifier)1