Search in sources :

Example 6 with CommentIdentifier

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());
}
Also used : ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) CommentIdentifier(org.ambraproject.rhino.identity.CommentIdentifier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with CommentIdentifier

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);
}
Also used : ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) CommentIdentifier(org.ambraproject.rhino.identity.CommentIdentifier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with CommentIdentifier

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

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