Merge pull request #605 from rcordovano/parallel_file_ingest

Ordered ingest modules in ingest job configuration panel
This commit is contained in:
Richard Cordovano 2014-04-09 16:37:58 -04:00
commit bd46a5a8f1
2 changed files with 44 additions and 6 deletions

View File

@ -87,7 +87,7 @@ import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel;
* extend the abstract class IngestModuleFactoryAdapter to get default
* implementations of most of the IngestModuleFactory methods.
*/
// @ServiceProvider(service = IngestModuleFactory.class)
@ServiceProvider(service = IngestModuleFactory.class) // Sample is discarded at runtime
public class SampleIngestModuleFactory implements IngestModuleFactory {
private static final String VERSION_NUMBER = "1.0.0";

View File

@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.ingest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
@ -27,7 +28,7 @@ import org.openide.util.Lookup;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
* Looks up loaded ingest module factories using the NetBean global lookup.
* Looks up loaded ingest module factories using the NetBeans global lookup.
*/
final class IngestModuleFactoryLoader {
@ -43,20 +44,57 @@ final class IngestModuleFactoryLoader {
}
return instance;
}
synchronized List<IngestModuleFactory> getIngestModuleFactories() {
List<IngestModuleFactory> moduleFactories = new ArrayList<>();
// Discover the ingest module factories, making sure that there are no
// duplicate module display names. The duplicates requirement could be
// eliminated if the enabled/disabled modules setting was by factory
// class name instead of module display name. Also note that that we are
// temporarily hard-coding ordering of module factories until the
// module configuration file is reworked, so the discovered factories
// are initially mapped by class name.
HashSet<String> moduleDisplayNames = new HashSet<>();
HashMap<String, IngestModuleFactory> moduleFactoriesByClass = new HashMap<>();
Collection<? extends IngestModuleFactory> factories = Lookup.getDefault().lookupAll(IngestModuleFactory.class);
for (IngestModuleFactory factory : factories) {
logger.log(Level.INFO, "Found ingest module factory: name = {0}, version = {1}", new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
moduleFactories.add(factory);
moduleFactoriesByClass.put(factory.getClass().getCanonicalName(), factory);
moduleDisplayNames.add(factory.getModuleDisplayName());
} else {
// Not popping up a message box to keep this class UI-indepdent.
logger.log(Level.SEVERE, "Found duplicate ingest module display name, discarding ingest module factory (name = {0}", new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
}
}
return new ArrayList<>(moduleFactories);
// Kick out the sample modules factory.
moduleFactoriesByClass.remove("org.sleuthkit.autopsy.examples.SampleIngestModuleFactory");
// Do the core ingest module ordering hack described above.
ArrayList<String> coreModuleOrdering = new ArrayList<String>() {{
add("org.sleuthkit.autopsy.recentactivity.RecentActivityExtracterModuleFactory");
add("org.sleuthkit.autopsy.ewfverify.EwfVerifierModuleFactory");
add("org.sleuthkit.autopsy.hashdatabase.HashLookupModuleFactory");
add("org.sleuthkit.autopsy.modules.filetypeid.FileTypeIdModuleFactory");
add("org.sleuthkit.autopsy.modules.sevenzip.ArchiveFileExtractorModuleFactory");
add("org.sleuthkit.autopsy.modules.exif.ExifParserModuleFactory");
add("org.sleuthkit.autopsy.keywordsearch.KeywordSearchModuleFactory");
add("org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory");
add("org.sleuthkit.autopsy.fileextmismatch.FileExtMismatchDetectorModuleFactory");
}};
List<IngestModuleFactory> orderedModuleFactories = new ArrayList<>();
for (String className : coreModuleOrdering) {
IngestModuleFactory coreFactory = moduleFactoriesByClass.remove(className);
if (coreFactory != null) {
orderedModuleFactories.add(coreFactory);
}
}
// Add in any non-core factories discovered. Order is not guaranteed!
for (IngestModuleFactory nonCoreFactory : moduleFactoriesByClass.values()) {
orderedModuleFactories.add(nonCoreFactory);
}
return orderedModuleFactories;
}
}