1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-09-02 18:25:51 +00:00

Tidying EFE class changes for java.io.File retries

This commit is contained in:
Richard Cordovano
2020-12-16 12:53:46 -05:00
parent 87a2cb740e
commit 1b3ec602b5
3 changed files with 28 additions and 30 deletions

View File

@@ -123,7 +123,7 @@ class DocumentEmbeddedContentExtractor {
DocumentEmbeddedContentExtractor(IngestJobContext context, FileTypeDetector fileTypeDetector, String moduleDirRelative, String moduleDirAbsolute) throws NoCurrentCaseException {
this.fileManager = Case.getCurrentCase().getServices().getFileManager();
this.fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
this.services = IngestServices.getInstance();
this.context = context;
this.fileTypeDetector = fileTypeDetector;

View File

@@ -83,8 +83,8 @@ public final class EmbeddedFileExtractorIngestModule extends FileIngestModuleAda
*
*/
Case currentCase = Case.getCurrentCase();
final String moduleDirAbsolute = Paths.get(currentCase.getModuleDirectory(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString();
final String moduleDirRelative = Paths.get(currentCase.getModuleOutputDirectoryRelativePath(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString();
String moduleDirAbsolute = Paths.get(currentCase.getModuleDirectory(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString();
String moduleDirRelative = Paths.get(currentCase.getModuleOutputDirectoryRelativePath(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString();
/*
* Construct an executor that will be used for calling java.io.File
@@ -94,31 +94,7 @@ public final class EmbeddedFileExtractorIngestModule extends FileIngestModuleAda
* FileTaskExecutor class header docs for more details.
*/
fileTaskExecutor = new FileTaskExecutor(context);
try {
fileTypeDetector = new FileTypeDetector();
} catch (FileTypeDetector.FileTypeDetectorInitException ex) {
throw new IngestModuleException(Bundle.CannotRunFileTypeDetection(), ex);
}
try {
archiveExtractor = new SevenZipExtractor(context, fileTypeDetector, moduleDirRelative, moduleDirAbsolute, fileTaskExecutor);
} catch (SevenZipNativeInitializationException ex) {
throw new IngestModuleException(Bundle.UnableToInitializeLibraries(), ex);
}
try {
documentExtractor = new DocumentEmbeddedContentExtractor(context, fileTypeDetector, moduleDirRelative, moduleDirAbsolute);
} catch (NoCurrentCaseException ex) {
fileTaskExecutor.shutDown();
/*
* Exception message is localized because these ingestmodule start
* up exceptions are displayed to the user when running with the RCP
* GUI.
*/
throw new IngestModuleException(Bundle.EmbeddedFileExtractorIngestModule_UnableToGetMSOfficeExtractor_errMsg(), ex);
}
if (refCounter.incrementAndGet(jobId) == 1) {
try {
File extractionDirectory = new File(moduleDirAbsolute);
@@ -146,6 +122,30 @@ public final class EmbeddedFileExtractorIngestModule extends FileIngestModuleAda
*/
mapOfDepthTrees.put(jobId, new ConcurrentHashMap<>());
}
try {
fileTypeDetector = new FileTypeDetector();
} catch (FileTypeDetector.FileTypeDetectorInitException ex) {
throw new IngestModuleException(Bundle.CannotRunFileTypeDetection(), ex);
}
try {
archiveExtractor = new SevenZipExtractor(context, fileTypeDetector, moduleDirRelative, moduleDirAbsolute, fileTaskExecutor);
} catch (SevenZipNativeInitializationException ex) {
throw new IngestModuleException(Bundle.UnableToInitializeLibraries(), ex);
}
try {
documentExtractor = new DocumentEmbeddedContentExtractor(context, fileTypeDetector, moduleDirRelative, moduleDirAbsolute);
} catch (NoCurrentCaseException ex) {
fileTaskExecutor.shutDown();
/*
* Exception message is localized because these ingestmodule start
* up exceptions are displayed to the user when running with the RCP
* GUI.
*/
throw new IngestModuleException(Bundle.EmbeddedFileExtractorIngestModule_UnableToGetMSOfficeExtractor_errMsg(), ex);
}
}
@Override

View File

@@ -18,7 +18,6 @@
*/
package org.sleuthkit.autopsy.modules.embeddedfileextractor;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -34,7 +33,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.logging.Level;
import net.sf.sevenzipjbinding.ArchiveFormat;
import static net.sf.sevenzipjbinding.ArchiveFormat.RAR;