summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2017-10-24 11:19:16 +0300
committertalio <tali.orenbach@amdocs.com>2017-10-24 11:19:35 +0300
commitfdd32ad2577756a180258f3e09081139bcda63ed (patch)
tree9058cdbf85d784ba864490bca00cf4f3cc9357b1
parentaa61644704edc4b2ef231d75b537b38d0ae6d7c6 (diff)
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 <tali.orenbach@amdocs.com>
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java2
3 files changed, 35 insertions, 1 deletions
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);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java
new file mode 100644
index 0000000000..6545ca1fdd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION;
+
+public class OrchestrationTemplateFileExtensionErrorBuilder {
+ private static final String INVALID_EXTENSION_MSG = "Invalid file extension. Valid extensions " +
+ "are : zip, csar.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public OrchestrationTemplateFileExtensionErrorBuilder(){
+ builder.withId(INVALID_EXTENSION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_EXTENSION_MSG));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
index da64f5a2e5..d3c2a22fff 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
@@ -127,4 +127,6 @@ public class VendorSoftwareProductErrorCodes {
public static final String DELETE_IMAGE_NOT_ALLOWED = "DELETE_IMAGE_NOT_ALLOWED";
public static final String UPDATE_IMAGE_NOT_ALLOWED = "UPDATE_IMAGE_NOT_ALLOWED";
+ public static final String INVALID_EXTENSION = "INVALID_EXTENSION";
+
}