summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2017-10-25 11:25:29 +0300
committertalio <tali.orenbach@amdocs.com>2017-10-25 11:25:29 +0300
commit4a8b03f2ed94e0d7048aeca6346ec65f0c282192 (patch)
tree55038ad10255b3155233cc9ed35c55ccce4ba3f1
parent26ffac7f0f508f73a1b0701bc3897d0259409a35 (diff)
upload
enable upload for files with extension in uppercase, while not saving the extension in lowercase in the DB Issue - Id : SDC-526 Change-Id: I42baa128d533937f0b257df9f174230f21676b12 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/OrchestrationTemplateCandidateManagerImpl.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java2
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java10
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java3
6 files changed, 19 insertions, 15 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index 3f6ffcc622..07a3fa7f2c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -30,6 +30,7 @@ import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -258,20 +259,20 @@ public class OrchestrationTemplateCandidateManagerImpl
OnboardingTypesEnum type =
OnboardingTypesEnum.getOnboardingTypesEnum(vspDetails.getOnboardingOrigin());
- if(vspDetails.getOnboardingOrigin().equals(OnboardingTypesEnum.ZIP.toString())) {
+ if(CommonUtil.isFileOriginFromZip(vspDetails.getOnboardingOrigin())) {
FilesDataStructure structure = JsonUtil
.json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
String manifest = candidateService.createManifest(vspDetails, structure);
mdcDataDebugMessage
.debugExitMessage("VSP id", vspId);
- return Optional.ofNullable(
+ return Optional.of(
new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(),candidateService
.replaceManifestInZip(candidateDataEntity.get().getContentData(),
manifest, vspId, type)));
}
- return Optional.ofNullable(
+ return Optional.of(
new ImmutablePair<>(vspDetails.getOnboardingOrigin(),candidateDataEntity.get()
.getContentData().array()));
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index ceb635fc74..d4879da8d7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -1102,7 +1102,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
(vspDetails.getOnboardingOrigin()),
uploadData.getContentData().array());
- if (vspDetails.getOnboardingOrigin().equals(OnboardingTypesEnum.ZIP.name().toLowerCase())) {
+ if (CommonUtil.isFileOriginFromZip(vspDetails.getOnboardingOrigin())) {
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
validationErrors.putAll(validationManager.validate());
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
index db43e0084e..516d85c2a7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
@@ -28,11 +28,11 @@ public class OrchestrationProcessFactory {
}
public static Optional<OrchestrationTemplateProcessHandler> getInstance(String filePrefix) {
- filePrefix = filePrefix == null ? null : filePrefix.toLowerCase().trim();
if (filePrefix == null) {
return Optional.empty();
}
+ filePrefix = filePrefix.toLowerCase().trim();
OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(filePrefix);
if (onboardingTypesEnum == null) {
return Optional.empty();
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index 1c5293004d..72485d7162 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -42,6 +42,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -67,7 +68,7 @@ public class CommonUtil {
throws IOException {
Pair<FileContentHandler,List<String> > pair = getFileContentMapFromOrchestrationCandidateZip(uploadFileData);
- if(type.equals(OnboardingTypesEnum.ZIP)) {
+ if(isFileOriginFromZip(type.toString())) {
validateNoFolders(pair.getRight());
}
@@ -133,7 +134,7 @@ public class CommonUtil {
return -1;
}
- public static boolean validateFilesExtensions(Set<String> allowedExtensions, FileContentHandler
+ private static boolean validateFilesExtensions(Set<String> allowedExtensions, FileContentHandler
files) {
for (String fileName : files.getFileList()) {
if (!allowedExtensions.contains(FilenameUtils.getExtension(fileName))) {
@@ -147,4 +148,9 @@ public class CommonUtil {
Set<String> allowedExtensions = new HashSet<>(Arrays.asList("yml", "yaml"));
return validateFilesExtensions(allowedExtensions, files);
}
+
+ public static boolean isFileOriginFromZip(String fileOrigin){
+ return Objects.nonNull(fileOrigin)
+ && fileOrigin.toLowerCase().equals(OnboardingTypesEnum.ZIP.toString());
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
index 04e64c33a9..85fe305060 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
@@ -20,13 +20,11 @@ public enum OnboardingTypesEnum {
if (inStr == null) {
return null;
}
+
Optional<OnboardingTypesEnum> onboardingTypesOptional = asList(OnboardingTypesEnum.values()).stream()
- .filter(onboardingTypesEnum -> onboardingTypesEnum.toString().equals(inStr)).findAny();
- if( onboardingTypesOptional.isPresent()){
- return onboardingTypesOptional.get();
- }else {
- return null;
- }
+ .filter(onboardingTypesEnum -> onboardingTypesEnum.toString().equals(inStr.toLowerCase()))
+ .findAny();
+ return onboardingTypesOptional.orElse(null);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
index e871ecfe13..3f9768b9d7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
@@ -226,8 +226,7 @@ public class VspDetails implements VersionableEntity {
}
public void setOnboardingOrigin(String onboardingOrigin) {
- this.onboardingOrigin = Objects.isNull(onboardingOrigin) ? null
- : onboardingOrigin.toLowerCase();
+ this.onboardingOrigin = onboardingOrigin;
}
public String getOnboardingMethod() {