19package org.sleuthkit.autopsy.modules.drones;
22import java.io.IOException;
23import java.nio.file.Path;
24import java.nio.file.Paths;
25import org.sleuthkit.autopsy.casemodule.Case;
26import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
27import org.sleuthkit.autopsy.datamodel.ContentUtils;
28import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleProgress;
29import org.sleuthkit.autopsy.ingest.IngestJobContext;
30import org.sleuthkit.datamodel.AbstractFile;
31import org.sleuthkit.datamodel.Content;
32import org.sleuthkit.datamodel.SleuthkitCase;
37abstract class DroneExtractor {
39 static private final String TEMP_FOLDER_NAME =
"DroneExtractor";
40 private final Case currentCase;
47 protected DroneExtractor() throws DroneIngestException {
49 currentCase = Case.getCurrentCaseThrows();
50 }
catch (NoCurrentCaseException ex) {
51 throw new DroneIngestException(
"Unable to create drone extractor, no open case.", ex);
55 abstract void process(Content dataSource, IngestJobContext context, DataSourceIngestModuleProgress progressBar)
throws DroneIngestException;
57 abstract String getName();
64 final protected Case getCurrentCase() {
73 final protected SleuthkitCase getSleuthkitCase() {
74 return currentCase.getSleuthkitCase();
86 protected Path getExtractorTempPath() {
87 Path path = Paths.get(currentCase.getTempDirectory(), TEMP_FOLDER_NAME,
this.getClass().getCanonicalName());
88 File dir = path.toFile();
106 protected File getTemporaryFile(IngestJobContext context, AbstractFile file)
throws DroneIngestException {
107 String tempFileName = file.getName() + file.getId() + file.getNameExtension();
109 Path tempFilePath = Paths.get(getExtractorTempPath().toString(), tempFileName);
112 ContentUtils.writeToFile(file, tempFilePath.toFile(), context::dataSourceIngestIsCancelled);
113 }
catch (IOException ex) {
114 throw new DroneIngestException(String.format(
"Unable to create temp file %s for abstract file %s objectID: %d", tempFilePath.toString(), file.getName(), file.getId()), ex);
117 return tempFilePath.toFile();