use of org.ambraproject.rhino.identity.CommentIdentifier in project rhino by PLOS.
the class CommentCrudController method removeAllFlags.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi}/flags", method = RequestMethod.DELETE)
public ResponseEntity<?> removeAllFlags(@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.removeFlagsFromComment(commentId);
return reportDeleted(commentId.toString());
}
use of org.ambraproject.rhino.identity.CommentIdentifier in project rhino by PLOS.
the class CommentCrudController method readFlag.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi}/flags/{flagId}", method = RequestMethod.GET)
public void readFlag(@RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Date ifModifiedSince, @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.readCommentFlag(flagId).getIfModified(ifModifiedSince).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.identity.CommentIdentifier 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