Skip to content

Commit

Permalink
Merge pull request #5510 from effective-webwork/fail-on-warning
Browse files Browse the repository at this point in the history
Add 'strict' mode to let metadata validation fail on warnings
  • Loading branch information
solth authored Feb 20, 2023
2 parents 5a959f3 + 0d5dfe7 commit 61affed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Kitodo/src/main/resources/kitodo_config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 61affed

Please sign in to comment.