Skip to content

Commit 4839880

Browse files
committed
Adapt WorkflowControllerService
1 parent d78243c commit 4839880

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

Kitodo-Command/src/main/java/org/kitodo/command/Command.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public CommandResult runCommand(String command) {
4545
process = new ProcessBuilder(callSequence).start();
4646
try (InputStream inputStream = process.getInputStream();
4747
InputStream errorInputStream = process.getErrorStream()) {
48-
int errCode = process.waitFor();
4948
List<String> outputMessage = inputStreamArrayToList(inputStream);
5049
List<String> errorMessage = inputStreamArrayToList(errorInputStream);
50+
int errCode = process.waitFor();
5151
if (Integer.valueOf(errCode).equals(0)) {
5252
commandResult = new CommandResult(command, true, outputMessage);
5353
logger.info("Execution of Command {} was successful!: {}",

Kitodo/src/main/java/org/kitodo/production/services/data/TaskService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,9 @@ public boolean executeScript(Task task, String script, boolean automatic) throws
519519
CommandResult commandResult = commandService.runCommand(script);
520520
executedSuccessful = commandResult.isSuccessful();
521521
if (executedSuccessful && !commandResult.getMessages().isEmpty()) {
522-
Helper.setMessage(String.join(" | ", commandResult.getMessages()));
522+
for (String message : commandResult.getMessages()){
523+
Helper.setMessage(message);
524+
}
523525
}
524526
}
525527
finishOrReturnAutomaticTask(task, automatic, executedSuccessful);

Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,13 @@ private boolean runScriptCondition(String script, Process process) throws IOExce
669669
process, null);
670670

671671
script = replacer.replace(script);
672-
673-
CommandResult commandResult = ServiceManager.getCommandService().runCommand(script);
674-
return commandResult.isSuccessful();
672+
try {
673+
CommandResult commandResult = ServiceManager.getCommandService().runCommand(script);
674+
return commandResult.isSuccessful();
675+
} catch (IOException e) {
676+
Helper.setErrorMessage("runCommandError", logger, e);
677+
return false;
678+
}
675679
}
676680

677681
private boolean runXPathCondition(Process process, String xpath) throws IOException {

0 commit comments

Comments
 (0)