@@ -0,0 +1,1705 @@
+package org.yablogo.practice.resources;%0A%0A%0Aimport org.yablogo.practice.model.Post;%0A%0Aimport javax.ws.rs.*;%0Aimport javax.ws.rs.core.MediaType;%0Aimport javax.ws.rs.core.Response;%0Aimport java.util.List;%0A%0A/**%0A * Created by litemn on 30.11.14.%0A */%0A@Path(%22/api/posts%22)%0Apublic class ApiPostResource %7B%0A%0A    @GET%0A    @Produces(MediaType.APPLICATION_JSON)%0A    public List%3CPost%3E getPosts() %7B%0A        return Post.findAll();%0A    %7D%0A%0A    @GET%0A    @Path(%22/%7Bid%7D%22)%0A    @Produces(MediaType.APPLICATION_JSON)%0A    public Post getPost(@PathParam(%22id%22) int id) %7B%0A        return Post.findById(id);%0A    %7D%0A%0A    @POST%0A    @Produces(MediaType.APPLICATION_JSON)%0A    @Consumes(MediaType.APPLICATION_JSON)%0A    public Post newPost(Post post) %7B%0A        Post newPost = new Post();%0A        newPost.setBody(post.getBody());%0A        newPost.setTitle(post.getTitle());%0A        newPost.saveIt();%0A        return newPost;%0A%0A    %7D%0A%0A    @PUT%0A    @Path(%22/%7Bid%7D%22)%0A    @Produces(MediaType.APPLICATION_JSON)%0A    @Consumes(MediaType.APPLICATION_JSON)%0A    public Post editPost(Post post, @PathParam(%22id%22) int id) %7B%0A        Post editPost = Post.findById(id);%0A        if (editPost != null) %7B%0A            editPost.setBody(post.getBody());%0A            editPost.setTitle(post.getTitle());%0A            editPost.saveIt();%0A        %7D%0A        return editPost;%0A    %7D%0A%0A    @DELETE%0A    @Path(%22/%7Bid%7D%22)%0A    @Produces(MediaType.APPLICATION_JSON)%0A    public Response deletePost(@PathParam(%22id%22) int id) %7B%0A        Post post = Post.findById(id);%0A        Response res;%0A        if (post != null) %7B%0A            post.delete();%0A            res = Response.accepted().build();%0A        %7D else %7B%0A            res = Response.notModified().build();%0A        %7D%0A%0A        return res;%0A    %7D%0A%0A%0A%7D%0A

Make Api post resource