From 0d5dfe7430a4adae4c289d02d5971c0ec6643217 Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Mon, 16 Jan 2023 20:33:24 +0100 Subject: [PATCH] Let metadata validation fail on validation warning --- .../java/org/kitodo/config/enums/ParameterCore.java | 5 +++++ .../services/workflow/WorkflowControllerService.java | 10 ++++++++-- Kitodo/src/main/resources/kitodo_config.properties | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java b/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java index 1233d20ebac..b300555428b 100644 --- a/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java +++ b/Kitodo/src/main/java/org/kitodo/config/enums/ParameterCore.java @@ -374,6 +374,11 @@ public enum ParameterCore implements ParameterInterface { */ VALIDATE_IDENTIFIER_REGEX(new Parameter<>("validateIdentifierRegex", "[\\w|-]")), + /** + * Flag to control whether metadata validation should fail on warnings or just on errors. + */ + VALIDATION_FAIL_ON_WARNING(new Parameter<>("validationFailOnWarning", false)), + /** * Colours used to represent the issues in the calendar editor. */ diff --git a/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java b/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java index deb3ad5888d..3258c73f5e9 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java @@ -179,13 +179,19 @@ private boolean validateMetadata(Task task) throws IOException, DAOException { ConfigCore.getParameter(ParameterCore.DIR_RULESETS), task.getProcess().getRuleset().getFile()).toString())); ValidationResult validationResult = ServiceManager.getMetadataValidationService().validate(workpiece, ruleset); - if (State.ERROR.equals(validationResult.getState())) { + boolean strictValidation = ConfigCore.getBooleanParameter(ParameterCore.VALIDATION_FAIL_ON_WARNING); + State state = validationResult.getState(); + if (State.ERROR.equals(state) || (strictValidation && !State.SUCCESS.equals(state))) { Helper.setErrorMessage(Helper.getTranslation("dataEditor.validation.state.error")); for (String message : validationResult.getResultMessages()) { Helper.setErrorMessage(message); } } - return !validationResult.getState().equals(State.ERROR); + if (strictValidation) { + return State.SUCCESS.equals(state); + } else { + return !State.ERROR.equals(state); + } } /** diff --git a/Kitodo/src/main/resources/kitodo_config.properties b/Kitodo/src/main/resources/kitodo_config.properties index ddfe7fab35e..2e77a72af1b 100644 --- a/Kitodo/src/main/resources/kitodo_config.properties +++ b/Kitodo/src/main/resources/kitodo_config.properties @@ -728,6 +728,9 @@ LongTermPreservationValidation.mapping.UNDETERMINED.FALSE=ERROR LongTermPreservationValidation.mapping.UNDETERMINED.TRUE=SUCCESS LongTermPreservationValidation.mapping.UNDETERMINED.UNDETERMINED=WARNING +# Controls whether metadata validation should fail on warnings ("true") or just on errors ("false") +validationFailOnWarning=true + file.maxWaitMilliseconds=150000 # Default client parameter to be returned if no session client could be determined by user service.