From da5e2b085b5eb072e318fcf239b4b79bb30c83b8 Mon Sep 17 00:00:00 2001 From: sebdet Date: Fri, 4 Jun 2021 17:56:49 +0200 Subject: Add parameter for Zip Validation Add a onboarding config parameter to enable or disable the Zip Validation Issue-ID: SDC-3603 Signed-off-by: sebdet Change-Id: I83f539caccd29799f613d4e0bb65c7d7e6b97b45 --- .../impl/onboarding/OnboardingPackageProcessor.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java index 0446103491..e5b68cb917 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java @@ -49,6 +49,7 @@ import org.apache.commons.io.FilenameUtils; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; +import org.openecomp.sdc.common.CommonConfigurationManager; import org.openecomp.sdc.common.utils.CommonUtil; import org.openecomp.sdc.common.utils.SdcCommon; import org.openecomp.sdc.common.zip.exception.ZipException; @@ -145,19 +146,27 @@ public class OnboardingPackageProcessor { return new OnboardPackageInfo(onboardPackage, OnboardingTypesEnum.CSAR); } + private OnboardPackageInfo createOnboardPackageInfoForZip(String packageName, String packageExtension) { + return new OnboardPackageInfo( + new OnboardPackage(packageName, packageExtension, ByteBuffer.wrap(packageFileContent), + packageContent), OnboardingTypesEnum.ZIP); + } + private OnboardPackageInfo processOnapNativeZipPackage(String packageName, String packageExtension) { + if (CommonConfigurationManager.getInstance().getConfigValue("zipValidation", "ignoreManifest", false)) { + return createOnboardPackageInfoForZip(packageName, packageExtension); + } ManifestContent manifest = getManifest(); if (manifest != null) { List errors = validateZipPackage(manifest); if (errors.isEmpty()) { - final OnboardPackage onboardPackage = new OnboardPackage(packageName, packageExtension, ByteBuffer.wrap(packageFileContent), - packageContent); - return new OnboardPackageInfo(onboardPackage, OnboardingTypesEnum.ZIP); + return createOnboardPackageInfoForZip(packageName, packageExtension); } else { errors.forEach(message -> reportError(ErrorLevel.ERROR, message)); } } else { - reportError(ErrorLevel.ERROR, COULD_NOT_READ_MANIFEST_FILE.formatMessage(SdcCommon.MANIFEST_NAME, packageFileName)); + reportError(ErrorLevel.ERROR, + COULD_NOT_READ_MANIFEST_FILE.formatMessage(SdcCommon.MANIFEST_NAME, packageFileName)); } return null; } -- cgit 1.2.3-korg