Exemplo n.º 1
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    logger.debug("Get received");

    String bookid = request.getParameter("bookid");
    logger.debug("param bookid : " + bookid);
    Book book = new Book(bookid);
    Session session = HibernateUtil.getSessionFactory().openSession();
    BookDao bookDao = new BookDao(session);
    LoanDao loanDao = new LoanDao(session);
    BookService bookService = new BookService(bookDao, loanDao);
    if (!bookService.deleteBook(book.getBookid())) {
      logger.debug("Book not deleted");
      request.setAttribute("isBookDeleted", false);
    } else {
      request.setAttribute("isBookDeleted", true);
      logger.debug("Book  deleted");
    }
    List<Book> bookList = bookService.getAll();
    logger.debug("bookList : " + bookList);
    request.setAttribute("bookList", bookList);
    session.close();

    logger.debug(LogConstant.REDIRECT + PageConstant.BOOK_LIST_URL);
    RequestDispatcher rd = request.getRequestDispatcher(PageConstant.BOOK_LIST_URL);
    rd.forward(request, response);
  }
Exemplo n.º 2
0
  public void setUp() throws Exception {
    logger.info("Entered setUp for TC18");
    HttpUnitOptions.setScriptingEnabled(false);

    // open the session
    session = HibernateUtil.getSessionFactory().openSession();
    userDao = new UserDao(session);
    bookDao = new BookDao(session);
    loandao = new LoanDao(session);
    userService = new UserService(userDao, loandao);
    bookService = new BookService(bookDao, loandao);
    loanService = new LoanService(loandao);
    logger.info("Exited setUp for TC18");
  }