use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.CommentDTO in project ArachneCentralAPI by OHDSI.
the class CommentController method addComment.
@ApiOperation(value = "Add new comment")
@RequestMapping(value = "/api/v1/comments/{topicId}", method = RequestMethod.POST)
public JsonResult<CommentDTO> addComment(@PathVariable("topicId") Long topicId, @Validated @RequestBody CommentDTO commentDTO, Principal principal) throws PermissionDeniedException {
final IUser user = getUser(principal);
final Comment comment = conversionService.convert(commentDTO, Comment.class);
comment.setAuthor(user);
final Comment saved = commentService.addComment(topicId, commentDTO.getParentId(), comment);
JsonResult<CommentDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(saved, CommentDTO.class));
return result;
}
Aggregations