@Test public void jhoveProfileMismatchUc() { if (externalUtilManager.isUtilAvailable(ExternalUtil.JHOVE)) { ValidationFunction validationFunction = buildValidationFunction(ExternalUtil.JHOVE, ResourceType.IMAGE_USER_COPY, FILES_PROFILE_MISMATCH_UC); ValidationResult result = validationFunction.validate(); assertTrue(result.hasProblems()); } }
@Override public ValidationResult validate() { try { checkContractCompliance(); Level noFilesProblemLevel = Level.ERROR; List<ValueParam> noFilesProblemLevelParams = valueParams.getParams(PARAM_NO_FILES_PROBLEM_LEVEL); if (noFilesProblemLevelParams.size() == 1) { ValueEvaluation eval = noFilesProblemLevelParams.get(0).getEvaluation(); noFilesProblemLevel = (Level) eval.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILES).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return invalidValueParamNull(PARAM_FILES, paramFiles); } else if (files.isEmpty()) { return singlErrorResult(invalid(noFilesProblemLevel, "prázdný seznam souborů")); } Level validationProblemLevel = Level.ERROR; List<ValueParam> validationProblemLevelParams = valueParams.getParams(PARAM_VALIDATION_PROBLEM_LEVEL); if (!validationProblemLevelParams.isEmpty()) { ValueEvaluation eval = validationProblemLevelParams.get(0).getEvaluation(); validationProblemLevel = (Level) eval.getData(); } ValueEvaluation paramType = valueParams.getParams(PARAM_TYPE).get(0).getEvaluation(); ResourceType type = (ResourceType) paramType.getData(); if (type == null) { return invalidValueParamNull(PARAM_TYPE, paramType); } ValueEvaluation paramUtil = valueParams.getParams(PARAM_UTIL).get(0).getEvaluation(); ExternalUtil util = (ExternalUtil) paramUtil.getData(); if (util == null) { return invalidValueParamNull(PARAM_UTIL, paramUtil); } ValueEvaluation paramExecution = valueParams.getParams(PARAM_EXECUTION).get(0).getEvaluation(); String executionName = (String) paramExecution.getData(); if (executionName == null) { return invalidValueParamNull(PARAM_EXECUTION, paramExecution); } ExternalUtilExecution execution = new ExternalUtilExecution(executionName, util); return validate(validationProblemLevel, files, type, execution); } catch (ContractException e) { return invalidContractNotMet(e); } catch (Exception e) { e.printStackTrace(); return invalidUnexpectedError(e); } }
VfCheckBinaryFilesValidByExternalUtil extends ValidationFunction { @Override public ValidationResult validate() { try { checkContractCompliance(); Level noFilesProblemLevel = Level.ERROR; List<ValueParam> noFilesProblemLevelParams = valueParams.getParams(PARAM_NO_FILES_PROBLEM_LEVEL); if (noFilesProblemLevelParams.size() == 1) { ValueEvaluation eval = noFilesProblemLevelParams.get(0).getEvaluation(); noFilesProblemLevel = (Level) eval.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILES).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return invalidValueParamNull(PARAM_FILES, paramFiles); } else if (files.isEmpty()) { return singlErrorResult(invalid(noFilesProblemLevel, "prázdný seznam souborů")); } Level validationProblemLevel = Level.ERROR; List<ValueParam> validationProblemLevelParams = valueParams.getParams(PARAM_VALIDATION_PROBLEM_LEVEL); if (!validationProblemLevelParams.isEmpty()) { ValueEvaluation eval = validationProblemLevelParams.get(0).getEvaluation(); validationProblemLevel = (Level) eval.getData(); } ValueEvaluation paramType = valueParams.getParams(PARAM_TYPE).get(0).getEvaluation(); ResourceType type = (ResourceType) paramType.getData(); if (type == null) { return invalidValueParamNull(PARAM_TYPE, paramType); } ValueEvaluation paramUtil = valueParams.getParams(PARAM_UTIL).get(0).getEvaluation(); ExternalUtil util = (ExternalUtil) paramUtil.getData(); if (util == null) { return invalidValueParamNull(PARAM_UTIL, paramUtil); } ValueEvaluation paramExecution = valueParams.getParams(PARAM_EXECUTION).get(0).getEvaluation(); String executionName = (String) paramExecution.getData(); if (executionName == null) { return invalidValueParamNull(PARAM_EXECUTION, paramExecution); } ExternalUtilExecution execution = new ExternalUtilExecution(executionName, util); return validate(validationProblemLevel, files, type, execution); } catch (ContractException e) { return invalidContractNotMet(e); } catch (Exception e) { e.printStackTrace(); return invalidUnexpectedError(e); } } }
VfCheckBinaryFilesValidByExternalUtil extends ValidationFunction { @Override public ValidationResult validate() { try { checkContractCompliance(); Level noFilesProblemLevel = Level.ERROR; List<ValueParam> noFilesProblemLevelParams = valueParams.getParams(PARAM_NO_FILES_PROBLEM_LEVEL); if (noFilesProblemLevelParams.size() == 1) { ValueEvaluation eval = noFilesProblemLevelParams.get(0).getEvaluation(); noFilesProblemLevel = (Level) eval.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILES).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return invalidValueParamNull(PARAM_FILES, paramFiles); } else if (files.isEmpty()) { return singlErrorResult(invalid(noFilesProblemLevel, "prázdný seznam souborů")); } Level validationProblemLevel = Level.ERROR; List<ValueParam> validationProblemLevelParams = valueParams.getParams(PARAM_VALIDATION_PROBLEM_LEVEL); if (!validationProblemLevelParams.isEmpty()) { ValueEvaluation eval = validationProblemLevelParams.get(0).getEvaluation(); validationProblemLevel = (Level) eval.getData(); } ValueEvaluation paramType = valueParams.getParams(PARAM_TYPE).get(0).getEvaluation(); ResourceType type = (ResourceType) paramType.getData(); if (type == null) { return invalidValueParamNull(PARAM_TYPE, paramType); } ValueEvaluation paramUtil = valueParams.getParams(PARAM_UTIL).get(0).getEvaluation(); ExternalUtil util = (ExternalUtil) paramUtil.getData(); if (util == null) { return invalidValueParamNull(PARAM_UTIL, paramUtil); } ValueEvaluation paramExecution = valueParams.getParams(PARAM_EXECUTION).get(0).getEvaluation(); String executionName = (String) paramExecution.getData(); if (executionName == null) { return invalidValueParamNull(PARAM_EXECUTION, paramExecution); } ExternalUtilExecution execution = new ExternalUtilExecution(executionName, util); return validate(validationProblemLevel, files, type, execution); } catch (ContractException e) { return invalidContractNotMet(e); } catch (Exception e) { e.printStackTrace(); return invalidUnexpectedError(e); } } VfCheckBinaryFilesValidByExternalUtil(String name, Engine engine); }
VfCheckBinaryFilesValidByExternalUtil extends ValidationFunction { @Override public ValidationResult validate() { try { checkContractCompliance(); Level noFilesProblemLevel = Level.ERROR; List<ValueParam> noFilesProblemLevelParams = valueParams.getParams(PARAM_NO_FILES_PROBLEM_LEVEL); if (noFilesProblemLevelParams.size() == 1) { ValueEvaluation eval = noFilesProblemLevelParams.get(0).getEvaluation(); noFilesProblemLevel = (Level) eval.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILES).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return invalidValueParamNull(PARAM_FILES, paramFiles); } else if (files.isEmpty()) { return singlErrorResult(invalid(noFilesProblemLevel, "prázdný seznam souborů")); } Level validationProblemLevel = Level.ERROR; List<ValueParam> validationProblemLevelParams = valueParams.getParams(PARAM_VALIDATION_PROBLEM_LEVEL); if (!validationProblemLevelParams.isEmpty()) { ValueEvaluation eval = validationProblemLevelParams.get(0).getEvaluation(); validationProblemLevel = (Level) eval.getData(); } ValueEvaluation paramType = valueParams.getParams(PARAM_TYPE).get(0).getEvaluation(); ResourceType type = (ResourceType) paramType.getData(); if (type == null) { return invalidValueParamNull(PARAM_TYPE, paramType); } ValueEvaluation paramUtil = valueParams.getParams(PARAM_UTIL).get(0).getEvaluation(); ExternalUtil util = (ExternalUtil) paramUtil.getData(); if (util == null) { return invalidValueParamNull(PARAM_UTIL, paramUtil); } ValueEvaluation paramExecution = valueParams.getParams(PARAM_EXECUTION).get(0).getEvaluation(); String executionName = (String) paramExecution.getData(); if (executionName == null) { return invalidValueParamNull(PARAM_EXECUTION, paramExecution); } ExternalUtilExecution execution = new ExternalUtilExecution(executionName, util); return validate(validationProblemLevel, files, type, execution); } catch (ContractException e) { return invalidContractNotMet(e); } catch (Exception e) { e.printStackTrace(); return invalidUnexpectedError(e); } } VfCheckBinaryFilesValidByExternalUtil(String name, Engine engine); @Override ValidationResult validate(); }
VfCheckBinaryFilesValidByExternalUtil extends ValidationFunction { @Override public ValidationResult validate() { try { checkContractCompliance(); Level noFilesProblemLevel = Level.ERROR; List<ValueParam> noFilesProblemLevelParams = valueParams.getParams(PARAM_NO_FILES_PROBLEM_LEVEL); if (noFilesProblemLevelParams.size() == 1) { ValueEvaluation eval = noFilesProblemLevelParams.get(0).getEvaluation(); noFilesProblemLevel = (Level) eval.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILES).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return invalidValueParamNull(PARAM_FILES, paramFiles); } else if (files.isEmpty()) { return singlErrorResult(invalid(noFilesProblemLevel, "prázdný seznam souborů")); } Level validationProblemLevel = Level.ERROR; List<ValueParam> validationProblemLevelParams = valueParams.getParams(PARAM_VALIDATION_PROBLEM_LEVEL); if (!validationProblemLevelParams.isEmpty()) { ValueEvaluation eval = validationProblemLevelParams.get(0).getEvaluation(); validationProblemLevel = (Level) eval.getData(); } ValueEvaluation paramType = valueParams.getParams(PARAM_TYPE).get(0).getEvaluation(); ResourceType type = (ResourceType) paramType.getData(); if (type == null) { return invalidValueParamNull(PARAM_TYPE, paramType); } ValueEvaluation paramUtil = valueParams.getParams(PARAM_UTIL).get(0).getEvaluation(); ExternalUtil util = (ExternalUtil) paramUtil.getData(); if (util == null) { return invalidValueParamNull(PARAM_UTIL, paramUtil); } ValueEvaluation paramExecution = valueParams.getParams(PARAM_EXECUTION).get(0).getEvaluation(); String executionName = (String) paramExecution.getData(); if (executionName == null) { return invalidValueParamNull(PARAM_EXECUTION, paramExecution); } ExternalUtilExecution execution = new ExternalUtilExecution(executionName, util); return validate(validationProblemLevel, files, type, execution); } catch (ContractException e) { return invalidContractNotMet(e); } catch (Exception e) { e.printStackTrace(); return invalidUnexpectedError(e); } } VfCheckBinaryFilesValidByExternalUtil(String name, Engine engine); @Override ValidationResult validate(); static final String PARAM_NO_FILES_PROBLEM_LEVEL; static final String PARAM_FILES; static final String PARAM_TYPE; static final String PARAM_UTIL; static final String PARAM_EXECUTION; static final String PARAM_VALIDATION_PROBLEM_LEVEL; }