diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-12-10 17:01:38 -0500 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-12-10 17:01:38 -0500 |
commit | 08a5bc8044c8a11aff1797c8e8a8d52973c98605 (patch) | |
tree | f1da33201ae264f6635c1e1bde99d4b027677b4d /components/core | |
parent | 0948a5aefe07ad80092fd2e8e8499dd5609996e1 (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.kt | 12 |
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 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 @@ -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)
|