SevenZipIngestModule: only check 7zip init once

This commit is contained in:
Samuel H. Kenyon 2014-04-09 14:07:05 -04:00
parent be4f3194fc
commit 1e255f0979
2 changed files with 20 additions and 15 deletions

View File

@ -90,6 +90,7 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
private final byte[] fileHeaderBuffer = new byte[readHeaderSize]; private final byte[] fileHeaderBuffer = new byte[readHeaderSize];
private static final int ZIP_SIGNATURE_BE = 0x504B0304; private static final int ZIP_SIGNATURE_BE = 0x504B0304;
private IngestJobContext context; private IngestJobContext context;
private long jobId;
SevenZipIngestModule() { SevenZipIngestModule() {
} }
@ -97,6 +98,7 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
@Override @Override
public void startUp(IngestJobContext context) throws IngestModuleException { public void startUp(IngestJobContext context) throws IngestModuleException {
this.context = context; this.context = context;
jobId = context.getJobId();
final Case currentCase = Case.getCurrentCase(); final Case currentCase = Case.getCurrentCase();
@ -121,20 +123,23 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
} }
} }
try { // if first instance of this module for this job then check 7zip init
SevenZip.initSevenZipFromPlatformJAR(); if (IngestModuleAdapter.moduleRefCountIncrement(jobId) == 1) {
String platform = SevenZip.getUsedPlatform(); try {
logger.log(Level.INFO, "7-Zip-JBinding library was initialized on supported platform: {0}", platform); SevenZip.initSevenZipFromPlatformJAR();
} catch (SevenZipNativeInitializationException e) { String platform = SevenZip.getUsedPlatform();
logger.log(Level.SEVERE, "Error initializing 7-Zip-JBinding library", e); logger.log(Level.INFO, "7-Zip-JBinding library was initialized on supported platform: {0}", platform);
String msg = NbBundle.getMessage(this.getClass(), "SevenZipIngestModule.init.errInitModule.msg", } catch (SevenZipNativeInitializationException e) {
ArchiveFileExtractorModuleFactory.getModuleName()); logger.log(Level.SEVERE, "Error initializing 7-Zip-JBinding library", e);
String details = NbBundle.getMessage(this.getClass(), "SevenZipIngestModule.init.errCantInitLib", String msg = NbBundle.getMessage(this.getClass(), "SevenZipIngestModule.init.errInitModule.msg",
e.getMessage()); ArchiveFileExtractorModuleFactory.getModuleName());
services.postMessage(IngestMessage.createErrorMessage(ArchiveFileExtractorModuleFactory.getModuleName(), msg, details)); String details = NbBundle.getMessage(this.getClass(), "SevenZipIngestModule.init.errCantInitLib",
throw new RuntimeException(e); e.getMessage());
services.postMessage(IngestMessage.createErrorMessage(ArchiveFileExtractorModuleFactory.getModuleName(), msg, details));
throw new RuntimeException(e);
}
} }
archiveDepthCountTree = new ArchiveDepthCountTree(); archiveDepthCountTree = new ArchiveDepthCountTree();
} }

View File

@ -128,9 +128,9 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
tikaFormatDetector = new Tika(); tikaFormatDetector = new Tika();
ingester = Server.getIngester(); ingester = Server.getIngester();
// increment the module reference count
// if first instance of this module for this job then check the server and existence of keywords
if (IngestModuleAdapter.moduleRefCountIncrement(jobId) == 1) { if (IngestModuleAdapter.moduleRefCountIncrement(jobId) == 1) {
// if first module for this job then check the server and existence of keywords
final Server server = KeywordSearch.getServer(); final Server server = KeywordSearch.getServer();
try { try {
if (!server.isRunning()) { if (!server.isRunning()) {