From 08a5bc8044c8a11aff1797c8e8a8d52973c98605 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 10 Dec 2018 17:01:38 -0500 Subject: Implement Resource Resolution Services Change-Id: Ia1cf57c9fa16cb943836e3a78d4d2c9776f0e32f Issue-ID: CCSDK-724 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../apps/controllerblueprints/core/utils/JacksonUtils.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'components/core/src') 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 f53f86154..40210142c 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 @@ -121,6 +121,11 @@ object JacksonUtils { return objectMapper.writeValueAsString(any) } + @JvmStatic + fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + return getListFromJson(node.toString(), valueType) + } + @JvmStatic fun getListFromJson(content: String, valueType: Class): List? { val objectMapper = jacksonObjectMapper() @@ -148,6 +153,13 @@ object JacksonUtils { return objectMapper.readValue(content, typeRef) } + @JvmStatic + fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { + 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)) { -- cgit 1.2.3-korg