/**
   * Method execute
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    MentorReqResponseForm responseForm =
        (MentorReqResponseForm) form; // TODO Auto-generated method stub
    RootMaster rootMaster = new RootMaster();
    AdvtMaster advtMaster = new AdvtMaster();
    HttpSession session = request.getSession();
    String uId = (String) session.getAttribute("uId");

    String compId = (String) session.getAttribute("compId");
    Vector allRights = (Vector) session.getAttribute("allRights");
    String adminFlag = allRights.elementAt(18).toString();
    if (((String) session.getAttribute("flag1")).equalsIgnoreCase("1")) {

      Vector<String> dataVec = new Vector<String>();
      String responseTextt = responseForm.getResponsetext();
      ////
      // System.out.println("request.getParameter...respIdrespIdrespId>>>>>"+request.getParameter("respid"));
      String respId = request.getParameter("respid");
      String complaintId = request.getParameter("compId");
      String flagforcom =
          (request.getParameter("flagforcom") != null) ? request.getParameter("flagforcom") : "";
      String recpType =
          (request.getParameter("respType") != null) ? request.getParameter("respType") : "";
      String accept1 =
          (request.getParameter("accept") != null) ? request.getParameter("accept") : "";
      //// System.out.println("to accept...in respons  .....accept....."+accept1);
      String flag = (request.getParameter("flag") != null) ? request.getParameter("flag") : "";
      if (request.getParameter("flag") != null) {
        flag = request.getParameter("flag").trim();
      } else {
        flag = "0";
      }
      //////// System.out.println("to flag...in respons  .....flag.IN RESPaCTION	...."+flag);
      String uid = (String) session.getAttribute("uId");
      java.util.Date dt = new java.util.Date();
      SimpleDateFormat sform = new SimpleDateFormat("yyyy-MM-dd, HH:mm:ss");
      String completeRemDate = sform.format(dt);
      StringTokenizer sttotal = new StringTokenizer(completeRemDate, ",");
      String creationDate = sttotal.nextToken();
      String creationTime = sttotal.nextToken();

      dataVec.add(responseTextt);
      dataVec.add(creationDate);
      dataVec.add(complaintId);
      dataVec.add(uid);
      dataVec.add(creationTime);
      dataVec.add(respId);
      dataVec.add(flag);
      dataVec.add("0");
      dataVec.add("1");
      dataVec.add("0");
      if (flag.equalsIgnoreCase("1")) {
        dataVec.add("Accept");

      } else if (flag.equalsIgnoreCase("0")) {
        dataVec.add("Reject");

      } else {
        dataVec.add("");
      }
      dataVec.add(flagforcom);
      String result = rootMaster.insertMenResponse(getDataSource(request, "advt"), dataVec);

      if ((result.equalsIgnoreCase("success")) && (!respId.equalsIgnoreCase("0"))) {
        ActionErrors errors = new ActionErrors();
        errors.clear();
        errors.add("reply", new ActionError("errors.entp.replySuccess"));
        saveErrors(request, errors);
        result = "success";
      } else if (result.equalsIgnoreCase("success")) {
        ActionErrors errors = new ActionErrors();
        errors.clear();
        errors.add("response", new ActionError("errors.entp.responseSuccess"));
        saveErrors(request, errors);
        result = "success";
      }

      if (result.equalsIgnoreCase("success")) {
        if (!respId.equalsIgnoreCase("0")) {
          Vector<String> respVec = new Vector<String>();
          respVec.add(respId);
          respVec.add("advt");
          // update `entp_rflag` for communication table.
          result = rootMaster.updateResponseFlag(getDataSource(request, "advt"), respVec);
        }
      }

      ////////////// for mail///////////////
      if (result.equalsIgnoreCase("success")) {

        EntpMaster entpMaster = new EntpMaster();
        IndvMaster indvMaster = new IndvMaster();
        Vector<String> complaintVec = new Vector<String>();
        int cid = Integer.parseInt(complaintId);
        complaintVec = entpMaster.getComplaintDetails(getDataSource(request, "advt"), cid);
        String login_id = complaintVec.elementAt(3).toString();
        String cu_id = complaintVec.elementAt(6).toString();
        String fcomId = complaintVec.elementAt(7).toString();

        Vector<String> paramVec = new Vector<String>();

        //////// System.out.println("to Enterprise.............mail");
        paramVec.add(uid);
        paramVec.add(login_id);
        if (!cu_id.equalsIgnoreCase("0")) {
          paramVec.add(cu_id);
          //////// System.out.println(" to Enterprise..in if...........mail");
        }
        Vector emailVec = indvMaster.getEmailList(getDataSource(request, "advt"), paramVec);
        //////// System.out.println("emailVec..............."+emailVec);

        Vector<String> tempMailParam = new Vector<String>();
        tempMailParam.add("Corporates"); // sender company type Advertiser
        tempMailParam.add("Student"); // receipient company type Enterprise
        if (respId.equalsIgnoreCase("0")) {
          //////// System.out.println("Response if status in brand");
          tempMailParam.add("Response"); // mail description
        } else {
          //////// System.out.println("Reply else status in brand");
          tempMailParam.add("Reply"); // mail description
        }

        // get mail text alert fot sending mail to core user and admin core user
        String mailTextLAlert =
            rootMaster.getMailText(getDataSource(request, "advt"), tempMailParam);
        Vector brandVec = (Vector) emailVec.elementAt(0);
        String brandName =
            brandVec.elementAt(0).toString() + " " + brandVec.elementAt(1).toString();
        String brandmail = brandVec.elementAt(2).toString().trim();
        String subject = "";
        if (flag.equalsIgnoreCase("1")) {
          // dataVec.add("Accept");
          subject = "Acceptance of the mentoring request having reference id as (" + fcomId + ").";

        } else if (flag.equalsIgnoreCase("0")) {
          // dataVec.add("Reject");
          subject = "Denial of the mentoring request having reference id as (" + fcomId + ").";

        } else if (respId.equalsIgnoreCase("0")) {

          subject = "Response on mentoring request Id (" + fcomId + ") By " + brandName + ".";
        } else {

          subject =
              "Reply to your mail on mentoring request Id (" + fcomId + ") By " + brandName + ".";
        }

        for (int i = 1; i < emailVec.size(); i++) {
          MailText mt = new MailText();
          Resource resr = new Resource();
          Vector coreMailVec = (Vector) emailVec.elementAt(i);
          String strMailText =
              mt.getReplyByBrand(coreMailVec, fcomId, mailTextLAlert, brandName, flag);

          ////// System.out.println("strMailText....."+strMailText);

          String strEmailStatus =
              resr.sendMail(
                  strMailText,
                  Constant.Email_Sender,
                  ((Vector) emailVec.elementAt(i)).elementAt(2).toString(),
                  subject);
          ////// System.out.println("str Email status in corpo....."+strEmailStatus);
        }
      }
      ///////////////// end mail////////////

      session.setAttribute("numCid", complaintId);
      session.setAttribute("strResult", result);

      Vector dataVec1 = new Vector();
      dataVec1.add(uId);
      dataVec1.add(compId);
      dataVec1.add(adminFlag);
      Vector advtCountVec = advtMaster.complaintCountAdvt(getDataSource(request, "advt"), dataVec1);
      session.setAttribute("advtCountVec", advtCountVec);
      //////// System.out.println("advtCountVec.............ResponseAction...........
      // "+advtCountVec);
      if (result.equalsIgnoreCase("success")) {
        session.setAttribute("flag1", "0");
      }
      return mapping.findForward(result);
    } else {

      return mapping.findForward("success");
    }
  }
  /**
   * (non-Javadoc)
   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  public ActionForward executeme(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    errors.clear();
    errors.add("header", new ActionError("errors.header"));
    errors.add("footer", new ActionError("errors.footer"));

    HttpSession hs = request.getSession();
    String uname = (String) hs.getAttribute("userid");

    // TODO 临时用来监测用
    long l_begin, l_end;
    l_begin = System.currentTimeMillis();
    commsearch.util.CommDate cdtemp = new commsearch.util.CommDate();
    commsearch.util.CommActionLog.setTempLog(
        Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
        uname,
        hs.getId(),
        "PrintEipdtl",
        "B",
        "LYC0000000",
        0);

    if (uname == null) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //							TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC5555555",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
    if (uname.trim().equals("")) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //							TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC6666666",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }

    try {

      PropertyUtils.setSimpleProperty(form, "pagerow", "32");

      String temp = (String) request.getParameter("selectwhere");

      String stemp = temp;

      if (stemp == null) stemp = "";
      if (stemp.equals("")) {
        //							TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "PrintEipdtl",
            "E",
            "LYC3333333",
            l_end - l_begin);
        return (mapping.findForward("err"));
      }

      // temp=CommonTools.stringReplace(temp,"&#39;","'");
      DataBean dbBean = new DataBean();
      String ss = "";
      if (temp.indexOf("EIVIVN") != -1) {
        try {
          dbBean.executeSelect("select eivstr,eivnum,eivtyp from eivdtl where " + temp);
        } catch (Exception e) {
          errors.add("errormessage", new ActionError("Datebase.readdb"));
          saveErrors(request, errors);
          //								TODO 临时用来监测用
          l_end = System.currentTimeMillis();
          commsearch.util.CommActionLog.setTempLog(
              Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
              uname,
              hs.getId(),
              "PrintEipdtl",
              "C",
              "LYC9999991",
              l_end - l_begin);
          return (mapping.findForward("success"));
        }
        for (int i = 0; i < dbBean.getRowCount(); i++) {
          ss = ss + "OR (EIPSTR='" + dbBean.getElementValue(i, "eivstr").trim() + "' AND ";
          ss = ss + " EIPNUM='" + dbBean.getElementValue(i, "eivnum").trim() + "' AND ";
          ss = ss + " EIPTYP='" + dbBean.getElementValue(i, "eivtyp").trim() + "')";
        }
        ss = ss.substring(2);
        temp = ss;
      }

      PropertyUtils.setSimpleProperty(form, "selectwhere", temp);

      if (setFormbeen(form, request, temp, uname).equals("0")) {
        saveErrors(request, errors);
        //							TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "PrintEipdtl",
            "E",
            "LYC8888881",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }
      log.debug("成功刷新页面");

      //						TODO 临时用来监测用
      l_end = System.currentTimeMillis();

      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "E",
          "LYC8888882",
          l_end - l_begin);
      return (mapping.findForward("success"));

    } catch (Exception e) {
      e.printStackTrace();
      //						TODO 临时用来监测用
      l_end = System.currentTimeMillis();

      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "PrintEipdtl",
          "C",
          "LYC9999999",
          l_end - l_begin);
      errors.add("errormessage", new ActionError("OrderIn.formbean"));
      saveErrors(request, errors);
      return (mapping.findForward("success"));
    }
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    ActionErrors errors = new ActionErrors();

    AuthenticationManager authenticationManager = null;
    AuthorizationManager authorizationManager = null;
    UserProvisioningManager userProvisioningManager = null;
    boolean loginSuccessful = false;
    boolean hasPermission = false;
    String uptContextName = DisplayConstants.UPT_CONTEXT_NAME;
    Application application = null;

    String serverInfoPathPort =
        (request.isSecure() ? "https://" : "http://")
            + request.getServerName()
            + ":"
            + request.getServerPort();
    ObjectFactory.initialize("upt-beans.xml");
    UPTProperties uptProperties = null;
    String urlContextForLoginApp = "";
    String centralUPTConfiguration = "";
    try {
      uptProperties = (UPTProperties) ObjectFactory.getObject("UPTProperties");
      urlContextForLoginApp =
          uptProperties.getBackwardsCompatibilityInformation().getLoginApplicationContextName();
      if (!StringUtils.isBlank(urlContextForLoginApp)) {
        serverInfoPathPort = serverInfoPathPort + "/" + urlContextForLoginApp + "/";
      } else {
        serverInfoPathPort =
            serverInfoPathPort + "/" + DisplayConstants.LOGIN_APPLICATION_CONTEXT_NAME + "/";
      }

      centralUPTConfiguration =
          uptProperties.getBackwardsCompatibilityInformation().getCentralUPTConfiguration();
      if ("true".equalsIgnoreCase(centralUPTConfiguration)) {
        uptContextName = DisplayConstants.UPT_AUTHENTICATION_CONTEXT_NAME;
      }
    } catch (UPTConfigurationException e) {
      serverInfoPathPort =
          serverInfoPathPort + "/" + DisplayConstants.LOGIN_APPLICATION_CONTEXT_NAME + "/";
    }

    //		System.out.println("centralUPTConfiguration: "+centralUPTConfiguration);
    //		System.out.println("urlContextForLoginApp: "+urlContextForLoginApp);
    //		System.out.println("serverInfoPathPort: "+serverInfoPathPort);

    LoginForm loginForm = (LoginForm) form;
    if (StringUtils.isBlank(loginForm.getApplicationContextName())
        || StringUtils.isBlank(loginForm.getLoginId())
        || StringUtils.isBlank(loginForm.getPassword())) {

      ActionForward newActionForward = new ActionForward();
      newActionForward.setPath(serverInfoPathPort);
      newActionForward.setRedirect(true);

      return newActionForward;
    }

    UserInfoHelper.setUserInfo(loginForm.getLoginId(), request.getSession().getId());
    errors.clear();

    try {
      //			System.out.println("uptContextName1: "+uptContextName);
      authorizationManager = SecurityServiceProvider.getAuthorizationManager(uptContextName);
      if (null == authorizationManager) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                DisplayConstants.ERROR_ID,
                "Unable to initialize Authorization Manager for the given application context using new configuration"));
        saveErrors(request, errors);
        if (log.isDebugEnabled())
          log.debug(
              "|"
                  + loginForm.getLoginId()
                  + "||Login|Failure|Unable to instantiate Authorization Manager for UPT application using new configuration||");
        return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
      }
    } catch (CSException cse) {

      authorizationManager = null;
    }

    if (null == authorizationManager) {

      try {

        if (null == uptContextName || uptContextName.equalsIgnoreCase("")) {
          errors.add(
              ActionErrors.GLOBAL_ERROR,
              new ActionError(
                  DisplayConstants.ERROR_ID,
                  "Unable to read the UPT Context Name from Security Config File"));
          saveErrors(request, errors);
          if (log.isDebugEnabled())
            log.debug(
                "|"
                    + loginForm.getLoginId()
                    + "||Login|Failure|Unable to read the UPT Context Name from Security Config File");
          return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
        }
      } catch (Exception ex) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                DisplayConstants.ERROR_ID,
                org.apache.commons.lang.StringEscapeUtils.escapeHtml(ex.getMessage())));
        saveErrors(request, errors);
        if (log.isDebugEnabled())
          log.debug(
              "|"
                  + loginForm.getLoginId()
                  + "||Login|Failure|Unable to read the UPT Context Name from Security Config File||");
        return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
      }
    }
    try {

      authenticationManager =
          SecurityServiceProvider.getAuthenticationManager(
              DisplayConstants.UPT_AUTHENTICATION_CONTEXT_NAME);
      if (null == authenticationManager) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                DisplayConstants.ERROR_ID,
                "Unable to initialize Authentication Manager for the given application context"));
        saveErrors(request, errors);
        if (log.isDebugEnabled())
          log.debug(
              "|"
                  + loginForm.getLoginId()
                  + "||Login|Failure|Unable to instantiate AuthenticationManager for UPT application||");
        return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
      }
    } catch (CSException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Unable to instantiate AuthenticationManager for UPT application|"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
    }
    try {
      loginSuccessful =
          authenticationManager.login(loginForm.getLoginId(), loginForm.getPassword());
    } catch (CSCredentialExpiredException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Password Expired for user name "
                + loginForm.getLoginId()
                + " and"
                + loginForm.getApplicationContextName()
                + " application|"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.EXPIRED_PASSWORD);
    } catch (CSFirstTimeLoginException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Password Expired for user name "
                + loginForm.getLoginId()
                + " and"
                + loginForm.getApplicationContextName()
                + " application|"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.EXPIRED_PASSWORD);
    } catch (CSException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Login Failed for user name "
                + loginForm.getLoginId()
                + " and"
                + loginForm.getApplicationContextName()
                + " application|"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
    }

    try {
      authorizationManager = SecurityServiceProvider.getAuthorizationManager(uptContextName);
      if (null == authorizationManager) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                DisplayConstants.ERROR_ID,
                "Unable to initialize Authorization Manager for the given application context"));
        saveErrors(request, errors);
        if (log.isDebugEnabled())
          log.debug(
              "|"
                  + loginForm.getLoginId()
                  + "||Login|Failure|Unable to instantiate Authorization Manager for UPT application||");
        return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
      }
    } catch (CSException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Unable to instantiate AuthorizationManager for UPT application|"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
    }
    try {
      hasPermission =
          authorizationManager.checkPermission(
              loginForm.getLoginId(), loginForm.getApplicationContextName(), null);
      if (!hasPermission) {
        try {
          userProvisioningManager =
              getUserProvisioningManager(
                  authorizationManager, loginForm.getApplicationContextName());
          if (null == userProvisioningManager) {
            errors.add(
                ActionErrors.GLOBAL_ERROR,
                new ActionError(
                    DisplayConstants.ERROR_ID,
                    "Unable to initialize Authorization Manager for the given application context"));
            saveErrors(request, errors);
            if (log.isDebugEnabled())
              log.debug(
                  "|"
                      + loginForm.getLoginId()
                      + "||Login|Failure|Unable to instantiate User Provisioning Manager for "
                      + loginForm.getApplicationContextName()
                      + " application||");
            return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
          }
        } catch (CSException cse) {
          errors.add(
              ActionErrors.GLOBAL_ERROR,
              new ActionError(
                  DisplayConstants.ERROR_ID,
                  org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
          saveErrors(request, errors);
          if (log.isDebugEnabled())
            log.debug(
                "|"
                    + loginForm.getLoginId()
                    + "||Login|Failure|Unable to instantiate User Provisioning Manager for |"
                    + loginForm.toString()
                    + "|"
                    + cse.getMessage());
          return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
        }
        HttpSession session = request.getSession(true);
        session.setAttribute(DisplayConstants.USER_PROVISIONING_MANAGER, userProvisioningManager);
        session.setAttribute(DisplayConstants.LOGIN_OBJECT, form);
        session.setAttribute(DisplayConstants.CURRENT_TABLE_ID, DisplayConstants.HOME_ID);

        session.setAttribute(
            Constants.UPT_USER_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
        session.setAttribute(
            Constants.UPT_PROTECTION_ELEMENT_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE,
            "false");
        session.setAttribute(
            Constants.UPT_PRIVILEGE_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
        session.setAttribute(
            Constants.UPT_GROUP_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
        session.setAttribute(
            Constants.UPT_PROTECTION_GROUP_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE,
            "false");
        session.setAttribute(
            Constants.UPT_ROLE_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
        session.setAttribute(
            Constants.UPT_INSTANCE_LEVEL_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");

        //				errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(DisplayConstants.ERROR_ID,
        // "Access permission denied for the application" ));
        //				saveErrors( request,errors );
        //				if (log.isDebugEnabled())
        //					log.debug("|"+loginForm.getLoginId()+
        //							"||Login|Failure|User "+loginForm.getLoginId()+" doesnot have permission on
        // "+loginForm.getApplicationContextName()+" application||");

        return mapping.findForward(ForwardConstants.LOGIN_SUCCESS);
      }
    } catch (CSException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Error in checking permission|"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
    }

    try {
      // UserProvisioningManager upm = (UserProvisioningManager)authorizationManager;
      application = authorizationManager.getApplication(loginForm.getApplicationContextName());
      userProvisioningManager =
          getUserProvisioningManager(authorizationManager, loginForm.getApplicationContextName());
      if (null == userProvisioningManager) {
        errors.add(
            ActionErrors.GLOBAL_ERROR,
            new ActionError(
                DisplayConstants.ERROR_ID,
                "Unable to initialize Authorization Manager for the given application context"));
        saveErrors(request, errors);
        if (log.isDebugEnabled())
          log.debug(
              "|"
                  + loginForm.getLoginId()
                  + "||Login|Failure|Unable to instantiate User Provisioning Manager for "
                  + loginForm.getApplicationContextName()
                  + " application||");
        return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
      }
    } catch (CSException cse) {
      errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError(
              DisplayConstants.ERROR_ID,
              org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())));
      saveErrors(request, errors);
      if (log.isDebugEnabled())
        log.debug(
            "|"
                + loginForm.getLoginId()
                + "||Login|Failure|Unable to instantiate User Provisioning Manager for |"
                + loginForm.toString()
                + "|"
                + cse.getMessage());
      return mapping.findForward(ForwardConstants.LOGIN_FAILURE);
    }

    HttpSession session = request.getSession(true);
    session.setAttribute(DisplayConstants.USER_PROVISIONING_MANAGER, userProvisioningManager);
    session.setAttribute(DisplayConstants.LOGIN_OBJECT, form);
    session.setAttribute(DisplayConstants.CURRENT_TABLE_ID, DisplayConstants.HOME_ID);

    authenticationManager = null;
    authorizationManager = null;

    try {
      processUptOperation(
          userProvisioningManager,
          loginForm.getLoginId(),
          application.getApplicationName(),
          session);
    } catch (CSTransactionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    if (((LoginForm) form).getApplicationContextName().equalsIgnoreCase(uptContextName)) {
      session.setAttribute(DisplayConstants.ADMIN_USER, DisplayConstants.ADMIN_USER);
      if (log.isDebugEnabled())
        log.debug(
            session.getId()
                + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()
                + "||Login|Success|Login Successful for user "
                + loginForm.getLoginId()
                + " and "
                + loginForm.getApplicationContextName()
                + " application, Forwarding to the Super Admin Home Page||");
      return (mapping.findForward(ForwardConstants.ADMIN_LOGIN_SUCCESS));
    } else {
      if (log.isDebugEnabled())
        log.debug(
            session.getId()
                + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()
                + "||Login|Success|Login Successful for user "
                + loginForm.getLoginId()
                + " and "
                + loginForm.getApplicationContextName()
                + " application, Forwarding to the Home Page||");
      return (mapping.findForward(ForwardConstants.LOGIN_SUCCESS));
    }
  }
  /**
   * (non-Javadoc)
   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  public ActionForward executeme(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    errors.clear();
    errors.add("header", new ActionError("errors.header"));
    errors.add("footer", new ActionError("errors.footer"));

    HttpSession hs = request.getSession();
    String uname = (String) hs.getAttribute("userid");

    // TODO 临时用来监测用
    long l_begin, l_end;
    l_begin = System.currentTimeMillis();
    commsearch.util.CommDate cdtemp = new commsearch.util.CommDate();
    commsearch.util.CommActionLog.setTempLog(
        Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
        uname,
        hs.getId(),
        "ReturnOrder",
        "B",
        "LYC0000000",
        0);

    if (uname == null) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //				TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "E",
          "LYC5555555",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
    if (uname.trim().equals("")) {
      errors.add("errormessage", new ActionError("NoName"));
      saveErrors(request, errors);
      //				TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "E",
          "LYC6666666",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }

    try {
      PropertyUtils.setSimpleProperty(form, "message", "0");

      Date now = new Date();
      PropertyUtils.setSimpleProperty(
          form, "nowdate", com.idn.util.FormatDate.format(now, "yyyy-MM-dd"));

      String temp = request.getParameter("eponum");
      String queryid = request.getParameter("queryid");
      String selectwhere = request.getParameter("selectwhere");

      if (selectwhere == null) {
        queryid = (String) PropertyUtils.getSimpleProperty(form, "queryid");
        selectwhere = (String) PropertyUtils.getSimpleProperty(form, "selectwhere");
      }
      String stemp = selectwhere;

      if (stemp == null) stemp = "";
      if (stemp.equals("")) {
        //				TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "ReturnOrder",
            "E",
            "LYC3333333",
            l_end - l_begin);
        return (mapping.findForward("err"));
      }

      PropertyUtils.setSimpleProperty(form, "queryid", queryid);
      PropertyUtils.setSimpleProperty(form, "selectwhere", selectwhere);

      String flag = ((String) PropertyUtils.getSimpleProperty(form, "flag")).trim();

      if (flag.equals("")) {
        setFormbeen(form, request, selectwhere, uname);
        //				TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "ReturnOrder",
            "E",
            "LYC8888881",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }

      String epoflg = (String) PropertyUtils.getSimpleProperty(form, "epoflg");
      String freeformstate = (String) PropertyUtils.getSimpleProperty(form, "freeformstate");

      String eponum = (String) PropertyUtils.getSimpleProperty(form, "eponum");
      String epostr = (String) PropertyUtils.getSimpleProperty(form, "epostr");
      String epostn = (String) PropertyUtils.getSimpleProperty(form, "epostn");
      String eposdt = (String) PropertyUtils.getSimpleProperty(form, "eposdt");
      String epordt = (String) PropertyUtils.getSimpleProperty(form, "epordt");

      eposdt = CommonTools.stringReplace(eposdt, "-", "").trim();
      eposdt = eposdt.substring(2);
      epordt = CommonTools.stringReplace(epordt, "-", "").trim();
      epordt = epordt.substring(2);

      String epordtm = (String) PropertyUtils.getSimpleProperty(form, "epordtmshow");
      String epordtm2 = (String) PropertyUtils.getSimpleProperty(form, "epordtm2show");
      String operator = (String) PropertyUtils.getSimpleProperty(form, "operatorid");
      String operdate = (String) PropertyUtils.getSimpleProperty(form, "operdate");
      String opertime = (String) PropertyUtils.getSimpleProperty(form, "opertime");

      // SQLBean sis=new SQLBean();

      DataBean dbBean = new DataBean();
      String strsql1 = "select * from ORDERR where " + selectwhere + "";
      try {
        dbBean.executeSelect(strsql1);
      } catch (Exception e) {
        e.printStackTrace();
        errors.add("errormessage", new ActionError("Datebase.readdb"));
        //				TODO 临时用来监测用
        l_end = System.currentTimeMillis();
        commsearch.util.CommActionLog.setTempLog(
            Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
            uname,
            hs.getId(),
            "ReturnOrder",
            "E",
            "LYC8888882",
            l_end - l_begin);
        return (mapping.findForward("success"));
      }

      String strsql[] = new String[1];
      if (dbBean.getRowCount() == 0) {
        strsql[0] =
            "insert into ORDERR (eponum,epostr,epostn,eposdt,epordt,epordtm,epoflg,operator,operdate,opertime,epordtm2) values('"
                + eponum
                + "' ,'"
                + epostr
                + "' ,'"
                + epostn
                + "','"
                + eposdt
                + "','"
                + epordt
                + "','"
                + epordtm
                + "','0','"
                + operator
                + "','"
                + operdate
                + "','"
                + opertime
                + "','"
                + epordtm2
                + "')";
        // 第一次进入并且orderr中不存在记录
        // int retrunint1=sis.executeSQL(strsql);

        // 写日志(XIAOAI处理)
        commsearch.util.CommActionLog cal = new commsearch.util.CommActionLog();

        cal.setAct_user(uname);
        cal.setAct_from("homeworldReturnOrder");
        cal.setAct_do("INS");
        cal.setAct_key(temp);
        cal.setAct_table("ORDERR");
        cal.setAct_ip(request.getRemoteAddr());
        cal.setAct_memo("回复插入定单编号为" + temp);
        cal.setAct_me("");
        cal.setActionLog();
      } else {
        operator = uname;
        operdate = com.idn.util.FormatDate.format(now, "yyMMdd");
        opertime = com.idn.util.FormatDate.format(now, "hh:mm:ss");

        strsql[0] =
            "update ORDERR set epotrf='', epordt='"
                + epordt
                + "',epordtm='"
                + epordtm
                + "',epordtm2='"
                + epordtm2
                + "', operdate='"
                + operdate
                + "',opertime='"
                + opertime
                + "',operator='"
                + operator
                + "' where eponum='"
                + eponum
                + "'";

        // int returnint=sis.executeSQL(strsql);

        // 写日志(XIAOAI处理)
        commsearch.util.CommActionLog cal = new commsearch.util.CommActionLog();

        cal.setAct_user(uname);
        cal.setAct_from("homeworldReturnOrder");
        cal.setAct_do("UPD");
        cal.setAct_key(temp);
        cal.setAct_table("ORDERR");
        cal.setAct_ip(request.getRemoteAddr());
        cal.setAct_memo("回复修改定单编号为" + temp);
        cal.setAct_me("");
        cal.setActionLog();
      }
      DynaSqlBean dybBean = new DynaSqlBean();
      dybBean.setSql(strsql);
      dybBean.executeBatch();
      // setFormbeen(form,request,selectwhere,uname);

      PropertyUtils.setSimpleProperty(form, "freeformstate", "0");

      PropertyUtils.setSimpleProperty(form, "message", "1");

      //			TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "E",
          "LYC8888888",
          l_end - l_begin);
      return (mapping.findForward("success"));

    } catch (Exception e) {
      e.printStackTrace();
      errors.add("errormessage", new ActionError("Database.formbean"));
      saveErrors(request, errors);
      //			TODO 临时用来监测用
      l_end = System.currentTimeMillis();
      commsearch.util.CommActionLog.setTempLog(
          Long.parseLong(cdtemp.getNow(cdtemp.FORMAT_ALL_NOSIGN)),
          uname,
          hs.getId(),
          "ReturnOrder",
          "C",
          "LYC9999999",
          l_end - l_begin);
      return (mapping.findForward("success"));
    }
  }