/** * This action deletes a single alert from the system. * * @param userSession the user session that is performing the action. * @param request the http request object related to the action. * @param response the http response object related to the action. * @throws javax.servlet.ServletException * @throws java.io.IOException */ public void performDelete( UserSession userSession, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String alert_no = request.getParameter("alert_no"); LogController.write(this, "[USER REQUEST] Performing alert delete: " + alert_no); AlertBean alert = new AlertBean(); try { alert.setAlertNo(Integer.parseInt(alert_no)); } catch (Exception e) { LogController.write(this, "Received invalid value for alert number: " + alert_no); return; } SessionController.deleteAlert(userSession, alert); forward("welcome-employee.jsp", request, response); }
/** * Validate the form. * * @param mapping_ The action map from struts-config.xml. * @param request_ The servlet request object. * @return ActionErrors when an error is found, otherwise null. */ public ActionErrors validate(ActionMapping mapping_, HttpServletRequest request_) { ActionErrors errors = new ActionErrors(); HttpSession session = request_.getSession(); if (session == null) { _logger.info("No session exists. [" + this.getClass().getName() + "]"); errors.add("bean", new ActionMessage("error.nobean")); return errors; } AlertBean ub = (AlertBean) session.getAttribute(AlertBean._SESSIONNAME); if (ub == null) { _logger.info("No session bean exists. [" + this.getClass().getName() + "]"); errors.add("bean", new ActionMessage("error.nobean")); return errors; } if (!ub.getKey().equals(_sessionKey)) { _logger.error( "Sessionkeys do not match. [" + ub.getUser() + "] [" + this.getClass().getName() + "] [Page " + _sessionKey + "] [Bean " + ub.getKey() + "]"); errors.add("bean", new ActionMessage("error.nobean")); return errors; } if (!ub.checkHost(request_.getRemoteHost())) { _logger.error( "Request is made from a host other than the creator. [" + ub.getUser() + "] [" + this.getClass().getName() + "] [Creator " + ub.getRemoteHost() + "] [Requestor " + request_.getRemoteHost() + "]"); errors.add("bean", new ActionMessage("error.nobean")); return errors; } return validate(mapping_, request_, ub, errors); }