// ****VIEWING A BOOK****
 @GET
 @Path("/{isbn}")
 @Timed(name = "view-book")
 public BookDto getBookByIsbn(@PathParam("isbn") LongParam isbn) {
   Book book = bookRepository.getBookByISBN(isbn.get());
   BookDto bookResponse = new BookDto(book);
   bookResponse.addLink(new LinkDto("view-book", "/books/" + book.getIsbn(), "GET"));
   bookResponse.addLink(new LinkDto("update-book", "/books/" + book.getIsbn(), "POST"));
   return bookResponse;
 }
  @POST
  @Timed(name = "create-review")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public Response createReview(@PathParam("isbn") LongParam isbn, Review request) {

    // int rating = request.getRating();

    if (request.getComment() == null) {
      return Response.status(400).type("text/plain").entity(" Comment is a required field").build();
    }

    if (request.getRating() == 0) {
      return Response.status(400)
          .type("text/plain")
          .entity(" Rating is a required field !!!!")
          .build();
    }
    final List<Integer> ratingList = Arrays.asList(1, 2, 3, 4, 5);

    if (!(ratingList.contains(request.getRating()))) {
      return Response.status(400)
          .type("text/plain")
          .entity("Invalid value for Rating. Ratings can be between 1 - 5 stars")
          .build();
    }

    Review reviewObject = bookRepository.createReview(isbn.get(), request);

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

    String location = "/books/" + book.getIsbn() + "/reviews/" + reviewObject.getId();
    BookDto bookResponse = new BookDto(book);
    bookResponse.addLink(new LinkDto("view-review", location, "GET"));

    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("links", bookResponse.getLinks());
    return Response.status(201).entity(map).build();
  }
 @GET
 @Path("/{isbn}")
 @Timed(name = "view-book")
 public Response getBookByIsbn(@PathParam("isbn") LongParam isbn) {
   {
     Book book = (Book) book_map.get(isbn.get());
     checkNotNull(book, "newBook instance must not be null");
     BookDto bookResponse = new BookDto(book);
     bookResponse.addLink(new LinkDto("view-book", "/books/" + isbn, "GET"));
     bookResponse.addLink(new LinkDto("update-book", "/books/" + isbn, "PUT"));
     bookResponse.addLink(new LinkDto("delete-book", "/books/" + isbn, "DELETE"));
     bookResponse.addLink(new LinkDto("create-review", "/books/" + isbn + "/reviews", "POST"));
     if (reviewsArray.size() > 0)
       bookResponse.addLink(new LinkDto("view-all-reviews", "/books/" + isbn + "/reviews", "GET"));
     return Response.ok(bookResponse).build();
   }
 }