/**
   * Ejecuta la validacion en la p\u00E1gina JSP <code>redactarMail.jsp</code>
   *
   * @param mapping El mapeo utilizado para seleccionar esta instancia
   * @param request La petici\u00F3n que se est\u00E1 procesando
   * @return errors Coleccion de errores producidos por la validaci\u00F3n, si no hubieron errores
   *     se retorna <code>null</code>
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    PropertyValidator validar = new PropertyValidatorImpl();

    try {
      if (request.getParameter("ayuda") != null
          && request.getParameter("ayuda").equals("siEnviarEmail")) {
        LogSISPE.getLog().info("request redactarMail");
        validar.validateMandatory(
            errors, "emailContacto", this.emailEnviarCotizacion, "errors.requerido", "Para");
        if (errors.isEmpty()) {
          validar.validateFormato(
              errors,
              "emailContacto",
              this.emailEnviarCotizacion,
              false,
              "^[A-Za-z0-9_]+@[A-Za-z0-9_]|[A-Za-z0-9_]+@[A-Za-z0-9_]+\\.[A-Za-z0-9_]",
              "errors.formato.email");
        }
        if (this.ccMail != null && !this.ccMail.trim().isEmpty()) {
          validar.validateFormato(
              errors,
              "emailContactoConCopia",
              this.ccMail,
              false,
              "^[A-Za-z0-9_]+@[A-Za-z0-9_]|[A-Za-z0-9_]+@[A-Za-z0-9_]+\\.[A-Za-z0-9_]",
              "errors.formato.email");
        }
        validar.validateMandatory(
            errors, "asuntoMail", this.asuntoMail, "errors.requerido", "Asunto");
        validar.validateMandatory(
            errors, "textoMail", this.textoMail, "errors.requerido", "Contenido");
        request
            .getSession()
            .setAttribute(
                "ec.com.smx.sic.sispe.textoMail", this.textoMail != null ? this.textoMail : "");
        request
            .getSession()
            .setAttribute(
                "ec.com.smx.sic.sispe.asuntoMail", this.asuntoMail != null ? this.asuntoMail : "");
        request
            .getSession()
            .setAttribute(
                "ec.com.smx.sic.sispe.paraMail",
                this.emailEnviarCotizacion != null ? this.emailEnviarCotizacion : "");
        if (errors.size() > 0) {
          request.getSession().setAttribute(SessionManagerSISPE.MENSAJES_SISPE, "ok");
        }
      }
    } catch (Exception ex) {
      LogSISPE.getLog().error("error de aplicaci\u00F3n", ex);
    }
    return errors;
  }
 @Override
 public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
   System.out.println("In Additional Links Form");
   ActionErrors errors = new ActionErrors();
   setSearchAttributes(request);
   if (errors.size() > 0) {
     status = AccessionConstants.FAILURE;
   } else {
     status = AccessionConstants.SUCCESS;
   }
   return errors;
 }
  /**
   * perform method for the action bean which allows users the ability to request a new password
   * email.
   *
   * @param mapping Description of Parameter
   * @param form Description of Parameter
   * @param request Description of Parameter
   * @param response Description of Parameter
   * @return Description of the Returned Value
   */
  public ActionForward performSub(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    String reqAction = (String) request.getParameter("action");
    if (reqAction == null) {
      reqAction = (String) request.getAttribute("action");
    }
    if (reqAction == null) {
      reqAction = "init";
    }

    // Is there a currently logged on user?
    HttpSession currentSession = request.getSession();
    CleanwiseUser userLoggedIn = (CleanwiseUser) currentSession.getAttribute(Constants.APP_USER);
    if ((currentSession == null) || (userLoggedIn == null)) {
      return mapping.findForward("/userportal/logon");
    }

    if (reqAction.equals("init") || "jd_order_status".equals(reqAction)) {
      try {
        JdOrderStatusLogic.listOrders(request, form);
      } catch (Exception e) {
        System.err.println("List error: " + e);
      }
    } else if (reqAction.equals("sort")) {
      try {
        JdOrderStatusLogic.sort(request, form);
      } catch (Exception e) {
        System.err.println("Sort error: " + e);
      }
    } else if (reqAction.equals("search")) {
      ActionErrors ae = new ActionErrors();
      try {
        ae = JdOrderStatusLogic.search(request, form);
      } catch (Exception e) {
        System.err.println("search error: " + e);
      }

      if (ae.size() > 0) {
        saveErrors(request, ae);
      }
      return (mapping.findForward("success"));
    }

    return (mapping.findForward("display"));
  }
  /**
   * <br>
   * [機 能] 入力チェックを行う <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param con コネクション
   * @param gsMsg GsMessage
   * @param usrSid ユーザSID
   * @return エラー
   * @throws SQLException SQL実行時例外
   */
  public ActionErrors validateCmnDownload(Connection con, GsMessage gsMsg, int usrSid)
      throws SQLException {
    ActionErrors errors = new ActionErrors();
    ActionMessage msg = null;

    if (StringUtil.isNullZeroString(binSid__)) {
      // 未入力
      msg =
          new ActionMessage("error.input.required.text", gsMsg.getMessage(GSConstApi.TEXT_BIN_SID));
      StrutsUtil.addMessage(errors, msg, "binSid");

    } else if (!ValidateUtil.isNumber(binSid__)) {
      // 数字チェック
      msg =
          new ActionMessage(
              "error.input.number.hankaku", gsMsg.getMessage(GSConstApi.TEXT_BIN_SID));
      StrutsUtil.addMessage(errors, msg, "binSid");
    }

    if (StringUtil.isNullZeroString(smlSid__)) {
      // 未入力
      msg =
          new ActionMessage("error.input.required.text", gsMsg.getMessage(GSConstApi.TEXT_SML_SID));
      StrutsUtil.addMessage(errors, msg, "smlSid");

    } else if (!ValidateUtil.isNumber(smlSid__)) {
      // 数字チェック
      msg =
          new ActionMessage(
              "error.input.number.hankaku", gsMsg.getMessage(GSConstApi.TEXT_SML_SID));
      StrutsUtil.addMessage(errors, msg, "smlSid");
    }
    if (errors.size() < 1) {
      // ショートメール添付ファイルチェック
      if (!__isFileOk(usrSid, con)) {
        msg =
            new ActionMessage(
                "search.notfound.tdfkcode", gsMsg.getMessage(GSConstApi.TEXT_TEMP_FILE));
        StrutsUtil.addMessage(errors, msg, "smlSid");
      }
    }

    return errors;
  }
