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) {
73 if (context.dataSourceIngestIsCancelled()) {
74 return IngestModule.ProcessResult.OK;
78 progressBar.switchToDeterminate(2);
80 Case autopsyCase = Case.getCurrentCase();
81 SleuthkitCase sleuthkitCase = autopsyCase.getSleuthkitCase();
82 Services services =
new Services(sleuthkitCase);
83 FileManager fileManager = services.getFileManager();
87 List<AbstractFile> docFiles = fileManager.findFiles(dataSource,
"%.doc");
88 for (AbstractFile docFile : docFiles) {
89 if (!skipKnownFiles || docFile.getKnown() != TskData.FileKnown.KNOWN) {
93 progressBar.progress(1);
95 if (context.dataSourceIngestIsCancelled()) {
96 return IngestModule.ProcessResult.OK;
100 long currentTime = System.currentTimeMillis() / 1000;
101 long minTime = currentTime - (14 * 24 * 60 * 60);
102 List<AbstractFile> otherFiles = fileManager.findFiles(dataSource,
"crtime > " + minTime);
103 for (AbstractFile otherFile : otherFiles) {
104 if (!skipKnownFiles || otherFile.getKnown() != TskData.FileKnown.KNOWN) {
108 progressBar.progress(1);
110 if (context.dataSourceIngestIsCancelled()) {
111 return IngestModule.ProcessResult.OK;
115 String msgText = String.format(
"Found %d files", fileCount);
116 IngestMessage message = IngestMessage.createMessage(
117 IngestMessage.MessageType.DATA,
118 SampleIngestModuleFactory.getModuleName(),
120 IngestServices.getInstance().postMessage(message);
122 return IngestModule.ProcessResult.OK;
124 }
catch (TskCoreException ex) {
125 IngestServices ingestServices = IngestServices.getInstance();
126 Logger logger = ingestServices.getLogger(SampleIngestModuleFactory.getModuleName());
127 logger.log(Level.SEVERE,
"File query failed", ex);
128 return IngestModule.ProcessResult.ERROR;