protected void enforceFieldRequiredness(
     ActionParametersMap params, ErrorCollection errorCollection) {
   for (String field : getFieldsToCopy()) {
     if (StringUtils.isEmpty(params.getString(field))) {
       errorCollection.addError(field, getI18nBean().getText("com.heroku.errors.emptyField"));
     }
   }
 }
 /** {@inheritDoc} */
 @Override
 public void validateSonarProject(ActionParametersMap params, ErrorCollection errorCollection) {
   LOGGER.debug("Validating Sonar Project Properties");
   if (!params.getBoolean(CFG_SONAR_PROJECT_CONFIGURED)) {
     if (StringUtils.isBlank(params.getString(CFG_SONAR_PROJECT_KEY))) {
       errorCollection.addError(
           CFG_SONAR_PROJECT_KEY, getI18nBean().getText("sonar.project.key.mandatory"));
     } else if (params.getString(CFG_SONAR_PROJECT_KEY).indexOf(":") == -1) {
       errorCollection.addError(
           CFG_SONAR_PROJECT_KEY, getI18nBean().getText("sonar.project.key.invalid"));
     }
     if (StringUtils.isBlank(params.getString(CFG_SONAR_PROJECT_NAME))) {
       errorCollection.addError(
           CFG_SONAR_PROJECT_NAME, getI18nBean().getText("sonar.project.name.mandatory"));
     }
     if (StringUtils.isBlank(params.getString(CFG_SONAR_PROJECT_VERSION))) {
       errorCollection.addError(
           CFG_SONAR_PROJECT_VERSION, getI18nBean().getText("sonar.project.version.mandatory"));
     }
     if (StringUtils.isBlank(params.getString(CFG_SONAR_SOURCES))) {
       errorCollection.addError(
           CFG_SONAR_SOURCES, getI18nBean().getText("sonar.sources.mandatory"));
     } else if (StringUtils.split(params.getString(CFG_SONAR_SOURCES), DIRECTORY_SEPARATOR).length
         < 1) {
       errorCollection.addError(
           CFG_SONAR_SOURCES, getI18nBean().getText("sonar.sources.mandatory"));
     }
   }
 }
コード例 #3
0
  void validateWaittime(String value) {
    if (StringUtils.isEmpty(value)) {
      errorCollection.addError(
          "waittime", textProvider.getText("com.zend.zendserver.plugins.waittime.required"));
    }

    try {
      int normalizedValue = Integer.parseInt(value);
      if (normalizedValue <= 0) {
        errorCollection.addError(
            "waittime", textProvider.getText("com.zend.zendserver.plugins.waittime.zero"));
      }

      if (normalizedValue > 100) {
        errorCollection.addError(
            "waittime", textProvider.getText("com.zend.zendserver.plugins.waittime.too_large"));
      }
    } catch (Exception e) {
      errorCollection.addError(
          "waittime", textProvider.getText("com.zend.zendserver.plugins.waittime.error"));
    }
  }