*/
@SuppressWarnings("finally")
public ModelAndView enableBooking(HttpServletRequest req, HttpServletResponse resp) throws Exception{
int id = Integer.parseInt(req.getParameter("id"));
UnconfirmedBooking unConfirmed= (UnconfirmedBooking) bookingManager.get(id);
GregorianCalendar beginDate= unConfirmed.getBeginDate();
GregorianCalendar finishDate=unConfirmed.getFinishDate();
Room room=unConfirmed.getRoom();
Booking booking=new Booking(unConfirmed);
if(bookingManager.isRoomVacant(beginDate, finishDate, room)){
bookingManager.add(booking);
try {
mail.sendMailEnable(booking);
} catch (MailException e) {
System.out.println(e.getMessage());
bookingManager.remove(booking.getId());
throw new Exception ();
}
bookingManager.remove(id);
}
else{
id=unConfirmed.getId();
try {
mail.sendMailEnable(booking);
} catch (MailException e) {
System.out.println(e.getMessage());
throw new Exception ();
}
return new ModelAndView("redirect:/Booking/edit.htm","id", unConfirmed.getId());
}
return this.listUnconfirmed(req, resp);