19 package org.sleuthkit.autopsy.modules.drones;
 
   22 import java.io.IOException;
 
   23 import java.nio.file.Path;
 
   24 import java.nio.file.Paths;
 
   37 abstract 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();