diff options
Diffstat (limited to 'common-be/src/main')
-rw-r--r-- | common-be/src/main/java/org/openecomp/sdc/be/config/NonManoConfigurationManager.java | 19 |
1 files changed, 14 insertions, 5 deletions
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> T convertFromString(final String yamlContents, final Class<T> 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); + } + } + } |