示例#5
0
  /**
   * <br>
   * [機 能] 条件1~5の入力チェックを行う <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param errors ActionErrors
   * @param req リクエスト
   */
  public void validateCondition(ActionErrors errors, HttpServletRequest req) {

    int errSize = errors.size();

    // 条件チェック
    errSize =
        conditionCheck(
            sml340condition1__,
            sml340conditionText1__,
            errSize,
            errors,
            getInterMessage(req, GSConstSmail.TEXT_CONDITION1));
    errSize =
        conditionCheck(
            sml340condition2__,
            sml340conditionText2__,
            errSize,
            errors,
            getInterMessage(req, GSConstSmail.TEXT_CONDITION2));
    errSize =
        conditionCheck(
            sml340condition3__,
            sml340conditionText3__,
            errSize,
            errors,
            getInterMessage(req, GSConstSmail.TEXT_CONDITION3));
    errSize =
        conditionCheck(
            sml340condition4__,
            sml340conditionText4__,
            errSize,
            errors,
            getInterMessage(req, GSConstSmail.TEXT_CONDITION4));
    errSize =
        conditionCheck(
            sml340condition5__,
            sml340conditionText5__,
            errSize,
            errors,
            getInterMessage(req, GSConstSmail.TEXT_CONDITION5));
  }
