From 9cb92987d7941020432f14943ad96ebf9b85e122 Mon Sep 17 00:00:00 2001 From: Ekaterina_Kazachkova Date: Wed, 15 Feb 2023 15:41:26 +0100 Subject: [PATCH] Issue #3029: Optionally exclude archived files from GUI S3 storage listing - cleanups --- .../datastorage/DataStorageManager.java | 22 ++----------------- .../DataStorageLifecycleRestoreManager.java | 18 +++++++++++++++ .../NgsPreprocessingManager.java | 1 - .../resource/StaticResourcesService.java | 1 - 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/api/src/main/java/com/epam/pipeline/manager/datastorage/DataStorageManager.java b/api/src/main/java/com/epam/pipeline/manager/datastorage/DataStorageManager.java index e358529211..a3e4832fcc 100644 --- a/api/src/main/java/com/epam/pipeline/manager/datastorage/DataStorageManager.java +++ b/api/src/main/java/com/epam/pipeline/manager/datastorage/DataStorageManager.java @@ -1406,7 +1406,8 @@ private String createStorageNameIfRequired(final DataStorageVO dataStorageVO) { private DataStorageLifecycleRestoredListingContainer loadRestoredPaths(final AbstractDataStorage storage, final String path) { final String normalizedPath = ProviderUtils.delimiterIfEmpty(ProviderUtils.withLeadingDelimiter(path)); - final List restoredItems = loadSucceededRestoreActions(storage, path); + final List restoredItems = storageLifecycleRestoreManager + .loadSucceededRestoreActions(storage, path); if (CollectionUtils.isEmpty(restoredItems)) { return DataStorageLifecycleRestoredListingContainer.builder() @@ -1438,23 +1439,4 @@ private List getRestoredFilePaths(final List resto .map(StorageRestoreAction::getPath) .collect(Collectors.toList()); } - - private List loadSucceededRestoreActions(final AbstractDataStorage storage, - final String path) { - final List restoredItems = ListUtils.emptyIfNull(storageLifecycleRestoreManager - .loadEffectiveRestoreStorageActionHierarchy(storage, StorageRestorePath.builder() - .path(path) - .type(StorageRestorePathType.FOLDER) - .build(), false)).stream() - .filter(action -> StorageRestoreStatus.SUCCEEDED.equals(action.getStatus())) - .collect(Collectors.toList()); - ListUtils.emptyIfNull(storageLifecycleRestoreManager - .loadEffectiveRestoreStorageActionHierarchy(storage, StorageRestorePath.builder() - .path(path) - .type(StorageRestorePathType.FILE) - .build(), false)).stream() - .filter(action -> StorageRestoreStatus.SUCCEEDED.equals(action.getStatus())) - .forEach(restoredItems::add); - return restoredItems; - } } diff --git a/api/src/main/java/com/epam/pipeline/manager/datastorage/lifecycle/DataStorageLifecycleRestoreManager.java b/api/src/main/java/com/epam/pipeline/manager/datastorage/lifecycle/DataStorageLifecycleRestoreManager.java index 5d9e33d866..43b1ab2c3f 100644 --- a/api/src/main/java/com/epam/pipeline/manager/datastorage/lifecycle/DataStorageLifecycleRestoreManager.java +++ b/api/src/main/java/com/epam/pipeline/manager/datastorage/lifecycle/DataStorageLifecycleRestoreManager.java @@ -198,6 +198,24 @@ public void deleteRestoreActions(final Long datastorageId) { dataStoragePathRestoreActionRepository.flush(); } + public List loadSucceededRestoreActions(final AbstractDataStorage storage, + final String path) { + final List restoredItems = ListUtils.emptyIfNull( + loadEffectiveRestoreStorageActionHierarchy(storage, StorageRestorePath.builder() + .path(path) + .type(StorageRestorePathType.FOLDER) + .build(), false)).stream() + .filter(action -> StorageRestoreStatus.SUCCEEDED.equals(action.getStatus())) + .collect(Collectors.toList()); + ListUtils.emptyIfNull(loadEffectiveRestoreStorageActionHierarchy(storage, StorageRestorePath.builder() + .path(path) + .type(StorageRestorePathType.FILE) + .build(), false)).stream() + .filter(action -> StorageRestoreStatus.SUCCEEDED.equals(action.getStatus())) + .forEach(restoredItems::add); + return restoredItems; + } + protected StorageRestoreActionEntity buildStoragePathRestoreAction( final AbstractDataStorage storage, final StorageRestorePath path, final String restoreMode, final Long days, final boolean restoreVersions, final boolean force, diff --git a/api/src/main/java/com/epam/pipeline/manager/preprocessing/NgsPreprocessingManager.java b/api/src/main/java/com/epam/pipeline/manager/preprocessing/NgsPreprocessingManager.java index 9f8f25d11d..6953ac7592 100644 --- a/api/src/main/java/com/epam/pipeline/manager/preprocessing/NgsPreprocessingManager.java +++ b/api/src/main/java/com/epam/pipeline/manager/preprocessing/NgsPreprocessingManager.java @@ -372,7 +372,6 @@ private List mapSampleSheetToMetadataEntities(final Long folde private boolean checkPathExistence(final Long dataStorageId, final String path) { try { // if we can list it, it should exist - // TODO: do we need to check archived? storageManager.getDataStorageItems(dataStorageId, path, false, 1, null, false); return true; } catch (RuntimeException e) { diff --git a/api/src/main/java/com/epam/pipeline/manager/resource/StaticResourcesService.java b/api/src/main/java/com/epam/pipeline/manager/resource/StaticResourcesService.java index 26853e9ceb..3911676a1c 100644 --- a/api/src/main/java/com/epam/pipeline/manager/resource/StaticResourcesService.java +++ b/api/src/main/java/com/epam/pipeline/manager/resource/StaticResourcesService.java @@ -69,7 +69,6 @@ public DataStorageStreamingContent getContent(final String requestPath) { throw new InvalidPathException( messageHelper.getMessage(MessageConstants.ERROR_STATIC_RESOURCES_FOLDER_PATH)); } - // TODO: Special error on archived content? final List items = dataStorageManager.getDataStorageItems(storage.getId(), ProviderUtils.withTrailingDelimiter(filePath), false, null, null, false).getResults(); final String templatePath = preferenceManager.getPreference(