diff options
author | 2020-11-27 12:50:27 +0100 | |
---|---|---|
committer | 2020-12-02 12:59:56 +0000 | |
commit | ad99b805537fc8f3103fa5646abe5342924e10cd (patch) | |
tree | 266fbadbef9ea2412455b907e9ac688f9e746d60 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java | |
parent | e7f2dfba0cb4d917c8da83c319b47ae279a6151e (diff) |
[SDC] PM_Dictionary file validation for ZIP onboarding
Use PM_Dictionary validator from VNF-SDK to validate PM_Dictionary files when onboarding ZIP package
Issue-ID: SDC-3390
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com>
Change-Id: I03fd622393d675977527b9845b6cf8b87b2ec0a3
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java new file mode 100644 index 0000000000..c49062acc0 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.validation.impl.validators; + +import java.util.Set; + +class FileExtensionUtils { + + private static final Set<String> VALID_PM_DICTIONARY_EXTENSIONS = Set.of( + "pmdict.yml", + "pmdict.yaml", + "pm_dict.yml", + "pm_dict.yaml", + "pmdictionary.yml", + "pmdictionary.yaml", + "pm_dictionary.yml", + "pm_dictionary.yaml" + ); + private static final Set<String> VALID_YAML_EXTENSIONS = Set.of( + ".yaml", + ".yml", + ".env" + ); + + static boolean isYaml(String fileName) { + return isValidExt(fileName, VALID_YAML_EXTENSIONS); + } + + static boolean isPmDictionary(String fileName) { + return isValidExt(fileName, VALID_PM_DICTIONARY_EXTENSIONS); + } + + private static boolean isValidExt(String fileName, Set<String> validExtensions) { + String fileNameLower = fileName.toLowerCase(); + return validExtensions.stream() + .anyMatch(fileNameLower::endsWith); + } +} |