示例#6
0
  /**
   * <br>
   * [機 能] 条件の入力チェックを行う <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param condition 条件No
   * @param conditionText 条件テキスト
   * @param errSize エラーサイズ
   * @param errors ActionErrors
   * @param textCondition テキスト条件
   * @return エラー数
   */
  public int conditionCheck(
      String condition,
      String conditionText,
      int errSize,
      ActionErrors errors,
      String textCondition) {

    // 条件
    if (condition != null) {

      GSValidateSmail.validateTextBoxInput(
          errors,
          conditionText,
          "conditionText" + condition,
          textCondition,
          GSConstSmail.MAXLEN_CONDITION_KEYWORD,
          true);
    }
    errSize = errors.size();
    return errSize;
  }
  protected boolean validateBondSelections(DynaActionForm form, RequestContext ctx) {
    if (!StringUtils.isBlank(form.getString(HIDDEN_BOND_SLAVE_INTERFACES))) {
      form.set(BOND_SLAVE_INTERFACES, form.getString(HIDDEN_BOND_SLAVE_INTERFACES).split(","));
    }

    String[] slaves = (String[]) form.get(BOND_SLAVE_INTERFACES);
    ActionErrors errors = new ActionErrors();

    // if we are trying to create a bond but have not specified a name or at
    // least one slave interface
    if (form.getString(BOND_TYPE).equals(CREATE_BOND_VALUE)
        && (StringUtils.isBlank(form.getString(BOND_INTERFACE))
            || slaves.length < 1
            || StringUtils.isBlank(slaves[0]))) {
      errors.add(
          ActionMessages.GLOBAL_MESSAGE, new ActionMessage("kickstart.bond.not.defined.jsp"));
    }

    final String ipv4addressPattern =
        "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
            + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
            + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
            + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";

    /*
     * The IPv6 address regex was created by Stephen Ryan at Dartware
     * and taken from this forum: http://forums.intermapper.com/viewtopic.php?t=452
     * It is licenced under a Creative Commons Attribution-ShareAlike 3.0 Unported
     * License. We can freely use it in (even in commercial products) as long as
     * we attribute its creation to him, so don't remove this message.
     */
    final String ipv6addressPattern =
        "^(((?=(?>.*?::)(?!.*::)))(::)?([0-9A-"
            + "F]{1,4}::?){0,5}|([0-9A-F]{1,4}:){6})(\\2([0-9A-F]{1,4}(::?|$))"
            + "{0,2}|((25[0-5]|(2[0-4]|1\\d|[1-9])?\\d)(\\.|$)){4}|[0-9A-F]{1,"
            + "4}:[0-9A-F]{1,4})(?<![^:]:|\\.)\\z";

    if (form.getString(BOND_STATIC).equals(STATIC_BOND_VALUE)) {
      String address = form.getString(BOND_IP_ADDRESS);
      String netmask = form.getString(BOND_NETMASK);
      String gateway = form.getString(BOND_GATEWAY);

      if (!address.matches(ipv4addressPattern) && !address.matches(ipv6addressPattern)) {
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("kickstart.bond.bad.ip.address.jsp"));
      }

      if (!netmask.matches(ipv4addressPattern) && !netmask.matches(ipv6addressPattern)) {
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("kickstart.bond.bad.netmask.jsp"));
      }

      if (!gateway.matches(ipv4addressPattern) && !gateway.matches(ipv6addressPattern)) {
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("kickstart.bond.bad.ip.address.jsp"));
      }
    }

    if (errors.size() > 0) {
      addErrors(ctx.getRequest(), errors);
      return false;
    }
    return true;
  }
  /**
   * Overrides the executeSecureAction method of SecureAction class.
   *
   * @param mapping object of ActionMapping
   * @param form : actionForm
   * @param request object of HttpServletRequest
   * @param response object of HttpServletResponse
   * @throws Exception generic exception
   * @return ActionForward : ActionForward
   */
  @Override
  public ActionForward executeSecureAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    DAO dao = null;
    String pageOf = null;
    try {
      final SessionDataBean sessionDataBean =
          (SessionDataBean) request.getSession().getAttribute(Constants.SESSION_DATA);
      dao = AppUtility.openDAOSession(sessionDataBean);
      final SpecimenArrayAliquotForm specimenArrayAliquotForm = (SpecimenArrayAliquotForm) form;
      pageOf = request.getParameter(Constants.PAGE_OF);
      final StorageContainerForSpArrayBizLogic bizLogic = new StorageContainerForSpArrayBizLogic();
      final SessionDataBean sessionData =
          (SessionDataBean) request.getSession().getAttribute(Constants.SESSION_DATA);
      final List<NameValueBean> storagePositionListForSpecimenArrayAliquot =
          AppUtility.getStoragePositionTypeListForTransferEvent();
      request.setAttribute(
          "storagePositionListForSpecimenArrayAliquot", storagePositionListForSpecimenArrayAliquot);
      final String exceedingMaxLimit = "false";
      if (specimenArrayAliquotForm.getButtonClicked().equalsIgnoreCase("submit")) {
        final Map tempAliquotMap = new HashMap();
        if (specimenArrayAliquotForm.getCheckedButton().equals("1")) {
          tempAliquotMap.put("label", specimenArrayAliquotForm.getParentSpecimenArrayLabel());
        } else {
          tempAliquotMap.put("barcode", specimenArrayAliquotForm.getBarcode());
        }
        tempAliquotMap.put("aliquotcount", specimenArrayAliquotForm.getAliquotCount());
        request.getSession().setAttribute("tempAliquotMap", tempAliquotMap);
      } else if (specimenArrayAliquotForm.getButtonClicked().equalsIgnoreCase("create")) {
        boolean arePropertiesChanged = false;
        final Map tempAliquotMap = (HashMap) request.getSession().getAttribute("tempAliquotMap");
        final String label = (String) tempAliquotMap.get("label");
        final String barcode = (String) tempAliquotMap.get("barcode");
        if (specimenArrayAliquotForm.getCheckedButton().equals("1")) {
          if (label == null
              || !label
                  .trim()
                  .equalsIgnoreCase(
                      specimenArrayAliquotForm.getParentSpecimenArrayLabel().trim())) {
            arePropertiesChanged = true;
          }
        } else {
          if (barcode == null
              || !barcode.trim().equalsIgnoreCase(specimenArrayAliquotForm.getBarcode().trim())) {
            arePropertiesChanged = true;
          }
        }
        final String aliquotcount = (String) tempAliquotMap.get("aliquotcount");
        if (!aliquotcount
            .trim()
            .equalsIgnoreCase(specimenArrayAliquotForm.getAliquotCount().trim())) {
          arePropertiesChanged = true;
        }

        /**
         * Repopulate the form with storage container locations in case user has changed any of
         * label/barcode, aliquot count, quantity per aliquot.
         */
        if (arePropertiesChanged == true) {
          specimenArrayAliquotForm.setParentSpecimenArrayLabel(label);
          specimenArrayAliquotForm.setAliquotCount(aliquotcount);
          specimenArrayAliquotForm.setBarcode(barcode);

          ActionErrors errors = this.getActionErrors(request);

          if (errors == null) {
            errors = new ActionErrors();
          }
          if (arePropertiesChanged == true) {
            errors.add(
                ActionErrors.GLOBAL_ERROR,
                new ActionError("errors.specimenArrayAliquots.reSubmit"));
          }

          TreeMap containerMap = new TreeMap();
          this.checkForSpecimenArray(request, specimenArrayAliquotForm, dao);
          // int aliquotCount =
          // Integer.parseInt(specimenArrayAliquotForm.getAliquotCount());
          final Long id = (Long) request.getAttribute(Constants.STORAGE_TYPE_ID);
          containerMap =
              bizLogic.getAllocatedContainerMapForSpecimenArray(id.longValue(), sessionData, dao);
          this.populateAliquotsStorageLocations(specimenArrayAliquotForm, containerMap);
          request.setAttribute(Constants.AVAILABLE_CONTAINER_MAP, containerMap);
          request.setAttribute(Constants.PAGE_OF, Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT);
          this.saveErrors(request, errors);
          return mapping.findForward(Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT);

        } else {
          // TODO
          specimenArrayAliquotForm.setButtonClicked("none");
          return mapping.findForward(Constants.COMMON_ADD_EDIT);
        }
      }

      if (Constants.PAGE_OF_SPECIMEN_ARRAY_ALIQUOT_SUMMARY.equals(pageOf)) {
        final Map map = (Map) request.getAttribute("forwardToHashMap");

        if (map != null) {
          // TODO
          specimenArrayAliquotForm.setSpecimenClass(
              CommonUtilities.toString(map.get(Constants.ALIQUOT_SPECIMEN_CLASS)));
          specimenArrayAliquotForm.setSpecimenArrayType(
              CommonUtilities.toString(map.get(Constants.ALIQUOT_SPECIMEN_ARRAY_TYPE)));
          specimenArrayAliquotForm.setAliquotCount(
              CommonUtilities.toString(map.get(Constants.ALIQUOT_ALIQUOT_COUNTS)));
          final Collection specimenTypesCollection =
              (Collection) map.get(Constants.ALIQUOT_SPECIMEN_TYPES);
          final List specimenTypeList =
              this.setSpecimenTypes(specimenTypesCollection, specimenArrayAliquotForm);
          request.setAttribute(Constants.SPECIMEN_TYPE_LIST, specimenTypeList);
          String containerNameKey = "";
          String posDim1Key = "";
          String posDim2Key = "";
          /** This code is added to set storage positions in case of manual mode. bug 15085 */
          for (int iCount = 1;
              iCount <= Integer.parseInt(specimenArrayAliquotForm.getAliquotCount());
              iCount++) {
            if (map.get("radio_" + iCount) != null && map.get("radio_" + iCount).equals("2")) {
              containerNameKey = "SpecimenArray:" + iCount + "_StorageContainer_name";
              posDim1Key = "SpecimenArray:" + iCount + "_positionDimensionOne";
              posDim2Key = "SpecimenArray:" + iCount + "_positionDimensionTwo";
              map.put(containerNameKey, map.get(containerNameKey + "_fromMap"));
              if (!map.get(posDim1Key + "_fromMap").equals("")) {
                map.put(posDim1Key, map.get(posDim1Key + "_fromMap"));
              }
              if (!map.get(posDim2Key + "_fromMap").equals("")) {
                map.put(posDim2Key, map.get(posDim2Key + "_fromMap"));
              }
            }
          }
          specimenArrayAliquotForm.setSpecimenArrayAliquotMap(map);
        }

        final ActionErrors errors = this.getActionErrors(request);

        if (errors == null || errors.size() == 0) {
          final ActionMessages messages = new ActionMessages();
          messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("aliquots.success"));
          this.saveMessages(request, messages);
        }
        return mapping.findForward(pageOf);
      }

      Map containerMap = new HashMap();
      if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(
          request.getParameter(Constants.PAGE_OF))) {
        pageOf = this.validate(request, specimenArrayAliquotForm);

        if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(pageOf)) {
          pageOf = this.checkForSpecimenArray(request, specimenArrayAliquotForm, dao);

          if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(pageOf)) {
            final int aliquotCount = Integer.parseInt(specimenArrayAliquotForm.getAliquotCount());
            final Long id = (Long) request.getAttribute(Constants.STORAGE_TYPE_ID);
            containerMap =
                bizLogic.getAllocatedContainerMapForSpecimenArray(id.longValue(), sessionData, dao);
            pageOf = this.checkForSufficientAvailablePositions(request, containerMap, aliquotCount);

            if (Constants.PAGE_OF_SPECIMEN_ARRAY_CREATE_ALIQUOT.equals(pageOf)) {
              final ActionErrors errors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
              if (errors == null || errors.size() == 0) {
                this.populateAliquotsStorageLocations(specimenArrayAliquotForm, containerMap);
              }
            }
          }
        }
      }
      request.setAttribute(Constants.EXCEEDS_MAX_LIMIT, exceedingMaxLimit);
      request.setAttribute(Constants.AVAILABLE_CONTAINER_MAP, containerMap);
      request.setAttribute(Constants.PAGE_OF, pageOf);
    } finally {
      dao.closeSession();
    }
    return mapping.findForward(pageOf);
  }
