use of org.ambraproject.rhino.identity.CommentIdentifier in project rhino by PLOS.
the class CommentCrudController method read.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi:.+}", method = RequestMethod.GET)
public ResponseEntity<?> read(@PathVariable("articleDoi") String articleDoi, @PathVariable("commentDoi") String commentDoi) throws IOException {
ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(articleDoi));
CommentIdentifier commentId = CommentIdentifier.create(DoiEscaping.unescape(commentDoi));
return commentCrudService.serveComment(commentId).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.identity.CommentIdentifier in project rhino by PLOS.
the class CommentCrudController method readFlagsOnComment.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi}/flags", method = RequestMethod.GET)
public void readFlagsOnComment(HttpServletRequest request, HttpServletResponse response, @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
commentCrudService.readCommentFlagsOn(commentId).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.identity.CommentIdentifier in project rhino by PLOS.
the class CommentCrudController method removeFlag.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi}/flags/{flagId}", method = RequestMethod.DELETE)
public ResponseEntity<Object> removeFlag(@PathVariable("articleDoi") String articleDoi, @PathVariable("commentDoi") String commentDoi, @PathVariable("flagId") long flagId) throws IOException {
ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(articleDoi));
CommentIdentifier commentId = CommentIdentifier.create(DoiEscaping.unescape(commentDoi));
// TODO: Validate articleId and commentId
commentCrudService.deleteCommentFlag(flagId);
return reportDeleted(Long.toString(flagId));
}
use of org.ambraproject.rhino.identity.CommentIdentifier in project rhino by PLOS.
the class CommentCrudController method delete.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi:.+}", method = RequestMethod.DELETE)
@ApiOperation(value = "delete", notes = "Performs a hard delete operation in the database. " + "NOTE: fails loudly if attempting to delete a comment that has any replies. All replies must " + "be deleted first.")
public ResponseEntity<?> delete(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
String deletedCommentUri = commentCrudService.deleteComment(commentId);
return reportDeleted(deletedCommentUri);
}
use of org.ambraproject.rhino.identity.CommentIdentifier 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