30 package org.sleuthkit.autopsy.examples;
32 import java.util.List;
33 import java.util.logging.Level;
55 class SampleDataSourceIngestModule
implements DataSourceIngestModule {
57 private final boolean skipKnownFiles;
58 private IngestJobContext context = null;
60 SampleDataSourceIngestModule(SampleModuleIngestJobSettings settings) {
61 this.skipKnownFiles = settings.skipKnownFiles();
65 public void startUp(IngestJobContext context)
throws IngestModuleException {
66 this.context = context;
70 public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress progressBar) {
73 progressBar.switchToDeterminate(2);
77 FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
78 List<AbstractFile> docFiles = fileManager.findFiles(dataSource,
"%.doc");
81 for (AbstractFile docFile : docFiles) {
82 if (!skipKnownFiles || docFile.getKnown() != TskData.FileKnown.KNOWN) {
86 progressBar.progress(1);
89 if (context.dataSourceIngestIsCancelled()) {
90 return IngestModule.ProcessResult.OK;
94 long currentTime = System.currentTimeMillis() / 1000;
95 long minTime = currentTime - (14 * 24 * 60 * 60);
96 List<AbstractFile> otherFiles = fileManager.findFiles(dataSource,
"crtime > " + minTime);
97 for (AbstractFile otherFile : otherFiles) {
98 if (!skipKnownFiles || otherFile.getKnown() != TskData.FileKnown.KNOWN) {
102 progressBar.progress(1);
104 if (context.dataSourceIngestIsCancelled()) {
105 return IngestModule.ProcessResult.OK;
109 String msgText = String.format(
"Found %d files", fileCount);
110 IngestMessage message = IngestMessage.createMessage(
111 IngestMessage.MessageType.DATA,
112 SampleIngestModuleFactory.getModuleName(),
114 IngestServices.getInstance().postMessage(message);
116 return IngestModule.ProcessResult.OK;
118 }
catch (TskCoreException | NoCurrentCaseException ex) {
119 IngestServices ingestServices = IngestServices.getInstance();
120 Logger logger = ingestServices.getLogger(SampleIngestModuleFactory.getModuleName());
121 logger.log(Level.SEVERE,
"File query failed", ex);
122 return IngestModule.ProcessResult.ERROR;