From 6c32cbc7343bd56f62007451071c4b26c875382f Mon Sep 17 00:00:00 2001 From: vasraz Date: Fri, 26 Nov 2021 14:40:29 +0000 Subject: Add VNFD to NSD when using S3 storage Change-Id: I8eb810fadfe54b335647e71e21115514963b4be7 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3792 --- .../MinIoStorageArtifactStorageManager.java | 28 ++++++++++++++++++---- .../sdc/be/csar/storage/NoneStorageManager.java | 10 ++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) (limited to 'common-be/src') 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 0a48c2233c..850b4e1dda 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 @@ -108,6 +108,18 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage LOGGER.info("Bucket '{}' already exists.", vspId); } + put(vspId, name, fileToUpload); + + } catch (final Exception e) { + throw new ArtifactStorageException("Failed to upload artifact", e); + } + + return new MinIoArtifactInfo(vspId, name); + } + + @Override + public void put(final String vspId, final String name, final InputStream fileToUpload) { + try { minioClient.putObject( PutObjectArgs.builder() .bucket(vspId) @@ -115,12 +127,9 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage .stream(fileToUpload, fileToUpload.available(), -1) .build() ); - } catch (final Exception e) { throw new ArtifactStorageException("Failed to upload artifact", e); } - - return new MinIoArtifactInfo(vspId, name); } @Override @@ -131,10 +140,19 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage @Override public InputStream get(final ArtifactInfo artifactInfo) { final MinIoArtifactInfo minioObject = (MinIoArtifactInfo) artifactInfo; + try { + return get(minioObject.getBucket(), minioObject.getObjectName()); + } catch (final Exception e) { + throw new ArtifactStorageException("Failed to get Object", e); + } + } + + @Override + public InputStream get(final String bucketID, final String objectID) { try { return minioClient.getObject(GetObjectArgs.builder() - .bucket(minioObject.getBucket()) - .object(minioObject.getObjectName()) + .bucket(bucketID) + .object(objectID) .build()); } catch (final Exception e) { throw new ArtifactStorageException("Failed to get Object", e); diff --git a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/NoneStorageManager.java b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/NoneStorageManager.java index 3fa22d41be..aec69d5bd7 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/NoneStorageManager.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/NoneStorageManager.java @@ -36,6 +36,11 @@ public class NoneStorageManager implements ArtifactStorageManager { throw new UnsupportedOperationException(); } + @Override + public void put(final String vspId, final String versionId, final InputStream fileToUpload) { + throw new UnsupportedOperationException(); + } + @Override public ArtifactStorageConfig getStorageConfiguration() { throw new UnsupportedOperationException(); @@ -46,6 +51,11 @@ public class NoneStorageManager implements ArtifactStorageManager { throw new UnsupportedOperationException(); } + @Override + public InputStream get(final String vspId, final String versionId) { + throw new UnsupportedOperationException(); + } + @Override public void delete(final ArtifactInfo artifactInfo) { throw new UnsupportedOperationException(); -- cgit 1.2.3-korg