30 package org.sleuthkit.autopsy.examples;
32 import java.util.List;
33 import java.util.logging.Level;
58 class SampleDataSourceIngestModule
implements DataSourceIngestModule {
60 private final boolean skipKnownFiles;
61 private IngestJobContext context = null;
63 SampleDataSourceIngestModule(SampleModuleIngestJobSettings settings) {
64 this.skipKnownFiles = settings.skipKnownFiles();
68 public void startUp(IngestJobContext context)
throws IngestModuleException {
69 this.context = context;
73 public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress progressBar) {
76 progressBar.switchToDeterminate(2);
80 FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
81 List<AbstractFile> docFiles = fileManager.findFiles(dataSource,
"%.doc");
84 for (AbstractFile docFile : docFiles) {
85 if (!skipKnownFiles || docFile.getKnown() != TskData.FileKnown.KNOWN) {
89 progressBar.progress(1);
92 if (context.dataSourceIngestIsCancelled()) {
93 return IngestModule.ProcessResult.OK;
97 long currentTime = System.currentTimeMillis() / 1000;
98 long minTime = currentTime - (14 * 24 * 60 * 60);
99 List<AbstractFile> otherFiles = fileManager.findFiles(dataSource,
"crtime > " + minTime);
100 for (AbstractFile otherFile : otherFiles) {
101 if (!skipKnownFiles || otherFile.getKnown() != TskData.FileKnown.KNOWN) {
105 progressBar.progress(1);
107 if (context.dataSourceIngestIsCancelled()) {
108 return IngestModule.ProcessResult.OK;
112 String msgText = String.format(
"Found %d files", fileCount);
113 IngestMessage message = IngestMessage.createMessage(
114 IngestMessage.MessageType.DATA,
115 SampleIngestModuleFactory.getModuleName(),
117 IngestServices.getInstance().postMessage(message);
119 return IngestModule.ProcessResult.OK;
121 }
catch (TskCoreException | NoCurrentCaseException ex) {
122 IngestServices ingestServices = IngestServices.getInstance();
123 Logger logger = ingestServices.getLogger(SampleIngestModuleFactory.getModuleName());
124 logger.log(Level.SEVERE,
"File query failed", ex);
125 return IngestModule.ProcessResult.ERROR;