diff options
author | 2019-09-19 16:14:01 +0100 | |
---|---|---|
committer | 2019-11-03 15:41:37 +0000 | |
commit | 433947b5ab5e28fc29aee447de934de89a707419 (patch) | |
tree | a485b95b2ae7716ced4825fb7b9eb2b6eeb3433b /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java | |
parent | ee64a64fb0705422c18608304e63a505d10d8ba1 (diff) |
Centralize onboarding package validation
Change-Id: I3cc58cf15f62008e83cfc7ddb095d07ab216b82a
Issue-ID: SDC-2583
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java')
-rw-r--r-- | openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java index b8ef598d65..60bd5ae0a0 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java @@ -21,6 +21,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.types; import java.nio.ByteBuffer; import lombok.Getter; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.common.zip.exception.ZipException; +import org.openecomp.sdc.common.utils.CommonUtil; +import org.openecomp.sdc.vendorsoftwareproduct.exception.OnboardPackageException; @Getter public class OnboardPackage { @@ -28,11 +32,30 @@ public class OnboardPackage { private final String filename; private final String fileExtension; private final ByteBuffer fileContent; + private final FileContentHandler fileContentHandler; - public OnboardPackage(final String filename, final String fileExtension, final ByteBuffer fileContent) { + public OnboardPackage(final String filename, final String fileExtension, final ByteBuffer fileContent, + final FileContentHandler fileContentHandler) { this.filename = filename; this.fileExtension = fileExtension; this.fileContent = fileContent; + this.fileContentHandler = fileContentHandler; } + public OnboardPackage(final String filename, final String fileExtension, final ByteBuffer fileContent) + throws OnboardPackageException { + this.filename = filename; + this.fileExtension = fileExtension; + this.fileContent = fileContent; + try { + fileContentHandler = CommonUtil.getZipContent(fileContent.array()); + } catch (final ZipException e) { + throw new OnboardPackageException("Could not read the package content", e); + } + } + + public OnboardPackage(final String packageName, final String packageExtension, final byte[] packageContentBytes) + throws OnboardPackageException { + this(packageName, packageExtension, ByteBuffer.wrap(packageContentBytes)); + } } |