Package org.olat.core.util

Examples of org.olat.core.util.ValidationStatusImpl


  public void validate(List validationResults) {
    int lastFormError = getRootForm().getLastRequestError();
    if (lastFormError == Form.REQUEST_ERROR_UPLOAD_LIMIT_EXCEEDED) {
      // check if total upload limit is exceeded (e.g. sum of files)
      setErrorKey(i18nErrMaxSize, i18nErrMaxSizeArgs);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;

      // check for a general error
    } else if (lastFormError == Form.REQUEST_ERROR_GENERAL) {
      setErrorKey("file.element.error.general", null);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;

      // check if uploaded at all
    } else if (isMandatory() && (
                    (initialFile == null && (tempUploadFile == null || !tempUploadFile.exists()))
                ||   (initialFile != null && tempUploadFile != null && !tempUploadFile.exists())) 
                  ) {
      setErrorKey(i18nErrMandatory, null);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;

      // check for file size of current file
    } else if (checkForMaxFileSize && tempUploadFile != null && tempUploadFile.exists() && tempUploadFile.length() > maxUploadSizeKB * 1024l) {
      setErrorKey(i18nErrMaxSize, i18nErrMaxSizeArgs);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;

      // check for mime types
    } else if (checkForMimeTypes && tempUploadFile != null && tempUploadFile.exists()) {
      boolean found = false;
      // Fix problem with upload mimetype: if the mimetype differs from the
      // mimetype the webapp helper generates from the file name the match won't work
      String mimeFromWebappHelper = WebappHelper.getMimeType(uploadFilename);
      if (uploadMimeType != null || mimeFromWebappHelper != null) {
        for (String validType : mimeTypes) {
          if (validType.equals(uploadMimeType) || validType.equals(mimeFromWebappHelper)) {
            // exact match: image/jpg
            found = true;
            break;
          } else if (validType.endsWith("/*")) {
            // wildcard match: image/*
            if (uploadMimeType != null && uploadMimeType.startsWith(validType.substring(0, validType.length() - 2))) {
              found = true;
              break;
            } else if (mimeFromWebappHelper != null && mimeFromWebappHelper.startsWith(validType.substring(0, validType.length() - 2))) {
              // fallback to mime type from filename
              found = true;
              break;
            }
          }
        }
      }
      if (!found) {
        setErrorKey(i18nErrMimeType, i18nErrMimeTypeArgs);
        validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
        return;
      }
    }
    // No error, clear errors from previous attempts
    clearError();
View Full Code Here


 
  @SuppressWarnings("unchecked")
  @Override
  public void validate(List validationResults) {
    if(checkForNotEmpty && !notEmpty()){
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
    if(checkForLength && !notLongerThan()){
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
    if(checkForEquals && !checkForIsEqual()){
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
    if(checkForMatchRegexp && !checkRegexMatch()){
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
    if (checkForCustomItemValidator && !checkItemValidatorIsValid()){
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
    //else no error
    clearError();
  }
View Full Code Here

 

  @Override
  public void validate(List validationResults) {
    if ( ! isOneSelected()) {
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
    clearError();     
  }
View Full Code Here

    if(hasError){
      return;
    }
    // check valid date
    if (checkForValidDate && !checkValidDate()) {
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
    }
  }
View Full Code Here

    }
    // go further with specialized checks

    if (!intValueCheck()) {
      // int check is always done
      validationResults.add(new ValidationStatusImpl(
          ValidationStatus.ERROR));
      return;
    }
    if (hasEqualCheck && !isEqualCheck()) {
      validationResults.add(new ValidationStatusImpl(
          ValidationStatus.ERROR));
      return;
    }
    if(!isMaxValueCheck()) {
      validationResults.add(new ValidationStatusImpl(
          ValidationStatus.ERROR));
      return;
    }
    if(!isMinValueCheck()) {
      validationResults.add(new ValidationStatusImpl(
          ValidationStatus.ERROR));
      return;
    }   
    // else no error
    clearError();
View Full Code Here

TOP

Related Classes of org.olat.core.util.ValidationStatusImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.