summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src
diff options
context:
space:
mode:
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);
}