@POST public Response addComment( @PathParam("messageId") long messageId, @Context UriInfo uriInfo, Comment comment) { Comment newComment = commentService.addComment(messageId, comment); URI uri = uriInfo.getAbsolutePathBuilder().path(String.valueOf(newComment.getId())).build(); return Response.created(uri).entity(newComment).build(); }
@PUT @Path("/{commentId}") public Comment updateComment( @PathParam("messageId") long messageId, @PathParam("commentId") long commentId, Comment comment) { comment.setId(commentId); return commentService.updateComment(messageId, comment); }
@GET @Path("/{commentId}") public Comment getComment( @PathParam("messageId") long messageId, @PathParam("commentId") long commentId) { return commentService.getComment(messageId, commentId); }
@DELETE @Path("/{commentId}") public Comment deleteComment( @PathParam("messageId") long messageId, @PathParam("commentId") long commentId) { return commentService.removeComment(messageId, commentId); }
@GET public List<Comment> getAllComments(@PathParam("messageId") long messageId) { return commentService.getAllComments(messageId); }