1 package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
3 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
4 import org.onap.ccsdk.apps.controllerblueprints.core.data.*
5 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
8 interface BluePrintValidator<T> {
10 fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T)
15 interface BluePrintServiceTemplateValidator : BluePrintValidator<ServiceTemplate>
17 interface BluePrintTopologyTemplateValidator : BluePrintValidator<TopologyTemplate>
19 interface BluePrintArtifactTypeValidator : BluePrintValidator<ArtifactType>
21 interface BluePrintDataTypeValidator : BluePrintValidator<DataType>
23 interface BluePrintNodeTypeValidator : BluePrintValidator<NodeType>
25 interface BluePrintNodeTemplateValidator : BluePrintValidator<NodeTemplate>
27 interface BluePrintWorkflowValidator : BluePrintValidator<Workflow>
29 interface BluePrintPropertyDefinitionValidator : BluePrintValidator<PropertyDefinition>
31 interface BluePrintAttributeDefinitionValidator : BluePrintValidator<AttributeDefinition>
34 * Blueprint Validation Interface.
36 interface BluePrintValidatorService {
38 @Throws(BluePrintException::class)
39 fun validateBluePrints(basePath: String): Boolean
41 @Throws(BluePrintException::class)
42 fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean
46 interface BluePrintTypeValidatorService {
48 fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator>
50 fun getDataTypeValidators(): List<BluePrintDataTypeValidator>
52 fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator>
54 fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator>
56 fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator>
58 fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator>
60 fun getWorkflowValidators(): List<BluePrintWorkflowValidator>
62 fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator>
64 fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator>
66 fun validateServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) {
67 val validators = getServiceTemplateValidators()
68 doValidation(bluePrintRuntimeService, name, serviceTemplate, validators)
71 fun validateArtifactType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) {
72 val validators = getArtifactTypeValidators()
73 doValidation(bluePrintRuntimeService, name, artifactType, validators)
76 fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) {
77 val validators = getDataTypeValidators()
78 doValidation(bluePrintRuntimeService, name, dataType, validators)
81 fun validateNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
82 val validators = getNodeTypeValidators()
83 doValidation(bluePrintRuntimeService, name, nodeType, validators)
86 fun validateTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) {
87 val validators = getTopologyTemplateValidators()
88 doValidation(bluePrintRuntimeService, name, topologyTemplate, validators)
91 fun validateNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
92 val validators = getNodeTemplateValidators()
93 doValidation(bluePrintRuntimeService, name, nodeTemplate, validators)
96 fun validateWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
97 val validators = getWorkflowValidators()
98 doValidation(bluePrintRuntimeService, name, workflow, validators)
101 fun validatePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap<String, PropertyDefinition>) {
102 properties.forEach { propertyName, propertyDefinition ->
103 validatePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition)
107 fun validatePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
108 val validators = getPropertyDefinitionValidators()
109 doValidation(bluePrintRuntimeService, name, propertyDefinition, validators)
112 fun validateAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap<String, AttributeDefinition>) {
113 attributes.forEach { attributeName, attributeDefinition ->
114 validateAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition)
118 fun validateAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) {
119 val validators = getAttributeDefinitionValidators()
120 doValidation(bluePrintRuntimeService, name, attributeDefinition, validators)
123 @Suppress("UNCHECKED_CAST")
124 private fun <T> doValidation(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
126 it.validate(bluePrintRuntimeService, name, definition as T)