示例#9
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 request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @param form Description of Parameter
   * @return Description of the Returned Value
   * @exception IOException if an input/output error occurs
   * @exception ServletException if a servlet exception occurs
   */
  public ActionForward performSub(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    // Determine the store manager action to be performed
    String action = request.getParameter("action");
    if (action == null) {
      action = "init";
    }

    SessionTool st = new SessionTool(request);

    // Is there a currently logged on user?
    if (st.checkSession() == false) {
      return mapping.findForward("/userportal/logon");
    }

    MessageResources mr = getResources(request);

    // Get the form buttons as specified in the properties file.
    String saveStr = getMessage(mr, request, "global.action.label.save");
    String deleteStr = getMessage(mr, request, "global.action.label.delete");
    String searchStr = getMessage(mr, request, "global.action.label.search");
    String viewallStr = getMessage(mr, request, "admin.button.viewall");
    String createStr = getMessage(mr, request, "admin.button.create");

    // Determine if doing site configuration
    boolean siteConfig = false;
    String siteConfigS = request.getParameter("siteconfig");
    if (siteConfigS != null && siteConfigS.equals("true")) {
      siteConfig = true;
    }

    // Process the action
    try {

      if (action.equals("init")) {
        if (siteConfig) {
          // we're doing site config
          SiteMgrLogic.initConfig(request, form);
        } else {
          SiteMgrLogic.init(request, form);
        }
        return (mapping.findForward("success"));
      } else if (action.equals(searchStr)) {
        if (siteConfig) {
          SiteMgrLogic.searchConfig(request, form);
        } else {
          SiteMgrLogic.search(request, form);
        }
        return (mapping.findForward("success"));
      } else if (action.equals(viewallStr)) {
        if (siteConfig) {
          SiteMgrLogic.getAllConfig(request, form);
        } else {
          SiteMgrLogic.getAll(request, form);
        }
        return (mapping.findForward("success"));
      } else if (action.equals(createStr)) {
        SiteMgrLogic.addSite(request, form);
        return (mapping.findForward("sitedetail"));
      } else if (action.equals("site_workflow")) {
        SiteMgrLogic.fetchSiteWorkflow(request, form);
        return (mapping.findForward("success"));
      } else if (action.equals("updatesite") || action.equals(saveStr)) {

        if (siteConfig) {
          SiteMgrLogic.updateConfig(request, form);
          return (mapping.findForward("success"));
        } else {
          ActionErrors ae = SiteMgrLogic.updateSite(request, form);
          if (ae.size() > 0) {
            saveErrors(request, ae);
          }
          return (mapping.findForward("sitedetail"));
        }
      } else if (action.equals("sitedetail")) {
        SiteMgrLogic.getDetail(request, form);
        return (mapping.findForward("sitedetail"));
      } else if (action.equals("sitebudgets")) {
        SiteMgrLogic.getBudgets(request, form);
        return (mapping.findForward("sitebudgets"));
      } else if (action.equals("Set budgets")) {
        SiteMgrLogic.setBudgets(request, form);
        SiteMgrLogic.getBudgets(request, form);
        return (mapping.findForward("sitebudgets"));
      } else if (action.equals(deleteStr)) {
        ActionErrors ae = SiteMgrLogic.delete(request, form);
        if (ae.size() > 0) {
          saveErrors(request, ae);
          return (mapping.findForward("sitedetail"));
        }
        return (mapping.findForward("main"));
      } else if (action.equals("sort")) {
        SiteMgrLogic.sort(request, form);
        return (mapping.findForward("success"));
      } else if (action.equals("inventory_update")) {
        ActionErrors ae = SiteMgrLogic.lookupInventoryData(request, form);
        if (ae.size() > 0) {
          saveErrors(request, ae);
        }
        return (mapping.findForward("success"));
      } else if (action.equals("update_site_inventory")) {
        ActionErrors ae = SiteMgrLogic.updateInventoryData(request, form);
        if (ae.size() > 0) {
          saveErrors(request, ae);
        }
        return (mapping.findForward("success"));
      } else if (action.equals("update_site_controls")) {
        ActionErrors ae = SiteMgrLogic.updateShoppingRestrictions(request, form);
        if (ae.size() > 0) {
          saveErrors(request, ae);
        }
        return (mapping.findForward("success"));
      } else if (action.equals("list.all.bsc")) {
        ActionErrors ae = SiteMgrLogic.listAll(action, request, form);
        if (ae.size() > 0) {
          saveErrors(request, ae);
        }
        return (mapping.findForward("success"));
      } else if (action.equals("bscRelationships")) {
        ActionErrors ae = SiteMgrLogic.listBscRelationships(action, request, form);
        if (ae.size() > 0) {
          saveErrors(request, ae);
        }
        return (mapping.findForward("bscRelationships"));
      } else if (action.equals("bscdetail")) {
        return (mapping.findForward("bscdetail"));
      } else if (action.equals("bsc_modify") || action.equals("bsc_add")) {
        SiteMgrLogic.updateBSC(request, form);
        return (mapping.findForward("bscdetail"));
      } else if (action.equals("saveFieldValues")) {
        SiteMgrLogic.saveFieldValues(request, form);
        return (mapping.findForward("success"));
      } else {
        SiteMgrLogic.init(request, form);
        return (mapping.findForward("success"));
      }
    } catch (Exception e) {
      e.printStackTrace();
      ActionErrors ae = new ActionErrors();
      ae.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("error.genericError", "Uncaught Exception: " + e.getMessage()));
      saveErrors(request, ae);
      return (mapping.findForward("failure"));
    }
  }
  /**
   * @param errors
   * @param request
   * @return
   * @throws Exception
   */
  public int validarNumOrden(ActionMessages errors, HttpServletRequest request) throws Exception {
    ActionErrors errorsTemp = null;
    PropertyValidator validar = null;

    ArrayList estadosDetallesPedido = null;
    boolean[] autorizacionesIncorrectas = null;

    if (this.botonGuardarOrdenesCompra != null) {
      validar = new PropertyValidatorImpl();
      autorizacionesIncorrectas = new boolean[this.numerosAutorizaciones.length];

      LogSISPE.getLog().info("Valores arreglo boolean");
      for (boolean a : autorizacionesIncorrectas) {
        LogSISPE.getLog().info("a1: {}", a);
      }

      for (int i = 0; i < this.numerosAutorizaciones.length; i++) {
        if (this.numerosAutorizaciones[i].equals("")
            && this.observacionesNumerosAutorizaciones[i].equals("") == false) {
          errors.add(
              "numerosAutorizaciones",
              new ActionMessage("errors.numeroAutorizacionOrdenCompraObligatorio"));
          autorizacionesIncorrectas[i] = true;
        } else if (this.numerosAutorizaciones[i].equals("") == false
            && this.observacionesNumerosAutorizaciones[i].equals("")) {
          errors.add(
              "observacionesNumerosAutorizaciones",
              new ActionMessage("errors.observacionAutorizacionOrdenCompraObligatorio"));
          autorizacionesIncorrectas[i] = true;
        } else {
          errorsTemp = new ActionErrors();
          validar.validateFormato(
              errorsTemp,
              "numerosAutorizaciones",
              this.numerosAutorizaciones[i],
              false,
              "^(\\d)*$",
              "errors.formato.numeroAutorizacionOrdenCompra",
              "errors.requerido",
              "N\u00FAmero de autorizaci\u00F3n de orden de compra");
          validar.validateFormato(
              errorsTemp,
              "observacionesNumerosAutorizaciones",
              this.observacionesNumerosAutorizaciones[i],
              false,
              "^(.){1,500}$",
              "errors.formato.observacionNumeroAutorizacionOrdenCompra",
              "errors.requerido",
              "Observaci&oacute;n del abono");
          if (errorsTemp.size() > 0) {
            autorizacionesIncorrectas[i] = true;
            for (Iterator j = errorsTemp.get(); j.hasNext(); ) {
              // LogSISPE.getLog().info("ClaseErrorsRegistroOrdenCompra: " + j.next().getClass());
              errors.add("observacionesNumerosAutorizaciones", (ActionMessage) j.next());
            }
          }
        }
      }

      if (errors.size() > 0) {
        if (request.getSession().getAttribute("ec.com.smx.sic.sispe.ordenCompra.detallesPedido")
            != null) {
          estadosDetallesPedido =
              (ArrayList)
                  request
                      .getSession()
                      .getAttribute("ec.com.smx.sic.sispe.ordenCompra.detallesPedido");
          for (int i = 0; i < this.getNumerosAutorizaciones().length; i++) {
            if (this.getNumerosAutorizaciones()[i].equals("") == false) {
              EstadoDetallePedidoDTO estadoDetallePedidoActual =
                  (EstadoDetallePedidoDTO) estadosDetallesPedido.get(i);

              estadoDetallePedidoActual.setNumeroAutorizacionOrdenCompra(
                  this.getNumerosAutorizaciones()[i]);
              estadoDetallePedidoActual.setObservacionAutorizacionOrdenCompra(
                  this.getObservacionesNumerosAutorizaciones()[i]);
              estadoDetallePedidoActual.setNpNumeroAutorizacionOrdenCompraInCorrecto(
                  autorizacionesIncorrectas[i]);
            }
          }
        }
      }
    }

    LogSISPE.getLog().info("numero de errores:{}", errors.size());
    return errors.size();
  }
