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;
41 class AddLocalFilesTask
implements Runnable {
43 private static final Logger LOGGER = Logger.getLogger(AddLocalFilesTask.class.getName());
44 private final String deviceId;
45 private final String rootVirtualDirectoryName;
46 private final Host host;
47 private final List<String> localFilePaths;
48 private final DataSourceProcessorProgressMonitor progress;
49 private final DataSourceProcessorCallback callback;
74 AddLocalFilesTask(String deviceId, String rootVirtualDirectoryName, List<String> localFilePaths, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
75 this.deviceId = deviceId;
76 this.rootVirtualDirectoryName = rootVirtualDirectoryName;
77 this.localFilePaths = localFilePaths;
79 this.callback = callback;
80 this.progress = progressMonitor;
90 List<Content> newDataSources =
new ArrayList<>();
91 List<String> errors =
new ArrayList<>();
93 progress.setIndeterminate(
true);
94 FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
95 LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, rootVirtualDirectoryName,
"", host, localFilePaths,
new ProgressUpdater());
96 newDataSources.add(newDataSource);
97 }
catch (TskDataException | TskCoreException | NoCurrentCaseException ex) {
98 errors.add(ex.getMessage());
99 LOGGER.log(Level.SEVERE, String.format(
"Failed to add datasource: %s", ex.getMessage()), ex);
101 DataSourceProcessorCallback.DataSourceProcessorResult result;
102 if (!errors.isEmpty()) {
103 result = DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS;
105 result = DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS;
107 callback.done(result, errors, newDataSources);
126 if (count % 10 == 0) {
127 progress.setProgressText(NbBundle.getMessage(
this.getClass(),
128 "AddLocalFilesTask.localFileAdd.progress.text",
129 file.getParentPath(),
void fileAdded(final AbstractFile file)