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;
25 import org.openide.util.NbBundle;
37 final class DataSourceIngestPipeline {
39 private static final IngestManager ingestManager = IngestManager.getInstance();
40 private static final Logger logger = Logger.getLogger(DataSourceIngestPipeline.class.getName());
41 private final DataSourceIngestJob job;
42 private final List<PipelineModule> modules =
new ArrayList<>();
43 private volatile PipelineModule currentModule;
55 DataSourceIngestPipeline(DataSourceIngestJob job, List<IngestModuleTemplate> moduleTemplates) {
57 for (IngestModuleTemplate
template : moduleTemplates) {
58 if (
template.isDataSourceIngestModuleTemplate()) {
59 PipelineModule module =
new PipelineModule(
template.createDataSourceIngestModule(),
template.getModuleName());
71 return modules.isEmpty();
79 synchronized List<IngestModuleError> startUp() {
80 List<IngestModuleError> errors =
new ArrayList<>();
81 for (PipelineModule module : modules) {
83 module.startUp(
new IngestJobContext(this.job));
84 }
catch (Throwable ex) {
85 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
99 synchronized List<IngestModuleError> process(DataSourceIngestTask task) {
100 List<IngestModuleError> errors =
new ArrayList<>();
101 if (!this.job.isCancelled()) {
102 Content dataSource = task.getDataSource();
103 for (PipelineModule module : modules) {
105 this.currentModule = module;
106 String displayName = NbBundle.getMessage(this.getClass(),
107 "IngestJob.progress.dataSourceIngest.displayName",
108 module.getDisplayName(), dataSource.getName());
109 this.job.updateDataSourceIngestProgressBarDisplayName(displayName);
110 this.job.switchDataSourceIngestProgressBarToIndeterminate();
111 DataSourceIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName());
112 logger.log(Level.INFO,
"{0} analysis of {1} (jobId={2}) starting",
new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()});
113 module.process(dataSource,
new DataSourceIngestModuleProgress(this.job));
114 logger.log(Level.INFO,
"{0} analysis of {1} (jobId={2}) finished",
new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()});
115 }
catch (Throwable ex) {
116 errors.add(
new IngestModuleError(module.getDisplayName(), ex));
117 String msg = ex.getMessage();
122 MessageNotifyUtil.Notify.error(NbBundle.getMessage(
this.getClass(),
"DataSourceIngestPipeline.moduleError.title.text", module.getDisplayName()), msg);
124 if (this.job.isCancelled()) {
126 }
else if (this.job.currentDataSourceIngestModuleIsCancelled()) {
127 this.job.currentDataSourceIngestModuleCancellationCompleted(currentModule.getDisplayName());
131 this.currentModule = null;
132 ingestManager.setIngestTaskProgressCompleted(task);
141 PipelineModule getCurrentlyRunningModule() {
142 return this.currentModule;
149 static class PipelineModule
implements DataSourceIngestModule {
151 private final DataSourceIngestModule module;
152 private final String displayName;
153 private volatile Date processingStartTime;
163 PipelineModule(DataSourceIngestModule module, String displayName) {
164 this.module = module;
165 this.displayName = displayName;
166 this.processingStartTime =
new Date();
174 String getClassName() {
175 return this.module.getClass().getCanonicalName();
183 String getDisplayName() {
184 return this.displayName;
194 Date getProcessingStartTime() {
195 return this.processingStartTime;
199 public void startUp(IngestJobContext context)
throws IngestModuleException {
200 this.module.startUp(context);
204 public IngestModule.ProcessResult process(Content dataSource, DataSourceIngestModuleProgress statusHelper) {
205 this.processingStartTime =
new Date();
206 return this.module.process(dataSource, statusHelper);