aboutsummaryrefslogtreecommitdiffstats
path: root/components/core
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-10 17:01:38 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-10 17:01:38 -0500
commit1141bf4d7f7c641aecdc12c085a7410bbe713bb8 (patch)
tree5e908467c2cf252bcf640743812c2cc57ef940a4 /components/core
parentc9d21f343bf0536ea247151dcf7cacddcf1e8132 (diff)
Implement Resource Resolution Services
Change-Id: Ia1cf57c9fa16cb943836e3a78d4d2c9776f0e32f Issue-ID: CCSDK-724 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/core')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index f53f8615..40210142 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -122,6 +122,11 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
+
+ @JvmStatic
fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
val objectMapper = jacksonObjectMapper()
val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
@@ -149,6 +154,13 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ return getMapFromJson(content, valueType)
+ }
+
+ @JvmStatic
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)