Add parameter for Zip Validation 06/121706/7
authorsebdet <sebastien.determe@intl.att.com>
Fri, 4 Jun 2021 15:56:49 +0000 (17:56 +0200)
committersebdet <sebastien.determe@intl.att.com>
Thu, 10 Jun 2021 16:23:54 +0000 (18:23 +0200)
Add a onboarding config parameter to enable or disable the Zip Validation

Issue-ID: SDC-3603
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: I83f539caccd29799f613d4e0bb65c7d7e6b97b45

openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java
openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/configuration.yaml.erb
openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java

index 0446103..e5b68cb 100644 (file)
@@ -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<String> 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;
     }
index 853fcf7..474dd48 100644 (file)
@@ -49,4 +49,7 @@ basicAuth:
   enabled: <%= @basic_auth_enabled %>
   userName: <%= @basic_auth_username %>
   userPass: <%= @basic_auth_password %>
-  excludedUrls: "/v1.0/healthcheck"
\ No newline at end of file
+  excludedUrls: "/v1.0/healthcheck"
+
+zipValidation:
+  ignoreManifest: false
\ No newline at end of file
index b490f4b..c104085 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.common.utils.SdcCommon;
 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
 import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
 import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
@@ -44,7 +45,7 @@ class GlobalContextUtil {
     }
 
     private static boolean isManifestMissing(GlobalValidationContext globalContext) {
-        return globalContext.getFileContent("MANIFEST.json").isEmpty();
+        return globalContext.getFileContent(SdcCommon.MANIFEST_NAME).isEmpty();
     }
 
     private static Set<String> filterFilesByType(Map<String, FileData.Type> filesWithTypes,