/**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // PRIVS check that hrAdmin user is viewing this page
    if (!StandardCode.getInstance()
        .checkPrivStringArray(
            (String[]) request.getSession(false).getAttribute("userPrivs"), "hrAdmin")) {
      return (mapping.findForward("accessDenied"));
    } // END PRIVS check that hrAdmin user is viewing this page

    // get the employee to edit from the request
    String hrAdminUserId = request.getParameter("hrAdminUserId");
    User u = UserService.getInstance().getSingleUser(Integer.valueOf(hrAdminUserId));

    // get new performance review values
    DynaValidatorForm ha = (DynaValidatorForm) form;
    String dueDate = (String) ha.get("dueDate");
    String actualDate = (String) ha.get("actualDate");
    String signedDate = (String) ha.get("signedDate");
    PerformanceReview performanceReviewNew = (PerformanceReview) ha.get("performanceReviewNew");

    if (dueDate.length() > 0) // if entered
    performanceReviewNew.setDueDate(DateService.getInstance().convertDate(dueDate).getTime());
    if (actualDate.length() > 0) // if entered
    performanceReviewNew.setActualDate(DateService.getInstance().convertDate(actualDate).getTime());
    if (signedDate.length() > 0) // if entered
    performanceReviewNew.setSignedDate(DateService.getInstance().convertDate(signedDate).getTime());

    // add new performanceReview to the db
    UserService.getInstance().addPerformanceReview(performanceReviewNew, u);

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
Exemplo n.º 2
0
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // values for adding the related contact
    DynaValidatorForm qae2 = (DynaValidatorForm) form;

    // from wizard add clientContact
    String contactId = (String) request.getAttribute("clientContactViewId");
    if (contactId == null) {
      contactId = (String) (qae2.get("contact"));
    }

    // need the project and contact to build the link between contact and project
    String projectId = StandardCode.getInstance().getCookie("projectAddId", request.getCookies());
    Project p = ProjectService.getInstance().getSingleProject(Integer.valueOf(projectId));

    ClientContact cc =
        ClientService.getInstance().getSingleClientContact(Integer.valueOf(contactId));

    // insert into db, building link between contact and project
    ProjectService.getInstance().linkProjectClientContact(p, cc);

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // PRIVS check that hrAdmin user is viewing this page
    if (!StandardCode.getInstance()
        .checkPrivStringArray(
            (String[]) request.getSession(false).getAttribute("userPrivs"), "hrAdmin")) {
      return (mapping.findForward("accessDenied"));
    } // END PRIVS check that hrAdmin user is viewing this page

    // get user to edit from form hidden field
    String hrAdminUserId = request.getParameter("hrAdminUserId");
    User u = UserService.getInstance().getSingleUser(Integer.valueOf(hrAdminUserId));
    User currentUser =
        UserService.getInstance()
            .getSingleUser((String) request.getSession(false).getAttribute("username"));

    // values for update from form; change what is stored in db to these values
    DynaValidatorForm uvg = (DynaValidatorForm) form;

    String username = (String) uvg.get("username");
    String password = (String) uvg.get("password");

    // update the user's values
    if (username.length() > 0) { // if present
      u.setUsername(username);
    }
    if (password.length() > 0) { // if present, hash password for safe db store
      MessageDigest md = null;
      try {
        md = MessageDigest.getInstance("SHA"); // step 2
      } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
      }
      try {
        md.update(password.getBytes("UTF-8")); // step 3
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
      byte raw[] = md.digest(); // step 4
      String hash = (new BASE64Encoder()).encode(raw); // step 5
      u.setPassword(hash);
    }

    // set updated values to db
    UserService.getInstance().updateUser(u);
    String firstName = u.getFirstName();
    String msg =
        "<font size='2'><span style='font-family: Verdana,Arial,Helvetica,sans-serif;'>Dear <span style='color: rgb(255, 0, 0);'>"
            + firstName
            + "</span>,<br><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'></span><span style='font-family: Verdana,Arial,Helvetica,sans-serif;'>We have created an account for you on ExcelNet, Excel Translations' proprietary intra/extranet system. <br><br> Below you will find the information you need to enter our system, please keep this only to yourself in a secure place.  </span><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'><span style='font-family: Verdana,Arial,Helvetica,sans-serif;'><br>User Name: "
            + username
            + "</span><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'><span style='font-family: Verdana,Arial,Helvetica,sans-serif;'>Password&nbsp;&nbsp;: "
            + password
            + "</span><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'><span style='font-family: Verdana,Arial,Helvetica,sans-serif;'>You can log in into your Account on by clicking </span><a style='font-family: Verdana,Arial,Helvetica,sans-serif;' href='http://excelnet.xltrans.com'>here</a><span style='font-family: Verdana,Arial,Helvetica,sans-serif;'>.<br><br><br>Best Regards,</span><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'><br style='font-family: Verdana,Arial,Helvetica,sans-serif;'><span style='font-family: Verdana,Arial,Helvetica,sans-serif; Best regards,<br style='font-family: Verdana,Arial,Helvetica,sans-serif;'></font><font style='font-family: Verdana,Arial,Helvetica,sans-serif;' size='2'><span class='Apple-style-span' style='border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;'><span class='Apple-style-span' style='color: rgb(59, 105, 119); font-size: 11px; text-align: left;'><br> ExcelNet Administrator<br>Excel Translations, Inc.<br><br><img src=http://excelnet.xltrans.com/logo/images/-1168566039logoExcel.gif></span></span></font><br> ";
    String emailMsgTxt = msg;
    String emailSubjectTxt = "New User Account";
    String adminEmail;
    String userEmailId = "*****@*****.**";
    if (!u.getWorkEmail1().equalsIgnoreCase("")) {

      userEmailId = u.getWorkEmail1();
    } else if (!u.getWorkEmail2().equalsIgnoreCase("")) {
      userEmailId = u.getWorkEmail2();
    } else {
      userEmailId = "*****@*****.**";
    }
    if (currentUser.getWorkEmail1() == null || currentUser.getWorkEmail1().equalsIgnoreCase("")) {
      adminEmail = "*****@*****.**";

    } else adminEmail = currentUser.getWorkEmail1();

    try {
      String[] emailList = {userEmailId, adminEmail};
      SendEmail smtpMailSender = new SendEmail();
      smtpMailSender.postMail(emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
    } catch (Exception e) {

      // String[] emailList = {"niteshwar.kumarpatialideas.com"};
      // SendEmail smtpMailSender = new SendEmail();
      // smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);

    }

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // values for adding a new target Doc
    DynaValidatorForm qvgate1 = (DynaValidatorForm) form;

    String[] targets = (String[]) qvgate1.get("targets");
    String all = (String) qvgate1.get("all"); // the all languages box
    String engPrelim = (String) qvgate1.get("engPrelim");
    String engOther = (String) qvgate1.get("engOther");
    String engVerification = (String) qvgate1.get("engVerification");
    String engQA = (String) qvgate1.get("engQA");
    String engPrep = (String) qvgate1.get("engPrep");
    String engFunct = (String) qvgate1.get("engFunct");
    String engEng = (String) qvgate1.get("engEng");
    String engFinalQA = (String) qvgate1.get("engFinalQA");
    String engFinal = (String) qvgate1.get("engFinal");
    String eng0 = (String) (qvgate1.get("eng0"));
    String eng1 = (String) (qvgate1.get("eng1"));
    String eng2 = (String) (qvgate1.get("eng2"));
    String eng3 = (String) (qvgate1.get("eng3"));
    String eng4 = (String) (qvgate1.get("eng4"));
    String eng5 = (String) (qvgate1.get("eng5"));
    String eng6 = (String) (qvgate1.get("eng6"));
    String eng7 = (String) (qvgate1.get("eng7"));
    String eng8 = (String) (qvgate1.get("eng8"));
    String[] engTaskOptions = ProjectService.getInstance().getEngTaskOptions();

    // get the user's chosen source array for later use in case new target "new" needs to be created
    HttpSession session = request.getSession(false);
    SourceDoc[] sources = (SourceDoc[]) session.getAttribute("sourceArray");

    if (!all.equals("on")) { // if specific to only a few targets
      // for each target, add the new target to db and each target's new engineering tasks selected
      // from form
      for (int i = 0; i < targets.length; i++) {
        Set engTasks = new HashSet(); // list of new engTasks

        // need target doc and source doc to add tasks to it
        TargetDoc td = ProjectService.getInstance().getSingleTargetDoc(Integer.valueOf(targets[i]));
        SourceDoc sd = td.getSourceDoc();

        if (eng1.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[1 - 1]);
          et.setOrderNum(new Integer(1));
          engTasks.add(et);
        }

        if (eng2.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[2 - 1]);
          et.setOrderNum(new Integer(2));
          engTasks.add(et);
        }

        if (eng3.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[3 - 1]);
          et.setOrderNum(new Integer(3));
          engTasks.add(et);
        }

        if (eng4.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[4 - 1]);
          et.setOrderNum(new Integer(4));
          engTasks.add(et);
        }

        if (eng5.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[5 - 1]);
          et.setOrderNum(new Integer(5));
          engTasks.add(et);
        }

        if (eng6.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[6 - 1]);
          et.setOrderNum(new Integer(6));
          engTasks.add(et);
        }

        if (eng7.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[7 - 1]);
          et.setOrderNum(new Integer(7));
          engTasks.add(et);
        }

        if (eng8.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setNotes((String) (qvgate1.get("engOtherText")));
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[8 - 1]);
          et.setOrderNum(new Integer(8));
          engTasks.add(et);
        }

        // for each EngTask, add it to db and link it to this targetDoc
        for (Iterator iter = engTasks.iterator(); iter.hasNext(); ) {
          EngTask et = (EngTask) iter.next();

          // link this engTask to the targetDoc; add new engTask to db
          Integer z = ProjectService.getInstance().linkTargetDocEngTask(td, et);
        }
      }
    } // end if all.equals("on")
    else { // add tasks to all targets (actually a single "all" target)
      // for each source, add the new target to db and each target's new engineering tasks selected
      // from form
      for (int i = 0; i < sources.length; i++) {
        Set engTasks = new HashSet(); // list of new engTasks

        // target language's new object
        TargetDoc td = new TargetDoc(new HashSet(), new HashSet(), new HashSet(), new HashSet());
        td.setLanguage("All");
        SourceDoc sd = sources[i];

        // link this target Doc to the source Doc; add new target Doc to db
        Integer x = ProjectService.getInstance().linkSourceDocTargetDoc(sd, td);

        if (eng1.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[1 - 1]);
          et.setOrderNum(new Integer(1));
          engTasks.add(et);
        }

        if (eng2.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[2 - 1]);
          et.setOrderNum(new Integer(2));
          engTasks.add(et);
        }

        if (eng3.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[3 - 1]);
          et.setOrderNum(new Integer(3));
          engTasks.add(et);
        }

        if (eng4.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[4 - 1]);
          et.setOrderNum(new Integer(4));
          engTasks.add(et);
        }

        if (eng5.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[5 - 1]);
          et.setOrderNum(new Integer(5));
          engTasks.add(et);
        }

        if (eng6.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[6 - 1]);
          et.setOrderNum(new Integer(6));
          engTasks.add(et);
        }

        if (eng7.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[7 - 1]);
          et.setOrderNum(new Integer(7));
          engTasks.add(et);
        }

        if (eng8.equals("on")) { // if checked in form, then add this task to target Doc
          EngTask et = new EngTask();
          et.setNotes((String) (qvgate1.get("engOtherText")));
          et.setSourceLanguage(sd.getLanguage());
          et.setTargetLanguage(td.getLanguage());
          et.setPostQuote("true");
          et.setTargetDoc(td);
          et.setTaskName(engTaskOptions[8 - 1]);
          et.setOrderNum(new Integer(8));
          engTasks.add(et);
        }

        // for each EngTask, add it to db and link it to this targetDoc
        for (Iterator iter = engTasks.iterator(); iter.hasNext(); ) {
          EngTask et = (EngTask) iter.next();

          // link this engTask to the targetDoc; add new engTask to db
          Integer z = ProjectService.getInstance().linkTargetDocEngTask(td, et);
        }
      }
    } // end else (new target per source with tasks)

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }