diff --git a/services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/images/Jp2Processor.java b/services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/images/Jp2Processor.java index 41de1fefaf..7144ac1fa4 100644 --- a/services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/images/Jp2Processor.java +++ b/services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/images/Jp2Processor.java @@ -1,16 +1,19 @@ package edu.unc.lib.boxc.services.camel.images; import JP2ImageConverter.CLIMain; -import JP2ImageConverter.JP2ImageConverterCommand; -import JP2ImageConverter.options.JP2ImageConverterOptions; import edu.unc.lib.boxc.services.camel.util.CdrFcrepoHeaders; import org.apache.camel.Exchange; +import org.apache.camel.LoggingLevel; import org.apache.camel.Message; import org.apache.camel.Processor; +import org.apache.camel.component.exec.ExecCommand; +import org.apache.camel.component.exec.ExecResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.nio.file.Path; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Arrays; /** * Processor that runs jp24u to generate jp2 derivatives @@ -29,6 +32,19 @@ public void process(Exchange exchange) throws Exception { String[] command = new String[]{"jp24u", "kdu_compress", "-f", imagePath, "-o", tempPath, "-sf", mimetype}; log.debug("Run jp24u command {} for type {}", command, mimetype); - CLIMain.runCommand(command); + int exitCode = CLIMain.runCommand(command); + + Result result = new Result(new ByteArrayInputStream(tempPath.getBytes()), null, exitCode); + in.setBody(result); + } + + public static class Result extends ExecResult { + private static final ExecCommand command = new ExecCommand("jp24u", + Arrays.asList("kdu_compress"), null, Long.valueOf(60), null, + null, null, false, LoggingLevel.OFF); + + public Result(InputStream stdout, InputStream stderr, int exitCode) { + super(command, stdout, stderr, exitCode); + } } }