use of org.ambraproject.rhino.view.comment.CommentInputView in project rhino by PLOS.
the class CommentCrudController method create.
@RequestMapping(value = "/articles/{articleDoi}/comments", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "CommentInputView", value = "example: {\"creatorUserId\": 10365, " + "\"parentCommentId\": \"10.1371/annotation/0043aae2-f69d-4a05-ab19-4709704eb749\", " + "\"title\": \"no, really watch this\", " + "\"body\": \"http://www.youtube.com/watch?v=iGQdwSAAz9I\", " + "\"highlightedText\": \"whoah...\", " + "\"competingInterestStatement\": \"I'm going for an Emmy\"}")
public ResponseEntity<?> create(HttpServletRequest request, @PathVariable("articleDoi") String articleDoi) throws IOException {
ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(articleDoi));
CommentInputView input = readJsonFromRequest(request, CommentInputView.class);
// TODO: Pass Optional.empty() if client POSTed to "/comments"?
Optional<ArticleIdentifier> articleIdObj = Optional.of(articleId);
return commentCrudService.createComment(articleIdObj, input).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.view.comment.CommentInputView in project rhino by PLOS.
the class CommentCrudController method patch.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi:.+}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "CommentInputView", value = "example #1: {\"title\": \"new title\"}<br>" + "example #2: {\"body\": \"comment body replacement text\"}<br>" + "example #3: {\"isRemoved\": \"true\"}")
public ResponseEntity<?> patch(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
CommentInputView input = readJsonFromRequest(request, CommentInputView.class);
return commentCrudService.patchComment(commentId, input).asJsonResponse(entityGson);
}
Aggregations