From fdd32ad2577756a180258f3e09081139bcda63ed Mon Sep 17 00:00:00 2001 From: talio Date: Tue, 24 Oct 2017 11:19:16 +0300 Subject: Upload enable upload of files with zip or csar extensions in uppercase, and throwing an appropriate exception in case that the extension is invalid. Issue - Id : SDC-526 Change-Id: I9e556ac41173132cc67d64cd8a9d332a061cc942 Signed-off-by: talio --- .../impl/orchestration/OrchestrationUploadFactory.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'openecomp-be/backend') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java index 85f92662ea..99b311e473 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java @@ -3,9 +3,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration; import org.openecomp.config.api.Configuration; import org.openecomp.config.api.ConfigurationManager; import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration; +import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.OrchestrationTemplateFileExtensionErrorBuilder; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE; @@ -22,7 +25,14 @@ public class OrchestrationUploadFactory { } public static final OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(String filePrefix) { - ImplementationConfiguration orchestrationTemplateFileHandler = fileHanlders.get(filePrefix); + String fileExtension = filePrefix.toLowerCase(); + ImplementationConfiguration orchestrationTemplateFileHandler = fileHanlders.get(fileExtension); + + if(Objects.isNull(orchestrationTemplateFileHandler)){ + throw new CoreException(new OrchestrationTemplateFileExtensionErrorBuilder + ().build()); + } + return CommonMethods.newInstance(orchestrationTemplateFileHandler.getImplementationClass(), OrchestrationTemplateFileHandler.class); } -- cgit 1.2.3-korg