示例#11
0
  /**
   * <br>
   * [機 能] 入力チェックを行う <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param map アクションマッピング
   * @param req リクエスト
   * @param con コネクション
   * @param sessionUsrSid ユーザSID
   * @return エラー
   * @throws SQLException SQL実行時例外
   */
  public Map<Integer, ActionErrors> validateCheck(
      ActionMapping map, HttpServletRequest req, Connection con, int sessionUsrSid)
      throws SQLException {

    ActionMessage msg = null;
    GsMessage gsMsg = new GsMessage();

    // 行番号とエラー内容を格納するMAP
    Map<Integer, ActionErrors> errorsMap = new TreeMap<Integer, ActionErrors>();

    for (Ntp030Param ntpData : ntp030nippouDataList__) {

      ActionErrors errors = new ActionErrors();

      String number = String.valueOf(ntpData.getRowId());
      String ntpYear = String.valueOf(ntpData.getNtpYear());
      String ntpMonth = String.valueOf(ntpData.getNtpMonth());
      String ntpDay = String.valueOf(ntpData.getNtpDay());
      String frHour = String.valueOf(ntpData.getFrHour());
      String frMin = String.valueOf(ntpData.getFrMin());
      String toHour = String.valueOf(ntpData.getToHour());
      String toMin = String.valueOf(ntpData.getToMin());
      String title = String.valueOf(ntpData.getTitle());
      String naiyou = String.valueOf(ntpData.getValueStr());

      // 開始年月日チェックフラグ(true=入力OK、false=NG)
      boolean fromOk = false;

      int iSYear = -1;
      if (!StringUtil.isNullZeroStringSpace(ntpYear)) {
        iSYear = Integer.parseInt(ntpYear);
      }
      int iSMonth = Integer.parseInt(ntpMonth);
      int iSDay = Integer.parseInt(ntpDay);

      UDate frDate = new UDate();
      frDate.setDate(iSYear, iSMonth, iSDay);
      frDate.setSecond(GSConstSchedule.DAY_START_SECOND);
      frDate.setMilliSecond(GSConstSchedule.DAY_START_MILLISECOND);
      if (frDate.getYear() != iSYear
          || frDate.getMonth() != iSMonth
          || frDate.getIntDay() != iSDay) {
        msg =
            new ActionMessage(
                "error.input.notfound.date", gsMsg.getMessage(req, "schedule.sch100.10"));
        errors.add("error.input.notfound.date", msg);
        log__.debug("error:1");
      } else {
        fromOk = true;
      }

      // 終了年月日チェックフラグ(true=入力OK、false=NG)
      boolean toOk = false;

      int iEYear = -1;
      if (!StringUtil.isNullZeroStringSpace(ntpYear)) {
        iEYear = Integer.parseInt(ntpYear);
      }
      int iEMonth = Integer.parseInt(ntpMonth);
      int iEDay = Integer.parseInt(ntpDay);

      UDate toDate = new UDate();
      toDate.setDate(iEYear, iEMonth, iEDay);
      toDate.setSecond(GSConstSchedule.DAY_START_SECOND);
      toDate.setMilliSecond(GSConstSchedule.DAY_START_MILLISECOND);
      if (toDate.getYear() != iEYear
          || toDate.getMonth() != iEMonth
          || toDate.getIntDay() != iEDay) {
        msg =
            new ActionMessage(
                "error.input.notfound.date", gsMsg.getMessage(req, "schedule.sch100.15"));
        errors.add("error.input.notfound.date", msg);
        log__.debug("error:2");
      } else {
        toOk = true;
      }

      if (fromOk && toOk && ntp030TimeKbn__.equals(String.valueOf(GSConstSchedule.TIME_EXIST))) {

        if (frHour.equals("-1")
            || frMin.equals("-1")
            || toHour.equals("-1")
            || toMin.equals("-1")) {
          // 時分
          String textHourMinute = gsMsg.getMessage(req, "schedule.src.36");
          msg = new ActionMessage("error.input.required.text", textHourMinute);
          errors.add("" + "error.input.required.text", msg);
          fromOk = false;
        }
      }

      // 個別チェックOKの場合
      if (fromOk && toOk) {

        if (ntp030TimeKbn__.equals(String.valueOf(GSConstSchedule.TIME_EXIST))) {
          if (frHour.equals("-1") && frMin.equals("-1")) {
            frDate.setHour(GSConstSchedule.DAY_START_HOUR);
            frDate.setMinute(GSConstSchedule.DAY_START_MINUTES);
          } else {
            frDate.setHour(Integer.parseInt(frHour));
            frDate.setMinute(Integer.parseInt(frMin));
          }
          if (toHour.equals("-1") && toMin.equals("-1")) {
            toDate.setHour(GSConstSchedule.DAY_END_HOUR);
            toDate.setMinute(GSConstSchedule.DAY_SYSMAX_MINUTES);
          } else {
            toDate.setHour(Integer.parseInt(toHour));
            toDate.setMinute(Integer.parseInt(toMin));
          }
        } else {
          frDate.setZeroHhMmSs();
          toDate.setMaxHhMmSs();
        }

        // from~to大小チェック
        if (frDate.compare(frDate, toDate) != UDate.LARGE) {
          // 開始 < 終了
          String textStartLessEnd = gsMsg.getMessage(req, "cmn.start.lessthan.end");
          // 開始・終了
          String textStartEnd = gsMsg.getMessage(req, "cmn.start.end");
          msg = new ActionMessage("error.input.comp.text", textStartEnd, textStartLessEnd);
          errors.add("" + "error.input.comp.text", msg);
          log__.debug("error:5");
        }
      }

      // タイトルのチェック
      if (__checkNoInput(errors, title, "ntp030Title", gsMsg.getMessage(req, "cmn.title"))) {
        if (__checkRange(
            errors,
            title,
            "ntp030Title",
            gsMsg.getMessage(req, "cmn.title"),
            GSConstSchedule.MAX_LENGTH_TITLE)) {
          // 先頭スペースチェック
          if (ValidateUtil.isSpaceStart(title)) {
            // タイトル
            String textTitle = gsMsg.getMessage(req, "cmn.title");
            msg = new ActionMessage("error.input.spase.start", textTitle);
            StrutsUtil.addMessage(errors, msg, "ntp030Title");
          } else {
            __checkJisString(errors, title, "ntp030Title", gsMsg.getMessage(req, "cmn.title"));
          }
        }
      }
      boolean valueError = false;
      // 内容のチェック
      if (__checkRangeTextarea(
          errors,
          naiyou,
          "ntp030Value",
          gsMsg.getMessage(req, "cmn.content"),
          GSConstSchedule.MAX_LENGTH_VALUE)) {
        if (!StringUtil.isNullZeroString(naiyou)) {
          // スペースのみチェック
          if (!valueError && ValidateUtil.isSpaceOrKaigyou(naiyou)) {
            msg =
                new ActionMessage(
                    "error.input.spase.cl.only", gsMsg.getMessage(req, "cmn.content"));
            StrutsUtil.addMessage(errors, msg, "ntp030Value");
            valueError = true;
          }

          if (!valueError) {
            // JIS
            __checkJisString(errors, naiyou, "ntp030Value", gsMsg.getMessage(req, "cmn.content"));
          }
        }
      }

      if (errors.size() > 0) {
        errorsMap.put(Integer.valueOf(number), errors);
      }
    }
    return errorsMap;
  }