Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package webservices;
- import java.util.ArrayList;
- import javax.ws.rs.GET;
- import javax.ws.rs.Path;
- import javax.ws.rs.PathParam;
- import javax.ws.rs.Produces;
- import javax.ws.rs.core.MediaType;
- import classes.*;
- @Path(value = "comments")
- public class CommentRestResource {
- @GET
- @Produces(value = MediaType.APPLICATION_JSON)
- public RestResponse getComment() {
- ArrayList<Comment> comments = CommentDAO.getAllComments();
- ArrayList<RestComment> restStocks = new ArrayList<>();
- for (Comment comment : comments) {
- restComments.add(new RestComment(comment));
- }
- RestResponse response = new RestResponse(comments);
- return response;
- }
- @GET
- @Path("{id}")
- @Produces(value = MediaType.APPLICATION_JSON)
- public RestResponse getStockById(@PathParam("id") long id) {
- Stock stock = CommentDAO.getStockById(id);
- RestComment restComment = new RestComment (comment);
- RestResponse response = new RestResponse(restComment);
- return response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement