@GET
  @Path("/{reviewId}")
  @Timed(name = "view-book-by-reviewId")
  public Response viewBookReview(
      @PathParam("isbn") LongParam isbn, @PathParam("reviewId") IntParam reviewId) {

    Book book = bookRepository.getBookByISBN(isbn.get());

    ReviewDto reviewResponse = null;
    List<Review> reviewList = book.getReview();

    List<Review> tempList = new ArrayList<Review>();
    for (Review reviewObj : reviewList) {

      if (reviewObj.getId() == reviewId.get()) tempList.add(reviewObj);
    }
    reviewResponse = new ReviewDto(tempList);
    String location = "/books/" + book.getIsbn() + "/reviews/";

    HashMap<String, Object> map = new HashMap<String, Object>();

    Review review = reviewResponse.getReviewList().get(0);
    map.put("review", review);
    reviewResponse.addLink(new LinkDto("view-review", location + reviewId.get(), "GET"));
    map.put("links", reviewResponse.getLinks());
    return Response.status(200).entity(map).build();
  }
Example #2
0
  @GET
  @Timed
  @Path("/find/{userId}")
  public UserEntity findUserById(@PathParam("userId") IntParam userId) {

    int id = (int) userId.get();

    return userDao.getObjectById(id);
  }
Example #3
0
  @DELETE
  @Timed
  @Path("/delete/{userId}")
  public Response deleteUserById(@PathParam("userId") IntParam userId) {

    userDao.deleteObjectById(userId.get());

    // TODO Build Response from User delete with Status
    return Response.noContent().build();
  }