Implement Enhancer Framework Interfaces
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Wed, 12 Dec 2018 00:40:51 +0000 (19:40 -0500)
committerBrinda Santh Muthuramalingam <bs2796@att.com>
Wed, 12 Dec 2018 00:55:13 +0000 (00:55 +0000)
Change-Id: Iff85dc50f87ab6d6f7d9ceb4a309ea6e4d55e362
Issue-ID: CCSDK-803
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
20 files changed:
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt [moved from components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt with 96% similarity]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java

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 (file)
index 0000000..989617b
--- /dev/null
@@ -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
index 322f657..adc94c4 100644 (file)
@@ -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)
         }
index dec7a50..5ca4395 100644 (file)
 \r
 package org.onap.ccsdk.apps.controllerblueprints.core.service\r
 \r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
-import reactor.core.publisher.Mono\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
 import java.io.Serializable\r
 \r
 /**\r
@@ -35,19 +34,19 @@ import java.io.Serializable
 interface BluePrintRepoService : Serializable {\r
 \r
     @Throws(BluePrintException::class)\r
-    fun getNodeType(nodeTypeName: String): Mono<NodeType>\r
+    fun getNodeType(nodeTypeName: String): NodeType\r
 \r
     @Throws(BluePrintException::class)\r
-    fun getDataType(dataTypeName: String): Mono<DataType>\r
+    fun getDataType(dataTypeName: String): DataType\r
 \r
     @Throws(BluePrintException::class)\r
-    fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>\r
+    fun getArtifactType(artifactTypeName: String): ArtifactType\r
 \r
     @Throws(BluePrintException::class)\r
-    fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>\r
+    fun getRelationshipType(relationshipTypeName: String): RelationshipType\r
 \r
     @Throws(BluePrintException::class)\r
-    fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>\r
+    fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition\r
 \r
 }\r
 \r
@@ -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)\r
     private val extension = ".json"\r
 \r
-    override fun getDataType(dataTypeName: String): Mono<DataType> {\r
+    override fun getDataType(dataTypeName: String): DataType {\r
         val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
                 .plus(dataTypeName).plus(extension)\r
         return getModelType(fileName, DataType::class.java)\r
     }\r
 \r
-    override fun getNodeType(nodeTypeName: String): Mono<NodeType> {\r
+    override fun getNodeType(nodeTypeName: String): NodeType {\r
         val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)\r
         return getModelType(fileName, NodeType::class.java)\r
     }\r
 \r
-    override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType> {\r
+    override fun getArtifactType(artifactTypeName: String): ArtifactType {\r
         val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
                 .plus(artifactTypeName).plus(extension)\r
         return getModelType(fileName, ArtifactType::class.java)\r
     }\r
 \r
-    override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType> {\r
+    override fun getRelationshipType(relationshipTypeName: String): RelationshipType {\r
         val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
                 .plus(relationshipTypeName).plus(extension)\r
         return getModelType(fileName, RelationshipType::class.java)\r
     }\r
 \r
-    override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition> {\r
+    override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition {\r
         val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
                 .plus(capabilityDefinitionName).plus(extension)\r
         return getModelType(fileName, CapabilityDefinition::class.java)\r
     }\r
 \r
-    private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {\r
-        return JacksonReactorUtils.readValueFromFile(fileName, valueType)\r
+    private fun <T> getModelType(fileName: String, valueType: Class<T>): T {\r
+        return JacksonUtils.readValueFromFile(fileName, valueType)\r
+                ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}")\r
     }\r
 }
\ No newline at end of file
index 4021014..be23172 100644 (file)
@@ -24,12 +24,12 @@ import com.fasterxml.jackson.core.type.TypeReference
 import com.fasterxml.jackson.databind.JsonNode\r
 import com.fasterxml.jackson.databind.SerializationFeature\r
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
-import org.apache.commons.io.FileUtils\r
+import kotlinx.coroutines.Dispatchers\r
+import kotlinx.coroutines.runBlocking\r
+import kotlinx.coroutines.withContext\r
 import org.apache.commons.io.IOUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
-import org.onap.ccsdk.apps.controllerblueprints.core.format\r
 import java.io.File\r
 import java.nio.charset.Charset\r
 \r
@@ -56,19 +56,26 @@ object JacksonUtils {
 \r
     @JvmStatic\r
     fun getContent(fileName: String): String {\r
-        return File(fileName).readText(Charsets.UTF_8)\r
+        return runBlocking {\r
+            withContext(Dispatchers.Default) {\r
+                File(fileName).readText(Charsets.UTF_8)\r
+            }\r
+        }\r
     }\r
 \r
     @JvmStatic\r
     fun getClassPathFileContent(fileName: String): String {\r
-        return IOUtils.toString(JacksonUtils::class.java.classLoader\r
-                .getResourceAsStream(fileName), Charset.defaultCharset())\r
+        return runBlocking {\r
+            withContext(Dispatchers.Default) {\r
+                IOUtils.toString(JacksonUtils::class.java.classLoader\r
+                        .getResourceAsStream(fileName), Charset.defaultCharset())\r
+            }\r
+        }\r
     }\r
 \r
     @JvmStatic\r
     fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
-        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
-                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        val content: String = getContent(fileName)\r
         return readValue(content, valueType)\r
     }\r
 \r
@@ -89,8 +96,7 @@ object JacksonUtils {
 \r
     @JvmStatic\r
     fun jsonNodeFromFile(fileName: String): JsonNode {\r
-        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
-                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        val content: String = getContent(fileName)\r
         return jsonNode(content)\r
     }\r
 \r
@@ -135,8 +141,7 @@ object JacksonUtils {
 \r
     @JvmStatic\r
     fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
-        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
-                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        val content: String = getContent(fileName)\r
         return getListFromJson(content, valueType)\r
     }\r
 \r
@@ -155,8 +160,7 @@ object JacksonUtils {
 \r
     @JvmStatic\r
     fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
-        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
-                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        val content: String = getContent(fileName)\r
         return getMapFromJson(content, valueType)\r
     }\r
 \r
index 9208bda..3fd3185 100644 (file)
@@ -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!!)
         }
index d0faf1c..98abc1e 100644 (file)
@@ -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
index c8d8a74..1241aa6 100644 (file)
@@ -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 {
index 94d6251..26a246d 100644 (file)
@@ -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
index 86bf521..e15724a 100644 (file)
@@ -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
index f4804d4..f7a1cbf 100644 (file)
@@ -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
 
index 66c504d..848dcc5 100644 (file)
@@ -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
index 411cdb4..2783e14 100644 (file)
@@ -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
index 10e8d65..4ddf76b 100644 (file)
@@ -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")}")
index 8ba6f72..f4434a5 100644 (file)
@@ -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
index b8cfdd4..f7f995f 100644 (file)
@@ -33,25 +33,25 @@ class BluePrintRepoFileServiceTest {
 \r
     @Test\r
     fun testGetDataType() {\r
-        val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate").block()\r
+        val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")\r
         assertNotNull(dataType, "Failed to get DataType from repo")\r
     }\r
 \r
     @Test\r
     fun testGetNodeType() {\r
-        val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment").block()\r
+        val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")\r
         assertNotNull(nodeType, "Failed to get NodeType from repo")\r
     }\r
 \r
     @Test\r
     fun testGetArtifactType() {\r
-        val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity").block()\r
+        val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")\r
         assertNotNull(nodeType, "Failed to get ArtifactType from repo")\r
     }\r
 \r
     @Test(expected = FileNotFoundException::class)\r
     fun testModelNotFound() {\r
-        val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found").block()\r
+        val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")\r
         assertNotNull(dataType, "Failed to get DataType from repo")\r
     }\r
 }
\ No newline at end of file
index 569b668..3ea494a 100644 (file)
@@ -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
index 6d186b5..bcb7e7d 100644 (file)
@@ -21,9 +21,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService\r
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
-import reactor.core.publisher.Mono\r
 \r
 /**\r
  * ResourceDefinitionRepoService.\r
@@ -33,7 +32,7 @@ import reactor.core.publisher.Mono
 interface ResourceDefinitionRepoService : BluePrintRepoService {\r
 \r
     @Throws(BluePrintException::class)\r
-    fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>\r
+    fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition\r
 }\r
 \r
 /**\r
@@ -57,11 +56,12 @@ open class ResourceDefinitionFileRepoService : BluePrintRepoFileService,
         resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary")\r
     }\r
 \r
-    override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition> {\r
+    override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition {\r
 \r
         val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)\r
                 .plus(resourceDefinitionName).plus(extension)\r
 \r
-        return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)\r
+        return JacksonUtils.readValueFromFile(fileName, ResourceDefinition::class.java)\r
+                ?: throw BluePrintException("couldn't get resource definition for file($fileName)")\r
     }\r
 }\r
index 9f45d16..9ed0773 100644 (file)
@@ -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
         }
 
index 6789c0e..ac8cbcb 100644 (file)
@@ -24,13 +24,13 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
 public class ResourceDefinitionRepoServiceTest {\r
 \r
     @Test\r
-    public void testGetResourceDefinition() throws Exception{\r
+    public void testGetResourceDefinition() throws Exception {\r
         ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog");\r
         ResourceDefinition resourceDefinition = resourceDefinitionRepoService\r
-                .getResourceDefinition("db-source").block();\r
+                .getResourceDefinition("db-source");\r
         Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition);\r
 \r
-        NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block();\r
+        NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db");\r
         Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition);\r
     }\r
 }
\ No newline at end of file