Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceIngestPipeline.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-2021 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest;
20 
21 import java.util.List;
22 import java.util.Optional;
23 import java.util.logging.Level;
24 import org.openide.util.NbBundle;
26 import org.sleuthkit.datamodel.Content;
27 
32 final class DataSourceIngestPipeline extends IngestTaskPipeline<DataSourceIngestTask> {
33 
34  private static final Logger logger = Logger.getLogger(DataSourceIngestPipeline.class.getName());
35  private static final IngestManager ingestManager = IngestManager.getInstance();
36 
45  DataSourceIngestPipeline(IngestJobPipeline ingestJobPipeline, List<IngestModuleTemplate> moduleTemplates) {
46  super(ingestJobPipeline, moduleTemplates);
47  }
48 
49  @Override
50  Optional<IngestTaskPipeline.PipelineModule<DataSourceIngestTask>> acceptModuleTemplate(IngestModuleTemplate template) {
51  Optional<IngestTaskPipeline.PipelineModule<DataSourceIngestTask>> module = Optional.empty();
52  if (template.isDataSourceIngestModuleTemplate()) {
53  DataSourceIngestModule ingestModule = template.createDataSourceIngestModule();
54  module = Optional.of(new DataSourcePipelineModule(ingestModule, template.getModuleName()));
55  }
56  return module;
57  }
58 
59  @Override
60  void prepareForTask(DataSourceIngestTask task) {
61  }
62 
63  @Override
64  void cleanUpAfterTask(DataSourceIngestTask task) {
65  ingestManager.setIngestTaskProgressCompleted(task);
66  }
67 
72  static final class DataSourcePipelineModule extends IngestTaskPipeline.PipelineModule<DataSourceIngestTask> {
73 
74  private final DataSourceIngestModule module;
75 
80  DataSourcePipelineModule(DataSourceIngestModule module, String displayName) {
81  super(module, displayName);
82  this.module = module;
83  }
84 
85  @Override
86  void executeTask(IngestJobPipeline ingestJobPipeline, DataSourceIngestTask task) throws IngestModuleException {
87  Content dataSource = task.getDataSource();
88  String progressBarDisplayName = NbBundle.getMessage(this.getClass(), "IngestJob.progress.dataSourceIngest.displayName", getDisplayName(), dataSource.getName());
89  ingestJobPipeline.updateDataSourceIngestProgressBarDisplayName(progressBarDisplayName);
90  ingestJobPipeline.switchDataSourceIngestProgressBarToIndeterminate();
91  ingestManager.setIngestTaskProgress(task, getDisplayName());
92  logger.log(Level.INFO, "{0} analysis of {1} starting", new Object[]{getDisplayName(), dataSource.getName()}); //NON-NLS
93  module.process(dataSource, new DataSourceIngestModuleProgress(ingestJobPipeline));
94  logger.log(Level.INFO, "{0} analysis of {1} finished", new Object[]{getDisplayName(), dataSource.getName()}); //NON-NLS
95  if (!ingestJobPipeline.isCancelled() && ingestJobPipeline.currentDataSourceIngestModuleIsCancelled()) {
96  ingestJobPipeline.currentDataSourceIngestModuleCancellationCompleted(getDisplayName());
97  }
98  }
99 
100  }
101 
102 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.