public void handle(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
      try {
        log.debug("in sell product");
        String name = request.getParameter("name");
        String delayString = request.getParameter("delay");
        int delay = Integer.parseInt(delayString);
        String minBidString = request.getParameter("midBid");
        double minBid = Double.parseDouble(minBidString);
        String sellerId = request.getParameter("userId");

        AuctionItem item = new AuctionItem();
        item.setName(name);
        item.setMinBid(minBid);
        Calendar cal = Calendar.getInstance();
        item.setStartDate(cal.getTime());
        cal.add(Calendar.SECOND, delay);
        item.setEndDate(cal.getTime());

        log.debug("calling EJB");
        long itemId = seller.sellProduct(sellerId, item);
        item = seller.getItem(itemId);
        request.setAttribute(ITEM, item);
        log.debug("about to forward");

        RequestDispatcher rd = getServletContext().getRequestDispatcher(DISPLAYITEM_URL);
        rd.forward(request, response);
      } catch (Exception ex) {
        request.setAttribute(EXCEPTION_PARAM, ex);
        RequestDispatcher rd = getServletContext().getRequestDispatcher(DISPLAY_EXCEPTION_URL);
        rd.forward(request, response);
      }
    }
Esempio n. 2
0
  /**
   * Use remote interfaces to clear DB for next test.
   *
   * @throws Exception
   */
  private void cleanup() throws Exception {
    auctionmgmt.cancelTimers();

    List<AuctionItem> items = null;
    int index = 0;
    do {
      items = auctionmgmt.getItems(index, 10);
      for (AuctionItem item : items) {
        log.debug("removing item:" + item);
        auctionmgmt.removeItem(item.getId());
      }

    } while (items.size() > 0);

    List<Person> users = null;
    index = 0;
    do {
      users = usermgmt.getUsers(index, 10);
      for (Person user : users) {
        log.debug("removing user:" + user.getUserId());
        usermgmt.removeUser(user.getUserId());
      }
      index += users.size();
    } while (users.size() > 0);
  }