From fb0dea26c8db442173b7d93eddf514f33caa15dd Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 22 Feb 2019 10:14:24 -0500 Subject: Add extension validation framework Change-Id: I5674e8da70cc4d20899f6fe2163a595b28861036 Issue-ID: CCSDK-1103 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/data/BluePrintModel.kt | 7 ++--- .../core/interfaces/BlueprintValidator.kt | 33 ++++++++++++++++++++++ .../core/utils/JacksonUtils.kt | 9 +++--- 3 files changed, 39 insertions(+), 10 deletions(-) (limited to 'ms/controllerblueprints/modules/blueprint-core') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 2647083f..aab4e7c7 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -118,16 +118,13 @@ or Node Template and used by orchestration engine to facilitate deployment and i class ArtifactDefinition { @get:JsonIgnore var id: String? = null - var type: String? = null - var file: String? = null + lateinit var type: String + lateinit var file: String var repository: String? = null var description: String? = null @get:JsonProperty("deploy_Path") var deployPath: String? = null var properties: MutableMap? = null - var content: String? = null - @Deprecated("Mapping content is define by the Type") - var mappingContent: String? = null } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt index bea790fd..a485c677 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -1,3 +1,20 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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.apps.controllerblueprints.core.interfaces import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -18,6 +35,8 @@ interface BluePrintTopologyTemplateValidator : BluePrintValidator +interface BluePrintArtifactDefinitionValidator : BluePrintValidator + interface BluePrintDataTypeValidator : BluePrintValidator interface BluePrintNodeTypeValidator : BluePrintValidator @@ -45,12 +64,20 @@ interface BluePrintValidatorService { interface BluePrintTypeValidatorService { + fun > bluePrintValidator(referenceName: String, classType: Class): T? + + fun > bluePrintValidators(referenceNamePrefix: String, classType: Class): List? + + fun > bluePrintValidators(classType: Class): List? + fun getServiceTemplateValidators(): List fun getDataTypeValidators(): List fun getArtifactTypeValidators(): List + fun getArtifactDefinitionsValidators(): List + fun getNodeTypeValidators(): List fun getTopologyTemplateValidators(): List @@ -73,6 +100,12 @@ interface BluePrintTypeValidatorService { doValidation(bluePrintRuntimeService, name, artifactType, validators) } + fun validateArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, + artifactDefinition: ArtifactDefinition) { + val validators = getArtifactDefinitionsValidators() + doValidation(bluePrintRuntimeService, name, artifactDefinition, validators) + } + fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { val validators = getDataTypeValidators() doValidation(bluePrintRuntimeService, name, dataType, validators) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 76f3f329..1bc25005 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.node.ArrayNode @@ -148,22 +147,22 @@ class JacksonUtils { return objectMapper.valueToTree(any) } - fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + fun getListFromJsonNode(node: JsonNode, valueType: Class): List { return getListFromJson(node.toString(), valueType) } - fun getListFromJson(content: String, valueType: Class): List? { + fun getListFromJson(content: String, valueType: Class): List { val objectMapper = jacksonObjectMapper() val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) return objectMapper.readValue>(content, javaType) } - fun getListFromFile(fileName: String, valueType: Class): List? { + fun getListFromFile(fileName: String, valueType: Class): List { val content: String = getContent(fileName) return getListFromJson(content, valueType) } - fun getListFromClassPathFile(fileName: String, valueType: Class): List? { + fun getListFromClassPathFile(fileName: String, valueType: Class): List { val content: String = getClassPathFileContent(fileName) return getListFromJson(content, valueType) } -- cgit 1.2.3-korg