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