X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=template-node%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Ftemplate%2FTemplateNode.java;h=005b620679edb312f359d26f071b8e4c0dddc033;hb=5e71bd18e508ebdb4dbe3458ff13bdf26af16627;hp=0b5850a0a526c9802fa34fdb4954ed2818e373c3;hpb=3ebdd07fb6eaa2bd5e2c2b95a08ca011df045c0f;p=ccsdk%2Fsli%2Fplugins.git diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java old mode 100644 new mode 100755 index 0b5850a0..005b6206 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -25,6 +25,7 @@ package org.onap.ccsdk.sli.plugins.template; import java.io.FileInputStream; import java.io.StringWriter; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; @@ -41,7 +42,7 @@ public class TemplateNode implements SvcLogicJavaPlugin { public static final String TEMPLATE_PATH = "templatePath"; public static final String OUTPUT_PATH_KEY = "output"; public static final String PREFIX_KEY = "prefix"; - public final static String REQUIRED_PARAMETERS_ERROR_MESSAGE = "templateName & outputPath are required fields"; + public static final String REQUIRED_PARAMETERS_ERROR_MESSAGE = "templateName & outputPath are required fields"; protected static final String TEMPLATE_PROPERTIES_FILE_NAME = "template-node.properties"; protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; @@ -61,7 +62,7 @@ public class TemplateNode implements SvcLogicJavaPlugin { try (FileInputStream in = new FileInputStream(configDir + "/" + TEMPLATE_PROPERTIES_FILE_NAME)) { props.load(in); } catch (Exception e) { - logger.error("Caught exception loading properties!", e); + logger.warn("Properties not loaded for template node, using sensible defaults. " + e.getMessage()); } // give sensible defaults for required properties @@ -97,6 +98,10 @@ public class TemplateNode implements SvcLogicJavaPlugin { VelocityContext context = new VelocityContext(); context.put("ctx", ctx); context.put("params", params); + //Adding these values directly to context makes working with the values cleaner + for (Entry entry : params.entrySet()) { + context.put(entry.getKey(), entry.getValue()); + } StringWriter sw = new StringWriter(); template.merge(context, sw); ctx.setAttribute(outputPath, sw.toString()); @@ -106,4 +111,4 @@ public class TemplateNode implements SvcLogicJavaPlugin { } } -} \ No newline at end of file +}