Advertisement
Guest User

Untitled

a guest
May 24th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package webservices;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import javax.ws.rs.GET;
  6. import javax.ws.rs.Path;
  7. import javax.ws.rs.PathParam;
  8. import javax.ws.rs.Produces;
  9. import javax.ws.rs.core.MediaType;
  10.  
  11. import classes.*;
  12.  
  13. @Path(value = "comments")
  14. public class CommentRestResource {
  15.  
  16. @GET
  17. @Produces(value = MediaType.APPLICATION_JSON)
  18. public RestResponse getComment() {
  19. ArrayList<Comment> comments = CommentDAO.getAllComments();
  20. ArrayList<RestComment> restStocks = new ArrayList<>();
  21. for (Comment comment : comments) {
  22. restComments.add(new RestComment(comment));
  23. }
  24. RestResponse response = new RestResponse(comments);
  25. return response;
  26. }
  27.  
  28. @GET
  29. @Path("{id}")
  30. @Produces(value = MediaType.APPLICATION_JSON)
  31. public RestResponse getStockById(@PathParam("id") long id) {
  32. Stock stock = CommentDAO.getStockById(id);
  33. RestComment restComment = new RestComment (comment);
  34. RestResponse response = new RestResponse(restComment);
  35. return response;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement