19 package org.sleuthkit.autopsy.ingest;
21 import java.util.ArrayList;
22 import java.util.Date;
23 import java.util.List;
24 import java.util.logging.Level;
26 import org.openide.util.NbBundle;
39 final class FileIngestPipeline {
41 private static final IngestManager ingestManager = IngestManager.getInstance();
42 private final IngestJobPipeline ingestJobPipeline;
43 private final List<PipelineModule> modules =
new ArrayList<>();
44 private Date startTime;
45 private volatile boolean running;
56 FileIngestPipeline(IngestJobPipeline ingestJobPipeline, List<IngestModuleTemplate> moduleTemplates) {
57 this.ingestJobPipeline = ingestJobPipeline;
58 for (IngestModuleTemplate
template : moduleTemplates) {
59 if (
template.isFileIngestModuleTemplate()) {
60 PipelineModule module =
new PipelineModule(
template.createFileIngestModule(),
template.getModuleName());
72 return this.modules.isEmpty();
91 return this.startTime;
99 synchronized List<IngestModuleError> startUp() {
100 this.startTime =
new Date();
102 List<IngestModuleError> errors =
new ArrayList<>();
103 for (PipelineModule module : this.modules) {
105 module.startUp(
new IngestJobContext(this.ingestJobPipeline));
106 }
catch (Throwable ex) {
107 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
120 synchronized List<IngestModuleError> process(FileIngestTask task) {
121 List<IngestModuleError> errors =
new ArrayList<>();
122 if (!this.ingestJobPipeline.isCancelled()) {
125 file = task.getFile();
126 }
catch (TskCoreException ex) {
129 errors.add(
new IngestModuleError(
"File Ingest Pipeline", ex));
130 FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task);
133 for (PipelineModule module : this.modules) {
135 FileIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName());
136 this.ingestJobPipeline.setCurrentFileIngestModule(module.getDisplayName(), task.getFile().getName());
137 module.process(file);
138 }
catch (Throwable ex) {
139 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
141 if (this.ingestJobPipeline.isCancelled()) {
146 if (!this.ingestJobPipeline.isCancelled()) {
150 }
catch (TskCoreException ex){
151 Logger.getLogger(FileIngestPipeline.class.getName()).log(Level.SEVERE,
"Failed to save data for file " + file.getId(), ex);
153 IngestManager.getInstance().fireFileIngestDone(file);
157 FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task);
166 synchronized List<IngestModuleError> shutDown() {
167 List<IngestModuleError> errors =
new ArrayList<>();
168 if (this.running ==
true) {
169 for (PipelineModule module : this.modules) {
172 }
catch (Throwable ex) {
173 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
174 String msg = ex.getMessage();
179 MessageNotifyUtil.Notify.error(NbBundle.getMessage(
this.getClass(),
"FileIngestPipeline.moduleError.title.text", module.getDisplayName()), msg);
183 this.running =
false;
212 String getClassName() {
213 return module.getClass().getCanonicalName();
221 String getDisplayName() {
ProcessResult process(AbstractFile file)
void startUp(IngestJobContext context)
IngestModule.ProcessResult process(AbstractFile file)
void startUp(IngestJobContext context)
final FileIngestModule module