19 package org.sleuthkit.autopsy.casemodule;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.logging.Level;
24 import org.openide.util.NbBundle;
40 class AddLocalFilesTask
implements Runnable {
42 private static final Logger LOGGER = Logger.getLogger(AddLocalFilesTask.class.getName());
43 private final String deviceId;
44 private final String rootVirtualDirectoryName;
45 private final List<String> localFilePaths;
46 private final DataSourceProcessorProgressMonitor progress;
47 private final DataSourceProcessorCallback callback;
71 AddLocalFilesTask(String deviceId, String rootVirtualDirectoryName, List<String> localFilePaths, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
72 this.deviceId = deviceId;
73 this.rootVirtualDirectoryName = rootVirtualDirectoryName;
74 this.localFilePaths = localFilePaths;
75 this.callback = callback;
76 this.progress = progressMonitor;
86 List<Content> newDataSources =
new ArrayList<>();
87 List<String> errors =
new ArrayList<>();
89 progress.setIndeterminate(
true);
90 FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
91 LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, rootVirtualDirectoryName,
"", localFilePaths,
new ProgressUpdater());
92 newDataSources.add(newDataSource);
93 }
catch (TskDataException | TskCoreException | NoCurrentCaseException ex) {
94 errors.add(ex.getMessage());
95 LOGGER.log(Level.SEVERE, String.format(
"Failed to add datasource: %s", ex.getMessage()), ex);
97 DataSourceProcessorCallback.DataSourceProcessorResult result;
98 if (!errors.isEmpty()) {
99 result = DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS;
101 result = DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS;
103 callback.done(result, errors, newDataSources);
122 if (count % 10 == 0) {
123 progress.setProgressText(NbBundle.getMessage(
this.getClass(),
124 "AddLocalFilesTask.localFileAdd.progress.text",
125 file.getParentPath(),
void fileAdded(final AbstractFile file)