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;
40 final class FileIngestPipeline {
42 private static final IngestManager ingestManager = IngestManager.getInstance();
43 private final DataSourceIngestJob job;
44 private final List<PipelineModule> modules =
new ArrayList<>();
45 private Date startTime;
46 private volatile boolean running;
57 FileIngestPipeline(DataSourceIngestJob job, List<IngestModuleTemplate> moduleTemplates) {
59 for (IngestModuleTemplate
template : moduleTemplates) {
60 if (
template.isFileIngestModuleTemplate()) {
61 PipelineModule module =
new PipelineModule(
template.createFileIngestModule(),
template.getModuleName());
73 return this.modules.isEmpty();
92 return this.startTime;
100 synchronized List<IngestModuleError> startUp() {
101 this.startTime =
new Date();
103 List<IngestModuleError> errors =
new ArrayList<>();
104 for (PipelineModule module : this.modules) {
106 module.startUp(
new IngestJobContext(this.job));
107 }
catch (Throwable ex) {
108 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
121 synchronized List<IngestModuleError> process(FileIngestTask task) {
122 List<IngestModuleError> errors =
new ArrayList<>();
123 if (!this.job.isCancelled()) {
124 AbstractFile file = task.getFile();
125 for (PipelineModule module : this.modules) {
127 FileIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName());
128 this.job.setCurrentFileIngestModule(module.getDisplayName(), task.getFile().getName());
129 module.process(file);
130 }
catch (Throwable ex) {
131 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
133 if (this.job.isCancelled()) {
138 if (!this.job.isCancelled()) {
142 }
catch (TskCoreException ex){
143 Logger.getLogger(FileIngestPipeline.class.getName()).log(Level.SEVERE,
"Failed to save data for file " + file.getId(), ex);
145 IngestManager.getInstance().fireFileIngestDone(file);
149 FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task);
158 synchronized List<IngestModuleError> shutDown() {
159 List<IngestModuleError> errors =
new ArrayList<>();
160 if (this.running ==
true) {
161 for (PipelineModule module : this.modules) {
164 }
catch (Throwable ex) {
165 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
166 String msg = ex.getMessage();
171 MessageNotifyUtil.Notify.error(NbBundle.getMessage(
this.getClass(),
"FileIngestPipeline.moduleError.title.text", module.getDisplayName()), msg);
175 this.running =
false;
204 String getClassName() {
205 return module.getClass().getCanonicalName();
213 String getDisplayName() {
ProcessResult process(AbstractFile file)
void startUp(IngestJobContext context)
IngestModule.ProcessResult process(AbstractFile file)
void startUp(IngestJobContext context)
final FileIngestModule module