Skip to content

Commit

Permalink
Issue #3029: Optionally exclude archived files from GUI S3 storage li…
Browse files Browse the repository at this point in the history
…sting - cleanups
  • Loading branch information
ekazachkova committed Feb 15, 2023
1 parent 245e8cf commit 9cb9298
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<StorageRestoreAction> restoredItems = loadSucceededRestoreActions(storage, path);
final List<StorageRestoreAction> restoredItems = storageLifecycleRestoreManager
.loadSucceededRestoreActions(storage, path);

if (CollectionUtils.isEmpty(restoredItems)) {
return DataStorageLifecycleRestoredListingContainer.builder()
Expand Down Expand Up @@ -1438,23 +1439,4 @@ private List<String> getRestoredFilePaths(final List<StorageRestoreAction> resto
.map(StorageRestoreAction::getPath)
.collect(Collectors.toList());
}

private List<StorageRestoreAction> loadSucceededRestoreActions(final AbstractDataStorage storage,
final String path) {
final List<StorageRestoreAction> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ public void deleteRestoreActions(final Long datastorageId) {
dataStoragePathRestoreActionRepository.flush();
}

public List<StorageRestoreAction> loadSucceededRestoreActions(final AbstractDataStorage storage,
final String path) {
final List<StorageRestoreAction> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ private List<MetadataEntityVO> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AbstractDataStorageItem> items = dataStorageManager.getDataStorageItems(storage.getId(),
ProviderUtils.withTrailingDelimiter(filePath), false, null, null, false).getResults();
final String templatePath = preferenceManager.getPreference(
Expand Down

0 comments on commit 9cb9298

Please sign in to comment.