diff options
Diffstat (limited to 'common-be/src/main/java')
-rw-r--r-- | common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java index bc0792b472..78ee4bed23 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java @@ -92,7 +92,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage try { // Make bucket if not exist. - final boolean found = minioClient.bucketExists(BucketExistsArgs.builder().bucket(vspId).build()); + final boolean found = bucketExists(vspId); if (!found) { // Make a new bucket ${vspId} . @@ -174,6 +174,10 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage @Override public void delete(final String vspId) { LOGGER.debug("DELETE VSP - bucket: '{}'", vspId); + if (!bucketExists(vspId)) { + LOGGER.debug("VSP '{}' bucket was not found while trying to delete it", vspId); + return; + } final var listObjects = minioClient.listObjects(ListObjectsArgs.builder().bucket(vspId).build()); listObjects.forEach(itemResult -> { Item versionId; @@ -193,6 +197,14 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage } } + private boolean bucketExists(final String vspId) { + try { + return minioClient.bucketExists(BucketExistsArgs.builder().bucket(vspId).build()); + } catch (final Exception e) { + throw new ArtifactStorageException(String.format("An unexpected error occurred while checking for vsp '%s'", vspId), e); + } + } + private MinIoStorageArtifactStorageConfig readMinIoStorageArtifactStorageConfig() { final var commonConfigurationManager = CommonConfigurationManager.getInstance(); final Map<String, Object> endpoint = commonConfigurationManager.getConfigValue(EXTERNAL_CSAR_STORE, ENDPOINT, null); |