Autopsy  4.21.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 IngestPipeline<DataSourceIngestTask> {
33 
34  private static final Logger logger = Logger.getLogger(DataSourceIngestPipeline.class.getName());
35  private static final IngestManager ingestManager = IngestManager.getInstance();
36 
47  DataSourceIngestPipeline(IngestJobExecutor ingestJobExecutor, List<IngestModuleTemplate> moduleTemplates) {
48  super(ingestJobExecutor, moduleTemplates);
49  }
50 
51  @Override
52  Optional<IngestPipeline.PipelineModule<DataSourceIngestTask>> acceptModuleTemplate(IngestModuleTemplate template) {
53  Optional<IngestPipeline.PipelineModule<DataSourceIngestTask>> module = Optional.empty();
54  if (template.isDataSourceIngestModuleTemplate()) {
55  DataSourceIngestModule ingestModule = template.createDataSourceIngestModule();
56  module = Optional.of(new DataSourcePipelineModule(ingestModule, template.getModuleName()));
57  }
58  return module;
59  }
60 
61  @Override
62  void prepareForTask(DataSourceIngestTask task) {
63  }
64 
65  @Override
66  void cleanUpAfterTask(DataSourceIngestTask task) {
67  ingestManager.setIngestTaskProgressCompleted(task);
68  }
69 
74  static final class DataSourcePipelineModule extends IngestPipeline.PipelineModule<DataSourceIngestTask> {
75 
76  private final DataSourceIngestModule module;
77 
82  DataSourcePipelineModule(DataSourceIngestModule module, String displayName) {
83  super(module, displayName);
84  this.module = module;
85  }
86 
87  @Override
88  void process(IngestJobExecutor ingestJobExecutor, DataSourceIngestTask task) throws IngestModuleException {
89  Content dataSource = task.getDataSource();
90  String progressBarDisplayName = NbBundle.getMessage(this.getClass(), "IngestJob.progress.dataSourceIngest.displayName", getDisplayName(), dataSource.getName());
91  ingestJobExecutor.changeDataSourceIngestProgressBarTitle(progressBarDisplayName);
92  ingestJobExecutor.switchDataSourceIngestProgressBarToIndeterminate();
93  ingestManager.setIngestTaskProgress(task, getDisplayName());
94  logger.log(Level.INFO, "{0} analysis of {1} starting", new Object[]{getDisplayName(), dataSource.getName()}); //NON-NLS
95  module.process(dataSource, new DataSourceIngestModuleProgress(ingestJobExecutor));
96  logger.log(Level.INFO, "{0} analysis of {1} finished", new Object[]{getDisplayName(), dataSource.getName()}); //NON-NLS
97  if (!ingestJobExecutor.isCancelled() && ingestJobExecutor.currentDataSourceIngestModuleIsCancelled()) {
98  ingestJobExecutor.currentDataSourceIngestModuleCancellationCompleted(getDisplayName());
99  }
100  }
101 
102  }
103 
104 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.