30 package org.sleuthkit.autopsy.examples;
32 import java.util.List;
33 import java.util.logging.Level;
57 class SampleDataSourceIngestModule
implements DataSourceIngestModule {
59 private final boolean skipKnownFiles;
60 private IngestJobContext context = null;
62 SampleDataSourceIngestModule(SampleModuleIngestJobSettings settings) {
63 this.skipKnownFiles = settings.skipKnownFiles();
67 public void startUp(IngestJobContext context)
throws IngestModuleException {
68 this.context = context;
72 public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress progressBar) {
75 progressBar.switchToDeterminate(2);
79 FileManager fileManager = Case.getCurrentCase().getServices().getFileManager();
80 List<AbstractFile> docFiles = fileManager.findFiles(dataSource,
"%.doc");
83 for (AbstractFile docFile : docFiles) {
84 if (!skipKnownFiles || docFile.getKnown() != TskData.FileKnown.KNOWN) {
88 progressBar.progress(1);
91 if (context.dataSourceIngestIsCancelled()) {
92 return IngestModule.ProcessResult.OK;
96 long currentTime = System.currentTimeMillis() / 1000;
97 long minTime = currentTime - (14 * 24 * 60 * 60);
98 List<AbstractFile> otherFiles = fileManager.findFiles(dataSource,
"crtime > " + minTime);
99 for (AbstractFile otherFile : otherFiles) {
100 if (!skipKnownFiles || otherFile.getKnown() != TskData.FileKnown.KNOWN) {
104 progressBar.progress(1);
106 if (context.dataSourceIngestIsCancelled()) {
107 return IngestModule.ProcessResult.OK;
111 String msgText = String.format(
"Found %d files", fileCount);
112 IngestMessage message = IngestMessage.createMessage(
113 IngestMessage.MessageType.DATA,
114 SampleIngestModuleFactory.getModuleName(),
116 IngestServices.getInstance().postMessage(message);
118 return IngestModule.ProcessResult.OK;
120 }
catch (TskCoreException ex) {
121 IngestServices ingestServices = IngestServices.getInstance();
122 Logger logger = ingestServices.getLogger(SampleIngestModuleFactory.getModuleName());
123 logger.log(Level.SEVERE,
"File query failed", ex);
124 return IngestModule.ProcessResult.ERROR;