summaryrefslogtreecommitdiffstats
path: root/components/resource-dict/src/main
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-11 19:40:51 -0500
committerBrinda Santh Muthuramalingam <bs2796@att.com>2018-12-12 00:55:13 +0000
commita567903b114503a13c225ed720a96391e75f0126 (patch)
tree59266407163c9ebfd2174acccf741522dc1c3c0f /components/resource-dict/src/main
parent9321f6dea8f57f3e1b9a05c446e59d243f94bfc5 (diff)
Implement Enhancer Framework Interfaces
Change-Id: Iff85dc50f87ab6d6f7d9ceb4a309ea6e4d55e362 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/resource-dict/src/main')
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt10
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt13
2 files changed, 11 insertions, 12 deletions
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
index 6d186b59..bcb7e7da 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
@@ -21,9 +21,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import reactor.core.publisher.Mono
/**
* ResourceDefinitionRepoService.
@@ -33,7 +32,7 @@ import reactor.core.publisher.Mono
interface ResourceDefinitionRepoService : BluePrintRepoService {
@Throws(BluePrintException::class)
- fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>
+ fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition
}
/**
@@ -57,11 +56,12 @@ open class ResourceDefinitionFileRepoService : BluePrintRepoFileService,
resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary")
}
- override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition> {
+ override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition {
val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(resourceDefinitionName).plus(extension)
- return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)
+ return JacksonUtils.readValueFromFile(fileName, ResourceDefinition::class.java)
+ ?: throw BluePrintException("couldn't get resource definition for file($fileName)")
}
}
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
index 9f45d166..9ed07732 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
@@ -18,6 +18,7 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
import com.google.common.base.Preconditions
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
@@ -30,8 +31,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpression
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import com.att.eelf.configuration.EELFManager
import java.io.Serializable
+
/**
* ResourceDefinitionValidationService.
*
@@ -43,6 +44,7 @@ interface ResourceDefinitionValidationService : Serializable {
fun validate(resourceDefinition: ResourceDefinition)
}
+
/**
* ResourceDefinitionValidationService.
*
@@ -59,8 +61,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS
resourceDefinition.sources.forEach { (name, nodeTemplate) ->
val sourceType = nodeTemplate.type
- val sourceNodeType = bluePrintRepoService.getNodeType(sourceType).block()
- ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType))
+ val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)
// Validate Property Name, expression, values and Data Type
validateNodeTemplateProperties(nodeTemplate, sourceNodeType)
@@ -91,7 +92,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS
open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) {
val propertyType = propertyDefinition.type
- val isValid : Boolean
+ val isValid: Boolean
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
@@ -100,9 +101,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS
isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
} else {
- bluePrintRepoService.getDataType(propertyType).block()
- ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository",
- propertyName, propertyType))
+ bluePrintRepoService.getDataType(propertyType)
isValid = true
}