diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java index f2b826c67b1e96a736967d542dc83765587b2970..f4da03765309fea0841c211b82a29778b68c87a6 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java @@ -167,23 +167,9 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP // wait for the output reader thread to terminate procOutputReaderThread.join(); - - if (p.exitValue() == 0) { - isvalid = true; - iswellformed = true; - } else { // something wrong - isvalid = false; - iswellformed = false; - } - - for (String line : procOutputLineList) { - if (line.contains("pass!")) { - break; - } - System.out.println("MEDIACONCH line: " + line); - validationLog.add(line); - log.info( line ); - } + + boolean fileIsValid = evaluateAndLogMediaconchOutput(p.exitValue(), procOutputLineList, filePath); + setValid(fileIsValid); } catch (IOException e) { log.error("(actual) mediaconch not available, path=" + this.mediaconch_binary_path + ", " , e.getMessage()); System.out.println("ERROR: (actual) mediaconch not available, path=" + this.mediaconch_binary_path + ", " + e.getMessage()); @@ -201,14 +187,35 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP iswellformed = value; } - private void extractErrorsFromReader(BufferedReader reader) throws IOException { - while (true) { - String line = reader.readLine(); - if (line == null) break; - System.out.println("MEDIACONCH line: " + line); - validationLog.add(line); - log.info(line); + + private boolean evaluateMediaconchOutput(int processExitValue, List<String> procOutputLineList, String filePath) { + if (processExitValue != 0) { + log.info("the mediaconch process returned a non-zero exit code (" +processExitValue+ ") -> file '"+filePath+"' is considered invalid"); + + return false; + } + + if (procOutputLineList == null || procOutputLineList.isEmpty()) { + log.info("the mediaconch process returned an empty validation result -> file '"+filePath+"' is considered invalid"); + + return false; + } + + // the result is in the first line + return procOutputLineList.get(0).startsWith("pass! "+ filePath); + } + + private boolean evaluateAndLogMediaconchOutput(int processExitValue, List<String> procOutputLineList, String filePath) { + boolean result = evaluateMediaconchOutput(processExitValue, procOutputLineList, filePath); + + if (!result) { + validationLog.add("mediaconch exit code for file " + filePath + " is "+processExitValue); + for (String line : procOutputLineList) { + validationLog.add("MEDIACONCH line: " + line); + } } + + return result; } @Override