PrintWriter p = response.getWriter();
if(servletPath.equals("/admin/auctions/save")) {
if(session.getAttribute("admin") != null && session.getAttribute("admin").equals("true")) {
Auction auction = new Auction();
MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");
auction.setProduct(multi.getParameter("newProduct"));
auction.setCatId(new Integer(multi.getParameter("newCat")));
File f = multi.getFile("newImage");
String fileName = multi.getFilesystemName("newImage");
auction.setPhoto(fileName);
auction.setStartingPrice(new Float (multi.getParameter("newStartingPrice")));
auction.setLastPrice(new Float (multi.getParameter("newStartingPrice")));
auction.setMinPrice( new Float (multi.getParameter("newMinPrice")));
Integer duration,i = new Integer(multi.getParameter("newDuration"));
if(i == 1) duration = 4;
else if(i == 2) duration = 6;
else duration = 10;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, duration );
Long e = (cal.getTimeInMillis());
java.sql.Date expire = new java.sql.Date(e);
auction.setExpire(expire);
auction.setShipping(multi.getParameter("newShip"));
auction.setUserId(new Integer(multi.getParameter("newCat")));
auction.setLastPrice(null);
auction.setLastUserId(null);
auction.setDescription(multi.getParameter("newDesc"));
auction.save();
}
}
else if(servletPath.equals("/admin/auctions/update")) {
if(session.getAttribute("admin") != null && session.getAttribute("admin").equals("true")) {
Auction auction = new Auction();
MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");
auction.setId(new Integer(multi.getParameter("editId")));
auction.setProduct(multi.getParameter("editProduct"));
auction.setCatId(new Integer(multi.getParameter("editCat")));
String fileName = multi.getFilesystemName("editImage");
File f = null;
if(fileName == null || fileName.equals("")) {
fileName = multi.getParameter("oldImage");
}
else {
f = multi.getFile("editImage");
}
auction.setPhoto(fileName);
//auction.setStartingPrice(new Float (multi.getParameter("editStartingPrice")));
//auction.setMinPrice( new Float (multi.getParameter("editMinPrice")));
auction.setShipping(multi.getParameter("editShip"));
auction.setUserId(new Integer(multi.getParameter("editCat")));
auction.setDescription(multi.getParameter("editDesc"));
auction.update();
}
}
response.sendRedirect(request.getContextPath() + "/admin/auctions");