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));
132 String msg = ex.getMessage();
137 MessageNotifyUtil.Notify.error(NbBundle.getMessage(
this.getClass(),
"FileIngestPipeline.moduleError.title.text", module.getDisplayName()), msg);
139 if (this.job.isCancelled()) {
144 if (!this.job.isCancelled()) {
148 }
catch (TskCoreException ex){
149 Logger.getLogger(FileIngestPipeline.class.getName()).log(Level.SEVERE,
"Failed to save data for file " + file.getId(), ex);
151 IngestManager.getInstance().fireFileIngestDone(file);
155 FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task);
164 synchronized List<IngestModuleError> shutDown() {
165 List<IngestModuleError> errors =
new ArrayList<>();
166 if (this.running ==
true) {
167 for (PipelineModule module : this.modules) {
170 }
catch (Throwable ex) {
171 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
172 String msg = ex.getMessage();
177 MessageNotifyUtil.Notify.error(NbBundle.getMessage(
this.getClass(),
"FileIngestPipeline.moduleError.title.text", module.getDisplayName()), msg);
181 this.running =
false;
210 String getClassName() {
211 return module.getClass().getCanonicalName();
219 String getDisplayName() {
ProcessResult process(AbstractFile file)
void startUp(IngestJobContext context)
IngestModule.ProcessResult process(AbstractFile file)
void startUp(IngestJobContext context)
final FileIngestModule module