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