aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-02-07 10:14:06 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-22 12:47:42 +0000
commit1a64c83fc436e17f93e468f7d46ff9f5fcb081ce (patch)
tree835abbeb362b01216df6549233d48745b9c19bb4 /openecomp-be/lib/openecomp-tosca-lib/src
parent6329f959f27920179604e1a015003a0f6614bd97 (diff)
Add support for simple yaml profile 1.2
Change-Id: I735d25c6b6c3344c4b742f09b3aeaf4d03c2d17c Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-2738
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java5
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java14
2 files changed, 10 insertions, 9 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
index 1bc547aed7..3ce9badea0 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
@@ -56,6 +56,7 @@ import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.common.zip.ZipUtils;
@@ -192,8 +193,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean isToscaYamlFile(byte[] fileContent) {
- Map fileMap = new YamlUtil().yamlToObject(new String(fileContent), Map.class);
- return fileMap.containsKey("tosca_definitions_version");
+ final Map fileMap = new YamlUtil().yamlToObject(new String(fileContent), Map.class);
+ return fileMap.containsKey(ToscaTagNamesEnum.TOSCA_VERSION.getElementName());
}
private void updateMinMaxOccurencesForNodeTypeRequirement(Map.Entry<String, RequirementAssignment> entry,
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java
index 0394073e57..9f3dd0790f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaValidationServiceImpl.java
@@ -26,6 +26,7 @@ import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.api.Logger;
@@ -55,7 +56,6 @@ public class ToscaValidationServiceImpl implements ToscaValidationService {
private static final String SDCPARSER_JTOSCA_VALIDATIONISSUE_CONFIG =
"SDCParser_jtosca-validation-issue-configuration.yaml";
private static final String SDCPARSER_ERROR_CONFIG = "SDCParser_error-configuration.yaml";
- private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
static {
// Override default SDC Parser configuration
@@ -119,17 +119,17 @@ public class ToscaValidationServiceImpl implements ToscaValidationService {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
- private boolean isToscaYaml(String filePath) {
+ private boolean isToscaYaml(final String filePath) {
boolean retValue = false;
- try (InputStream input = new BufferedInputStream(new FileInputStream(new File(filePath)));) {
- Yaml yaml = new Yaml();
- LinkedHashMap<String,Object> data = (LinkedHashMap) yaml.load(input);
- if(data.get(TOSCA_DEFINITION_VERSION) != null) {
+ try (final InputStream input = new BufferedInputStream(new FileInputStream(new File(filePath)));) {
+ final Yaml yaml = new Yaml();
+ final LinkedHashMap<String,Object> data = (LinkedHashMap) yaml.load(input);
+ if(data.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName()) != null) {
retValue = true;
}
}
- catch(Exception e){
+ catch(final Exception e){
LOGGER.info("Ignore the exception as the input file may not be a Tosca Yaml; let the " +
"default value return", e);
}