summaryrefslogtreecommitdiffstats
path: root/components
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
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')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt (renamed from components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt)2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt122
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt28
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt32
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt32
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt4
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt4
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt4
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt4
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt6
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt8
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json6
-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
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java6
20 files changed, 218 insertions, 93 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt
index 3ec0691f..ea5bda42 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt
@@ -16,7 +16,7 @@
package org.onap.ccsdk.apps.controllerblueprints.core
-class BluePrintValidationError {
+class BluePrintError {
var errors: MutableList<String> = arrayListOf()
fun addError(type: String, name: String, error: String) {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
new file mode 100644
index 00000000..989617bd
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+interface BluePrintEnhancer<T> {
+ fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
+}
+
+interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer<ServiceTemplate>
+
+interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer<TopologyTemplate>
+
+interface BluePrintWorkflowEnhancer : BluePrintEnhancer<Workflow>
+
+interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer<NodeTemplate>
+
+interface BluePrintNodeTypeEnhancer : BluePrintEnhancer<NodeType>
+
+interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer<PolicyType>
+
+interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer<PropertyDefinition>
+
+interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer<AttributeDefinition>
+
+
+interface BluePrintEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext
+
+ @Throws(BluePrintException::class)
+ fun enhance(basePath: String): BluePrintContext
+
+ @Throws(BluePrintException::class)
+ fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
+}
+
+interface BluePrintTypeEnhancerService {
+
+ fun getServiceTemplateEnhancers(): List<BluePrintServiceTemplateEnhancer>
+
+ fun getTopologyTemplateEnhancers(): List<BluePrintTopologyTemplateEnhancer>
+
+ fun getWorkflowEnhancers(): List<BluePrintWorkflowEnhancer>
+
+ fun getNodeTemplateEnhancers(): List<BluePrintNodeTemplateEnhancer>
+
+ fun getNodeTypeEnhancers(): List<BluePrintNodeTypeEnhancer>
+
+ fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer>
+
+ fun getPropertyDefinitionEnhancers(): List<BluePrintPropertyDefinitionEnhancer>
+
+ fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer>
+
+ fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
+ val enhancers = getServiceTemplateEnhancers()
+ doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers)
+ }
+
+ fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
+ val enhancers = getTopologyTemplateEnhancers()
+ doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers)
+ }
+
+ fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ val enhancers = getWorkflowEnhancers()
+ doEnhancement(bluePrintContext, error, name, workflow, enhancers)
+ }
+
+ fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+ val enhancers = getNodeTemplateEnhancers()
+ doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers)
+ }
+
+ fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
+ val enhancers = getNodeTypeEnhancers()
+ doEnhancement(bluePrintContext, error, name, nodeType, enhancers)
+ }
+
+ fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) {
+ val enhancers = getPolicyTypeEnhancers()
+ doEnhancement(bluePrintContext, error, name, policyType, enhancers)
+ }
+
+ fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
+ val enhancers = getPropertyDefinitionEnhancers()
+ doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers)
+ }
+
+ fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
+ val enhancers = getAttributeDefinitionEnhancers()
+ doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers)
+ }
+
+ private fun <T> doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
+ if (enhancers.isNotEmpty()) {
+ enhancers.forEach {
+ it.enhance(bluePrintContext, error, name, definition as T)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
index 322f6574..adc94c4c 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
@@ -1,14 +1,14 @@
package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
interface BluePrintValidator<T> {
- fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: T)
+ fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
}
@@ -61,64 +61,64 @@ interface BluePrintTypeValidatorService {
fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator>
- fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) {
+ fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
val validators = getServiceTemplateValidators()
doValidation(bluePrintContext, error, name, serviceTemplate, validators)
}
- fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) {
+ fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) {
val validators = getArtifactTypeValidators()
doValidation(bluePrintContext, error, name, artifactType, validators)
}
- fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) {
+ fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) {
val validators = getDataTypeValidators()
doValidation(bluePrintContext, error, name, dataType, validators)
}
- fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeType: NodeType) {
+ fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
val validators = getNodeTypeValidators()
doValidation(bluePrintContext, error, name, nodeType, validators)
}
- fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) {
+ fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
val validators = getTopologyTemplateValidators()
doValidation(bluePrintContext, error, name, topologyTemplate, validators)
}
- fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeTemplate: NodeTemplate) {
+ fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
val validators = getNodeTemplateValidators()
doValidation(bluePrintContext, error, name, nodeTemplate, validators)
}
- fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, workflow: Workflow) {
+ fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
val validators = getWorkflowValidators()
doValidation(bluePrintContext, error, name, workflow, validators)
}
- fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, properties: MutableMap<String, PropertyDefinition>) {
+ fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap<String, PropertyDefinition>) {
properties.forEach { propertyName, propertyDefinition ->
validatePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition)
}
}
- fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) {
+ fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
val validators = getPropertyDefinitionValidators()
doValidation(bluePrintContext, error, name, propertyDefinition, validators)
}
- fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, attributes: MutableMap<String, AttributeDefinition>) {
+ fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap<String, AttributeDefinition>) {
attributes.forEach { attributeName, attributeDefinition ->
validateAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition)
}
}
- fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, attributeDefinition: AttributeDefinition) {
+ fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
val validators = getAttributeDefinitionValidators()
doValidation(bluePrintContext, error, name, attributeDefinition, validators)
}
- private fun <T> doValidation(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
+ private fun <T> doValidation(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
validators.forEach {
it.validate(bluePrintContext, error, name, definition as T)
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
index dec7a50d..5ca43952 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
@@ -17,13 +17,12 @@
package org.onap.ccsdk.apps.controllerblueprints.core.service
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
-import reactor.core.publisher.Mono
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import java.io.Serializable
/**
@@ -35,19 +34,19 @@ import java.io.Serializable
interface BluePrintRepoService : Serializable {
@Throws(BluePrintException::class)
- fun getNodeType(nodeTypeName: String): Mono<NodeType>
+ fun getNodeType(nodeTypeName: String): NodeType
@Throws(BluePrintException::class)
- fun getDataType(dataTypeName: String): Mono<DataType>
+ fun getDataType(dataTypeName: String): DataType
@Throws(BluePrintException::class)
- fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>
+ fun getArtifactType(artifactTypeName: String): ArtifactType
@Throws(BluePrintException::class)
- fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>
+ fun getRelationshipType(relationshipTypeName: String): RelationshipType
@Throws(BluePrintException::class)
- fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>
+ fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition
}
@@ -63,36 +62,37 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic
private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
- override fun getDataType(dataTypeName: String): Mono<DataType> {
+ override fun getDataType(dataTypeName: String): DataType {
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(dataTypeName).plus(extension)
return getModelType(fileName, DataType::class.java)
}
- override fun getNodeType(nodeTypeName: String): Mono<NodeType> {
+ override fun getNodeType(nodeTypeName: String): NodeType {
val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)
return getModelType(fileName, NodeType::class.java)
}
- override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType> {
+ override fun getArtifactType(artifactTypeName: String): ArtifactType {
val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(artifactTypeName).plus(extension)
return getModelType(fileName, ArtifactType::class.java)
}
- override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType> {
+ override fun getRelationshipType(relationshipTypeName: String): RelationshipType {
val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(relationshipTypeName).plus(extension)
return getModelType(fileName, RelationshipType::class.java)
}
- override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition> {
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition {
val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(capabilityDefinitionName).plus(extension)
return getModelType(fileName, CapabilityDefinition::class.java)
}
- private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {
- return JacksonReactorUtils.readValueFromFile(fileName, valueType)
+ private fun <T> getModelType(fileName: String, valueType: Class<T>): T {
+ return JacksonUtils.readValueFromFile(fileName, valueType)
+ ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}")
}
} \ No newline at end of file
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 40210142..be23172a 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
@@ -24,12 +24,12 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
-import org.apache.commons.io.FileUtils
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.format
import java.io.File
import java.nio.charset.Charset
@@ -56,19 +56,26 @@ object JacksonUtils {
@JvmStatic
fun getContent(fileName: String): String {
- return File(fileName).readText(Charsets.UTF_8)
+ return runBlocking {
+ withContext(Dispatchers.Default) {
+ File(fileName).readText(Charsets.UTF_8)
+ }
+ }
}
@JvmStatic
fun getClassPathFileContent(fileName: String): String {
- return IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
+ return runBlocking {
+ withContext(Dispatchers.Default) {
+ IOUtils.toString(JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset())
+ }
+ }
}
@JvmStatic
fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ val content: String = getContent(fileName)
return readValue(content, valueType)
}
@@ -89,8 +96,7 @@ object JacksonUtils {
@JvmStatic
fun jsonNodeFromFile(fileName: String): JsonNode {
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ val content: String = getContent(fileName)
return jsonNode(content)
}
@@ -135,8 +141,7 @@ object JacksonUtils {
@JvmStatic
fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ val content: String = getContent(fileName)
return getListFromJson(content, valueType)
}
@@ -155,8 +160,7 @@ 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))
+ val content: String = getContent(fileName)
return getMapFromJson(content, valueType)
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt
index 9208bdac..3fd31854 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt
@@ -16,7 +16,7 @@
package org.onap.ccsdk.apps.controllerblueprints.core.validation
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -24,7 +24,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator {
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) {
artifactType.properties?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!)
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt
index d0faf1c2..98abc1e2 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt
@@ -16,7 +16,7 @@
package org.onap.ccsdk.apps.controllerblueprints.core.validation
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -24,7 +24,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator {
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: AttributeDefinition) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) {
//TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt
index c8d8a74d..1241aa6d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt
@@ -18,7 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -27,7 +27,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString())
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) {
log.trace("Validating DataType($name)")
dataType.properties?.let {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
index 94d6251c..26a246dd 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -21,7 +21,7 @@ import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator
@@ -36,10 +36,10 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
log.trace("Validating NodeTemplate($nodeTemplateName)")
this.bluePrintContext = bluePrintContext
this.error = error
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt
index 86bf521f..e15724ae 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt
@@ -20,7 +20,7 @@ import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator
@@ -33,10 +33,10 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTypeName: String, nodeType: NodeType) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTypeName: String, nodeType: NodeType) {
log.trace("Validating NodeType($nodeTypeName)")
this.bluePrintContext = bluePrintContext
this.error = error
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt
index f4804d4c..f7a1cbf4 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt
@@ -20,7 +20,7 @@ import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator
@@ -32,9 +32,9 @@ open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeVal
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
this.bluePrintContext = bluePrintContext
this.error = error
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt
index 66c504de..848dcc5f 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt
@@ -21,7 +21,7 @@ import com.att.eelf.configuration.EELFManager
import com.google.common.base.Preconditions
import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -32,10 +32,10 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
log.trace("Validating Service Template..")
try {
this.bluePrintContext = bluePrintContext
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt
index 411cdb4d..2783e14e 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt
@@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate
@@ -33,9 +33,9 @@ open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValid
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
log.trace("Validating Topology Template..")
this.bluePrintContext = bluePrintContext
this.error = error
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt
index 10e8d65b..4ddf76b2 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt
@@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
@@ -30,7 +30,7 @@ open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorServi
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>): Boolean {
- val error = BluePrintValidationError()
+ val error = BluePrintError()
bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate)
if (error.errors.size > 0) {
throw BluePrintException("failed in blueprint validation : ${error.errors.joinToString("\n")}")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
index 8ba6f720..f4434a54 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
@@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator
@@ -29,10 +29,10 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, workflowName: String, workflow: Workflow) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, workflowName: String, workflow: Workflow) {
log.info("Validating Workflow($workflowName)")
this.bluePrintContext = bluePrintContext
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
index b8cfdd40..f7f995fb 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
@@ -33,25 +33,25 @@ class BluePrintRepoFileServiceTest {
@Test
fun testGetDataType() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate").block()
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment").block()
+ val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity").block()
+ val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
@Test(expected = FileNotFoundException::class)
fun testModelNotFound() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found").block()
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")
assertNotNull(dataType, "Failed to get DataType from repo")
}
} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
index 569b668a..3ea494ac 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
@@ -41,7 +41,7 @@
"type": "string"
}
},
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.datatypes.Dynamic"
},
"resource-assignment-properties": {
"description": "This is Dynamically generated data type for workflow activate",
@@ -64,7 +64,7 @@
"type": "string"
}
},
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.datatypes.Dynamic"
},
"assign-activate-properties": {
"description": "This is Dynamically generated data type for workflow assign-activate",
@@ -87,7 +87,7 @@
"type": "string"
}
},
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.datatypes.Dynamic"
}
}
} \ No newline at end of file
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
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java
index 6789c0e0..ac8cbcb4 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java
@@ -24,13 +24,13 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
public class ResourceDefinitionRepoServiceTest {
@Test
- public void testGetResourceDefinition() throws Exception{
+ public void testGetResourceDefinition() throws Exception {
ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog");
ResourceDefinition resourceDefinition = resourceDefinitionRepoService
- .getResourceDefinition("db-source").block();
+ .getResourceDefinition("db-source");
Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition);
- NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block();
+ NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db");
Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition);
}
} \ No newline at end of file