aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-common-lib/src/main
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 /openecomp-be/lib/openecomp-common-lib/src/main
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>
Diffstat (limited to 'openecomp-be/lib/openecomp-common-lib/src/main')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java10
1 files changed, 8 insertions, 2 deletions
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());
+ }
}