示例#1
0
  public ActionForward createEscalation(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward();

    try {
      HttpSession session = request.getSession(false);
      UserDetailsDTO userDetails = (UserDetailsDTO) session.getAttribute("USER_INFO");

      EscalationForm escalationForm = (EscalationForm) form;
      EscalationDTO escalationDTO = new EscalationDTO();
      EscalationDao escalationDaoImpl = new EscalationDaoImpl();

      if (escalationForm != null) {
        logger.info("Form is not null");
        logger.debug("Form is not null");

        String userName = userDetails.getUserLoginId();
        escalationForm.setCreated_by(userName);
        escalationForm.setModified_by(userName);
        List escalation_level_list = escalationForm.getEscalation_level_list();

        BeanUtils.copyProperties(escalationDTO, escalationForm);

        int flag = escalationDaoImpl.createEscalation(escalationDTO);

        if (flag == 1) {
          //					errors.add(null, new ActionError("create.escalation.success"));
          //					saveErrors(request, errors);
          request.setAttribute(
              "RESET",
              "TRUE"); // used to identify from the initCreate Action that the action is called
          // after successfull creation.
          errors.add(null, new ActionError("create.escalation.success"));
          saveErrors(request, errors);
        } else if (flag == 2) {
          //					errors.add(null, new ActionError("create.escalation.existing"));
          //					saveErrors(request, errors);
          request.setAttribute(
              "RESET",
              "TRUE"); // used to identify from the initCreate Action that the action is called
          // after successfull creation.
          errors.add(null, new ActionError("create.escalation.existing"));
          saveErrors(request, errors);
        }
      }

    } catch (BusinessException exp) {
      exp.printStackTrace();
      errors.add("createEscalation", new ActionError(exp.getBusinessCode()));
      saveErrors(request, errors);
      return mapping.findForward("InitCreateEscalation");
    } catch (ApplicationException exp) {
      exp.printStackTrace();
      errors.add("createEscalation", new ActionError(exp.getBusinessCode()));
      saveErrors(request, errors);
      return mapping.findForward("InitCreateEscalation");
    } catch (Exception exp) {
      exp.printStackTrace();
      errors.add("createEscalation", new ActionError(""));
      saveErrors(request, errors);
      return mapping.findForward("InitCreateEscalation");
    }

    forward = mapping.findForward("CreateEscalationSuccess");
    return (forward);
  }