Skip to content
Snippets Groups Projects
Commit 820e4f2d authored by Gerald Hübsch's avatar Gerald Hübsch
Browse files

fix evaluation of mediaconch output

The mediaconch process returns code 0 for valid and
invalid files. Therefore, the text output produced
by the process must be parsed to determined the
validation result.
parent ee44d038
No related branches found
No related tags found
No related merge requests found
Pipeline #9043 passed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment