From 9714961d2950d00ae66be01e20c1ebb8552a82e9 Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 19 Oct 2020 16:33:00 +0100 Subject: Remove sdc-tosca-parser dependency Change-Id: I762b7a1098505312486d690902f2f10108a601ff Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3317 --- .../sdc/be/config/NonManoConfigurationManager.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'common-be/src') diff --git a/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java index 12813f231d..640c95bf65 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java @@ -19,13 +19,12 @@ package org.openecomp.sdc.be.config; -import org.apache.commons.io.IOUtils; -import org.onap.sdc.tosca.parser.utils.YamlToObjectConverter; -import org.openecomp.sdc.be.config.exception.LoadConfigurationException; - import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import org.apache.commons.io.IOUtils; +import org.openecomp.sdc.be.config.exception.LoadConfigurationException; +import org.yaml.snakeyaml.Yaml; /** * Singleton that loads and stores the Non Mano configuration @@ -52,7 +51,7 @@ public class NonManoConfigurationManager { } catch (final IOException e) { throw new LoadConfigurationException("Could not parse non-mano configuration file 'config/nonManoConfig.yaml' to string", e); } - nonManoConfiguration = new YamlToObjectConverter().convertFromString(data, NonManoConfiguration.class); + nonManoConfiguration = convertFromString(data, NonManoConfiguration.class); } public static NonManoConfigurationManager getInstance() { @@ -66,4 +65,14 @@ public class NonManoConfigurationManager { public NonManoConfiguration getNonManoConfiguration() { return nonManoConfiguration; } + + private T convertFromString(final String yamlContents, final Class className) { + try { + return (new Yaml()).loadAs(yamlContents, className); + } catch (final Exception e) { + throw new + LoadConfigurationException(String.format("Failed to convert YAML %s to object.", yamlContents), e); + } + } + } -- cgit 1.2.3-korg