19package org.sleuthkit.autopsy.testutils;
21import java.nio.file.Path;
24import org.apache.commons.collections.CollectionUtils;
25import org.sleuthkit.autopsy.casemodule.Case;
26import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
27import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
28import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor;
29import org.sleuthkit.autopsy.ingest.IngestJobSettings;
30import org.sleuthkit.autopsy.ingest.IngestModuleError;
31import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
32import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
33import org.sleuthkit.autopsy.ingest.IngestModuleTemplate;
34import org.sleuthkit.datamodel.Content;
60 if (!dataSourcePath.toFile().exists()) {
61 throw new TestUtilsException(
"IngestUtils.addDataSource: Data source not found: " + dataSourcePath.toString());
63 UUID taskId = UUID.randomUUID();
68 String joinedErrors = String.join(System.lineSeparator(), callBack.getErrorMessages());
69 throw new TestUtilsException(String.format(
"IngestUtils.addDataSource: Error(s) occurred while running the data source processor: %s", joinedErrors));
71 for (Content c:callBack.getDataSourceContent()) {
75 throw new TestUtilsException(
"IngestUtils.addDataSource encountered an error on adding a datasource: " + ex.getMessage(), ex);
90 StringBuilder joinedErrors =
new StringBuilder(
"");
91 errs.forEach((err) -> {
92 joinedErrors.append(String.format(
"Error: %s: %s.", err.getModuleDisplayName(), err.toString())).append(System.lineSeparator());
95 if (CollectionUtils.isNotEmpty(errs)) {
96 throw new TestUtilsException(
"An error occurred while running an ingest job: " + joinedErrors);
99 }
catch (InterruptedException ex) {
116 template.setEnabled(
true);
void notifyAddingDataSource(UUID eventId)
static Case getCurrentCaseThrows()
void notifyDataSourceAdded(Content dataSource, UUID addingDataSourceEventId)
static ProcessorCallback runDataSourceProcessor(AutoIngestDataSourceProcessor processor, Path dataSourcePath)
static List< IngestModuleError > runIngestJob(Collection< Content > dataSources, IngestJobSettings settings)
static void addDataSource(AutoIngestDataSourceProcessor dataSourceProcessor, Path dataSourcePath)
static void runIngestJob(List< Content > datasources, IngestJobSettings ingestJobSettings)
static IngestModuleTemplate getIngestModuleTemplate(IngestModuleFactory factory)
default IngestModuleIngestJobSettings getDefaultIngestJobSettings()