Package org.apache.padaf.preflight.ValidationResult

Examples of org.apache.padaf.preflight.ValidationResult.ValidationError


   * @return true if the color space is valid, false otherwise.
   */
  protected boolean processCYMKColorSpace(List<ValidationError> result) {
    // ---- ICCProfile must contain a CYMK Color Space
    if (iccpw == null) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing"));
      return false;     
    } if (!iccpw.isCMYKColorSpace()) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_CMYK, "DestOutputProfile isn't CMYK ColorSpace"));
      return false;
    }
    return true;
  }
View Full Code Here


   * @return true if the color space is valid, false otherwise.
   */
  protected boolean processPatternColorSpace(List<ValidationError> result) {
    if (iccpw == null) {
      result
      .add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing"));
      return false;
    }
    return true;
  }
View Full Code Here

   */
  protected boolean processGrayColorSpace(List<ValidationError> result) {
    // ---- OutputIntent is mandatory
    if (iccpw == null) {
      result
      .add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing"));
      return false;
    }
    return true;
  }
View Full Code Here

    }

    List<ValidationError> errors = new ArrayList<ValidationError>();
    try {
      if (!csHelper.validate(errors)) {
        ValidationError ve = errors.get(0);
        throwContentStreamException(ve.getDetails(), ve.getErrorCode());
      }
    } catch (ValidationException e) {
      //      throw new IOException(e.getMessage(), e); java 6
      throw new IOException(e.getMessage());
    }
View Full Code Here

      List<ValidationError> result) {
    PDICCBased iccBased = (PDICCBased) pdcs;
    try {
      ICC_Profile iccp = ICC_Profile.getInstance(iccBased.getPDStream().getByteArray());
      if (iccp == null) {
        result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_ICCBASED, "Unable to read ICCBase color space "));
        return false;
      }
      List<PDColorSpace> altCs = iccBased.getAlternateColorSpaces();
      for (PDColorSpace altpdcs : altCs) {
        if (altpdcs != null) {

          ColorSpaces altCsId = ColorSpaces.valueOf(altpdcs.getName());
          if (altCsId == ColorSpaces.Pattern) {
            result.add(new ValidationError(
                ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN, "Pattern is forbidden as AlternateColorSpace of a ICCBased"));
            return false;
          }
          /*
           * According to the ISO-19005-1:2005
           *
           * A conforming reader shall render ICCBased colour spaces as specified
           * by the ICC specification, and shall not use the Alternate colour space
           * specified in an ICC profile stream dictionary
           *
           * We don't check the alternate ColorSpaces
           */
        }
      }
    } catch (IOException e) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read ICCBase color space : " + e.getMessage()));
      return false;
    }

    return true;
  }
View Full Code Here

  protected boolean processDeviceNColorSpace(PDColorSpace pdcs,
      List<ValidationError> result) {
    PDDeviceN deviceN = (PDDeviceN) pdcs;
    try {
      if (iccpw == null) {
        result.add(new ValidationError(
            ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing"));
        return false;
      }

      PDColorSpace altColor = deviceN.getAlternateColorSpace();
      boolean res = true;
      if (altColor != null) {
        res = processAllColorSpace(altColor, result);
      }

      int numberOfColorants = 0;
      PDDeviceNAttributes attr = deviceN.getAttributes();
      if (attr != null) {
        Map colorants = attr.getColorants();
        if (colorants != null) {
          numberOfColorants = colorants.size();
          for (Object col : colorants.values()) {
            if (col != null) {
              res = res && processAllColorSpace((PDColorSpace) col, result);
            }
          }
        }
      }
      int numberOfComponents = deviceN.getNumberOfComponents();
      if (numberOfColorants > MAX_DEVICE_N_LIMIT || numberOfComponents > MAX_DEVICE_N_LIMIT ) {
        result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_TOO_MANY_COMPONENTS_DEVICEN, "DeviceN has too many tint components or colorants"))
        res = false;
      }
      return res;
    } catch (IOException e) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read DeviceN color space : " + e.getMessage()));
      return false;
    }
  }
View Full Code Here

    PDIndexed indexed = (PDIndexed) pdcs;
    try {
      PDColorSpace based = indexed.getBaseColorSpace();
      ColorSpaces cs = ColorSpaces.valueOf(based.getName());
      if (cs == ColorSpaces.Indexed || cs == ColorSpaces.Indexed_SHORT) {
        result.add(new ValidationError(
            ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED,"Indexed color space can't be used as Base color space"));
        return false;
      }
      if (cs == ColorSpaces.Pattern) {
        result.add(new ValidationError(
            ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED,"Pattern color space can't be used as Base color space"));
        return false;
      }
      return processAllColorSpace(based, result);
    } catch (IOException e) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Indexed color space : " + e.getMessage()));
      return false;
    }
  }
View Full Code Here

  protected boolean checkSpecificMandatoryFields() {
    // ---- name is required only in a PDF-1.0.
    // ---- Currently our grammar matches only with PDF-1.[1-4]
    // ---- baseFont is required and is usually the FontName
    if (basefont == null || "".equals(basefont)) {
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_DICTIONARY_INVALID, "BaseFont is missing"));
      return false;
    }

    boolean allPresent = (firstChar != null && lastChar != null && widths != null);
    if (!allPresent) {
      this.fontContainer.addError(new ValidationError(
          ERROR_FONTS_DICTIONARY_INVALID, "Required keys are missing"));
      return false;
    }
    // else
    // ---- Event if the Font is one of the 14 standard Fonts, those keys are
View Full Code Here

        case Separation:
        case DeviceN:
        case Pattern:
        case Indexed:
        case Indexed_SHORT:
          result.add(new ValidationError(
              ERROR_GRAPHIC_INVALID_COLOR_SPACE_ALTERNATE, acs.getLabel() + " color space can't be used as alternate color space"));
          return false;
        default:
          return processAllColorSpace(altCol, result);
        }
      }

      return true;
    } catch (IOException e) {
      result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Separation color space : " + e.getMessage()));
      return false;
    }
  }
View Full Code Here

      String prefExpected, String schema) {
    StringBuilder sb = new StringBuilder(80);
    sb.append(schema).append(" found but prefix used is '").append(prefFound)
        .append("', prefix '").append(prefExpected).append("' is expected.");

    return new ValidationError(
        ValidationConstants.ERROR_METADATA_WRONG_NS_PREFIX, sb.toString());
  }
View Full Code Here

TOP

Related Classes of org.apache.padaf.preflight.ValidationResult.ValidationError

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.