/** * Changes apartment information. * * @param id_apartment * @param number_room * @param category * @param positions * @param cost * @throws ServiceException */ public static void applyApartmentData( int id_apartment, int number_room, String category, int positions, int cost) throws ServiceException { IApartmentDAO apartmentDAO = new ApartmentDAO(); if (id_apartment != 0) { try { if (Pattern.matches(ROOM_NUMBER_VALIDATION, String.valueOf(number_room)) && Pattern.matches(COST_VALIDATION, String.valueOf(cost))) { apartmentDAO.changeApartmentData(id_apartment, number_room, category, positions, cost); } } catch (DAOException e) { throw new ServiceException(e.getMessage(), e); } } else { ConfigManager.getInstance().getProperty(ConfigManager.CHANGE_APARTMENT_DATA_ERROR_MESSAGE); } }
/** * Execute command for login. Calls class LoginService. * * @param request request to read the command from * @return String (name of the command) * @throws CommandException */ public String execute(HttpServletRequest request) throws CommandException { HttpSession session = request.getSession(true); String page = null; User user = null; String login = request.getParameter(LOGIN).trim(); String password = request.getParameter(PASSWORD).trim(); try { if ((user = LoginService.checkLogin(login, password)) != null) { session.setAttribute(USER, user); LOG.info(LOG_MESSAGE + user.getLogin()); page = LoginService.checkUserRole(user.getRole(), request); } else { request.setAttribute( ERROR_MESSAGE, ConfigManager.getInstance().getProperty(ConfigManager.LOGIN_ERROR_MESSAGE)); page = JspPageName.LOGIN; } } catch (ServiceException e) { throw new CommandException(e.getMessage(), e); } return page; }