aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules
diff options
context:
space:
mode:
authorSteve Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-07-08 12:33:43 -0400
committerDan Timoney <dtimoney@att.com>2019-07-09 17:39:52 +0000
commit49552ce33c9b675a1cbb53d631d81fbe5ceab21c (patch)
tree3a917e4a42a3c61cc41e604316c5e18cea65530d /ms/controllerblueprints/modules
parent22d3293ec88d18e20f58c87e3f34c1cd24ad61f4 (diff)
Velocity template engine implement a separate instance
Issue-ID: CCSDK-1457 Signed-off-by: Steve Siani <alphonse.steve.siani.djissitchi@ibm.com> Change-Id: I8fd9918df5e03e1f7c0cdcf4bc63ddc5846195b8
Diffstat (limited to 'ms/controllerblueprints/modules')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt13
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt15
2 files changed, 14 insertions, 14 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt
index baddd6a12..a06fb99ff 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt
@@ -19,22 +19,16 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
-import com.google.common.io.Resources
import com.hubspot.jinjava.Jinjava
-import com.hubspot.jinjava.interpret.Context
+import com.hubspot.jinjava.JinjavaConfig
import com.hubspot.jinjava.interpret.JinjavaInterpreter
-import com.hubspot.jinjava.loader.ClasspathResourceLocator
import com.hubspot.jinjava.loader.ResourceLocator
import com.hubspot.jinjava.loader.ResourceNotFoundException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintJsonNodeFactory
-import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.removeNullNode
-import org.springframework.context.annotation.Scope
-import org.springframework.stereotype.Service
import java.io.IOException
import java.nio.charset.Charset
import java.nio.file.Files.readAllBytes
@@ -70,8 +64,7 @@ object BluePrintJinjaTemplateService {
additionalContext: MutableMap<String, Any>,
bluePrintPathConfiguration: BluePrintPathConfiguration, artifactName: String,
artifactVersion: String): String {
-
-
+
return generateContent(template,
json,
ignoreJsonNull,
@@ -81,7 +74,7 @@ object BluePrintJinjaTemplateService {
fun generateContent(template: String, json: String, ignoreJsonNull: Boolean,
additionalContext: MutableMap<String, Any>, resourceLocator: ResourceLocator? = null): String {
- val jinJava = Jinjava()
+ val jinJava = Jinjava(JinjavaConfig())
if (resourceLocator != null) {
jinJava.resourceLocator = resourceLocator
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt
index 43e6d221f..2d3c35de7 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.apache.commons.lang3.BooleanUtils
import org.apache.commons.lang3.StringUtils
import org.apache.velocity.VelocityContext
-import org.apache.velocity.app.Velocity
+import org.apache.velocity.app.VelocityEngine
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintJsonNodeFactory
import org.onap.ccsdk.cds.controllerblueprints.core.removeNullNode
@@ -57,7 +57,15 @@ object BluePrintVelocityTemplateService {
fun generateContent(template: String, jsonNode: JsonNode?, ignoreJsonNull: Boolean = false,
additionalContext: MutableMap<String, Any> = mutableMapOf()): String {
- Velocity.init()
+ /*
+ * create a new instance of the velocity engine
+ */
+ val velocity = VelocityEngine()
+
+ /*
+ * initialize the engine
+ */
+ velocity.init()
val velocityContext = VelocityContext()
velocityContext.put("StringUtils", StringUtils::class.java)
@@ -76,9 +84,8 @@ object BluePrintVelocityTemplateService {
}
val stringWriter = StringWriter()
- Velocity.evaluate(velocityContext, stringWriter, "TemplateData", template)
+ velocity.evaluate(velocityContext, stringWriter, "TemplateData", template)
stringWriter.flush()
return stringWriter.toString()
-
}
}