Initial check in of fix for admin data source deletion

This commit is contained in:
Richard Cordovano 2019-04-05 16:58:56 -04:00
parent ceacd50c58
commit db74d751ae
2 changed files with 25 additions and 21 deletions

View File

@ -89,6 +89,10 @@ AutoIngestControlPanel.runningTable.toolTipText=The Running table displays the c
AutoIngestControlPanel.SharedConfigurationDisabled=Shared configuration disabled AutoIngestControlPanel.SharedConfigurationDisabled=Shared configuration disabled
AutoIngestControlPanel.ShowLogFailed.Message=Case log file does not exist AutoIngestControlPanel.ShowLogFailed.Message=Case log file does not exist
AutoIngestControlPanel.ShowLogFailed.Title=Unable to display case log AutoIngestControlPanel.ShowLogFailed.Title=Unable to display case log
# {0} - case db status
# {1} - search svc Status
# {2} - coord svc Status
# {3} - msg broker status
AutoIngestControlPanel.tbServicesStatusMessage.Message=Case databases {0}, keyword search {1}, coordination {2}, messaging {3} AutoIngestControlPanel.tbServicesStatusMessage.Message=Case databases {0}, keyword search {1}, coordination {2}, messaging {3}
AutoIngestControlPanel.tbServicesStatusMessage.Message.Down=down AutoIngestControlPanel.tbServicesStatusMessage.Message.Down=down
AutoIngestControlPanel.tbServicesStatusMessage.Message.Unknown=unknown AutoIngestControlPanel.tbServicesStatusMessage.Message.Unknown=unknown
@ -182,9 +186,8 @@ DeleteCaseTask.progress.acquiringManifestLocks=Acquiring exclusive manifest file
DeleteCaseTask.progress.connectingToCoordSvc=Connecting to the coordination service... DeleteCaseTask.progress.connectingToCoordSvc=Connecting to the coordination service...
DeleteCaseTask.progress.deletingCaseDirCoordSvcNode=Deleting case directory znode... DeleteCaseTask.progress.deletingCaseDirCoordSvcNode=Deleting case directory znode...
DeleteCaseTask.progress.deletingCaseNameCoordSvcNode=Deleting case name znode... DeleteCaseTask.progress.deletingCaseNameCoordSvcNode=Deleting case name znode...
# {0} - data source name # {0} - data source path
# {1} - device id DeleteCaseTask.progress.deletingDataSource=Deleting data source {0}...
DeleteCaseTask.progress.deletingDataSource=Deleting data source {0} with device id {1}...
DeleteCaseTask.progress.deletingJobLogLockNode=Deleting case auto ingest log znode... DeleteCaseTask.progress.deletingJobLogLockNode=Deleting case auto ingest log znode...
# {0} - manifest file path # {0} - manifest file path
DeleteCaseTask.progress.deletingManifest=Deleting manifest file {0}... DeleteCaseTask.progress.deletingManifest=Deleting manifest file {0}...

View File

@ -594,12 +594,12 @@ final class DeleteCaseTask implements Runnable {
* otherwise. * otherwise.
*/ */
@NbBundle.Messages({ @NbBundle.Messages({
"# {0} - data source name", "# {1} - device id", "DeleteCaseTask.progress.deletingDataSource=Deleting data source {0} with device id {1}...",}) "# {0} - data source path", "DeleteCaseTask.progress.deletingDataSource=Deleting data source {0}..."
})
private boolean deleteDataSources(Manifest manifest, List<DataSource> dataSources) { private boolean deleteDataSources(Manifest manifest, List<DataSource> dataSources) {
final String dataSourceFileName = manifest.getDataSourceFileName(); final Path dataSourcePath = manifest.getDataSourcePath();
final String dataSourceDeviceId = manifest.getDeviceId(); progress.progress(Bundle.DeleteCaseTask_progress_deletingDataSource(dataSourcePath));
progress.progress(Bundle.DeleteCaseTask_progress_deletingDataSource(dataSourceFileName, dataSourceDeviceId)); logger.log(Level.INFO, String.format("Deleting data source %s from %s", dataSourcePath, caseNodeData.getDisplayName()));
logger.log(Level.INFO, String.format("Deleting data source %s with device id %s from %s", dataSourceFileName, dataSourceDeviceId, caseNodeData.getDisplayName()));
/* /*
* There are two possibilities here. The data source may be an image, * There are two possibilities here. The data source may be an image,
@ -609,26 +609,27 @@ final class DeleteCaseTask implements Runnable {
* set, report file, archive file, etc.). In this case, just the file * set, report file, archive file, etc.). In this case, just the file
* referenced by the manifest will be deleted. * referenced by the manifest will be deleted.
*/ */
boolean allFilesDeleted = true;
Set<Path> filesToDelete = new HashSet<>(); Set<Path> filesToDelete = new HashSet<>();
for (DataSource dataSource : dataSources) { int index = 0;
while (index < dataSources.size() && filesToDelete.isEmpty()) {
DataSource dataSource = dataSources.get(index);
if (dataSource instanceof Image) { if (dataSource instanceof Image) {
Image image = (Image) dataSource; Image image = (Image) dataSource;
if (image.getName().equals(dataSourceFileName) && image.getDeviceId().equals(dataSourceDeviceId)) { String[] imageFilePaths = image.getPaths();
String[] imageFilePaths = image.getPaths(); for (String imageFilePath : imageFilePaths) {
for (String path : imageFilePaths) { Path candidatePath = Paths.get(imageFilePath);
Path imageFilePath = Paths.get(path); if (candidatePath.equals(dataSourcePath)) {
filesToDelete.add(imageFilePath); for (String path : imageFilePaths) {
filesToDelete.add(Paths.get(path));
}
break;
} }
break;
} }
} }
} }
if (filesToDelete.isEmpty()) { filesToDelete.add(dataSourcePath);
final Path dataSourcePath = manifest.getDataSourcePath();
filesToDelete.add(dataSourcePath); boolean allFilesDeleted = true;
}
for (Path path : filesToDelete) { for (Path path : filesToDelete) {
File fileOrDir = path.toFile(); File fileOrDir = path.toFile();
if (fileOrDir.exists() && !FileUtil.deleteFileDir(fileOrDir)) { if (fileOrDir.exists() && !FileUtil.deleteFileDir(fileOrDir)) {