summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints')
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt91
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt29
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt112
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt16
4 files changed, 171 insertions, 77 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
index 7e70a762d..fb466f7c3 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018-2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,17 +19,14 @@ package org.onap.ccsdk.cds.controllerblueprints.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.cds.controllerblueprints.core.data.*
-import org.onap.ccsdk.cds.controllerblueprints.core.format
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintExpressionService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -43,6 +40,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
+ lateinit var propertyAssignmentValidationUtils: PropertyAssignmentValidationUtils
var paths: MutableList<String> = arrayListOf()
override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
@@ -51,6 +49,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+ propertyAssignmentValidationUtils = PropertyAssignmentValidationUtils(bluePrintContext)
+
paths.add(name)
val type: String = nodeTemplate.type
@@ -58,7 +58,10 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type)
?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($name)")
- nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
+ nodeTemplate.properties?.let {
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!)
+ }
nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, name, nodeTemplate) }
nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, name, nodeTemplate) }
nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, name, nodeTemplate) }
@@ -80,29 +83,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
paths.removeAt(paths.lastIndex)
}
-
- @Throws(BluePrintException::class)
- open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
- properties: MutableMap<String, JsonNode>) {
- properties.forEach { propertyName, propertyAssignment ->
- val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
- ?: throw BluePrintException("failed to get definition for the property ($propertyName)")
-
- validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
-
- }
- }
-
- @Throws(BluePrintException::class)
- open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition,
- propertyAssignment: JsonNode) {
- // Check and Validate if Expression Node
- val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
- if (!expressionData.isExpression) {
- checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
- }
- }
-
@Throws(BluePrintException::class)
open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
val capabilities = nodeTemplate.capabilities
@@ -125,7 +105,10 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String,
capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) {
- capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) }
+ capabilityAssignment.properties?.let {
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!)
+ }
}
@@ -224,7 +207,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation " +
"definition ($operationAssignmentName) property definition($propertyName)")
// Check the property values with property definition
- validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
outputs?.forEach { propertyName, propertyAssignment ->
@@ -232,7 +216,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " +
"output property definition($propertyName)")
// Check the property values with property definition
- validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
}
@@ -240,48 +225,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
}
- open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
- val propertyType = propertyDefinition.type
- val isValid: Boolean
-
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
- isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
-
- } else if (BluePrintTypes.validComplexTypes().contains(propertyType)) {
- isValid = true
- } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
-
- val entrySchemaType = propertyDefinition.entrySchema?.type
- ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
-
- if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) {
- checkPropertyDataType(entrySchemaType, propertyName)
- }
- isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
- } else {
- checkPropertyDataType(propertyType, propertyName)
- isValid = true
- }
-
- check(isValid) {
- throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)")
- }
- }
-
- private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
-
- val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
- ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found")
-
- checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
-
- }
-
- private fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
- check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
- throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
- }
- }
private fun validateExtension(referencePrefix: String, name: String, nodeTemplate: NodeTemplate) {
val customValidator = bluePrintTypeValidatorService
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
index 306203128..a7dbbf846 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +19,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -45,6 +47,12 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
paths.add(workflowName)
paths.joinToString(BluePrintConstants.PATH_DIVIDER)
+ // Validate Workflow Inputs
+ validateInputs(workflow)
+
+ // Validate Workflow outputs
+ validateOutputs(workflow)
+
// Step Validation Start
paths.add("steps")
workflow.steps?.forEach { stepName, step ->
@@ -69,14 +77,33 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
"definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!)
}
}
- paths.removeAt(paths.lastIndex)
+
}
paths.removeAt(paths.lastIndex)
// Step Validation Ends
paths.removeAt(paths.lastIndex)
+ paths.removeAt(paths.lastIndex)
+ }
+
+ private fun validateInputs(workflow: Workflow) {
workflow.inputs?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!)
}
}
+
+ private fun validateOutputs(workflow: Workflow) {
+ workflow.outputs?.let {
+
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.outputs!!)
+
+ PropertyAssignmentValidationUtils(bluePrintRuntimeService.bluePrintContext())
+ .validatePropertyDefinitionNAssignments(workflow.outputs!!)
+ }
+ // Validate Value or Expression
+ workflow.outputs?.forEach { propertyName, propertyDefinition ->
+
+ }
+ }
+
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt
new file mode 100644
index 000000000..35ddc5b6f
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt
@@ -0,0 +1,112 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * 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.cds.controllerblueprints.validation.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.format
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintExpressionService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+open class PropertyAssignmentValidationUtils(private val bluePrintContext: BluePrintContext) {
+
+ // Property Definition holds both Definitons and Expression in same construct
+ open fun validatePropertyDefinitionNAssignments(propertyDefinitions: MutableMap<String, PropertyDefinition>) {
+ propertyDefinitions.forEach { propertyName, propertyDefinition ->
+ validatePropertyDefinitionNAssignment(propertyName, propertyDefinition)
+ }
+ }
+
+ // Property Definition holds both Definitons and Expression in same construct
+ open fun validatePropertyDefinitionNAssignment(propertyName: String, propertyDefinition: PropertyDefinition) {
+ // Check and Validate if Expression Node
+ checkNotNull(propertyDefinition.value) {
+ throw BluePrintException("couldn't get 'value' property from PropertyDefinition($propertyName)")
+ }
+ val propertyAssignment = propertyDefinition.value!!
+ val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+ if (!expressionData.isExpression) {
+ checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
+ }
+ }
+
+ open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
+ properties: MutableMap<String, JsonNode>) {
+ properties.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
+ ?: throw BluePrintException("failed to get definition for the property ($propertyName)")
+
+ validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+
+ }
+ }
+
+ open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition,
+ propertyAssignment: JsonNode) {
+ // Check and Validate if Expression Node
+ val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+ if (!expressionData.isExpression) {
+ checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
+ }
+ }
+
+ open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
+ val propertyType = propertyDefinition.type
+ val isValid: Boolean
+
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+ isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
+
+ } else if (BluePrintTypes.validComplexTypes().contains(propertyType)) {
+ isValid = true
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+
+ val entrySchemaType = propertyDefinition.entrySchema?.type
+ ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
+
+ if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) {
+ checkPropertyDataType(entrySchemaType, propertyName)
+ }
+ isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
+ } else {
+ checkPropertyDataType(propertyType, propertyName)
+ isValid = true
+ }
+
+ check(isValid) {
+ throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)")
+ }
+ }
+
+ open fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
+
+ val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found")
+
+ checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
+
+ }
+
+ open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
index 091dfdafc..8379e5032 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,11 +67,16 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
// Clean Dynamic Property Field, If present
workflow.inputs?.remove(dynamicPropertyName)
+ // Enrich Workflow Inputs
+ enhanceWorkflowInputs(name, workflow)
+
+ // Enrich Workflow Outputs
+ enhanceWorkflowOutputs(name, workflow)
+
// Enrich Only for Resource Assignment and Dynamic Input Properties if any
enhanceStepTargets(name, workflow)
- // Enrich Workflow Inputs
- enhanceWorkflowInputs(name, workflow)
+
}
open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
@@ -80,6 +86,12 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
}
}
+ open fun enhanceWorkflowOutputs(name: String, workflow: Workflow) {
+ workflow.outputs?.let { outputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, outputs)
+ }
+ }
+
private fun enhanceStepTargets(name: String, workflow: Workflow) {
// Get the first Step Target NodeTemplate name( It may be Component or DG Node Template)