-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BXC-4762 integrate jp24u jar into box-c (#1839)
* add jp24u submodule * build jp24u submodule * add jp24u to pom.xml and runJp24u method * use checkout v3 and remove separate checkout submodules step * add separate checkout submodules step * remove separate checkout submodules step * remove build jp24u with maven step * add new Jp2Processor and tests * skip jp24u tests during build * fix skip jp24u tests during build * skip jp24u during maven verify * forgot an ! * try removing quotes to fix build * try excluding jp24u logging dependencies * remove exclusions * update jp24u submodule git reference * add javadoc, remove "\"" and recipientList * fix tests * verify jp2Processor is called * update jp24u submodule and use runCommand method instead of main * add result class to extend ExecResult and set the body * suppress kakadu warnings
- Loading branch information
Showing
13 changed files
with
191 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "clamav-java"] | ||
path = clamav-java | ||
url = https://github.com/UNC-Libraries/clamav-java.git | ||
[submodule "jp24u"] | ||
path = jp24u | ||
url = https://github.com/UNC-Libraries/jp24u.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/images/Jp2Processor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package edu.unc.lib.boxc.services.camel.images; | ||
|
||
import JP2ImageConverter.CLIMain; | ||
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.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Processor that runs jp24u to generate jp2 derivatives | ||
* @author krwong | ||
*/ | ||
public class Jp2Processor implements Processor { | ||
private static final Logger log = LoggerFactory.getLogger(Jp2Processor.class); | ||
|
||
@Override | ||
public void process(Exchange exchange) throws Exception { | ||
Message in = exchange.getIn(); | ||
String imagePath = (String) in.getHeader(CdrFcrepoHeaders.CdrImagePath); | ||
String tempPath = (String) in.getHeader(CdrFcrepoHeaders.CdrTempPath); | ||
String mimetype = (String) in.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType); | ||
|
||
String[] command = new String[]{"jp24u", "kdu_compress", "-f", imagePath, | ||
"-o", tempPath, "-sf", mimetype}; | ||
log.debug("Run jp24u command {} for type {}", command, mimetype); | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.