Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceProcessorRunner.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018 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.testutils;
20 
21 import java.nio.file.Path;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.UUID;
25 import javax.annotation.concurrent.Immutable;
29 import org.sleuthkit.datamodel.Content;
30 
35 public final class DataSourceProcessorRunner {
36 
39  Object ingestMonitor = new Object();
40  ProcessorCallback callBack = new ProcessorCallback(ingestMonitor);
41  synchronized (ingestMonitor) {
42  processor.process(UUID.randomUUID().toString(), dataSourcePath, progressMonitor, callBack);
43  ingestMonitor.wait();
44  }
45  return callBack;
46  }
47 
52  }
53 
59  @Immutable
60  public static final class ProcessorCallback extends DataSourceProcessorCallback {
61 
62  private final Object monitor;
63  private final List<String> errorMessages = new ArrayList<>();
64  private final List<Content> dataSourceContent = new ArrayList<>();
66 
76  private ProcessorCallback(Object monitor) {
77  this.monitor = monitor;
78  }
79 
91  @Override
92  public void done(DataSourceProcessorCallback.DataSourceProcessorResult result, List<String> errorMessages, List<Content> dataSourceContent) {
93  this.errorMessages.addAll(errorMessages);
94  this.dataSourceContent.addAll(dataSourceContent);
95  this.result = result;
96  synchronized (monitor) {
97  monitor.notify();
98  }
99  }
100 
113  @Override
114  public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List<String> errorMessages, List<Content> dataSourceContent) {
115  done(result, errorMessages, dataSourceContent);
116  }
117 
123  public List<String> getErrorMessages() {
124  return new ArrayList<>(this.errorMessages);
125  }
126 
133  public List<Content> getDataSourceContent() {
134  return new ArrayList<>(this.dataSourceContent);
135  }
136 
143  return result;
144  }
145  }
146 
150  @Immutable
151  private static final class ProgressMonitor implements DataSourceProcessorProgressMonitor {
152 
161  @Override
162  public void setIndeterminate(final boolean indeterminate) {
163  }
164 
172  @Override
173  public void setProgress(final int workUnitsCompleted) {
174  }
175 
181  @Override
182  public void setProgressText(final String message) {
183  }
184  }
185 
186 }
static ProcessorCallback runDataSourceProcessor(AutoIngestDataSourceProcessor processor, Path dataSourcePath)
void done(DataSourceProcessorCallback.DataSourceProcessorResult result, List< String > errorMessages, List< Content > dataSourceContent)
void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List< String > errorMessages, List< Content > dataSourceContent)

Copyright © 2012-2022 Basis Technology. Generated on: Wed Oct 5 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.