Search in sources :

Example 1 with CommentFlagInputView

use of org.ambraproject.rhino.view.comment.CommentFlagInputView 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)

Aggregations

ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)1 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)1 CommentIdentifier (org.ambraproject.rhino.identity.CommentIdentifier)1 Flag (org.ambraproject.rhino.model.Flag)1 CommentFlagInputView (org.ambraproject.rhino.view.comment.CommentFlagInputView)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1