diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core')
77 files changed, 1367 insertions, 1367 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintConstants.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt index 256339c62..5c2ae7e16 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintConstants.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt @@ -18,11 +18,11 @@ package org.onap.ccsdk.cds.controllerblueprints.core /** - * BlueprintConstants + * BluePrintConstants * * @author Brinda Santh */ -object BlueprintConstants { +object BluePrintConstants { val APP_NAME = System.getenv("APP_NAME") ?: "cds-controller" diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintError.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt index 2ecdce770..1ac49d6fe 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintError.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core -class BlueprintError { +class BluePrintError { private val errors: MutableMap<String, MutableList<String>> = mutableMapOf() diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintException.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt index 10e6f5959..74e6bb6bd 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintException.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt @@ -22,7 +22,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core * * @author Brinda Santh */ -class BlueprintException : BlueprintProcessorException { +class BluePrintException : BluePrintProcessorException { constructor(cause: Throwable) : super(cause) constructor(message: String) : super(message) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintExtensionFunctions.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt index 0a1b0954a..daf833494 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintExtensionFunctions.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt @@ -18,9 +18,9 @@ package org.onap.ccsdk.cds.controllerblueprints.core import org.onap.ccsdk.cds.controllerblueprints.core.annotations.ArtifactExpression import org.onap.ccsdk.cds.controllerblueprints.core.annotations.AttributeExpression -import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BlueprintsConstrain -import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BlueprintsDataType -import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BlueprintsProperty +import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsConstrain +import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsDataType +import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsProperty import org.onap.ccsdk.cds.controllerblueprints.core.annotations.DSLExpression import org.onap.ccsdk.cds.controllerblueprints.core.annotations.InputExpression import org.onap.ccsdk.cds.controllerblueprints.core.annotations.OperationOutputExpression @@ -41,9 +41,9 @@ import kotlin.reflect.KProperty1 import kotlin.reflect.KType import kotlin.reflect.full.declaredMemberProperties -fun <T : KClass<*>> T.asBlueprintsDataTypes(): DataType { - val annotation = this.annotations.filter { it is BlueprintsDataType }.single() as BlueprintsDataType - checkNotNull(annotation) { "BlueprintsDataType annotation definition not found" } +fun <T : KClass<*>> T.asBluePrintsDataTypes(): DataType { + val annotation = this.annotations.filter { it is BluePrintsDataType }.single() as BluePrintsDataType + checkNotNull(annotation) { "BluePrintsDataType annotation definition not found" } val dataType = DataType().apply { id = annotation.name version = annotation.version @@ -67,20 +67,20 @@ fun <T> KProperty1<T, *>.asPropertyDefinition(): PropertyDefinition { property.id = this.name val getter = this.getter property.required = !this.returnType.isMarkedNullable - property.type = this.returnType.asBlueprintsDataType(this.name) + property.type = this.returnType.asBluePrintsDataType(this.name) if (this.returnType.arguments.isNotEmpty()) { property.entrySchema = this.returnType.entitySchema() } this.annotations.forEach { fieldAnnotation -> // println("Field : ${this.name} : Annotation : $fieldAnnotation") when (fieldAnnotation) { - is BlueprintsProperty -> + is BluePrintsProperty -> property.description = fieldAnnotation.description is PropertyDefaultValue -> property.value = fieldAnnotation.value.asJsonType(property.type) - is BlueprintsConstrain -> { + is BluePrintsConstrain -> { if (property.constraints == null) property.constraints = arrayListOf() - property.constraints!!.add(fieldAnnotation.asBlueprintConstraintClause()) + property.constraints!!.add(fieldAnnotation.asBluePrintConstraintClause()) } is InputExpression -> { property.value = getInput(fieldAnnotation.propertyName) @@ -117,32 +117,32 @@ fun <T> KProperty1<T, *>.asPropertyDefinition(): PropertyDefinition { return property } -internal fun BlueprintsConstrain.asBlueprintConstraintClause(): ConstraintClause { +internal fun BluePrintsConstrain.asBluePrintConstraintClause(): ConstraintClause { TODO() } internal fun <T : KType> T.entitySchema(): EntrySchema { val entrySchema = EntrySchema() if (this.arguments.size == 1) { - entrySchema.type = this.arguments[0].type!!.asBlueprintsDataType("") + entrySchema.type = this.arguments[0].type!!.asBluePrintsDataType("") } else if (this.arguments.size == 2) { - entrySchema.type = this.arguments[1].type!!.asBlueprintsDataType("") + entrySchema.type = this.arguments[1].type!!.asBluePrintsDataType("") } return entrySchema } -internal fun <T : KType> T.asBlueprintsDataType(propertyName: String): String { +internal fun <T : KType> T.asBluePrintsDataType(propertyName: String): String { val simpleName = (this.classifier as? KClass<*>)?.java?.simpleName - ?: throw BlueprintException("filed to get simple name.") + ?: throw BluePrintException("filed to get simple name.") return when (simpleName) { - "String", "Date" -> BlueprintConstants.DATA_TYPE_STRING - "int" -> BlueprintConstants.DATA_TYPE_INTEGER - "Boolean" -> BlueprintConstants.DATA_TYPE_BOOLEAN - "Float" -> BlueprintConstants.DATA_TYPE_FLOAT - "Double" -> BlueprintConstants.DATA_TYPE_DOUBLE - "List" -> BlueprintConstants.DATA_TYPE_LIST - "Map" -> BlueprintConstants.DATA_TYPE_MAP - "Object", "JsonNode", "ObjectNode", "ArrayNode" -> BlueprintConstants.DATA_TYPE_JSON + "String", "Date" -> BluePrintConstants.DATA_TYPE_STRING + "int" -> BluePrintConstants.DATA_TYPE_INTEGER + "Boolean" -> BluePrintConstants.DATA_TYPE_BOOLEAN + "Float" -> BluePrintConstants.DATA_TYPE_FLOAT + "Double" -> BluePrintConstants.DATA_TYPE_DOUBLE + "List" -> BluePrintConstants.DATA_TYPE_LIST + "Map" -> BluePrintConstants.DATA_TYPE_MAP + "Object", "JsonNode", "ObjectNode", "ArrayNode" -> BluePrintConstants.DATA_TYPE_JSON else -> simpleName } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintProcessorException.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt index 10a299bd0..c818b0a44 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintProcessorException.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt @@ -27,7 +27,7 @@ import org.onap.ccsdk.cds.error.catalog.core.ErrorMessage * * @author Brinda Santh */ -open class BlueprintProcessorException : ErrorCatalogException, ErrorCatalogExceptionFluent<BlueprintProcessorException> { +open class BluePrintProcessorException : ErrorCatalogException, ErrorCatalogExceptionFluent<BluePrintProcessorException> { constructor(message: String, cause: Throwable) : super(message, cause) constructor(message: String) : super(message) @@ -37,48 +37,48 @@ open class BlueprintProcessorException : ErrorCatalogException, ErrorCatalogExce constructor(code: Int, message: String) : super(code, message) constructor(code: Int, message: String, cause: Throwable) : super(code, message, cause) - override fun code(code: Int): BlueprintProcessorException { + override fun code(code: Int): BluePrintProcessorException { return this.updateCode(code) } - override fun domain(domain: String): BlueprintProcessorException { + override fun domain(domain: String): BluePrintProcessorException { return this.updateDomain(domain) } - override fun action(action: String): BlueprintProcessorException { + override fun action(action: String): BluePrintProcessorException { return this.updateAction(action) } - override fun http(type: String): BlueprintProcessorException { + override fun http(type: String): BluePrintProcessorException { return this.updateHttp(type) } - override fun grpc(type: String): BlueprintProcessorException { + override fun grpc(type: String): BluePrintProcessorException { return this.updateGrpc(type) } - override fun convertToHttp(): BlueprintProcessorException { + override fun convertToHttp(): BluePrintProcessorException { return this.inverseToHttp() } - override fun convertToGrpc(): BlueprintProcessorException { + override fun convertToGrpc(): BluePrintProcessorException { return this.inverseToHttp() } - override fun payloadMessage(message: String): BlueprintProcessorException { + override fun payloadMessage(message: String): BluePrintProcessorException { return this.updatePayloadMessage(message) } - override fun addErrorPayloadMessage(message: String): BlueprintProcessorException { + override fun addErrorPayloadMessage(message: String): BluePrintProcessorException { return this.updateErrorPayloadMessage(message) } - override fun addSubError(errorMessage: ErrorMessage): BlueprintProcessorException { + override fun addSubError(errorMessage: ErrorMessage): BluePrintProcessorException { return this.updateSubError(errorMessage) } } -class BlueprintRetryException : RuntimeException { +class BluePrintRetryException : RuntimeException { constructor(message: String, cause: Throwable) : super(message, cause) constructor(message: String) : super(message) constructor(cause: Throwable) : super(cause) @@ -87,89 +87,89 @@ class BlueprintRetryException : RuntimeException { /** Extension Functions */ -fun processorException(message: String): BlueprintProcessorException { - return BlueprintProcessorException(message) +fun processorException(message: String): BluePrintProcessorException { + return BluePrintProcessorException(message) } -fun processorException(message: String, cause: Throwable): BlueprintProcessorException { - return BlueprintProcessorException(message, cause) +fun processorException(message: String, cause: Throwable): BluePrintProcessorException { + return BluePrintProcessorException(message, cause) } -fun processorException(cause: Throwable, message: String, vararg args: Any?): BlueprintProcessorException { - return BlueprintProcessorException(cause, message, args) +fun processorException(cause: Throwable, message: String, vararg args: Any?): BluePrintProcessorException { + return BluePrintProcessorException(cause, message, args) } -fun processorException(code: Int, message: String): BlueprintProcessorException { +fun processorException(code: Int, message: String): BluePrintProcessorException { return processorException(message).code(code) } -fun processorException(code: Int, message: String, cause: Throwable): BlueprintProcessorException { +fun processorException(code: Int, message: String, cause: Throwable): BluePrintProcessorException { return processorException(message, cause).code(code) } -fun processorException(code: Int, cause: Throwable, message: String, vararg args: Any?): BlueprintProcessorException { +fun processorException(code: Int, cause: Throwable, message: String, vararg args: Any?): BluePrintProcessorException { return processorException(cause, message, args).code(code) } -fun httpProcessorException(type: String, message: String): BlueprintProcessorException { +fun httpProcessorException(type: String, message: String): BluePrintProcessorException { return processorException(message).http(type) } -fun grpcProcessorException(type: String, message: String): BlueprintProcessorException { +fun grpcProcessorException(type: String, message: String): BluePrintProcessorException { return processorException(message).grpc(type) } -fun httpProcessorException(type: String, domain: String, message: String): BlueprintProcessorException { +fun httpProcessorException(type: String, domain: String, message: String): BluePrintProcessorException { val bluePrintProcessorException = processorException(message).http(type) return bluePrintProcessorException.addDomainAndErrorMessage(domain, message) } -fun grpcProcessorException(type: String, domain: String, message: String): BlueprintProcessorException { +fun grpcProcessorException(type: String, domain: String, message: String): BluePrintProcessorException { val bluePrintProcessorException = processorException(message).grpc(type) return bluePrintProcessorException.addDomainAndErrorMessage(domain, message) } fun httpProcessorException(type: String, domain: String, message: String, cause: Throwable): - BlueprintProcessorException { + BluePrintProcessorException { val bluePrintProcessorException = processorException(message, cause).http(type) return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) } fun grpcProcessorException(type: String, domain: String, message: String, cause: Throwable): - BlueprintProcessorException { + BluePrintProcessorException { val bluePrintProcessorException = processorException(message, cause).grpc(type) return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) } fun httpProcessorException(type: String, domain: String, message: String, cause: Throwable, vararg args: Any?): - BlueprintProcessorException { + BluePrintProcessorException { val bluePrintProcessorException = processorException(cause, message, args).http(type) return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) } fun grpcProcessorException(type: String, domain: String, message: String, cause: Throwable, vararg args: Any?): - BlueprintProcessorException { + BluePrintProcessorException { val bluePrintProcessorException = processorException(cause, message, args).grpc(type) return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) } -fun BlueprintProcessorException.updateErrorMessage(domain: String, message: String, cause: String): - BlueprintProcessorException { +fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String, cause: String): + BluePrintProcessorException { return this.addDomainAndErrorMessage(domain, message, cause).domain(domain) .addErrorPayloadMessage(message) .payloadMessage(message) } -fun BlueprintProcessorException.updateErrorMessage(domain: String, message: String): BlueprintProcessorException { +fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String): BluePrintProcessorException { return this.addDomainAndErrorMessage(domain, message).domain(domain) .addErrorPayloadMessage(message) .payloadMessage(message) } -private fun BlueprintProcessorException.addDomainAndErrorMessage( +private fun BluePrintProcessorException.addDomainAndErrorMessage( domain: String, message: String, cause: String = "" -): BlueprintProcessorException { +): BluePrintProcessorException { return this.addSubError(ErrorMessage(domain, message, cause)).domain(domain) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt new file mode 100644 index 000000000..1c769932f --- /dev/null +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt @@ -0,0 +1,170 @@ +/* + * 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.cds.controllerblueprints.core + +import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition + +/** + * + * + * @author Brinda Santh + */ +object BluePrintTypes { + + @JvmStatic + val validNodeTypeDerivedFroms: MutableList<String> = arrayListOf( + BluePrintConstants.MODEL_TYPE_NODES_ROOT, + BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, + BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, + BluePrintConstants.MODEL_TYPE_NODE_VNF, + BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT + ) + + @JvmStatic + val validArtifactTypeDerivedFroms: MutableList<String> = arrayListOf( + BluePrintConstants.MODEL_TYPE_ARTIFACTS_ROOT, + BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION + ) + + @JvmStatic + val validDataTypeDerivedFroms: MutableList<String> = arrayListOf( + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, + BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC + ) + + @JvmStatic + val validRelationShipDerivedFroms: MutableList<String> = arrayListOf( + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO + ) + + @JvmStatic + val validCapabilityTypes: MutableList<String> = arrayListOf( + BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_RESTCONF, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP + ) + + @JvmStatic + fun validModelTypes(): List<String> { + val validTypes: MutableList<String> = arrayListOf() + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + return validTypes + } + + @JvmStatic + fun validPropertyTypes(): List<String> { + val validTypes: MutableList<String> = arrayListOf() + validTypes.addAll(validPrimitiveTypes()) + validTypes.addAll(validComplexTypes()) + validTypes.addAll(validCollectionTypes()) + return validTypes + } + + @JvmStatic + fun validPrimitiveTypes(): List<String> { + val validTypes: MutableList<String> = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_STRING) + validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) + validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) + validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) + validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) + validTypes.add(BluePrintConstants.DATA_TYPE_NULL) + return validTypes + } + + @JvmStatic + fun validComplexTypes(): List<String> { + val validTypes: MutableList<String> = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_JSON) + validTypes.add(BluePrintConstants.DATA_TYPE_MAP) + return validTypes + } + + @JvmStatic + fun validCollectionTypes(): List<String> { + val validTypes: MutableList<String> = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_LIST) + return validTypes + } + + @JvmStatic + fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean { + val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL + return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type) && + BluePrintTypes.validPrimitiveTypes().contains(entrySchema) + } + + @JvmStatic + fun validCommands(): List<String> { + return listOf( + BluePrintConstants.EXPRESSION_DSL_REFERENCE, + BluePrintConstants.EXPRESSION_GET_INPUT, + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE, + BluePrintConstants.EXPRESSION_GET_PROPERTY, + BluePrintConstants.EXPRESSION_GET_ARTIFACT, + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT, + BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE + ) + } + + @JvmStatic + fun rootNodeTypes(): List<String> { + return listOf(BluePrintConstants.MODEL_TYPE_NODES_ROOT) + } + + @JvmStatic + fun rootRelationshipTypes(): List<String> { + return listOf(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT) + } + + @JvmStatic + fun rootDataTypes(): List<String> { + return listOf(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT) + } +} diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintTypes.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintTypes.kt deleted file mode 100644 index cb78ea19f..000000000 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintTypes.kt +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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.cds.controllerblueprints.core - -import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition - -/** - * - * - * @author Brinda Santh - */ -object BlueprintTypes { - - @JvmStatic - val validNodeTypeDerivedFroms: MutableList<String> = arrayListOf( - BlueprintConstants.MODEL_TYPE_NODES_ROOT, - BlueprintConstants.MODEL_TYPE_NODE_WORKFLOW, - BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, - BlueprintConstants.MODEL_TYPE_NODE_VNF, - BlueprintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, - BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA, - BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE, - BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT, - BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON, - BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON, - BlueprintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT - ) - - @JvmStatic - val validArtifactTypeDerivedFroms: MutableList<String> = arrayListOf( - BlueprintConstants.MODEL_TYPE_ARTIFACTS_ROOT, - BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION - ) - - @JvmStatic - val validDataTypeDerivedFroms: MutableList<String> = arrayListOf( - BlueprintConstants.MODEL_TYPE_DATATYPES_ROOT, - BlueprintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC - ) - - @JvmStatic - val validRelationShipDerivedFroms: MutableList<String> = arrayListOf( - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO, - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO - ) - - @JvmStatic - val validCapabilityTypes: MutableList<String> = arrayListOf( - BlueprintConstants.MODEL_TYPE_CAPABILITIES_ROOT, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_RESTCONF, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH, - BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP - ) - - @JvmStatic - fun validModelTypes(): List<String> { - val validTypes: MutableList<String> = arrayListOf() - validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) - validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) - validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) - validTypes.add(BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) - return validTypes - } - - @JvmStatic - fun validPropertyTypes(): List<String> { - val validTypes: MutableList<String> = arrayListOf() - validTypes.addAll(validPrimitiveTypes()) - validTypes.addAll(validComplexTypes()) - validTypes.addAll(validCollectionTypes()) - return validTypes - } - - @JvmStatic - fun validPrimitiveTypes(): List<String> { - val validTypes: MutableList<String> = arrayListOf() - validTypes.add(BlueprintConstants.DATA_TYPE_STRING) - validTypes.add(BlueprintConstants.DATA_TYPE_INTEGER) - validTypes.add(BlueprintConstants.DATA_TYPE_FLOAT) - validTypes.add(BlueprintConstants.DATA_TYPE_DOUBLE) - validTypes.add(BlueprintConstants.DATA_TYPE_BOOLEAN) - validTypes.add(BlueprintConstants.DATA_TYPE_TIMESTAMP) - validTypes.add(BlueprintConstants.DATA_TYPE_NULL) - return validTypes - } - - @JvmStatic - fun validComplexTypes(): List<String> { - val validTypes: MutableList<String> = arrayListOf() - validTypes.add(BlueprintConstants.DATA_TYPE_JSON) - validTypes.add(BlueprintConstants.DATA_TYPE_MAP) - return validTypes - } - - @JvmStatic - fun validCollectionTypes(): List<String> { - val validTypes: MutableList<String> = arrayListOf() - validTypes.add(BlueprintConstants.DATA_TYPE_LIST) - return validTypes - } - - @JvmStatic - fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean { - val entrySchema = propertyDefinition.entrySchema?.type ?: BlueprintConstants.DATA_TYPE_NULL - return BlueprintTypes.validPropertyTypes().contains(propertyDefinition.type) && - BlueprintTypes.validPrimitiveTypes().contains(entrySchema) - } - - @JvmStatic - fun validCommands(): List<String> { - return listOf( - BlueprintConstants.EXPRESSION_DSL_REFERENCE, - BlueprintConstants.EXPRESSION_GET_INPUT, - BlueprintConstants.EXPRESSION_GET_ATTRIBUTE, - BlueprintConstants.EXPRESSION_GET_PROPERTY, - BlueprintConstants.EXPRESSION_GET_ARTIFACT, - BlueprintConstants.EXPRESSION_GET_OPERATION_OUTPUT, - BlueprintConstants.EXPRESSION_GET_NODE_OF_TYPE - ) - } - - @JvmStatic - fun rootNodeTypes(): List<String> { - return listOf(BlueprintConstants.MODEL_TYPE_NODES_ROOT) - } - - @JvmStatic - fun rootRelationshipTypes(): List<String> { - return listOf(BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT) - } - - @JvmStatic - fun rootDataTypes(): List<String> { - return listOf(BlueprintConstants.MODEL_TYPE_DATATYPES_ROOT) - } -} diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt index 25abcd30b..ebe682611 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt @@ -113,7 +113,7 @@ fun <T : Any?> T.asJsonPrimitive(): JsonNode { is Double -> this.asJsonPrimitive() else -> - throw BlueprintException("$this type is not supported") + throw BluePrintException("$this type is not supported") } } } @@ -121,11 +121,11 @@ fun <T : Any?> T.asJsonPrimitive(): JsonNode { /** Based on Blueprint DataType Convert string value to JsonNode Type **/ fun String.asJsonType(bpDataType: String): JsonNode { return when (bpDataType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_STRING -> this.asJsonPrimitive() - BlueprintConstants.DATA_TYPE_BOOLEAN -> this.toBoolean().asJsonPrimitive() - BlueprintConstants.DATA_TYPE_INTEGER -> this.toInt().asJsonPrimitive() - BlueprintConstants.DATA_TYPE_FLOAT -> this.toFloat().asJsonPrimitive() - BlueprintConstants.DATA_TYPE_DOUBLE -> this.toDouble().asJsonPrimitive() + BluePrintConstants.DATA_TYPE_STRING -> this.asJsonPrimitive() + BluePrintConstants.DATA_TYPE_BOOLEAN -> this.toBoolean().asJsonPrimitive() + BluePrintConstants.DATA_TYPE_INTEGER -> this.toInt().asJsonPrimitive() + BluePrintConstants.DATA_TYPE_FLOAT -> this.toFloat().asJsonPrimitive() + BluePrintConstants.DATA_TYPE_DOUBLE -> this.toDouble().asJsonPrimitive() // For List, Map and Complex Types. else -> this.jsonAsJsonType() } @@ -182,7 +182,7 @@ fun <T : Any> Map<String, *>.castValue(key: String, valueType: KClass<T>): T { if (containsKey(key)) { return get(key) as T } else { - throw BlueprintException("couldn't find the key $key") + throw BluePrintException("couldn't find the key $key") } } @@ -197,7 +197,7 @@ fun JsonNode.asByteArray(): ByteArray { fun <T> JsonNode.asType(clazzType: Class<T>): T { return JacksonUtils.readValue(this, clazzType) - ?: throw BlueprintException("couldn't convert JsonNode of type $clazzType") + ?: throw BluePrintException("couldn't convert JsonNode of type $clazzType") } fun JsonNode.asListOfString(): List<String> { @@ -226,7 +226,7 @@ fun JsonNode.rootFieldsToMap(): MutableMap<String, JsonNode> { } return propertyMap } else { - throw BlueprintException("json node should be Object Node Type") + throw BluePrintException("json node should be Object Node Type") } } @@ -248,19 +248,19 @@ fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) { } fun Map<String, JsonNode>.getAsString(key: String): String { - return this[key]?.asText() ?: throw BlueprintException("couldn't find value for key($key)") + return this[key]?.asText() ?: throw BluePrintException("couldn't find value for key($key)") } fun Map<String, JsonNode>.getAsBoolean(key: String): Boolean { - return this[key]?.asBoolean() ?: throw BlueprintException("couldn't find value for key($key)") + return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)") } fun Map<String, JsonNode>.getAsInt(key: String): Int { - return this[key]?.asInt() ?: throw BlueprintException("couldn't find value for key($key)") + return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)") } fun Map<String, JsonNode>.getAsDouble(key: String): Double { - return this[key]?.asDouble() ?: throw BlueprintException("couldn't find value for key($key)") + return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)") } fun Map<String, JsonNode>.getOptionalAsString(key: String): String? { @@ -285,7 +285,7 @@ inline fun checkEquals(value1: String?, value2: String?, lazyMessage: () -> Any) if (value1.equals(value2, ignoreCase = true)) { return true } else { - throw BlueprintException(lazyMessage().toString()) + throw BluePrintException(lazyMessage().toString()) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt index ca3d815f3..518e9b236 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt @@ -19,7 +19,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.apache.commons.io.FileUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintArchiveUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils import java.io.File import java.io.InputStream import java.nio.charset.Charset @@ -39,7 +39,7 @@ fun File.reCreateDirs(): File { // this.mkdirs() FileUtils.forceMkdir(this) check(this.exists()) { - throw BlueprintException("failed to re create dir(${this.absolutePath})") + throw BluePrintException("failed to re create dir(${this.absolutePath})") } return this } @@ -52,7 +52,7 @@ fun File.compress(targetZipFileName: String): File { * Compress the current Dir to the target zip file and return the target zip file */ fun File.compress(targetZipFile: File): File { - BlueprintArchiveUtils.compress(this, targetZipFile) + BluePrintArchiveUtils.compress(this, targetZipFile) return targetZipFile } @@ -64,7 +64,7 @@ fun File.deCompress(targetFileName: String): File { * De-Compress the current zip file to the target file and return the target file */ fun File.deCompress(targetFile: File): File { - BlueprintArchiveUtils.deCompress(this, targetFile.path) + BluePrintArchiveUtils.deCompress(this, targetFile.path) return targetFile } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BlueprintsAnnotations.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt index a72860ae2..c39442976 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BlueprintsAnnotations.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt @@ -16,25 +16,25 @@ package org.onap.ccsdk.cds.controllerblueprints.core.annotations -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import kotlin.reflect.KClass @Target(AnnotationTarget.CLASS) -annotation class BlueprintsDataType( +annotation class BluePrintsDataType( val name: String, - val version: String = BlueprintConstants.DEFAULT_VERSION_NUMBER, + val version: String = BluePrintConstants.DEFAULT_VERSION_NUMBER, val description: String, val derivedFrom: String = "tosca.datatypes.root" ) @Target(AnnotationTarget.CLASS) -annotation class BlueprintsWorkflowInput +annotation class BluePrintsWorkflowInput @Target(AnnotationTarget.CLASS) -annotation class BlueprintsWorkflowOutput +annotation class BluePrintsWorkflowOutput @Target(AnnotationTarget.CLASS) -annotation class BlueprintsNodeType( +annotation class BluePrintsNodeType( val propertiesType: KClass<*>, val attributesType: KClass<*>, val inputsType: KClass<*>, @@ -42,14 +42,14 @@ annotation class BlueprintsNodeType( ) @Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY) -annotation class BlueprintsProperty( +annotation class BluePrintsProperty( val name: String = "", val description: String = "" ) @Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY) @Repeatable -annotation class BlueprintsConstrain() +annotation class BluePrintsConstrain() @Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY) annotation class PropertyDefaultValue(val value: String) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BlueprintLoadConfiguration.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt index 5176ffefd..adfbf2905 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BlueprintLoadConfiguration.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt @@ -17,13 +17,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.config -open class BlueprintLoadConfiguration { +open class BluePrintLoadConfiguration { lateinit var blueprintDeployPath: String lateinit var blueprintArchivePath: String lateinit var blueprintWorkingPath: String - var loadBlueprintPaths: String? = null + var loadBluePrintPaths: String? = null var loadModeTypePaths: String? = null var loadResourceDictionaryPaths: String? = null } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintExpressionData.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt index 37c128714..37c128714 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintExpressionData.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintGraph.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt index bc6cbe426..bc6cbe426 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintGraph.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintModel.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt index 49736c18b..9f32d8830 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintModel.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonPropertyOrder import com.fasterxml.jackson.databind.JsonNode import io.swagger.annotations.ApiModelProperty -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType /** @@ -248,7 +248,7 @@ class Implementation { var dependencies: MutableList<String>? = null @get:JsonProperty("operation_host") - var operationHost: String = BlueprintConstants.PROPERTY_SELF + var operationHost: String = BluePrintConstants.PROPERTY_SELF // Timeout value in seconds var timeout: Int = 180 @@ -732,5 +732,5 @@ class ToscaMetaData { lateinit var templateName: String lateinit var templateVersion: String lateinit var templateTags: String - var templateType: String = BlueprintConstants.BLUEPRINT_TYPE_DEFAULT + var templateType: String = BluePrintConstants.BLUEPRINT_TYPE_DEFAULT } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSL.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt index 81593c935..7f300041a 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSL.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType @@ -35,9 +35,9 @@ fun blueprint( version: String, author: String, tags: String, - block: DSLBlueprintBuilder.() -> Unit -): DSLBlueprint { - return DSLBlueprintBuilder(name, version, author, tags).apply(block).build() + block: DSLBluePrintBuilder.() -> Unit +): DSLBluePrint { + return DSLBluePrintBuilder(name, version, author, tags).apply(block).build() } // TOSCA DSLs @@ -172,59 +172,59 @@ fun getNodeTemplateOperationOutput( /** Blueprint Type Extensions */ fun ServiceTemplateBuilder.nodeTypeComponent() { - val nodeType = BlueprintTypes.nodeTypeComponent() + val nodeType = BluePrintTypes.nodeTypeComponent() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BlueprintTypes.nodeTypeComponent(): NodeType { +fun BluePrintTypes.nodeTypeComponent(): NodeType { return nodeType( - id = BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_NODES_ROOT, + id = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT, description = "This is default Component Node" ) { } } @Deprecated("CDS won't support, use implerative workflow definitions.") -fun BlueprintTypes.nodeTypeWorkflow(): NodeType { +fun BluePrintTypes.nodeTypeWorkflow(): NodeType { return nodeType( - id = BlueprintConstants.MODEL_TYPE_NODE_WORKFLOW, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_NODES_ROOT, + id = BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT, description = "This is default Workflow Node" ) { } } fun ServiceTemplateBuilder.nodeTypeVnf() { - val nodeType = BlueprintTypes.nodeTypeVnf() + val nodeType = BluePrintTypes.nodeTypeVnf() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BlueprintTypes.nodeTypeVnf(): NodeType { +fun BluePrintTypes.nodeTypeVnf(): NodeType { return nodeType( - id = BlueprintConstants.MODEL_TYPE_NODE_VNF, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_NODES_ROOT, + id = BluePrintConstants.MODEL_TYPE_NODE_VNF, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT, description = "This is default VNF Node" ) { } } fun ServiceTemplateBuilder.nodeTypeResourceSource() { - val nodeType = BlueprintTypes.nodeTypeResourceSource() + val nodeType = BluePrintTypes.nodeTypeResourceSource() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BlueprintTypes.nodeTypeResourceSource(): NodeType { +fun BluePrintTypes.nodeTypeResourceSource(): NodeType { return nodeType( - id = BlueprintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_NODES_ROOT, + id = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT, description = "This is default Resource Source Node" ) { } @@ -232,16 +232,16 @@ fun BlueprintTypes.nodeTypeResourceSource(): NodeType { /** Artifacts */ fun ServiceTemplateBuilder.artifactTypeTemplateVelocity() { - val artifactType = BlueprintTypes.artifactTypeTemplateVelocity() + val artifactType = BluePrintTypes.artifactTypeTemplateVelocity() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeTemplateVelocity(): ArtifactType { +fun BluePrintTypes.artifactTypeTemplateVelocity(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Velocity Artifact" ) { fileExt("vtl") @@ -249,16 +249,16 @@ fun BlueprintTypes.artifactTypeTemplateVelocity(): ArtifactType { } fun ServiceTemplateBuilder.artifactTypeTempleJinja() { - val artifactType = BlueprintTypes.artifactTypeTempleJinja() + val artifactType = BluePrintTypes.artifactTypeTempleJinja() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeTempleJinja(): ArtifactType { +fun BluePrintTypes.artifactTypeTempleJinja(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Jinja Artifact" ) { fileExt("jinja") @@ -266,16 +266,16 @@ fun BlueprintTypes.artifactTypeTempleJinja(): ArtifactType { } fun ServiceTemplateBuilder.artifactTypeMappingResource() { - val artifactType = BlueprintTypes.artifactTypeMappingResource() + val artifactType = BluePrintTypes.artifactTypeMappingResource() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeMappingResource(): ArtifactType { +fun BluePrintTypes.artifactTypeMappingResource(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_MAPPING_RESOURCE, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_MAPPING_RESOURCE, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Mapping Resource Artifact" ) { fileExt("json") @@ -283,11 +283,11 @@ fun BlueprintTypes.artifactTypeMappingResource(): ArtifactType { } @Deprecated("CDS won't support", replaceWith = ReplaceWith("artifactTypeScriptKotlin")) -fun BlueprintTypes.artifactTypeScriptJython(): ArtifactType { +fun BluePrintTypes.artifactTypeScriptJython(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_JYTHON, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_JYTHON, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Jython Script Artifact" ) { fileExt("py") @@ -295,16 +295,16 @@ fun BlueprintTypes.artifactTypeScriptJython(): ArtifactType { } fun ServiceTemplateBuilder.artifactTypeScriptKotlin() { - val artifactType = BlueprintTypes.artifactTypeScriptKotlin() + val artifactType = BluePrintTypes.artifactTypeScriptKotlin() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeScriptKotlin(): ArtifactType { +fun BluePrintTypes.artifactTypeScriptKotlin(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Kotlin Script Artifact" ) { fileExt("kts") @@ -312,43 +312,43 @@ fun BlueprintTypes.artifactTypeScriptKotlin(): ArtifactType { } fun ServiceTemplateBuilder.artifactTypeK8sProfileFolder() { - val artifactType = BlueprintTypes.artifactTypeK8sProfileFolder() + val artifactType = BluePrintTypes.artifactTypeK8sProfileFolder() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeK8sProfileFolder(): ArtifactType { +fun BluePrintTypes.artifactTypeK8sProfileFolder(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_K8S_PROFILE, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_K8S_PROFILE, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "K8s Profile Folder Artifact" ) { } } fun ServiceTemplateBuilder.artifactTypeK8sConfigFolder() { - val artifactType = BlueprintTypes.artifactTypeK8sConfigFolder() + val artifactType = BluePrintTypes.artifactTypeK8sConfigFolder() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeK8sConfigFolder(): ArtifactType { +fun BluePrintTypes.artifactTypeK8sConfigFolder(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_K8S_CONFIG, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_K8S_CONFIG, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "K8s Config Folder Artifact" ) { } } @Deprecated("CDS won't support, use implerative workflow definitions.") -fun BlueprintTypes.artifactTypeDirectedGraph(): ArtifactType { +fun BluePrintTypes.artifactTypeDirectedGraph(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_DIRECTED_GRAPH, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_DIRECTED_GRAPH, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Directed Graph Artifact" ) { fileExt("xml", "json") @@ -356,16 +356,16 @@ fun BlueprintTypes.artifactTypeDirectedGraph(): ArtifactType { } fun ServiceTemplateBuilder.artifactTypeComponentJar() { - val artifactType = BlueprintTypes.artifactTypeComponentJar() + val artifactType = BluePrintTypes.artifactTypeComponentJar() if (this.artifactTypes == null) this.artifactTypes = hashMapOf() this.artifactTypes!![artifactType.id!!] = artifactType } -fun BlueprintTypes.artifactTypeComponentJar(): ArtifactType { +fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType { return artifactType( - id = BlueprintConstants.MODEL_TYPE_ARTIFACT_COMPONENT_JAR, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_COMPONENT_JAR, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, description = "Component Artifact" ) { fileExt("jar") @@ -375,49 +375,49 @@ fun BlueprintTypes.artifactTypeComponentJar(): ArtifactType { /** Relationship Types */ fun ServiceTemplateBuilder.relationshipTypeConnectsTo() { - val relationshipType = BlueprintTypes.relationshipTypeConnectsTo() + val relationshipType = BluePrintTypes.relationshipTypeConnectsTo() if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf() this.relationshipTypes!![relationshipType.id!!] = relationshipType } -fun BlueprintTypes.relationshipTypeConnectsTo(): RelationshipType { +fun BluePrintTypes.relationshipTypeConnectsTo(): RelationshipType { return relationshipType( - id = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, + id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, description = "Relationship connects to" ) { - validTargetTypes(arrayListOf(BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT)) + validTargetTypes(arrayListOf(BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT)) } } fun ServiceTemplateBuilder.relationshipTypeDependsOn() { - val relationshipType = BlueprintTypes.relationshipTypeDependsOn() + val relationshipType = BluePrintTypes.relationshipTypeDependsOn() if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf() this.relationshipTypes!![relationshipType.id!!] = relationshipType } -fun BlueprintTypes.relationshipTypeDependsOn(): RelationshipType { +fun BluePrintTypes.relationshipTypeDependsOn(): RelationshipType { return relationshipType( - id = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, + id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, description = "Relationship depends on" ) { } } fun ServiceTemplateBuilder.relationshipTypeHostedOn() { - val relationshipType = BlueprintTypes.relationshipTypeHostedOn() + val relationshipType = BluePrintTypes.relationshipTypeHostedOn() if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf() this.relationshipTypes!![relationshipType.id!!] = relationshipType } -fun BlueprintTypes.relationshipTypeHostedOn(): RelationshipType { +fun BluePrintTypes.relationshipTypeHostedOn(): RelationshipType { return relationshipType( - id = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, + id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, description = "Relationship hosted on" ) { } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt index f92a955a5..b469ded74 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSLBuilder.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType @@ -30,14 +30,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.Step /** * @author Brinda Santh */ -class DSLBlueprintBuilder( +class DSLBluePrintBuilder( private val name: String, private val version: String, private val author: String, private val tags: String ) { - private var dslBlueprint = DSLBlueprint() + private var dslBluePrint = DSLBluePrint() private var metadata: MutableMap<String, String> = hashMapOf() var properties: MutableMap<String, JsonNode>? = null var dataTypes: MutableMap<String, DataType> = hashMapOf() @@ -47,10 +47,10 @@ class DSLBlueprintBuilder( var workflows: MutableMap<String, DSLWorkflow> = hashMapOf() private fun initMetaData() { - metadata[BlueprintConstants.METADATA_TEMPLATE_NAME] = name - metadata[BlueprintConstants.METADATA_TEMPLATE_VERSION] = version - metadata[BlueprintConstants.METADATA_TEMPLATE_AUTHOR] = author - metadata[BlueprintConstants.METADATA_TEMPLATE_TAGS] = tags + metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = name + metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] = version + metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] = author + metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS] = tags } fun metadata(id: String, value: String) { @@ -117,16 +117,16 @@ class DSLBlueprintBuilder( workflows[id] = DSLWorkflowBuilder(id, description).apply(block).build() } - fun build(): DSLBlueprint { + fun build(): DSLBluePrint { initMetaData() - dslBlueprint.metadata = metadata - dslBlueprint.properties = properties - dslBlueprint.dataTypes = dataTypes - dslBlueprint.artifactTypes = artifactTypes - dslBlueprint.components = components - dslBlueprint.registryComponents = registryComponents - dslBlueprint.workflows = workflows - return dslBlueprint + dslBluePrint.metadata = metadata + dslBluePrint.properties = properties + dslBluePrint.dataTypes = dataTypes + dslBluePrint.artifactTypes = artifactTypes + dslBluePrint.components = components + dslBluePrint.registryComponents = registryComponents + dslBluePrint.workflows = workflows + return dslBluePrint } } @@ -190,7 +190,7 @@ class DSLComponentBuilder( properties!![id] = property } - fun implementation(timeout: Int, operationHost: String? = BlueprintConstants.PROPERTY_SELF) { + fun implementation(timeout: Int, operationHost: String? = BluePrintConstants.PROPERTY_SELF) { implementation = Implementation().apply { this.operationHost = operationHost!! this.timeout = timeout @@ -291,7 +291,7 @@ class DSLRegistryComponentBuilder( properties!![id] = expression.asJsonType() } - fun implementation(timeout: Int, operationHost: String? = BlueprintConstants.PROPERTY_SELF) { + fun implementation(timeout: Int, operationHost: String? = BluePrintConstants.PROPERTY_SELF) { implementation = Implementation().apply { this.operationHost = operationHost!! this.timeout = timeout @@ -413,7 +413,7 @@ class DSLWorkflowBuilder(private val actionName: String, private val description class DSLAttributeDefinitionBuilder( private val id: String, - private val type: String? = BlueprintConstants.DATA_TYPE_STRING, + private val type: String? = BluePrintConstants.DATA_TYPE_STRING, private val required: Boolean? = false, private val expression: JsonNode, private val description: String? = "" @@ -446,7 +446,7 @@ class DSLAttributeDefinitionBuilder( class DSLPropertyDefinitionBuilder( private val id: String, - private val type: String? = BlueprintConstants.DATA_TYPE_STRING, + private val type: String? = BluePrintConstants.DATA_TYPE_STRING, private val required: Boolean? = false, private val expression: JsonNode, private val description: String? = "" diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSLData.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt index 8f1a8d145..370531d2a 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSLData.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt @@ -31,7 +31,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.Step * @author Brinda Santh */ -class DSLBlueprint { +class DSLBluePrint { var metadata: MutableMap<String, String> = hashMapOf() var properties: MutableMap<String, JsonNode>? = null diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintServiceTemplateGenerator.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt index 21bc8c7d8..d07fc9c71 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintServiceTemplateGenerator.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.bpClone import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition @@ -38,7 +38,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow * Generate Service Template for the simplified DSL. * @author Brinda Santh */ -class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) { +class BluePrintServiceTemplateGenerator(private val dslBluePrint: DSLBluePrint) { private var serviceTemplate = ServiceTemplate() @@ -47,11 +47,11 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) private val dataTypes: MutableMap<String, DataType> = hashMapOf() fun serviceTemplate(): ServiceTemplate { - serviceTemplate.metadata = dslBlueprint.metadata - serviceTemplate.dslDefinitions = dslBlueprint.properties + serviceTemplate.metadata = dslBluePrint.metadata + serviceTemplate.dslDefinitions = dslBluePrint.properties - dataTypes.putAll(dslBlueprint.dataTypes) - artifactTypes.putAll(dslBlueprint.artifactTypes) + dataTypes.putAll(dslBluePrint.dataTypes) + artifactTypes.putAll(dslBluePrint.artifactTypes) serviceTemplate.dataTypes = dataTypes serviceTemplate.artifactTypes = artifactTypes @@ -74,7 +74,7 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) val nodeTemplates: MutableMap<String, NodeTemplate> = hashMapOf() // For New or Dynamic Components - val components = dslBlueprint.components + val components = dslBluePrint.components components.forEach { (dslCompName, dslComp) -> val nodeTemplate = NodeTemplate() nodeTemplate.type = dslComp.type @@ -88,7 +88,7 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) } // For Registry Components - val registryComponents = dslBlueprint.registryComponents + val registryComponents = dslBluePrint.registryComponents registryComponents.forEach { (dslCompName, dslComp) -> val nodeTemplate = NodeTemplate() nodeTemplate.type = dslComp.type @@ -102,10 +102,10 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) private fun populateWorkflow(): MutableMap<String, Workflow>? { var workflows: MutableMap<String, Workflow>? = null - if (dslBlueprint.workflows.isNotEmpty()) { + if (dslBluePrint.workflows.isNotEmpty()) { workflows = hashMapOf() - dslBlueprint.workflows.forEach { (dslWorkflowName, dslWorkflow) -> + dslBluePrint.workflows.forEach { (dslWorkflowName, dslWorkflow) -> val workflow = Workflow() workflow.description = dslWorkflow.description workflow.steps = dslWorkflow.steps @@ -119,7 +119,7 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) private fun populateNodeType(dslComponent: DSLComponent): NodeType { val nodeType = NodeType() - nodeType.derivedFrom = BlueprintConstants.MODEL_TYPE_NODES_ROOT + nodeType.derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT nodeType.version = dslComponent.version nodeType.description = dslComponent.description nodeType.interfaces = populateInterfaceDefinitions(dslComponent, nodeType) @@ -136,13 +136,13 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) operationDefinition.outputs = propertyDefinitions(dslComponent.outputs) val operations: MutableMap<String, OperationDefinition> = hashMapOf() - operations[BlueprintConstants.DEFAULT_STEP_OPERATION] = operationDefinition + operations[BluePrintConstants.DEFAULT_STEP_OPERATION] = operationDefinition val interfaceDefinition = InterfaceDefinition() interfaceDefinition.operations = operations val interfaces: MutableMap<String, InterfaceDefinition> = hashMapOf() - interfaces[BlueprintConstants.DEFAULT_STEP_INTERFACE] = interfaceDefinition + interfaces[BluePrintConstants.DEFAULT_STEP_INTERFACE] = interfaceDefinition return interfaces } @@ -153,7 +153,7 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) operationAssignment.outputs = dslComponent.outputs val operations: MutableMap<String, OperationAssignment> = hashMapOf() - operations[BlueprintConstants.DEFAULT_STEP_OPERATION] = operationAssignment + operations[BluePrintConstants.DEFAULT_STEP_OPERATION] = operationAssignment val interfaceAssignment = InterfaceAssignment() interfaceAssignment.operations = operations @@ -170,13 +170,13 @@ class BlueprintServiceTemplateGenerator(private val dslBlueprint: DSLBlueprint) operationAssignment.outputs = propertyAssignments(dslComponent.outputs) val operations: MutableMap<String, OperationAssignment> = hashMapOf() - operations[BlueprintConstants.DEFAULT_STEP_OPERATION] = operationAssignment + operations[BluePrintConstants.DEFAULT_STEP_OPERATION] = operationAssignment val interfaceAssignment = InterfaceAssignment() interfaceAssignment.operations = operations val interfaces: MutableMap<String, InterfaceAssignment> = hashMapOf() - interfaces[BlueprintConstants.DEFAULT_STEP_INTERFACE] = interfaceAssignment + interfaces[BluePrintConstants.DEFAULT_STEP_INTERFACE] = interfaceAssignment return interfaces } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintTemplateDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt index f8f6080ad..3a3503403 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintTemplateDSLBuilder.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityAssignment @@ -156,7 +156,7 @@ open class NodeTemplateBuilder( if (interfaces == null) interfaces = hashMapOf() val interfaceAssignment = InterfaceAssignment() - val defaultOperationName = BlueprintConstants.DEFAULT_STEP_OPERATION + val defaultOperationName = BluePrintConstants.DEFAULT_STEP_OPERATION interfaceAssignment.operations = hashMapOf() interfaceAssignment.operations!![defaultOperationName] = OperationAssignmentBuilder<In, Out>(defaultOperationName, description).apply(block).build() @@ -380,7 +380,7 @@ class OperationAssignmentBuilder<In : PropertiesAssignmentBuilder, Out : Propert operationAssignment.implementation = implementation } - fun implementation(timeout: Int, operationHost: String? = BlueprintConstants.PROPERTY_SELF) { + fun implementation(timeout: Int, operationHost: String? = BluePrintConstants.PROPERTY_SELF) { operationAssignment.implementation = Implementation().apply { this.operationHost = operationHost!! this.timeout = timeout @@ -389,7 +389,7 @@ class OperationAssignmentBuilder<In : PropertiesAssignmentBuilder, Out : Propert fun implementation( timeout: Int, - operationHost: String? = BlueprintConstants.PROPERTY_SELF, + operationHost: String? = BluePrintConstants.PROPERTY_SELF, block: ImplementationBuilder.() -> Unit ) { operationAssignment.implementation = ImplementationBuilder(timeout, operationHost!!).apply(block).build() diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintTypeDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt index 3b3b4b41f..3dfdbac57 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintTypeDSLBuilder.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.asListOfString @@ -285,7 +285,7 @@ class CapabilityDefinitionBuilder(private val id: String, private val type: Stri private var capabilityDefinition = CapabilityDefinition() private val properties: MutableMap<String, PropertyDefinition> = hashMapOf() - fun property(id: String, type: String? = BlueprintConstants.DATA_TYPE_STRING, required: Boolean? = false, description: String? = "") { + fun property(id: String, type: String? = BluePrintConstants.DATA_TYPE_STRING, required: Boolean? = false, description: String? = "") { val property = PropertyDefinitionBuilder(id, type, required, description).build() properties[id] = property } @@ -361,7 +361,7 @@ class OperationDefinitionBuilder( class AttributeDefinitionBuilder( private val id: String, - private val type: String? = BlueprintConstants.DATA_TYPE_STRING, + private val type: String? = BluePrintConstants.DATA_TYPE_STRING, private val required: Boolean? = false, private val description: String? = "" ) { @@ -432,7 +432,7 @@ class PropertiesDefinitionBuilder { class PropertyDefinitionBuilder( private val id: String, - private val type: String? = BlueprintConstants.DATA_TYPE_STRING, + private val type: String? = BluePrintConstants.DATA_TYPE_STRING, private val required: Boolean? = false, private val description: String? = "" ) { diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintWorkflowDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt index 0de1a510c..8a1a9d63c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintWorkflowDSLBuilder.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asPropertyDefinitionMap import org.onap.ccsdk.cds.controllerblueprints.core.data.Activity import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition @@ -111,7 +111,7 @@ class StepBuilder( step.id = id step.target = target // Add Default Activity, Assumption is only one Operation - activity(".${BlueprintConstants.DEFAULT_STEP_OPERATION}") + activity(".${BluePrintConstants.DEFAULT_STEP_OPERATION}") step.description = description step.activities = activities step.onSuccess = onSuccess diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt index 4391e89e0..254e644b3 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.asBlueprintsDataTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.asBluePrintsDataTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.asPropertyDefinitionMap @@ -51,10 +51,10 @@ class ServiceTemplateBuilder( var policyTypes: MutableMap<String, PolicyType>? = null private fun initMetaData() { - metadata[BlueprintConstants.METADATA_TEMPLATE_NAME] = name - metadata[BlueprintConstants.METADATA_TEMPLATE_VERSION] = version - metadata[BlueprintConstants.METADATA_TEMPLATE_AUTHOR] = author - metadata[BlueprintConstants.METADATA_TEMPLATE_TAGS] = tags + metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = name + metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] = version + metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] = author + metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS] = tags } fun metadata(id: String, value: String) { @@ -73,7 +73,7 @@ class ServiceTemplateBuilder( } fun dataType(dataType: KClass<*>) { - dataType(dataType.asBlueprintsDataTypes()) + dataType(dataType.asBluePrintsDataTypes()) } fun dsl(id: String, content: Any) { diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintCatalogService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt index 87ee0e4f9..bd45bed06 100644..100755 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintCatalogService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt @@ -16,11 +16,11 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import java.io.File import java.nio.file.Path -interface BlueprintCatalogService { +interface BluePrintCatalogService { /** * Save the CBA to database. @@ -28,9 +28,9 @@ interface BlueprintCatalogService { * @param blueprintFile Either a directory, or an archive * @param validate whether to validate blueprint content. Default true. * @return The unique blueprint identifier - * @throws BlueprintException if process failed + * @throws BluePrintException if process failed */ - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) suspend fun saveToDatabase(processingId: String, blueprintFile: File, validate: Boolean = true): String /** @@ -39,19 +39,19 @@ interface BlueprintCatalogService { * @param version Version of the blueprint * @param extract true to extract the content, false for archived content. Default to true * @return Path where CBA is located - * @throws BlueprintException if process failed + * @throws BluePrintException if process failed */ - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) suspend fun getFromDatabase(name: String, version: String, extract: Boolean = true): Path /** * Delete the CBA from database. * @param name Name of the blueprint * @param version Version of the blueprint - * @throws BlueprintException if process failed + * @throws BluePrintException if process failed */ - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) suspend fun deleteFromDatabase(name: String, version: String) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintDefinitions.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt index 109bc7b85..fcc9bf2d7 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintDefinitions.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate -interface BlueprintDefinitions { +interface BluePrintDefinitions { /** Define the service Template Model */ fun serviceTemplate(): ServiceTemplate @@ -35,7 +35,7 @@ interface BlueprintDefinitions { fun otherDefinitions(): MutableMap<String, Any> } -abstract class AbstractBlueprintDefinitions : BlueprintDefinitions { +abstract class AbstractBluePrintDefinitions : BluePrintDefinitions { private val otherDefinitionMap: MutableMap<String, Any> = hashMapOf() diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintEnhancer.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt index 318fd2b91..2080cd161 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintEnhancer.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate @@ -29,71 +29,71 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService -interface BlueprintEnhancer<T> { +interface BluePrintEnhancer<T> { - fun enhance(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, type: T) + fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) } -interface BlueprintServiceTemplateEnhancer : BlueprintEnhancer<ServiceTemplate> +interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer<ServiceTemplate> -interface BlueprintTopologyTemplateEnhancer : BlueprintEnhancer<TopologyTemplate> +interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer<TopologyTemplate> -interface BlueprintWorkflowEnhancer : BlueprintEnhancer<Workflow> +interface BluePrintWorkflowEnhancer : BluePrintEnhancer<Workflow> -interface BlueprintNodeTemplateEnhancer : BlueprintEnhancer<NodeTemplate> +interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer<NodeTemplate> -interface BlueprintNodeTypeEnhancer : BlueprintEnhancer<NodeType> +interface BluePrintNodeTypeEnhancer : BluePrintEnhancer<NodeType> -interface BlueprintRelationshipTemplateEnhancer : BlueprintEnhancer<RelationshipTemplate> +interface BluePrintRelationshipTemplateEnhancer : BluePrintEnhancer<RelationshipTemplate> -interface BlueprintRelationshipTypeEnhancer : BlueprintEnhancer<RelationshipType> +interface BluePrintRelationshipTypeEnhancer : BluePrintEnhancer<RelationshipType> -interface BlueprintArtifactDefinitionEnhancer : BlueprintEnhancer<ArtifactDefinition> +interface BluePrintArtifactDefinitionEnhancer : BluePrintEnhancer<ArtifactDefinition> -interface BlueprintPolicyTypeEnhancer : BlueprintEnhancer<PolicyType> +interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer<PolicyType> -interface BlueprintPropertyDefinitionEnhancer : BlueprintEnhancer<PropertyDefinition> +interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer<PropertyDefinition> -interface BlueprintAttributeDefinitionEnhancer : BlueprintEnhancer<AttributeDefinition> +interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer<AttributeDefinition> -interface BlueprintEnhancerService { +interface BluePrintEnhancerService { - @Throws(BlueprintException::class) - suspend fun enhance(basePath: String, enrichedBasePath: String): BlueprintContext + @Throws(BluePrintException::class) + suspend fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext - @Throws(BlueprintException::class) - suspend fun enhance(basePath: String): BlueprintContext + @Throws(BluePrintException::class) + suspend fun enhance(basePath: String): BluePrintContext } -interface BlueprintTypeEnhancerService { +interface BluePrintTypeEnhancerService { - fun getServiceTemplateEnhancers(): List<BlueprintServiceTemplateEnhancer> + fun getServiceTemplateEnhancers(): List<BluePrintServiceTemplateEnhancer> - fun getTopologyTemplateEnhancers(): List<BlueprintTopologyTemplateEnhancer> + fun getTopologyTemplateEnhancers(): List<BluePrintTopologyTemplateEnhancer> - fun getWorkflowEnhancers(): List<BlueprintWorkflowEnhancer> + fun getWorkflowEnhancers(): List<BluePrintWorkflowEnhancer> - fun getNodeTemplateEnhancers(): List<BlueprintNodeTemplateEnhancer> + fun getNodeTemplateEnhancers(): List<BluePrintNodeTemplateEnhancer> - fun getNodeTypeEnhancers(): List<BlueprintNodeTypeEnhancer> + fun getNodeTypeEnhancers(): List<BluePrintNodeTypeEnhancer> - fun getRelationshipTemplateEnhancers(): List<BlueprintRelationshipTemplateEnhancer> + fun getRelationshipTemplateEnhancers(): List<BluePrintRelationshipTemplateEnhancer> - fun getRelationshipTypeEnhancers(): List<BlueprintRelationshipTypeEnhancer> + fun getRelationshipTypeEnhancers(): List<BluePrintRelationshipTypeEnhancer> - fun getArtifactDefinitionEnhancers(): List<BlueprintArtifactDefinitionEnhancer> + fun getArtifactDefinitionEnhancers(): List<BluePrintArtifactDefinitionEnhancer> - fun getPolicyTypeEnhancers(): List<BlueprintPolicyTypeEnhancer> + fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer> - fun getPropertyDefinitionEnhancers(): List<BlueprintPropertyDefinitionEnhancer> + fun getPropertyDefinitionEnhancers(): List<BluePrintPropertyDefinitionEnhancer> - fun getAttributeDefinitionEnhancers(): List<BlueprintAttributeDefinitionEnhancer> + fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer> fun enhanceServiceTemplate( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate ) { @@ -102,7 +102,7 @@ interface BlueprintTypeEnhancerService { } fun enhanceTopologyTemplate( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate ) { @@ -110,13 +110,13 @@ interface BlueprintTypeEnhancerService { doEnhancement(bluePrintRuntimeService, name, topologyTemplate, enhancers) } - fun enhanceWorkflow(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, workflow: Workflow) { + fun enhanceWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { val enhancers = getWorkflowEnhancers() doEnhancement(bluePrintRuntimeService, name, workflow, enhancers) } fun enhanceNodeTemplate( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate ) { @@ -124,13 +124,13 @@ interface BlueprintTypeEnhancerService { doEnhancement(bluePrintRuntimeService, name, nodeTemplate, enhancers) } - fun enhanceNodeType(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, nodeType: NodeType) { + fun enhanceNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { val enhancers = getNodeTypeEnhancers() doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers) } fun enhanceRelationshipTemplate( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, relationshipTemplate: RelationshipTemplate ) { @@ -139,7 +139,7 @@ interface BlueprintTypeEnhancerService { } fun enhanceRelationshipType( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, relationshipType: RelationshipType ) { @@ -148,7 +148,7 @@ interface BlueprintTypeEnhancerService { } fun enhanceArtifactDefinition( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition ) { @@ -156,31 +156,31 @@ interface BlueprintTypeEnhancerService { doEnhancement(bluePrintRuntimeService, name, artifactDefinition, enhancers) } - fun enhancePolicyType(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, policyType: PolicyType) { + fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) { val enhancers = getPolicyTypeEnhancers() doEnhancement(bluePrintRuntimeService, name, policyType, enhancers) } fun enhancePropertyDefinitions( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap<String, PropertyDefinition> ) { - val errorMap = linkedMapOf<String, BlueprintException>() + val errorMap = linkedMapOf<String, BluePrintException>() properties.forEach { propertyName, propertyDefinition -> try { enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) - } catch (e: BlueprintException) { + } catch (e: BluePrintException) { errorMap[propertyName] = e } } if (errorMap.isNotEmpty()) { val nestedErrors = errorMap.keys.map { "[ property: ${errorMap[it]?.message} ]" }.joinToString(";") - throw BlueprintException("Failed to enhance properties $nestedErrors") + throw BluePrintException("Failed to enhance properties $nestedErrors") } } fun enhancePropertyDefinition( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition ) { @@ -189,25 +189,25 @@ interface BlueprintTypeEnhancerService { } fun enhanceAttributeDefinitions( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap<String, AttributeDefinition> ) { - val errorMap = linkedMapOf<String, BlueprintException>() + val errorMap = linkedMapOf<String, BluePrintException>() attributes.forEach { attributeName, attributeDefinition -> try { enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) - } catch (e: BlueprintException) { + } catch (e: BluePrintException) { errorMap[attributeName] = e } } if (errorMap.isNotEmpty()) { val nestedErrors = errorMap.keys.map { "[ attribute: ${errorMap[it]?.message} ]" }.joinToString(";") - throw BlueprintException("Failed to enhance attributes $nestedErrors") + throw BluePrintException("Failed to enhance attributes $nestedErrors") } } fun enhanceAttributeDefinition( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition ) { @@ -217,17 +217,17 @@ interface BlueprintTypeEnhancerService { @Suppress("UNCHECKED_CAST") private fun <T> doEnhancement( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, - enhancers: List<BlueprintEnhancer<T>> + enhancers: List<BluePrintEnhancer<T>> ) { if (enhancers.isNotEmpty()) { - val errorMap = linkedMapOf<String, BlueprintException>() + val errorMap = linkedMapOf<String, BluePrintException>() enhancers.forEach { try { it.enhance(bluePrintRuntimeService, name, definition as T) - } catch (e: BlueprintException) { + } catch (e: BluePrintException) { errorMap[name] = e } } @@ -235,7 +235,7 @@ interface BlueprintTypeEnhancerService { val nestedErrors = errorMap.keys.map { "${errorMap[it]?.message ?: errorMap[it].toString()}" }.joinToString(";") - throw BlueprintException("$name-->$nestedErrors") + throw BluePrintException("$name-->$nestedErrors") } } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintRepoService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt index 631236a40..8d04e5489 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintRepoService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType @@ -26,25 +26,25 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType import java.io.Serializable /** - * BlueprintRepoFileService + * BluePrintRepoFileService * @author Brinda Santh * */ -interface BlueprintRepoService : Serializable { +interface BluePrintRepoService : Serializable { - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) fun getNodeType(nodeTypeName: String): NodeType - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) fun getDataType(dataTypeName: String): DataType - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) fun getArtifactType(artifactTypeName: String): ArtifactType - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) fun getRelationshipType(relationshipTypeName: String): RelationshipType - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintScriptsService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt index b7a06e264..aa61b0c4d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintScriptsService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt @@ -17,11 +17,11 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintSourceCode +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintSourceCode -interface BlueprintScriptsService { +interface BluePrintScriptsService { - suspend fun <T> scriptInstance(bluePrintSourceCode: BlueprintSourceCode, scriptClassName: String): T + suspend fun <T> scriptInstance(bluePrintSourceCode: BluePrintSourceCode, scriptClassName: String): T suspend fun <T> scriptInstance( blueprintBasePath: String, diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt index 4f20a1a33..70c797326 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintWorkflowExecutionService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt @@ -16,12 +16,12 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService -interface BlueprintWorkflowExecutionService<Input, Output> { +interface BluePrintWorkflowExecutionService<Input, Output> { - suspend fun executeBlueprintWorkflow( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + suspend fun executeBluePrintWorkflow( + bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: Input, properties: MutableMap<String, Any> = hashMapOf() ): Output diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt index 4f6689022..b56fac541 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt @@ -18,29 +18,29 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import java.util.function.Function interface BlueprintFunctionNode<T, R> : Function<T, R> { fun getName(): String - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) fun prepareRequest(executionRequest: T): T = runBlocking { prepareRequestNB(executionRequest) } - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) fun process(executionRequest: T) = runBlocking { processNB(executionRequest) } - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) fun recover(runtimeException: RuntimeException, executionRequest: T) = runBlocking { recoverNB(runtimeException, executionRequest) } - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) fun prepareResponse(): R = runBlocking { prepareResponseNB() } @@ -55,18 +55,18 @@ interface BlueprintFunctionNode<T, R> : Function<T, R> { return prepareResponse() } - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) suspend fun prepareRequestNB(executionRequest: T): T - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) suspend fun processNB(executionRequest: T) - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: T) - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) suspend fun prepareResponseNB(): R - @Throws(BlueprintProcessorException::class) + @Throws(BluePrintProcessorException::class) suspend fun applyNB(t: T): R } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt index 799011568..1958e23ac 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces import com.fasterxml.jackson.core.io.CharTypes import com.fasterxml.jackson.databind.node.JsonNodeFactory import com.fasterxml.jackson.databind.node.TextNode -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService interface BlueprintTemplateService { @@ -35,7 +35,7 @@ interface BlueprintTemplateService { * **/ suspend fun generateContent( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactName: String, jsonData: String = "", @@ -47,14 +47,14 @@ interface BlueprintTemplateService { /** * Customise JsonNodeFactory and TextNode, Since it introduces quotes for string data. */ -open class BlueprintJsonNodeFactory : JsonNodeFactory() { +open class BluePrintJsonNodeFactory : JsonNodeFactory() { override fun textNode(text: String): TextNode { - return BlueprintTextNode(text) + return BluePrintTextNode(text) } } -open class BlueprintTextNode(v: String) : TextNode(v) { +open class BluePrintTextNode(v: String) : TextNode(v) { override fun toString(): String { var len = this._value.length diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt index 5f36e8ede..0d9876b81 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition @@ -28,85 +28,85 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService -interface BlueprintValidator<T> { +interface BluePrintValidator<T> { - fun validate(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, type: T) + fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) } -interface BlueprintServiceTemplateValidator : BlueprintValidator<ServiceTemplate> +interface BluePrintServiceTemplateValidator : BluePrintValidator<ServiceTemplate> -interface BlueprintTopologyTemplateValidator : BlueprintValidator<TopologyTemplate> +interface BluePrintTopologyTemplateValidator : BluePrintValidator<TopologyTemplate> -interface BlueprintArtifactTypeValidator : BlueprintValidator<ArtifactType> +interface BluePrintArtifactTypeValidator : BluePrintValidator<ArtifactType> -interface BlueprintArtifactDefinitionValidator : BlueprintValidator<ArtifactDefinition> +interface BluePrintArtifactDefinitionValidator : BluePrintValidator<ArtifactDefinition> -interface BlueprintDataTypeValidator : BlueprintValidator<DataType> +interface BluePrintDataTypeValidator : BluePrintValidator<DataType> -interface BlueprintNodeTypeValidator : BlueprintValidator<NodeType> +interface BluePrintNodeTypeValidator : BluePrintValidator<NodeType> -interface BlueprintNodeTemplateValidator : BlueprintValidator<NodeTemplate> +interface BluePrintNodeTemplateValidator : BluePrintValidator<NodeTemplate> -interface BlueprintWorkflowValidator : BlueprintValidator<Workflow> +interface BluePrintWorkflowValidator : BluePrintValidator<Workflow> -interface BlueprintPropertyDefinitionValidator : BlueprintValidator<PropertyDefinition> +interface BluePrintPropertyDefinitionValidator : BluePrintValidator<PropertyDefinition> -interface BlueprintAttributeDefinitionValidator : BlueprintValidator<AttributeDefinition> +interface BluePrintAttributeDefinitionValidator : BluePrintValidator<AttributeDefinition> /** * Blueprint Validation Interface. */ -interface BlueprintValidatorService { +interface BluePrintValidatorService { - @Throws(BlueprintException::class) - suspend fun validateBlueprints(basePath: String): Boolean + @Throws(BluePrintException::class) + suspend fun validateBluePrints(basePath: String): Boolean - @Throws(BlueprintException::class) - suspend fun validateBlueprints(bluePrintRuntimeService: BlueprintRuntimeService<*>): Boolean + @Throws(BluePrintException::class) + suspend fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean } -interface BlueprintTypeValidatorService { +interface BluePrintTypeValidatorService { - fun <T : BlueprintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T? + fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T? - fun <T : BlueprintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>? + fun <T : BluePrintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>? - fun <T : BlueprintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>? + fun <T : BluePrintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>? - fun getServiceTemplateValidators(): List<BlueprintServiceTemplateValidator> + fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> - fun getDataTypeValidators(): List<BlueprintDataTypeValidator> + fun getDataTypeValidators(): List<BluePrintDataTypeValidator> - fun getArtifactTypeValidators(): List<BlueprintArtifactTypeValidator> + fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> - fun getArtifactDefinitionsValidators(): List<BlueprintArtifactDefinitionValidator> + fun getArtifactDefinitionsValidators(): List<BluePrintArtifactDefinitionValidator> - fun getNodeTypeValidators(): List<BlueprintNodeTypeValidator> + fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> - fun getTopologyTemplateValidators(): List<BlueprintTopologyTemplateValidator> + fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> - fun getNodeTemplateValidators(): List<BlueprintNodeTemplateValidator> + fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> - fun getWorkflowValidators(): List<BlueprintWorkflowValidator> + fun getWorkflowValidators(): List<BluePrintWorkflowValidator> - fun getPropertyDefinitionValidators(): List<BlueprintPropertyDefinitionValidator> + fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> - fun getAttributeDefinitionValidators(): List<BlueprintAttributeDefinitionValidator> + fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> - fun validateServiceTemplate(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { + fun validateServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { val validators = getServiceTemplateValidators() doValidation(bluePrintRuntimeService, name, serviceTemplate, validators) } - fun validateArtifactType(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, artifactType: ArtifactType) { + fun validateArtifactType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { val validators = getArtifactTypeValidators() doValidation(bluePrintRuntimeService, name, artifactType, validators) } fun validateArtifactDefinition( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition ) { @@ -114,59 +114,59 @@ interface BlueprintTypeValidatorService { doValidation(bluePrintRuntimeService, name, artifactDefinition, validators) } - fun validateDataType(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, dataType: DataType) { + fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { val validators = getDataTypeValidators() doValidation(bluePrintRuntimeService, name, dataType, validators) } - fun validateNodeType(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, nodeType: NodeType) { + fun validateNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { val validators = getNodeTypeValidators() doValidation(bluePrintRuntimeService, name, nodeType, validators) } - fun validateTopologyTemplate(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { + fun validateTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { val validators = getTopologyTemplateValidators() doValidation(bluePrintRuntimeService, name, topologyTemplate, validators) } - fun validateNodeTemplate(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { + fun validateNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { val validators = getNodeTemplateValidators() doValidation(bluePrintRuntimeService, name, nodeTemplate, validators) } - fun validateWorkflow(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, workflow: Workflow) { + fun validateWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { val validators = getWorkflowValidators() doValidation(bluePrintRuntimeService, name, workflow, validators) } - fun validatePropertyDefinitions(bluePrintRuntimeService: BlueprintRuntimeService<*>, properties: MutableMap<String, PropertyDefinition>) { + fun validatePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap<String, PropertyDefinition>) { properties.forEach { propertyName, propertyDefinition -> validatePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) } } - fun validatePropertyDefinition(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { + fun validatePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { val validators = getPropertyDefinitionValidators() doValidation(bluePrintRuntimeService, name, propertyDefinition, validators) } - fun validateAttributeDefinitions(bluePrintRuntimeService: BlueprintRuntimeService<*>, attributes: MutableMap<String, AttributeDefinition>) { + fun validateAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap<String, AttributeDefinition>) { attributes.forEach { attributeName, attributeDefinition -> validateAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) } } - fun validateAttributeDefinition(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { + fun validateAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { val validators = getAttributeDefinitionValidators() doValidation(bluePrintRuntimeService, name, attributeDefinition, validators) } @Suppress("UNCHECKED_CAST") private fun <T> doValidation( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, - validators: List<BlueprintValidator<T>> + validators: List<BluePrintValidator<T>> ) { validators.forEach { it.validate(bluePrintRuntimeService, name, definition as T) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompileService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt index 5cf0a93af..230097f3c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompileService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.config.Services -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists import org.onap.ccsdk.cds.controllerblueprints.core.logger import java.io.File @@ -40,9 +40,9 @@ import kotlin.script.experimental.api.SourceCode import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty import kotlin.system.measureTimeMillis -open class BlueprintCompileService { +open class BluePrintCompileService { - val log = logger(BlueprintCompileService::class) + val log = logger(BluePrintCompileService::class) companion object { @@ -55,7 +55,7 @@ open class BlueprintCompileService { /** Compile the [bluePrintSourceCode] and get the [kClassName] instance for the constructor [args] */ suspend fun <T> eval( - bluePrintSourceCode: BlueprintSourceCode, + bluePrintSourceCode: BluePrintSourceCode, kClassName: String, args: ArrayList<Any?>? ): T { @@ -68,14 +68,14 @@ open class BlueprintCompileService { } } - val classLoaderWithDependencies = BlueprintCompileCache.classLoader(bluePrintSourceCode.cacheKey) + val classLoaderWithDependencies = BluePrintCompileCache.classLoader(bluePrintSourceCode.cacheKey) /** Create the instance from the class loader */ return instance(classLoaderWithDependencies, kClassName, args) } /** Compile [bluePrintSourceCode] and put into cache */ - suspend fun compile(bluePrintSourceCode: BlueprintSourceCode) { + suspend fun compile(bluePrintSourceCode: BluePrintSourceCode) { // TODO("Include Multiple folders") val sourcePath = bluePrintSourceCode.blueprintKotlinSources.first() val compiledJarFile = bluePrintSourceCode.targetJarFile @@ -110,7 +110,7 @@ open class BlueprintCompileService { checkFileExists(compiledJarFile) { "couldn't generate compiled jar(${compiledJarFile.absolutePath})" } } else -> { - throw BlueprintException("$exitCode :${messageCollector.errors().joinToString("\n")}") + throw BluePrintException("$exitCode :${messageCollector.errors().joinToString("\n")}") } } } @@ -123,21 +123,21 @@ open class BlueprintCompileService { /** create class [kClassName] instance from [classLoader] */ fun <T> instance(classLoader: URLClassLoader, kClassName: String, args: ArrayList<Any?>? = arrayListOf()): T { val kClazz = classLoader.loadClass(kClassName) - ?: throw BlueprintException("failed to load class($kClassName) from current class loader.") + ?: throw BluePrintException("failed to load class($kClassName) from current class loader.") val instance = if (args.isNullOrEmpty()) { kClazz.newInstance() } else { kClazz.constructors .single().newInstance(*args.toArray()) - } ?: throw BlueprintException("failed to create class($kClassName) instance for constructor argument($args).") + } ?: throw BluePrintException("failed to create class($kClassName) instance for constructor argument($args).") return instance as T } } /** Compile source code information */ -open class BlueprintSourceCode : SourceCode { +open class BluePrintSourceCode : SourceCode { lateinit var blueprintKotlinSources: MutableList<String> lateinit var moduleName: String diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompilerCache.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt index a6d4571a2..a0efc619c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompilerCache.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt @@ -19,18 +19,18 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCache -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import java.net.URLClassLoader -object BlueprintCompileCache { +object BluePrintCompileCache { - val log = logger(BlueprintCompileCache::class) + val log = logger(BluePrintCompileCache::class) private val classLoaderCache: LoadingCache<String, URLClassLoader> = CacheBuilder.newBuilder() .maximumSize(50) - .build(BlueprintClassLoader) + .build(BluePrintClassLoader) fun classLoader(key: String): URLClassLoader { return classLoaderCache.get(key) @@ -54,14 +54,14 @@ object BlueprintCompileCache { } } -object BlueprintClassLoader : CacheLoader<String, URLClassLoader>() { +object BluePrintClassLoader : CacheLoader<String, URLClassLoader>() { - val log = logger(BlueprintClassLoader::class) + val log = logger(BluePrintClassLoader::class) override fun load(key: String) = try { log.info("loading compiled cache($key)") - BlueprintFileUtils.getURLClassLoaderFromDirectory(key) + BluePrintFileUtils.getURLClassLoaderFromDirectory(key) } catch (e: Exception) { - throw BlueprintException("failed to load cache($key) with Exception($e)") + throw BluePrintException("failed to load cache($key) with Exception($e)") } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImpl.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt index c89d74dfb..f3eb1a2b9 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt @@ -17,20 +17,20 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintScriptsService +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService import org.onap.ccsdk.cds.controllerblueprints.core.logger import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintFileUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import java.util.ArrayList -open class BlueprintScriptsServiceImpl : BlueprintScriptsService { +open class BluePrintScriptsServiceImpl : BluePrintScriptsService { - val log = logger(BlueprintScriptsServiceImpl::class) + val log = logger(BluePrintScriptsServiceImpl::class) - override suspend fun <T> scriptInstance(bluePrintSourceCode: BlueprintSourceCode, scriptClassName: String): T { - val bluePrintCompileService = BlueprintCompileService() + override suspend fun <T> scriptInstance(bluePrintSourceCode: BluePrintSourceCode, scriptClassName: String): T { + val bluePrintCompileService = BluePrintCompileService() return bluePrintCompileService.eval(bluePrintSourceCode, scriptClassName, null) } @@ -43,13 +43,13 @@ open class BlueprintScriptsServiceImpl : BlueprintScriptsService { ): T { val sources: MutableList<String> = arrayListOf() - sources.add(normalizedPathName(blueprintBasePath, BlueprintConstants.TOSCA_SCRIPTS_KOTLIN_DIR)) + sources.add(normalizedPathName(blueprintBasePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR)) - val scriptSource = BlueprintSourceCode() + val scriptSource = BluePrintSourceCode() scriptSource.blueprintKotlinSources = sources scriptSource.moduleName = "$artifactName-$artifactVersion-cba-kts" - scriptSource.cacheKey = BlueprintFileUtils.compileCacheKey(blueprintBasePath) - scriptSource.targetJarFile = BlueprintFileUtils.compileJarFile(blueprintBasePath, artifactName, artifactVersion) + scriptSource.cacheKey = BluePrintFileUtils.compileCacheKey(blueprintBasePath) + scriptSource.targetJarFile = BluePrintFileUtils.compileJarFile(blueprintBasePath, artifactName, artifactVersion) scriptSource.regenerate = reCompile return scriptInstance(scriptSource, scriptClassName) } @@ -59,7 +59,7 @@ open class BlueprintScriptsServiceImpl : BlueprintScriptsService { scriptClassName: String, reCompile: Boolean ): T { - val toscaMetaData = BlueprintMetadataUtils.toscaMetaData(blueprintBasePath) + val toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintBasePath) checkNotNull(toscaMetaData.templateName) { "couldn't find 'Template-Name' key in TOSCA.meta" } checkNotNull(toscaMetaData.templateVersion) { "couldn't find 'Template-Version' key in TOSCA.meta" } return scriptInstance( @@ -70,7 +70,7 @@ open class BlueprintScriptsServiceImpl : BlueprintScriptsService { override suspend fun <T> scriptInstance(cacheKey: String, scriptClassName: String): T { val args = ArrayList<Any?>() - return BlueprintCompileCache.classLoader(cacheKey).loadClass(scriptClassName).constructors + return BluePrintCompileCache.classLoader(cacheKey).loadClass(scriptClassName).constructors .single().newInstance(*args.toArray()) as T } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintChainedService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt index e0a0f170b..1a43c3066 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintChainedService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition @@ -31,11 +31,11 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementDefinition * * @author Brinda Santh */ -internal class BlueprintChainedService { +internal class BluePrintChainedService { - var bpc: BlueprintContext + var bpc: BluePrintContext - constructor(bpc: BlueprintContext) { + constructor(bpc: BluePrintContext) { this.bpc = bpc } @@ -105,7 +105,7 @@ internal class BlueprintChainedService { val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) nodeType.id = nodeTypeName val derivedFrom: String = nodeType.derivedFrom - if (!BlueprintTypes.rootNodeTypes().contains(derivedFrom)) { + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { recNodeTypesChained(derivedFrom, nodeTypes) } nodeTypes!!.add(nodeType) @@ -116,7 +116,7 @@ internal class BlueprintChainedService { val dataType: DataType = bpc.dataTypeByName(dataTypeName)!! dataType.id = dataTypeName val derivedFrom: String = dataType.derivedFrom - if (!BlueprintTypes.rootDataTypes().contains(derivedFrom)) { + if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) { recDataTypesChained(derivedFrom, dataTypes) } dataTypes!!.add(dataType) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintContext.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt index 62026be88..76a6ff7cf 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintContext.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt @@ -19,8 +19,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityAssignment @@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory * * @author Brinda Santh */ -class BlueprintContext(val serviceTemplate: ServiceTemplate) { +class BluePrintContext(val serviceTemplate: ServiceTemplate) { private val log = LoggerFactory.getLogger(this::class.toString()) @@ -86,39 +86,39 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { return JacksonUtils.getJson(serviceTemplate, pretty) } - fun name(): String = metadata?.get(BlueprintConstants.METADATA_TEMPLATE_NAME) - ?: throw BlueprintException("could't get template name from meta data") + fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME) + ?: throw BluePrintException("could't get template name from meta data") - fun version(): String = metadata?.get(BlueprintConstants.METADATA_TEMPLATE_VERSION) - ?: throw BlueprintException("could't get template version from meta data") + fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION) + ?: throw BluePrintException("could't get template version from meta data") - fun author(): String = metadata?.get(BlueprintConstants.METADATA_TEMPLATE_AUTHOR) - ?: throw BlueprintException("could't get template author from meta data") + fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR) + ?: throw BluePrintException("could't get template author from meta data") // Workflow fun workflows(): MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows fun workflowByName(workFlowName: String): Workflow = workflows()?.get(workFlowName) - ?: throw BlueprintException("could't get workflow($workFlowName)") + ?: throw BluePrintException("could't get workflow($workFlowName)") fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs fun workflowSteps(workFlowName: String) = - workflowByName(workFlowName).steps ?: throw BlueprintException("could't get steps for workflow($workFlowName)") + workflowByName(workFlowName).steps ?: throw BluePrintException("could't get steps for workflow($workFlowName)") fun workflowStepByName(workFlowName: String, stepName: String): Step { return workflowSteps(workFlowName)[stepName] - ?: throw BlueprintException("could't get step($stepName) for workflow($workFlowName)") + ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)") } fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String { return workflowStepByName(workFlowName, stepName).target - ?: throw BlueprintException("could't get node template name for workflow($workFlowName)'s step($stepName)") + ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)") } fun workflowFirstStepNodeTemplate(workFlowName: String): String { val firstStepName = workflowSteps(workFlowName).keys.ifEmpty { - throw BlueprintException("could't get first step for workflow($workFlowName)") + throw BluePrintException("could't get first step for workflow($workFlowName)") }.first() return workflowStepNodeTemplate(workFlowName, firstStepName) } @@ -128,12 +128,12 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { workFlowName, stepName ).activities?.filter { it.callOperation != null }?.single()?.callOperation - ?: throw BlueprintException("couldn't get first callOperation for WorkFlow($workFlowName) ") + ?: throw BluePrintException("couldn't get first callOperation for WorkFlow($workFlowName) ") } // DSL fun dslPropertiesByName(name: String): JsonNode = dslDefinitions()?.get(name) - ?: throw BlueprintException("couldn't get policy type for the dsl($name)") + ?: throw BluePrintException("couldn't get policy type for the dsl($name)") // Data Type fun dataTypeByName(name: String): DataType? = dataTypes()?.get(name) @@ -145,7 +145,7 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { fun policyTypes(): MutableMap<String, PolicyType>? = serviceTemplate.policyTypes fun policyTypeByName(policyName: String) = policyTypes()?.get(policyName) - ?: throw BlueprintException("could't get policy type for the name($policyName)") + ?: throw BluePrintException("could't get policy type for the name($policyName)") fun policyTypesDerivedFrom(name: String): MutableMap<String, PolicyType>? { return policyTypes()?.filterValues { policyType -> policyType.derivedFrom == name }?.toMutableMap() @@ -166,7 +166,7 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { fun nodeTypeByName(name: String): NodeType = nodeTypes()?.get(name) - ?: throw BlueprintException("could't get node type for the name($name)") + ?: throw BluePrintException("could't get node type for the name($name)") fun nodeTypeDerivedFrom(name: String): MutableMap<String, NodeType>? { return nodeTypes()?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap() @@ -174,7 +174,7 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition { return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName) - ?: throw BlueprintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)") + ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)") } fun nodeTypeInterfaceOperation( @@ -183,12 +183,12 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { operationName: String ): OperationDefinition { return nodeTypeInterface(nodeTypeName, interfaceName).operations?.get(operationName) - ?: throw BlueprintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)") + ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)") } fun interfaceNameForNodeType(nodeTypeName: String): String { return nodeTypeByName(nodeTypeName).interfaces?.keys?.first() - ?: throw BlueprintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name") + ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name") } fun nodeTypeInterfaceOperationInputs( @@ -211,13 +211,13 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { fun relationshipTypes(): MutableMap<String, RelationshipType>? = serviceTemplate.relationshipTypes fun relationshipTypeByName(name: String): RelationshipType = relationshipTypes()?.get(name) - ?: throw BlueprintException("could't get relationship type for the name($name)") + ?: throw BluePrintException("could't get relationship type for the name($name)") // Node Template Methods fun nodeTemplates(): MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates fun nodeTemplateByName(name: String): NodeTemplate = - nodeTemplates()?.get(name) ?: throw BlueprintException("could't get node template for the name($name)") + nodeTemplates()?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? { return nodeTemplates()?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() @@ -242,27 +242,27 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition { return checkNodeTemplateArtifact(nodeTemplateName, artifactName) - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)") } fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition { return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0) - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)") } fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment { return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first() - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment") } fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String { return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first() - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name") } fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String { return nodeTemplateFirstInterface(nodeTemplateName).operations?.keys?.first() - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name") } fun nodeTemplateOperationImplementation(nodeTemplateName: String, interfaceName: String, operationName: String): @@ -288,7 +288,7 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment { return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName) - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)") } fun nodeTemplateInterfaceOperation( @@ -297,23 +297,23 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { operationName: String ): OperationAssignment { return nodeTemplateInterface(nodeTemplateName, interfaceName).operations?.get(operationName) - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)") } fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment { return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName) - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)") } fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment { return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName) - ?: throw BlueprintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)") + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)") } fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate { val filteredNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node - ?: throw BlueprintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ") + ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ") return nodeTemplateByName(filteredNodeTemplateName) } @@ -326,7 +326,7 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { serviceTemplate.topologyTemplate?.relationshipTemplates fun relationshipTemplateByName(name: String): RelationshipTemplate = relationshipTemplates()?.get(name) - ?: throw BlueprintException("could't get relationship template for the name($name)") + ?: throw BluePrintException("could't get relationship template for the name($name)") fun relationshipTemplateProperty(relationshipTemplateName: String, propertyName: String): Any? { return nodeTemplateByName(relationshipTemplateName).properties?.get(propertyName) @@ -345,10 +345,10 @@ class BlueprintContext(val serviceTemplate: ServiceTemplate) { // Chained Functions fun nodeTypeChained(nodeTypeName: String): NodeType { - return BlueprintChainedService(this).nodeTypeChained(nodeTypeName) + return BluePrintChainedService(this).nodeTypeChained(nodeTypeName) } fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap<String, PropertyDefinition>? { - return BlueprintChainedService(this).nodeTypeChainedProperties(nodeTypeName) + return BluePrintChainedService(this).nodeTypeChainedProperties(nodeTypeName) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintDependencyService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt index 8f3308568..e8457283e 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintDependencyService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.springframework.context.ApplicationContext import org.springframework.context.ConfigurableApplicationContext import kotlin.reflect.KClass @@ -29,12 +29,12 @@ import kotlin.reflect.KClass * @author Brinda Santh */ -object BlueprintDependencyService { +object BluePrintDependencyService { lateinit var applicationContext: ApplicationContext fun inject(applicationContext: ApplicationContext) { - BlueprintDependencyService.applicationContext = applicationContext + BluePrintDependencyService.applicationContext = applicationContext } /** Used to inject [instance] into spring application context for the [key], @@ -47,16 +47,16 @@ object BlueprintDependencyService { inline fun <reified T> instance(name: String): T { return applicationContext.getBean(name) as? T - ?: throw BlueprintProcessorException("failed to get instance($name)") + ?: throw BluePrintProcessorException("failed to get instance($name)") } inline fun <reified T> instance(type: Class<T>): T { return applicationContext.getBean(type) - ?: throw BlueprintProcessorException("failed to get instance($type)") + ?: throw BluePrintProcessorException("failed to get instance($type)") } inline fun <reified T> instance(type: KClass<*>): T { return applicationContext.getBean(type.java) as? T - ?: throw BlueprintProcessorException("failed to get instance($type)") + ?: throw BluePrintProcessorException("failed to get instance($type)") } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintExpressionService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt index ac90705a1..193ff7888 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintExpressionService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -21,9 +21,9 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.databind.node.TextNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactExpression import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeExpression import org.onap.ccsdk.cds.controllerblueprints.core.data.DSLExpression @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory * * @author Brinda Santh */ -object BlueprintExpressionService { +object BluePrintExpressionService { val log = LoggerFactory.getLogger(this::class.toString()) @@ -47,9 +47,9 @@ object BlueprintExpressionService { val json = propertyAssignmentNode.toString() // FIXME("Check if any Optimisation needed") return ( - json.contains(BlueprintConstants.EXPRESSION_GET_INPUT) || - json.contains(BlueprintConstants.EXPRESSION_GET_ATTRIBUTE) || - json.contains(BlueprintConstants.EXPRESSION_GET_PROPERTY) + json.contains(BluePrintConstants.EXPRESSION_GET_INPUT) || + json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE) || + json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY) ) } @@ -58,35 +58,35 @@ object BlueprintExpressionService { log.trace("Assignment Data/Expression : {}", propertyAssignmentNode) val expressionData = ExpressionData(valueNode = propertyAssignmentNode) if (propertyAssignmentNode is ObjectNode) { - val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BlueprintTypes.validCommands()) + val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands()) if (commands.isNotEmpty()) { expressionData.isExpression = true expressionData.command = commands.first() expressionData.expressionNode = propertyAssignmentNode when (expressionData.command) { - BlueprintConstants.EXPRESSION_GET_INPUT -> { + BluePrintConstants.EXPRESSION_GET_INPUT -> { expressionData.inputExpression = populateInputExpression(propertyAssignmentNode) } - BlueprintConstants.EXPRESSION_GET_ATTRIBUTE -> { + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode) } - BlueprintConstants.EXPRESSION_GET_PROPERTY -> { + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode) } - BlueprintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode) } - BlueprintConstants.EXPRESSION_GET_ARTIFACT -> { + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode) } } } } else if (propertyAssignmentNode is TextNode && - propertyAssignmentNode.textValue().startsWith(BlueprintConstants.EXPRESSION_DSL_REFERENCE) + propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE) ) { expressionData.isExpression = true - expressionData.command = BlueprintConstants.EXPRESSION_DSL_REFERENCE + expressionData.command = BluePrintConstants.EXPRESSION_DSL_REFERENCE expressionData.dslExpression = populateDSLExpression(propertyAssignmentNode) } return expressionData @@ -96,7 +96,7 @@ object BlueprintExpressionService { fun populateDSLExpression(jsonNode: TextNode): DSLExpression { return DSLExpression( propertyName = jsonNode.textValue() - .removePrefix(BlueprintConstants.EXPRESSION_DSL_REFERENCE) + .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE) ) } @@ -109,7 +109,7 @@ object BlueprintExpressionService { fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression { val arrayNode: ArrayNode = jsonNode.first() as ArrayNode check(arrayNode.size() >= 2) { - throw BlueprintException( + throw BluePrintException( String.format( "missing property expression, " + "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " + @@ -149,7 +149,7 @@ object BlueprintExpressionService { fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression { val arrayNode: ArrayNode = jsonNode.first() as ArrayNode check(arrayNode.size() >= 2) { - throw BlueprintException( + throw BluePrintException( String.format( "missing attribute expression, " + "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," + @@ -190,7 +190,7 @@ object BlueprintExpressionService { val arrayNode: ArrayNode = jsonNode.first() as ArrayNode check(arrayNode.size() >= 4) { - throw BlueprintException( + throw BluePrintException( String.format( "missing operation output expression, " + "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", @@ -217,7 +217,7 @@ object BlueprintExpressionService { val arrayNode: ArrayNode = jsonNode.first() as ArrayNode check(arrayNode.size() >= 2) { - throw BlueprintException( + throw BluePrintException( String.format( "missing artifact expression, " + "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintImportService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt index 6dbacd199..80b742705 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintImportService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ImportDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.utils.ServiceTemplateUtils @@ -28,7 +28,7 @@ import java.net.URL import java.net.URLDecoder import java.nio.charset.Charset -class BlueprintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { +class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { companion object { private const val PARENT_SERVICE_TEMPLATE: String = "parent" @@ -85,10 +85,10 @@ class BlueprintImportService(private val parentServiceTemplate: ServiceTemplate, serviceTemplate = ServiceTemplateUtils.getServiceTemplate(importDefinition.file) } } catch (e: Exception) { - throw BlueprintException("failed to populate service template for ${importDefinition.file} original error: ${e.message}", e) + throw BluePrintException("failed to populate service template for ${importDefinition.file} original error: ${e.message}", e) } if (serviceTemplate == null) { - throw BlueprintException("failed to populate service template for : ${importDefinition.file}") + throw BluePrintException("failed to populate service template for : ${importDefinition.file}") } return serviceTemplate } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintJinjaTemplateService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt index ac85cb3e8..fdc348bf7 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintJinjaTemplateService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt @@ -24,9 +24,9 @@ import com.hubspot.jinjava.JinjavaConfig import com.hubspot.jinjava.interpret.JinjavaInterpreter import com.hubspot.jinjava.loader.ResourceLocator import com.hubspot.jinjava.loader.ResourceNotFoundException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.config.BlueprintLoadConfiguration -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintJsonNodeFactory +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintJsonNodeFactory import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.removeNullNode import java.io.IOException @@ -34,13 +34,13 @@ import java.nio.charset.Charset import java.nio.file.Files.readAllBytes import java.nio.file.Paths -object BlueprintJinjaTemplateService { +object BluePrintJinjaTemplateService { /** * To enable inheritance within CBA, we need Jinja runtime to know where to load the templates. */ class BlueprintRelatedTemplateLocator( - private val bluePrintLoadConfiguration: BlueprintLoadConfiguration, + private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val artifactName: String, private val artifactVersion: String ) : ResourceLocator { @@ -68,7 +68,7 @@ object BlueprintJinjaTemplateService { json: String, ignoreJsonNull: Boolean, additionalContext: MutableMap<String, Any>, - bluePrintLoadConfiguration: BlueprintLoadConfiguration, + bluePrintLoadConfiguration: BluePrintLoadConfiguration, artifactName: String, artifactVersion: String ): String { @@ -95,13 +95,13 @@ object BlueprintJinjaTemplateService { } val mapper = ObjectMapper() - val nodeFactory = BlueprintJsonNodeFactory() + val nodeFactory = BluePrintJsonNodeFactory() mapper.nodeFactory = nodeFactory // Add the JSON Data to the context if (json.isNotEmpty()) { val jsonNode = mapper.readValue<JsonNode>(json, JsonNode::class.java) - ?: throw BlueprintProcessorException("couldn't get json node from json") + ?: throw BluePrintProcessorException("couldn't get json node from json") if (ignoreJsonNull) { jsonNode.removeNullNode() } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRepoFileService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt index dd07bade2..1f71495a3 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRepoFileService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt @@ -16,61 +16,61 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintRepoService +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.slf4j.LoggerFactory -open class BlueprintRepoFileService(modelTypePath: String) : BlueprintRepoService { +open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { - private val log = LoggerFactory.getLogger(BlueprintRepoFileService::class.toString()) + private val log = LoggerFactory.getLogger(BluePrintRepoFileService::class.toString()) - private val dataTypePath = modelTypePath.plus(BlueprintConstants.PATH_DIVIDER).plus(BlueprintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - private val nodeTypePath = modelTypePath.plus(BlueprintConstants.PATH_DIVIDER).plus(BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) - private val artifactTypePath = modelTypePath.plus(BlueprintConstants.PATH_DIVIDER).plus(BlueprintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) private val capabilityTypePath = - modelTypePath.plus(BlueprintConstants.PATH_DIVIDER).plus(BlueprintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) private val relationshipTypePath = - modelTypePath.plus(BlueprintConstants.PATH_DIVIDER).plus(BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) private val extension = ".json" override fun getDataType(dataTypeName: String): DataType { - val fileName = dataTypePath.plus(BlueprintConstants.PATH_DIVIDER) + val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(dataTypeName).plus(extension) return getModelType(fileName, DataType::class.java) } override fun getNodeType(nodeTypeName: String): NodeType { - val fileName = nodeTypePath.plus(BlueprintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) + val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) return getModelType(fileName, NodeType::class.java) } override fun getArtifactType(artifactTypeName: String): ArtifactType { - val fileName = artifactTypePath.plus(BlueprintConstants.PATH_DIVIDER) + val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(artifactTypeName).plus(extension) return getModelType(fileName, ArtifactType::class.java) } override fun getRelationshipType(relationshipTypeName: String): RelationshipType { - val fileName = relationshipTypePath.plus(BlueprintConstants.PATH_DIVIDER) + val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(relationshipTypeName).plus(extension) return getModelType(fileName, RelationshipType::class.java) } override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { - val fileName = capabilityTypePath.plus(BlueprintConstants.PATH_DIVIDER) + 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>): T { return JacksonUtils.readValueFromFile(fileName, valueType) - ?: throw BlueprintException("couldn't get file($fileName) for type(${valueType.name}") + ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRuntimeService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt index c05b94260..873e3a082 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRuntimeService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -21,9 +21,9 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintError -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants.LOG_REDACTED @@ -32,16 +32,16 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.returnNullIfMissing import org.onap.ccsdk.cds.controllerblueprints.core.rootFieldsToMap -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.PropertyDefinitionUtils.Companion.hasLogProtect import org.slf4j.LoggerFactory import java.io.File -interface BlueprintRuntimeService<T> { +interface BluePrintRuntimeService<T> { fun id(): String - fun bluePrintContext(): BlueprintContext + fun bluePrintContext(): BluePrintContext fun getExecutionContext(): T @@ -63,9 +63,9 @@ interface BlueprintRuntimeService<T> { fun getAsDouble(key: String): Double? - fun getBlueprintError(): BlueprintError + fun getBluePrintError(): BluePrintError - fun setBlueprintError(bluePrintError: BlueprintError) + fun setBluePrintError(bluePrintError: BluePrintError) fun loadEnvironments(type: String, fileName: String) @@ -211,30 +211,30 @@ interface BlueprintRuntimeService<T> { * * @author Brinda Santh */ -open class DefaultBlueprintRuntimeService(private var id: String, private var bluePrintContext: BlueprintContext) : - BlueprintRuntimeService<MutableMap<String, JsonNode>> { +open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) : + BluePrintRuntimeService<MutableMap<String, JsonNode>> { @Transient - private val log = LoggerFactory.getLogger(BlueprintRuntimeService::class.toString()) + private val log = LoggerFactory.getLogger(BluePrintRuntimeService::class.toString()) private var store: MutableMap<String, JsonNode> = hashMapOf() - private var bluePrintError = BlueprintError() + private var bluePrintError = BluePrintError() init { /** * Load Blueprint Environments Properties */ val absoluteEnvFilePath = bluePrintContext.rootPath.plus(File.separator) - .plus(BlueprintConstants.TOSCA_ENVIRONMENTS_DIR) - loadEnvironments(BlueprintConstants.PROPERTY_BPP, absoluteEnvFilePath) + .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR) + loadEnvironments(BluePrintConstants.PROPERTY_BPP, absoluteEnvFilePath) } override fun id(): String { return id } - override fun bluePrintContext(): BlueprintContext { + override fun bluePrintContext(): BluePrintContext { return bluePrintContext } @@ -252,7 +252,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl } override fun get(key: String): JsonNode { - return store[key] ?: throw BlueprintProcessorException("failed to get execution property($key)") + return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)") } override fun check(key: String): Boolean { @@ -283,16 +283,16 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl return get(key).asDouble() } - override fun getBlueprintError(): BlueprintError { + override fun getBluePrintError(): BluePrintError { return this.bluePrintError } - override fun setBlueprintError(bluePrintError: BlueprintError) { + override fun setBluePrintError(bluePrintError: BluePrintError) { this.bluePrintError = bluePrintError } override fun loadEnvironments(type: String, fileName: String) { - BlueprintMetadataUtils.environmentFileProperties(fileName).forEach { key, value -> + BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value -> setNodeTemplateAttributeValue(type, key.toString(), value.asJsonType()) } } @@ -300,7 +300,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl override fun resolveWorkflowOutputs(workflowName: String): MutableMap<String, JsonNode> { log.info("resolveWorkflowOutputs for workflow($workflowName)") val outputs = bluePrintContext.workflowByName(workflowName).outputs ?: mutableMapOf() - return resolvePropertyDefinitions(BlueprintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, "WORKFLOW", outputs) + return resolvePropertyDefinitions(BluePrintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, "WORKFLOW", outputs) } /** @@ -309,7 +309,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl */ override fun resolveDSLExpression(dslPropertyName: String): JsonNode { val propertyAssignments = bluePrintContext.dslPropertiesByName(dslPropertyName) - return if (BlueprintExpressionService.checkContainsExpression(propertyAssignments) && + return if (BluePrintExpressionService.checkContainsExpression(propertyAssignments) && propertyAssignments is ObjectNode ) { val rootKeyMap = propertyAssignments.rootFieldsToMap() @@ -318,7 +318,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl val propertyAssignmentExpression = PropertyAssignmentService(this) propertyAssignmentValue[propertyName] = propertyAssignmentExpression .resolveAssignmentExpression( - BlueprintConstants.MODEL_DEFINITION_TYPE_DSL, + BluePrintConstants.MODEL_DEFINITION_TYPE_DSL, "DSL", propertyName, propertyValue @@ -381,7 +381,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl } /** If property is Map type, then resolve the property value, It may have expressions */ - if (nodeTypeProperty.type == BlueprintConstants.DATA_TYPE_MAP && + if (nodeTypeProperty.type == BluePrintConstants.DATA_TYPE_MAP && resolvedValue.returnNullIfMissing() != null ) { val mapResolvedValue = resolvePropertyAssignments( @@ -443,7 +443,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl propertyAssignments: MutableMap<String, JsonNode> ): MutableMap<String, JsonNode> { return resolvePropertyAssignments( - BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, nodeTemplateName, propertyDefinitions, propertyAssignments ) } @@ -547,7 +547,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) return nodeTemplate.artifacts?.get(artifactName) - ?: throw BlueprintProcessorException( + ?: throw BluePrintProcessorException( "failed to get artifact definition($artifactName) from the node template" ) } @@ -561,7 +561,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl // Get the Relationship Type Definitions val propertiesDefinitions = bluePrintContext.relationshipTypeByName(relationshipTemplate.type).properties - ?: throw BlueprintProcessorException("failed to get ${relationshipTemplate.type} properties.") + ?: throw BluePrintProcessorException("failed to get ${relationshipTemplate.type} properties.") /** * Resolve the RelationshipTemplate Property Assignment Values. @@ -579,13 +579,13 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl propertyAssignments: MutableMap<String, JsonNode> ): MutableMap<String, JsonNode> { return resolvePropertyAssignments( - BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE, + BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE, relationshipTemplateName, propertyDefinitions, propertyAssignments ) } override fun setInputValue(propertyName: String, value: JsonNode) { - val path = """${BlueprintConstants.PATH_INPUTS}${BlueprintConstants.PATH_DIVIDER}$propertyName""" + val path = """${BluePrintConstants.PATH_INPUTS}${BluePrintConstants.PATH_DIVIDER}$propertyName""" put(path, value) } @@ -595,27 +595,27 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl propertyDefinition: PropertyDefinition, value: JsonNode ) { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_WORKFLOWS) - .append(BlueprintConstants.PATH_DIVIDER).append(workflowName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_INPUTS) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS) + .append(BluePrintConstants.PATH_DIVIDER).append(workflowName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() put(path, value) } override fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() put(path, value) } override fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_ATTRIBUTES) - .append(BlueprintConstants.PATH_DIVIDER).append(attributeName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() put(path, value) } @@ -626,14 +626,14 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl propertyName: String, value: JsonNode ) { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_INTERFACES) - .append(BlueprintConstants.PATH_DIVIDER).append(interfaceName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_OPERATIONS) - .append(BlueprintConstants.PATH_DIVIDER).append(operationName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() log.trace("setting operation property path ({}), values ({})", path, value) put(path, value) } @@ -645,15 +645,15 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl propertyName: String, value: JsonNode ) { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_INTERFACES) - .append(BlueprintConstants.PATH_DIVIDER).append(interfaceName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_OPERATIONS) - .append(BlueprintConstants.PATH_DIVIDER).append(operationName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_INPUTS) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() put(path, value) } @@ -664,21 +664,21 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl propertyName: String, value: JsonNode ) { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_INTERFACES) - .append(BlueprintConstants.PATH_DIVIDER).append(interfaceName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_OPERATIONS) - .append(BlueprintConstants.PATH_DIVIDER).append(operationName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_OUTPUTS) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() put(path, value) } override fun getInputValue(propertyName: String): JsonNode { - val path = StringBuilder(BlueprintConstants.PATH_INPUTS) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path = StringBuilder(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return getJsonNode(path) } @@ -688,31 +688,31 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl operationName: String, propertyName: String ): JsonNode { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_INTERFACES) - .append(BlueprintConstants.PATH_DIVIDER).append(interfaceName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_OPERATIONS) - .append(BlueprintConstants.PATH_DIVIDER).append(operationName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_OUTPUTS) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return getJsonNode(path) } override fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return getJsonNode(path) } override fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode { - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_ATTRIBUTES) - .append(BlueprintConstants.PATH_DIVIDER).append(attributeName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() return getJsonNode(path) } @@ -720,10 +720,10 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl relationshipTemplateName: String, propertyName: String ): JsonNode? { - val path: String = StringBuilder(BlueprintConstants.PATH_RELATIONSHIP_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(relationshipTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_PROPERTIES) - .append(BlueprintConstants.PATH_DIVIDER).append(propertyName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_RELATIONSHIP_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(relationshipTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return getJsonNode(path) } @@ -731,17 +731,17 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl relationshipTemplateName: String, attributeName: String ): JsonNode? { - val path: String = StringBuilder(BlueprintConstants.PATH_RELATIONSHIP_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(relationshipTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_ATTRIBUTES) - .append(BlueprintConstants.PATH_DIVIDER).append(attributeName).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_RELATIONSHIP_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(relationshipTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() return getJsonNode(path) } override fun assignInputs(jsonNode: JsonNode) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) bluePrintContext.inputs()?.forEach { propertyName, property -> - val valueNode: JsonNode = jsonNode.at(BlueprintConstants.PATH_DIVIDER + propertyName) + val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) ?: property.defaultValue ?: NullNode.getInstance() setInputValue(propertyName, valueNode) @@ -765,7 +765,7 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl } private fun findAndSetInputValue(propertyName: String, property: PropertyDefinition, jsonNode: JsonNode) { - val valueNode = jsonNode.at(BlueprintConstants.PATH_DIVIDER + propertyName) + val valueNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) .returnNullIfMissing() ?: property.defaultValue ?: NullNode.getInstance() @@ -777,10 +777,10 @@ open class DefaultBlueprintRuntimeService(private var id: String, private var bl override fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List<String>): JsonNode { val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode() - val path: String = StringBuilder(BlueprintConstants.PATH_NODE_TEMPLATES) - .append(BlueprintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BlueprintConstants.PATH_DIVIDER).append(BlueprintConstants.PATH_ATTRIBUTES) - .append(BlueprintConstants.PATH_DIVIDER).toString() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).toString() store.keys.filter { it.startsWith(path) }.map { diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateService.kt index d953bd54f..d7f7b9a60 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateService.kt @@ -15,18 +15,18 @@ */ package org.onap.ccsdk.cds.controllerblueprints.core.service -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.config.BlueprintLoadConfiguration +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintTemplateService import org.springframework.stereotype.Service @Service -class BlueprintTemplateService(private val bluePrintLoadConfiguration: BlueprintLoadConfiguration) : +class BluePrintTemplateService(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration) : BlueprintTemplateService { override suspend fun generateContent( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactName: String, jsonData: String, @@ -40,8 +40,8 @@ class BlueprintTemplateService(private val bluePrintLoadConfiguration: Blueprint val template = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName) return when (templateType) { - BlueprintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA -> { - BlueprintJinjaTemplateService.generateContent( + BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA -> { + BluePrintJinjaTemplateService.generateContent( template, jsonData, ignoreJsonNull, @@ -51,13 +51,13 @@ class BlueprintTemplateService(private val bluePrintLoadConfiguration: Blueprint bluePrintRuntimeService.bluePrintContext().version() ) } - BlueprintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY -> { - BlueprintVelocityTemplateService.generateContent(template, jsonData, ignoreJsonNull, additionalContext) + BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY -> { + BluePrintVelocityTemplateService.generateContent(template, jsonData, ignoreJsonNull, additionalContext) } else -> { - throw BlueprintProcessorException( - "Unknown Artifact type, expecting ${BlueprintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA}" + - "or ${BlueprintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY}" + throw BluePrintProcessorException( + "Unknown Artifact type, expecting ${BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA}" + + "or ${BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY}" ) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintValidatorService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt index 888c5c0c6..8a8ded752 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintValidatorService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -20,9 +20,9 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType @@ -51,35 +51,35 @@ import java.io.Serializable * * @author Brinda Santh */ -interface BlueprintValidatorService : Serializable { +interface BluePrintValidatorService : Serializable { - @Throws(BlueprintException::class) - fun validateBlueprint(bluePrintContext: BlueprintContext, properties: MutableMap<String, Any>) + @Throws(BluePrintException::class) + fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>) - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap<String, Any>) } @Deprecated("Decomposed implementation moved to blueprint-validation module") -open class BlueprintValidatorDefaultService : BlueprintValidatorService { +open class BluePrintValidatorDefaultService : BluePrintValidatorService { - val log = LoggerFactory.getLogger(BlueprintValidatorDefaultService::class.toString()) + val log = LoggerFactory.getLogger(BluePrintValidatorDefaultService::class.toString()) - lateinit var bluePrintContext: BlueprintContext + lateinit var bluePrintContext: BluePrintContext lateinit var serviceTemplate: ServiceTemplate lateinit var properties: MutableMap<String, Any> var message: StringBuilder = StringBuilder() - private val separator: String = BlueprintConstants.PATH_DIVIDER + private val separator: String = BluePrintConstants.PATH_DIVIDER var paths: MutableList<String> = arrayListOf() - @Throws(BlueprintException::class) - override fun validateBlueprint(bluePrintContext: BlueprintContext, properties: MutableMap<String, Any>) { + @Throws(BluePrintException::class) + override fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>) { validateBlueprint(bluePrintContext.serviceTemplate, properties) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) override fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap<String, Any>) { - this.bluePrintContext = BlueprintContext(serviceTemplate) + this.bluePrintContext = BluePrintContext(serviceTemplate) this.serviceTemplate = serviceTemplate this.properties = properties try { @@ -92,21 +92,21 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } catch (e: Exception) { log.error("validation failed in the path : {}", paths.joinToString(separator), e) log.error("validation trace message :{} ", message) - throw BlueprintException( + throw BluePrintException( e, format("failed to validate blueprint on path ({}) with message {}", paths.joinToString(separator), e.message) ) } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateMetadata(metaDataMap: MutableMap<String, String>) { paths.add("metadata") - val templateName = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_NAME] - val templateVersion = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_VERSION] - val templateTags = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_TAGS] - val templateAuthor = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_AUTHOR] + val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] + val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] + val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] + val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") @@ -115,7 +115,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateArtifactTypes(artifactTypes: MutableMap<String, ArtifactType>) { paths.add("artifact_types") artifactTypes.forEach { artifactName, artifactType -> @@ -127,7 +127,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateDataTypes(dataTypes: MutableMap<String, DataType>) { paths.add("dataTypes") dataTypes.forEach { dataTypeName, dataType -> @@ -139,7 +139,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateNodeTypes(nodeTypes: MutableMap<String, NodeType>) { paths.add("nodeTypes") nodeTypes.forEach { nodeTypeName, nodeType -> @@ -149,7 +149,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateNodeType(nodeTypeName: String, nodeType: NodeType) { paths.add(nodeTypeName) message.appendln("--> Node Type :" + paths.joinToString(separator)) @@ -157,9 +157,9 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { // Check Derived From checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) - if (!BlueprintTypes.rootNodeTypes().contains(derivedFrom)) { + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { serviceTemplate.nodeTypes?.get(derivedFrom) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get derivedFrom NodeType({})'s for NodeType({}) ", derivedFrom, nodeTypeName @@ -174,14 +174,14 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { - check(BlueprintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { - throw BlueprintException(format("Failed to get node type ({})'s derivedFrom({}) definition ", nodeTypeName, derivedFrom)) + check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get node type ({})'s derivedFrom({}) definition ", nodeTypeName, derivedFrom)) } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { paths.add("topology") message.appendln("--> Topology Template") @@ -191,7 +191,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateInputs(inputs: MutableMap<String, PropertyDefinition>) { paths.add("inputs") message.appendln("---> Input :" + paths.joinToString(separator)) @@ -199,7 +199,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateNodeTemplates(nodeTemplates: MutableMap<String, NodeTemplate>) { paths.add("nodeTemplates") nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> @@ -208,14 +208,14 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { paths.add(nodeTemplateName) message.appendln("---> NodeTemplate :" + paths.joinToString(separator)) val type: String = nodeTemplate.type val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type) - ?: throw BlueprintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName)) + ?: throw BluePrintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName)) nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } @@ -225,26 +225,26 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateArtifactDefinitions(artifacts: MutableMap<String, ArtifactDefinition>) { paths.add("artifacts") artifacts.forEach { artifactDefinitionName, artifactDefinition -> paths.add(artifactDefinitionName) message.appendln("Validating artifact " + paths.joinToString(separator)) val type: String = artifactDefinition.type - ?: throw BlueprintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName)) + ?: throw BluePrintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName)) // Check Artifact Type checkValidArtifactType(artifactDefinitionName, type) val file: String = artifactDefinition.file - ?: throw BlueprintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName)) + ?: throw BluePrintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName)) paths.removeAt(paths.lastIndex) } paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateWorkFlows(workflows: MutableMap<String, Workflow>) { paths.add("workflows") workflows.forEach { workflowName, workflow -> @@ -255,7 +255,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateWorkFlow(workflowName: String, workflow: Workflow) { paths.add(workflowName) message.appendln("---> Workflow :" + paths.joinToString(separator)) @@ -271,19 +271,19 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validatePropertyDefinitions(properties: MutableMap<String, PropertyDefinition>) { paths.add("properties") properties.forEach { propertyName, propertyDefinition -> paths.add(propertyName) val dataType: String = propertyDefinition.type when { - BlueprintTypes.validPrimitiveTypes().contains(dataType) -> { + BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { // Do Nothing } - BlueprintTypes.validCollectionTypes().contains(dataType) -> { + BluePrintTypes.validCollectionTypes().contains(dataType) -> { val entrySchemaType: String = propertyDefinition.entrySchema?.type - ?: throw BlueprintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName)) + ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName)) checkPrimitiveOrComplex(entrySchemaType, propertyName) } else -> checkPropertyDataType(dataType, propertyName) @@ -294,33 +294,33 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @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(format("failed to get definition for the property ({})", propertyName)) + ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validatePropertyAssignment( propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode ) { // Check and Validate if Expression Node - val expressionData = BlueprintExpressionService.getExpressionData(propertyAssignment) + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) if (!expressionData.isExpression) { checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { val capabilities = nodeTemplate.capabilities paths.add("capabilities") @@ -328,7 +328,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.add(capabilityName) val capabilityDefinition = nodeType.capabilities?.get(capabilityName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) capability definition ({}) " + "from NodeType({}) ", @@ -343,7 +343,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateCapabilityAssignment( nodeTemplateName: String, capabilityName: String, @@ -354,14 +354,14 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { val requirements = nodeTemplate.requirements paths.add("requirements") requirements?.forEach { requirementName, requirementAssignment -> paths.add(requirementName) val requirementDefinition = nodeType.requirements?.get(requirementName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) requirement definition ({}) from" + " NodeType({}) ", @@ -375,7 +375,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateRequirementAssignment( nodeTemplateName: String, requirementAssignmentName: String, @@ -387,8 +387,8 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { val capabilityName = requirementAssignment.capability val relationship = requirementAssignment.relationship!! - check(BlueprintTypes.validRelationShipDerivedFroms.contains(relationship)) { - throw BlueprintException( + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException( format( "Failed to get relationship type ({}) for NodeTemplate({})'s requirement({}) ", relationship, nodeTemplateName, requirementAssignmentName @@ -397,7 +397,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } val relationShipNodeTemplate = serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get requirement NodeTemplate({})'s for NodeTemplate({}) requirement({}) ", requirementNodeTemplateName, nodeTemplateName, requirementAssignmentName @@ -405,7 +405,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { ) relationShipNodeTemplate.capabilities?.get(capabilityName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get requirement NodeTemplate({})'s capability({}) for NodeTemplate ({})'s requirement({}) ", requirementNodeTemplateName, capabilityName, nodeTemplateName, requirementAssignmentName @@ -413,7 +413,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { ) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { val interfaces = nodeTemplate.interfaces @@ -421,7 +421,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> paths.add(interfaceAssignmentName) val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) interface definition ({}) from" + " NodeType({}) ", @@ -438,7 +438,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateInterfaceAssignment( nodeTemplateName: String, interfaceAssignmentName: String, @@ -455,7 +455,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateInterfaceOperationsAssignment( nodeTemplateName: String, interfaceAssignmentName: String, @@ -468,7 +468,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { it.forEach { operationAssignmentName, operationAssignments -> val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) operation definition ({}) ", nodeTemplateName, operationAssignmentName @@ -485,7 +485,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { inputs?.forEach { propertyName, propertyAssignment -> val propertyDefinition = operationDefinition.inputs?.get(propertyName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) operation definition ({}) " + "property definition({})", @@ -498,7 +498,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { outputs?.forEach { propertyName, propertyAssignment -> val propertyDefinition = operationDefinition.outputs?.get(propertyName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) operation definition ({}) " + "output property definition({})", @@ -513,7 +513,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { val capabilities = nodeType.capabilities paths.add("capabilities") @@ -527,7 +527,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateCapabilityDefinition( nodeTypeName: String, nodeType: NodeType, @@ -535,8 +535,8 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { capabilityDefinition: CapabilityDefinition ) { val capabilityType = capabilityDefinition.type - check(BlueprintTypes.validCapabilityTypes.contains(capabilityType)) { - throw BlueprintException( + check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { + throw BluePrintException( format( "Failed to get CapabilityType({}) for NodeType({})", capabilityType, nodeTypeName @@ -545,7 +545,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { paths.add("requirements") val requirements = nodeType.requirements @@ -559,7 +559,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateRequirementDefinition( nodeTypeName: String, nodeType: NodeType, @@ -572,8 +572,8 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { val capabilityName = requirementDefinition.capability val relationship = requirementDefinition.relationship!! - check(BlueprintTypes.validRelationShipDerivedFroms.contains(relationship)) { - throw BlueprintException( + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException( format( "Failed to get relationship({}) for NodeType({})'s requirement({}) ", relationship, nodeTypeName, requirementDefinitionName @@ -582,7 +582,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } val relationShipNodeType = serviceTemplate.nodeTypes?.get(requirementNodeTypeName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get requirement NodeType({})'s for requirement({}) ", requirementNodeTypeName, requirementDefinitionName @@ -590,7 +590,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { ) relationShipNodeType.capabilities?.get(capabilityName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "Failed to get requirement NodeType({})'s capability({}) for NodeType ({})'s requirement({}) ", requirementNodeTypeName, capabilityName, nodeTypeName, requirementDefinitionName @@ -598,7 +598,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { ) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateInterfaceDefinitions(interfaces: MutableMap<String, InterfaceDefinition>) { paths.add("interfaces") interfaces.forEach { interfaceName, interfaceDefinition -> @@ -610,7 +610,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateOperationDefinitions(operations: MutableMap<String, OperationDefinition>) { paths.add("operations") operations.forEach { opertaionName, operationDefinition -> @@ -624,38 +624,38 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { paths.removeAt(paths.lastIndex) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun validateImplementation(implementation: Implementation) { checkNotEmpty(implementation.primary) { "couldn't get implementation" } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BlueprintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") + ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { - check(BlueprintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { - throw BlueprintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") + check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { - check(BlueprintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { - throw BlueprintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) } } - @Throws(BlueprintException::class) + @Throws(BluePrintException::class) open fun checkValidRelationshipTypeDerivedFrom(relationshipTypeName: String, derivedFrom: String) { - check(BlueprintTypes.validRelationShipDerivedFroms.contains(derivedFrom)) { - throw BlueprintException(format("Failed to get relationship type ({})'s derivedFrom({}) definition ", relationshipTypeName, derivedFrom)) + check(BluePrintTypes.validRelationShipDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get relationship type ({})'s derivedFrom({}) definition ", relationshipTypeName, derivedFrom)) } } @@ -663,14 +663,14 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { val propertyType = propertyDefinition.type val isValid: Boolean - if (BlueprintTypes.validPrimitiveTypes().contains(propertyType)) { + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) - } else if (BlueprintTypes.validCollectionTypes().contains(propertyType)) { + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { val entrySchemaType = propertyDefinition.entrySchema?.type - ?: throw BlueprintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) + ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) - if (!BlueprintTypes.validPropertyTypes().contains(entrySchemaType)) { + if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { checkPropertyDataType(entrySchemaType, propertyName) } isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) @@ -680,7 +680,7 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { } check(isValid) { - throw BlueprintException( + throw BluePrintException( format( "property({}) defined of type({}) is not comptable with the value ({})", propertyName, propertyType, propertyAssignment @@ -692,16 +692,16 @@ open class BlueprintValidatorDefaultService : BlueprintValidatorService { private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { val dataType = serviceTemplate.dataTypes?.get(dataTypeName) - ?: throw BlueprintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) } private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { - if (BlueprintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { + if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { return true } else { - throw BlueprintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) + throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintVelocityTemplateService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt index 1c4847900..43e27d047 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintVelocityTemplateService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt @@ -24,12 +24,12 @@ import org.apache.commons.lang3.BooleanUtils import org.apache.commons.lang3.StringUtils import org.apache.velocity.VelocityContext import org.apache.velocity.app.VelocityEngine -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintJsonNodeFactory +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintJsonNodeFactory import org.onap.ccsdk.cds.controllerblueprints.core.removeNullNode import java.io.StringWriter -object BlueprintVelocityTemplateService { +object BluePrintVelocityTemplateService { /** * Generate Content from Velocity Template and JSON Content with injected API @@ -43,12 +43,12 @@ object BlueprintVelocityTemplateService { // Customized Object Mapper to remove String double quotes val mapper = ObjectMapper() - val nodeFactory = BlueprintJsonNodeFactory() + val nodeFactory = BluePrintJsonNodeFactory() mapper.nodeFactory = nodeFactory val jsonNode: JsonNode? = if (json.isNotEmpty()) { mapper.readValue(json, JsonNode::class.java) - ?: throw BlueprintProcessorException("couldn't get json node from json") + ?: throw BluePrintProcessorException("couldn't get json node from json") } else { null } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintWorkflowService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt index b5121caac..f3e4e59aa 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintWorkflowService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt @@ -25,8 +25,8 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.actor import kotlinx.coroutines.channels.consumeEach import kotlinx.coroutines.launch -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeStatus import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph @@ -39,11 +39,11 @@ import org.onap.ccsdk.cds.controllerblueprints.core.outgoingEdgesNotInLabels import org.onap.ccsdk.cds.controllerblueprints.core.startNodes import kotlin.coroutines.CoroutineContext -interface BlueprintWorkFlowService<In, Out> { +interface BluePrintWorkFlowService<In, Out> { /** Executes imperative workflow graph [graph] for the bluePrintRuntimeService [bluePrintRuntimeService] * and workflow input [input]*/ - suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BlueprintRuntimeService<*>, input: In): Out + suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: In): Out suspend fun initializeWorkflow(input: In): EdgeLabel @@ -91,11 +91,11 @@ enum class EdgeAction(val id: String) { } /** Abstract workflow service implementation */ -abstract class AbstractBlueprintWorkFlowService<In, Out> : CoroutineScope, BlueprintWorkFlowService<In, Out> { +abstract class AbstractBluePrintWorkFlowService<In, Out> : CoroutineScope, BluePrintWorkFlowService<In, Out> { lateinit var graph: Graph - private val log = logger(AbstractBlueprintWorkFlowService::class) + private val log = logger(AbstractBluePrintWorkFlowService::class) private val job = Job() @@ -131,7 +131,7 @@ abstract class AbstractBlueprintWorkFlowService<In, Out> : CoroutineScope, Bluep // Wait for workflow completion or Error nodeActor.invokeOnClose { exception -> launch { - if (exception != null) exceptions.add(BlueprintProcessorException(exception)) + if (exception != null) exceptions.add(BluePrintProcessorException(exception)) log.info("workflow($workflowId) nodes completed with (${exceptions.size})exceptions") val workflowOutput = prepareWorkflowOutput() workflowExecuteMessage.output.complete(workflowOutput) @@ -235,8 +235,8 @@ abstract class AbstractBlueprintWorkFlowService<In, Out> : CoroutineScope, Bluep suspend fun executeNodeWorker(message: NodeExecuteMessage<In, Out>) { val node = message.node node.status = NodeStatus.EXECUTING - val nodeState = if (node.id == BlueprintConstants.GRAPH_START_NODE_NAME || - node.id == BlueprintConstants.GRAPH_END_NODE_NAME + val nodeState = if (node.id == BluePrintConstants.GRAPH_START_NODE_NAME || + node.id == BluePrintConstants.GRAPH_END_NODE_NAME ) { EdgeLabel.SUCCESS } else { @@ -255,7 +255,7 @@ abstract class AbstractBlueprintWorkFlowService<In, Out> : CoroutineScope, Bluep // Close the current channel channel.close() } else if (!edgePresent) { - throw BlueprintProcessorException("node(${node.id}) outgoing edge($nodeState) is missing.") + throw BluePrintProcessorException("node(${node.id}) outgoing edge($nodeState) is missing.") } else { val skippingEdges = graph.outgoingEdgesNotInLabels(node.id, arrayListOf(nodeState)) log.debug("Skipping node($node)'s outgoing edges($skippingEdges)") diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt index 7a5a2d58f..b246054e2 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -19,8 +19,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactExpression @@ -40,11 +40,11 @@ import org.slf4j.LoggerFactory * * @author Brinda Santh */ -open class PropertyAssignmentService(var bluePrintRuntimeService: BlueprintRuntimeService<MutableMap<String, JsonNode>>) { +open class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService<MutableMap<String, JsonNode>>) { private val log = LoggerFactory.getLogger(this::class.toString()) - private var bluePrintContext: BlueprintContext = bluePrintRuntimeService.bluePrintContext() + private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext() /* @@ -60,7 +60,7 @@ open class PropertyAssignmentService(var bluePrintRuntimeService: BlueprintRunti assignment: JsonNode ): JsonNode { log.trace("Assignment ({})", assignment) - val expressionData = BlueprintExpressionService.getExpressionData(assignment) + val expressionData = BluePrintExpressionService.getExpressionData(assignment) return if (expressionData.isExpression) { resolveExpression(definitionType, definitionName, assignmentName, expressionData) @@ -82,32 +82,32 @@ open class PropertyAssignmentService(var bluePrintRuntimeService: BlueprintRunti val command = expressionData.command!! when (command) { - BlueprintConstants.EXPRESSION_GET_INPUT -> { + BluePrintConstants.EXPRESSION_GET_INPUT -> { valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!) } - BlueprintConstants.EXPRESSION_GET_ATTRIBUTE -> { + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { valueNode = resolveAttributeExpression(definitionType, definitionName, expressionData.attributeExpression!!) } - BlueprintConstants.EXPRESSION_GET_PROPERTY -> { + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { valueNode = resolvePropertyExpression(definitionType, definitionName, expressionData.propertyExpression!!) } - BlueprintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { valueNode = resolveOperationOutputExpression(definitionName, expressionData.operationOutputExpression!!) } - BlueprintConstants.EXPRESSION_GET_ARTIFACT -> { + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { valueNode = resolveArtifactExpression(definitionName, expressionData.artifactExpression!!) } - BlueprintConstants.EXPRESSION_DSL_REFERENCE -> { + BluePrintConstants.EXPRESSION_DSL_REFERENCE -> { valueNode = bluePrintRuntimeService.resolveDSLExpression(expressionData.dslExpression!!.propertyName) } - BlueprintConstants.EXPRESSION_GET_NODE_OF_TYPE -> { + BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> { } else -> { - throw BlueprintException( + throw BluePrintException( "for $definitionType($definitionName) property ($propName), " + "command ($command) is not supported " ) @@ -140,53 +140,53 @@ open class PropertyAssignmentService(var bluePrintRuntimeService: BlueprintRunti * SELF : Current Node Template properties. */ when (attributeExpression.modelableEntityName) { - BlueprintConstants.PROPERTY_ENV -> { + BluePrintConstants.PROPERTY_ENV -> { val environmentValue = System.getenv(attributeName) valueNode = environmentValue.asJsonPrimitive() } - BlueprintConstants.PROPERTY_APP -> { + BluePrintConstants.PROPERTY_APP -> { val environmentValue = System.getProperty(attributeName) valueNode = environmentValue.asJsonPrimitive() } - BlueprintConstants.PROPERTY_BPP -> { + BluePrintConstants.PROPERTY_BPP -> { valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue( - BlueprintConstants.PROPERTY_BPP, + BluePrintConstants.PROPERTY_BPP, attributeName - ) ?: throw BlueprintException("failed to get env attribute name ($attributeName) ") + ) ?: throw BluePrintException("failed to get env attribute name ($attributeName) ") } else -> { - if (!attributeExpression.modelableEntityName.equals(BlueprintConstants.PROPERTY_SELF, true)) { + if (!attributeExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) { attributeDefinitionName = attributeExpression.modelableEntityName } /** This block is to Validate, if Attribute definition is present */ when (definitionType) { - BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, - BlueprintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, - BlueprintConstants.MODEL_DEFINITION_TYPE_DSL -> + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, + BluePrintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, + BluePrintConstants.MODEL_DEFINITION_TYPE_DSL -> bluePrintContext.nodeTemplateNodeType(attributeDefinitionName).attributes - BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> + BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> bluePrintContext.relationshipTemplateRelationshipType(attributeDefinitionName).attributes - else -> throw BlueprintException("failed to understand template type($definitionType), it is not supported") + else -> throw BluePrintException("failed to understand template type($definitionType), it is not supported") }?.get(attributeName) - ?: throw BlueprintException( + ?: throw BluePrintException( "failed to get attribute definitions for " + "$definitionType ($attributeDefinitionName)'s attribute name ($attributeName) " ) valueNode = when (definitionType) { - BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, - BlueprintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, - BlueprintConstants.MODEL_DEFINITION_TYPE_DSL -> + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, + BluePrintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, + BluePrintConstants.MODEL_DEFINITION_TYPE_DSL -> bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeDefinitionName, attributeName) - BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> + BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> bluePrintRuntimeService.getRelationshipTemplateAttributeValue( attributeDefinitionName, attributeName ) - else -> throw BlueprintException("failed to understand template type($definitionType), it is not supported") + else -> throw BluePrintException("failed to understand template type($definitionType), it is not supported") } - ?: throw BlueprintException("failed to get node template ($attributeDefinitionName)'s attribute name ($attributeName) ") + ?: throw BluePrintException("failed to get node template ($attributeDefinitionName)'s attribute name ($attributeName) ") } } if (subAttributeName != null) { @@ -212,32 +212,32 @@ open class PropertyAssignmentService(var bluePrintRuntimeService: BlueprintRunti var propertyDefinitionName = definitionName - if (!propertyExpression.modelableEntityName.equals(BlueprintConstants.PROPERTY_SELF, true)) { + if (!propertyExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) { propertyDefinitionName = propertyExpression.modelableEntityName } val nodeTemplatePropertyExpression = when (definitionType) { - BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, - BlueprintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, - BlueprintConstants.MODEL_DEFINITION_TYPE_DSL -> + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, + BluePrintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, + BluePrintConstants.MODEL_DEFINITION_TYPE_DSL -> bluePrintContext.nodeTemplateByName(propertyDefinitionName).properties - BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> + BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> bluePrintContext.relationshipTemplateByName(propertyDefinitionName).properties - else -> throw BlueprintException("failed to understand template type($definitionType), it is not supported") + else -> throw BluePrintException("failed to understand template type($definitionType), it is not supported") }?.get(propertyName) - ?: throw BlueprintException("failed to get property assignment for node template ($definitionName)'s property name ($propertyName).") + ?: throw BluePrintException("failed to get property assignment for node template ($definitionName)'s property name ($propertyName).") /** This block is to Validate, if Property definition is present */ when (definitionType) { - BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, - BlueprintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, - BlueprintConstants.MODEL_DEFINITION_TYPE_DSL -> + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, + BluePrintConstants.MODEL_DEFINITION_TYPE_WORKFLOW, + BluePrintConstants.MODEL_DEFINITION_TYPE_DSL -> bluePrintContext.nodeTemplateNodeType(propertyDefinitionName).properties - BlueprintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> + BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TEMPLATE -> bluePrintContext.relationshipTemplateRelationshipType(propertyDefinitionName).properties - else -> throw BlueprintException("failed to understand template type($definitionType), it is not supported") + else -> throw BluePrintException("failed to understand template type($definitionType), it is not supported") }?.get(propertyName) - ?: throw BlueprintException("failed to get property definition for node template ($definitionName)'s property name ($propertyName).") + ?: throw BluePrintException("failed to get property definition for node template ($definitionName)'s property name ($propertyName).") log.info( "$definitionType($propertyDefinitionName), property($propertyName) resolved value ($nodeTemplatePropertyExpression)" @@ -295,7 +295,7 @@ open class PropertyAssignmentService(var bluePrintRuntimeService: BlueprintRunti } val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName) .artifacts?.get(artifactExpression.artifactName) - ?: throw BlueprintException( + ?: throw BluePrintException( format( "failed to get artifact definitions for node template ({})'s " + "artifact name ({}) ", diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintArchiveUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt index a16f58042..1a7c23cf1 100644..100755 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintArchiveUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -30,7 +30,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.compress.archivers.zip.ZipFile import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.slf4j.LoggerFactory import java.io.BufferedInputStream import java.io.ByteArrayInputStream @@ -56,11 +56,11 @@ enum class ArchiveType { Zip } -class BlueprintArchiveUtils { +class BluePrintArchiveUtils { companion object { - private val log = LoggerFactory.getLogger(BlueprintArchiveUtils::class.java) + private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) /** * Create a new Zip from a root directory @@ -208,7 +208,7 @@ class BlueprintArchiveUtils { val destinationDir = File(targetPath) check(destinationDir.isDirectory && destinationDir.exists()) { - throw BlueprintProcessorException("failed to decompress blueprint(${archiveFile.absolutePath}) to ($targetPath) ") + throw BluePrintProcessorException("failed to decompress blueprint(${archiveFile.absolutePath}) to ($targetPath) ") } return destinationDir diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintFileUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt index 583709f08..292eca92e 100644..100755 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintFileUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -21,14 +21,14 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import kotlinx.coroutines.runBlocking import org.apache.commons.io.FileUtils import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode import org.onap.ccsdk.cds.controllerblueprints.core.data.ImportDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.slf4j.LoggerFactory import java.io.File import java.io.FileFilter @@ -41,52 +41,52 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardOpenOption -class BlueprintFileUtils { +class BluePrintFileUtils { companion object { const val COMPILED_JAR_SUFFIX = "cba-kts.jar" private val log = LoggerFactory.getLogger(this::class.toString()) - fun createEmptyBlueprint(basePath: String) { + fun createEmptyBluePrint(basePath: String) { val blueprintDir = File(basePath) FileUtils.deleteDirectory(blueprintDir) Files.createDirectories(blueprintDir.toPath()) - val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_METADATA_DIR)) + val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR)) Files.createDirectories(metaDataDir.toPath()) val metaFile = File( blueprintDir.absolutePath.plus(File.separator).plus( - BlueprintConstants + BluePrintConstants .TOSCA_METADATA_ENTRY_DEFINITION_FILE ) ) Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) - val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR)) + val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)) Files.createDirectories(definitionsDir.toPath()) - val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_SCRIPTS_DIR)) + val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_SCRIPTS_DIR)) Files.createDirectories(scriptsDir.toPath()) - val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_PLANS_DIR)) + val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_PLANS_DIR)) Files.createDirectories(plansDir.toPath()) - val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_TEMPLATES_DIR)) + val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_TEMPLATES_DIR)) Files.createDirectories(templatesDir.toPath()) } - fun copyBlueprint(sourcePath: String, targetPath: String) { + fun copyBluePrint(sourcePath: String, targetPath: String) { val sourceFile = File(sourcePath) val targetFile = File(targetPath) sourceFile.copyRecursively(targetFile, true) } - fun deleteBlueprintTypes(basePath: String) { - val definitionPath = basePath.plus(File.separator).plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR) + fun deleteBluePrintTypes(basePath: String) { + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) log.info("deleting definition types under : $definitionPath") val definitionDir = File(definitionPath) @@ -98,24 +98,24 @@ class BlueprintFileUtils { } } - fun writeEnhancedBlueprint(blueprintContext: BlueprintContext) { + fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) { // Write Blueprint Types - writeBlueprintTypes(blueprintContext) + writeBluePrintTypes(blueprintContext) // Re Populate the Imports populateDefaultImports(blueprintContext) // Rewrite the Entry Definition Files writeEntryDefinitionFile(blueprintContext) } - fun writeBlueprintTypes(blueprintContext: BlueprintContext) { + fun writeBluePrintTypes(blueprintContext: BluePrintContext) { val basePath = blueprintContext.rootPath - val definitionPath = basePath.plus(File.separator).plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR) + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) val definitionDir = File(definitionPath) check(definitionDir.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + "path(${definitionDir.absolutePath})" @@ -123,37 +123,37 @@ class BlueprintFileUtils { } blueprintContext.serviceTemplate.dataTypes?.let { - val dataTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_DATA_TYPES, dataTypesContent) + val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) } blueprintContext.serviceTemplate.relationshipTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) } blueprintContext.serviceTemplate.artifactTypes?.let { - val artifactTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) + val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) } blueprintContext.serviceTemplate.nodeTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_NODE_TYPES, nodeTypesContent) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) } blueprintContext.serviceTemplate.policyTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_POLICY_TYPES, nodeTypesContent) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent) } } - private fun populateDefaultImports(blueprintContext: BlueprintContext) { + private fun populateDefaultImports(blueprintContext: BluePrintContext) { // Get the Default Types val types = arrayListOf( - BlueprintConstants.PATH_DATA_TYPES, BlueprintConstants.PATH_RELATIONSHIP_TYPES, - BlueprintConstants.PATH_ARTIFACT_TYPES, BlueprintConstants.PATH_NODE_TYPES, - BlueprintConstants.PATH_POLICY_TYPES + BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES, + BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES, + BluePrintConstants.PATH_POLICY_TYPES ) // Clean Type Imports @@ -162,7 +162,7 @@ class BlueprintFileUtils { val imports = mutableListOf<ImportDefinition>() types.forEach { typeName -> val import = ImportDefinition() - import.file = BlueprintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") + import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") imports.add(import) } @@ -181,9 +181,9 @@ class BlueprintFileUtils { } /** - * Re Generate the Blueprint Service Template Definition file based on Blueprint Context. + * Re Generate the Blueprint Service Template Definition file based on BluePrint Context. */ - private fun writeEntryDefinitionFile(blueprintContext: BlueprintContext) { + private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition) @@ -208,7 +208,7 @@ class BlueprintFileUtils { Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(definitionFile.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " + "path(${definitionFile.absolutePath})" @@ -221,7 +221,7 @@ class BlueprintFileUtils { Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(typeFile.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " + "path(${typeFile.absolutePath})" @@ -240,11 +240,11 @@ class BlueprintFileUtils { "\nTemplate-Tags: <TAGS>" } - fun getBlueprintFile(fileName: String, targetPath: Path): File { + fun getBluePrintFile(fileName: String, targetPath: Path): File { val filePath = targetPath.resolve(fileName).toString() val file = File(filePath) check(file.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + "path(${file.absolutePath})" @@ -255,7 +255,7 @@ class BlueprintFileUtils { fun getCbaStorageDirectory(path: String): Path { check(StringUtils.isNotBlank(path)) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " + "Blueprint folder under path($path)" @@ -280,7 +280,7 @@ class BlueprintFileUtils { fun compileJarFilePathName(basePath: String, artifactName: String, artifactVersion: String): String { return normalizedPathName( - basePath, BlueprintConstants.TOSCA_SCRIPTS_KOTLIN_DIR, + basePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR, compileJarFileName(artifactName, artifactVersion) ) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintIOUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt index c2e0ec39c..d29fed0d9 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintIOUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -object BlueprintIOUtils { +object BluePrintIOUtils { suspend fun <T> retry( times: Int = 1, diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintMetadataUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index ffaa9e72f..43f3a0b53 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintMetadataUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -19,45 +19,45 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import com.fasterxml.jackson.databind.JsonNode import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintDefinitions +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintScriptsServiceImpl -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintImportService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService -import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintImportService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.slf4j.LoggerFactory import java.io.File import java.util.Properties -class BlueprintMetadataUtils { +class BluePrintMetadataUtils { companion object { private val log = LoggerFactory.getLogger(this::class.toString()) suspend fun toscaMetaData(basePath: String): ToscaMetaData { - val toscaMetaPath = basePath.plus(BlueprintConstants.PATH_DIVIDER) - .plus(BlueprintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) return toscaMetaDataFromMetaFile(toscaMetaPath) } suspend fun entryDefinitionFile(basePath: String): String { - val toscaMetaPath = basePath.plus(BlueprintConstants.PATH_DIVIDER) - .plus(BlueprintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions } fun bluePrintEnvProperties(basePath: String): Properties { val blueprintsEnvFilePath = basePath.plus(File.separator) - .plus(BlueprintConstants.TOSCA_ENVIRONMENTS_DIR) + .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR) return environmentFileProperties(blueprintsEnvFilePath) } @@ -103,59 +103,59 @@ class BlueprintMetadataUtils { } /** Get the default blueprint runtime for [id] and [blueprintBasePath] */ - suspend fun getBlueprintRuntime(id: String, blueprintBasePath: String): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BlueprintContext = getBlueprintContext(blueprintBasePath) - return getBlueprintRuntime(id, bluePrintContext) + suspend fun getBluePrintRuntime(id: String, blueprintBasePath: String): + BluePrintRuntimeService<MutableMap<String, JsonNode>> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + return getBluePrintRuntime(id, bluePrintContext) } /** Get the default blocking blueprint runtime api for [id] and [blueprintBasePath] used in testing */ fun bluePrintRuntime(id: String, blueprintBasePath: String): - BlueprintRuntimeService<MutableMap<String, JsonNode>> = runBlocking { - val bluePrintContext: BlueprintContext = getBlueprintContext(blueprintBasePath) - getBlueprintRuntime(id, bluePrintContext) + BluePrintRuntimeService<MutableMap<String, JsonNode>> = runBlocking { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + getBluePrintRuntime(id, bluePrintContext) } /** Get the default blueprint runtime from [bluePrintContext] */ - fun getBlueprintRuntime(id: String, bluePrintContext: BlueprintContext): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { + fun getBluePrintRuntime(id: String, bluePrintContext: BluePrintContext): + BluePrintRuntimeService<MutableMap<String, JsonNode>> { checkNotEmpty(bluePrintContext.rootPath) { "blueprint context root path is missing." } checkNotEmpty(bluePrintContext.entryDefinition) { "blueprint context entry definition is missing." } val blueprintBasePath = bluePrintContext.rootPath - val bluePrintRuntimeService = DefaultBlueprintRuntimeService(id, bluePrintContext) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) bluePrintRuntimeService.put( - BlueprintConstants.PROPERTY_BLUEPRINT_BASE_PATH, + BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive() ) - bluePrintRuntimeService.put(BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) + bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) return bluePrintRuntimeService } /** Get the blueprint runtime for enhancement start for [id] and [blueprintBasePath] */ - suspend fun getBaseEnhancementBlueprintRuntime(id: String, blueprintBasePath: String): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { + suspend fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): + BluePrintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BlueprintContext = getBaseEnhancementBlueprintContext(blueprintBasePath) + val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBlueprintRuntimeService(id, bluePrintContext) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) bluePrintRuntimeService.put( - BlueprintConstants.PROPERTY_BLUEPRINT_BASE_PATH, + BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive() ) - bluePrintRuntimeService.put(BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) + bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) return bluePrintRuntimeService } /** Get the default blueprint runtime for enhancement start for [id], [blueprintBasePath] and [executionContext] */ - suspend fun getBlueprintRuntime( + suspend fun getBluePrintRuntime( id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode> ): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BlueprintContext = getBlueprintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBlueprintRuntimeService(id, bluePrintContext) + BluePrintRuntimeService<MutableMap<String, JsonNode>> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) executionContext.forEach { bluePrintRuntimeService.put(it.key, it.value) } @@ -165,7 +165,7 @@ class BlueprintMetadataUtils { } /** Get the default blueprint context for [blueprintBasePath]*/ - suspend fun getBlueprintContext(blueprintBasePath: String): BlueprintContext { + suspend fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) @@ -176,24 +176,24 @@ class BlueprintMetadataUtils { // If the EntryDefinition is Kotlin file, compile and get Service Template val bluePrintContext = when (toscaMetaData.templateType.toUpperCase()) { - BlueprintConstants.BLUEPRINT_TYPE_KOTLIN_DSL -> readBlueprintKotlinFile( + BluePrintConstants.BLUEPRINT_TYPE_KOTLIN_DSL -> readBlueprintKotlinFile( toscaMetaData, blueprintBasePath ) - BlueprintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT -> readBlueprintGenericScript( + BluePrintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT -> readBlueprintGenericScript( toscaMetaData, blueprintBasePath ) - BlueprintConstants.BLUEPRINT_TYPE_DEFAULT -> readBlueprintFile( + BluePrintConstants.BLUEPRINT_TYPE_DEFAULT -> readBlueprintFile( toscaMetaData.entityDefinitions, blueprintBasePath ) else -> - throw BlueprintException( + throw BluePrintException( "Unknown blueprint type(${toscaMetaData.templateType}), " + - "It should be any one of these types[${BlueprintConstants.BLUEPRINT_TYPE_KOTLIN_DSL}," + - "${BlueprintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT}, " + - "${BlueprintConstants.BLUEPRINT_TYPE_DEFAULT}]" + "It should be any one of these types[${BluePrintConstants.BLUEPRINT_TYPE_KOTLIN_DSL}," + + "${BluePrintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT}, " + + "${BluePrintConstants.BLUEPRINT_TYPE_DEFAULT}]" ) } // Copy the metadata info @@ -202,11 +202,11 @@ class BlueprintMetadataUtils { return bluePrintContext } - private suspend fun getBaseEnhancementBlueprintContext(blueprintBasePath: String): BlueprintContext { + private suspend fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) // Clean Type files - BlueprintFileUtils.deleteBlueprintTypes(blueprintBasePath) + BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) @@ -214,9 +214,9 @@ class BlueprintMetadataUtils { copyMetaInfoToServiceTemplate(toscaMetaData, rootServiceTemplate) // Clean the Import Definitions - BlueprintFileUtils.cleanImportTypes(rootServiceTemplate) + BluePrintFileUtils.cleanImportTypes(rootServiceTemplate) - val blueprintContext = BlueprintContext(rootServiceTemplate) + val blueprintContext = BluePrintContext(rootServiceTemplate) blueprintContext.rootPath = blueprintBasePath blueprintContext.entryDefinition = toscaMetaData.entityDefinitions return blueprintContext @@ -226,36 +226,36 @@ class BlueprintMetadataUtils { private fun copyMetaInfoToServiceTemplate(toscaMetaData: ToscaMetaData, serviceTemplate: ServiceTemplate) { if (serviceTemplate.metadata == null) serviceTemplate.metadata = mutableMapOf() val metadata = serviceTemplate.metadata!! - metadata[BlueprintConstants.METADATA_TEMPLATE_AUTHOR] = toscaMetaData.createdBy - metadata[BlueprintConstants.METADATA_TEMPLATE_NAME] = toscaMetaData.templateName - metadata[BlueprintConstants.METADATA_TEMPLATE_VERSION] = toscaMetaData.templateVersion - metadata[BlueprintConstants.METADATA_TEMPLATE_TAGS] = toscaMetaData.templateTags - metadata[BlueprintConstants.METADATA_TEMPLATE_TYPE] = toscaMetaData.templateType + metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] = toscaMetaData.createdBy + metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = toscaMetaData.templateName + metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] = toscaMetaData.templateVersion + metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS] = toscaMetaData.templateTags + metadata[BluePrintConstants.METADATA_TEMPLATE_TYPE] = toscaMetaData.templateType } - private suspend fun readBlueprintFile(entityDefinitions: String, basePath: String): BlueprintContext { + private suspend fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { val normalizedBasePath = normalizedPathName(basePath) val rootFilePath = normalizedPathName(normalizedBasePath, entityDefinitions) val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) // Recursively Import Template files - val schemaImportResolverUtils = BlueprintImportService(rootServiceTemplate, normalizedBasePath) + val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, normalizedBasePath) val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() - val blueprintContext = BlueprintContext(completeServiceTemplate) + val blueprintContext = BluePrintContext(completeServiceTemplate) blueprintContext.rootPath = normalizedBasePath blueprintContext.entryDefinition = entityDefinitions return blueprintContext } /** Reade the Service Template Definitions from the Kotlin file */ - private suspend fun readBlueprintKotlinFile(toscaMetaData: ToscaMetaData, basePath: String): BlueprintContext { + private suspend fun readBlueprintKotlinFile(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext { val definitionClassName = toscaMetaData.entityDefinitions.removeSuffix(".kt") val normalizedBasePath = normalizedPathName(basePath) - val bluePrintScriptsService = BlueprintScriptsServiceImpl() + val bluePrintScriptsService = BluePrintScriptsServiceImpl() val bluePrintDefinitions = bluePrintScriptsService - .scriptInstance<BlueprintDefinitions>( + .scriptInstance<BluePrintDefinitions>( normalizedBasePath, toscaMetaData.templateName, toscaMetaData.templateVersion, definitionClassName, false ) @@ -263,9 +263,9 @@ class BlueprintMetadataUtils { val serviceTemplate = bluePrintDefinitions.serviceTemplate() // Clean the Default type import Definitions - BlueprintFileUtils.cleanImportTypes(serviceTemplate) + BluePrintFileUtils.cleanImportTypes(serviceTemplate) - val blueprintContext = BlueprintContext(serviceTemplate) + val blueprintContext = BluePrintContext(serviceTemplate) blueprintContext.rootPath = normalizedBasePath blueprintContext.entryDefinition = toscaMetaData.entityDefinitions blueprintContext.otherDefinitions = bluePrintDefinitions.otherDefinitions() @@ -273,8 +273,8 @@ class BlueprintMetadataUtils { } /** Reade the Service Template Definitions from the generic script types */ - private fun readBlueprintGenericScript(toscaMetaData: ToscaMetaData, basePath: String): BlueprintContext { - return BlueprintContext(ServiceTemplate()) + private fun readBlueprintGenericScript(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext { + return BluePrintContext(ServiceTemplate()) } } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintRuntimeUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt index 1df185cf6..f4c51d455 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintRuntimeUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -18,8 +18,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.slf4j.LoggerFactory /** @@ -27,17 +27,17 @@ import org.slf4j.LoggerFactory * * @author Brinda Santh */ -object BlueprintRuntimeUtils { +object BluePrintRuntimeUtils { private val log = LoggerFactory.getLogger(this::class.toString()) - fun assignInputsFromFile(bluePrintContext: BlueprintContext, fileName: String, context: MutableMap<String, JsonNode>) { + fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode>) { val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) return assignInputs(bluePrintContext, jsonNode, context) } fun assignInputsFromClassPathFile( - bluePrintContext: BlueprintContext, + bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode> @@ -46,17 +46,17 @@ object BlueprintRuntimeUtils { return assignInputs(bluePrintContext, jsonNode, context) } - fun assignInputsFromContent(bluePrintContext: BlueprintContext, content: String, context: MutableMap<String, JsonNode>) { + fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap<String, JsonNode>) { val jsonNode: JsonNode = JacksonUtils.jsonNode(content) return assignInputs(bluePrintContext, jsonNode, context) } - fun assignInputs(bluePrintContext: BlueprintContext, jsonNode: JsonNode, context: MutableMap<String, JsonNode>) { + fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap<String, JsonNode>) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) bluePrintContext.inputs()?.forEach { propertyName, _ -> val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() - val path = BlueprintConstants.PATH_INPUTS.plus(BlueprintConstants.PATH_DIVIDER).plus(propertyName) + val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName) log.trace("setting input path ({}), values ({})", path, valueNode) context[path] = valueNode } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt index cacfc2cd2..7fe955b03 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import java.net.InetAddress object ClusterUtils { @@ -28,19 +28,19 @@ object ClusterUtils { } fun applicationName(): String { - return BlueprintConstants.APP_NAME + return BluePrintConstants.APP_NAME } fun clusterId(): String { - return System.getenv(BlueprintConstants.PROPERTY_CLUSTER_ID) ?: "cds-cluster" + return System.getenv(BluePrintConstants.PROPERTY_CLUSTER_ID) ?: "cds-cluster" } fun clusterNodeId(): String { - return System.getenv(BlueprintConstants.PROPERTY_CLUSTER_NODE_ID) ?: "cds-controller-0" + return System.getenv(BluePrintConstants.PROPERTY_CLUSTER_NODE_ID) ?: "cds-controller-0" } fun clusterNodeAddress(): String { - return System.getenv(BlueprintConstants.PROPERTY_CLUSTER_NODE_ADDRESS) + return System.getenv(BluePrintConstants.PROPERTY_CLUSTER_NODE_ADDRESS) ?: clusterNodeId() } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt index 14b308bc9..02dd2027d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.ZoneId @@ -31,19 +31,19 @@ fun controllerDate(): Date { fun currentTimestamp(): String { val localDateTime = LocalDateTime.now(ZoneId.systemDefault()) - val formatter = DateTimeFormatter.ofPattern(BlueprintConstants.DATE_TIME_PATTERN) + val formatter = DateTimeFormatter.ofPattern(BluePrintConstants.DATE_TIME_PATTERN) return formatter.format(localDateTime) } /** Parse string date in CDS string format */ fun String.toControllerDate(): Date { - val formatter = SimpleDateFormat(BlueprintConstants.DATE_TIME_PATTERN) + val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN) return formatter.parse(this) } /** Return date to CDS string format */ fun Date.currentTimestamp(): String { - val formatter = SimpleDateFormat(BlueprintConstants.DATE_TIME_PATTERN) + val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN) return formatter.format(this) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt index 1110f6f34..ace66cf7a 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt @@ -33,10 +33,10 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.readNBText import java.io.File @@ -76,7 +76,7 @@ class JacksonUtils { try { normalizedFile(fileName).readNBText() } catch (e: Exception) { - throw BlueprintException("couldn't get file ($fileName) content : ${e.message}") + throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") } } @@ -191,13 +191,13 @@ class JacksonUtils { fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T { return readValue(getJson(properties), classType) - ?: throw BlueprintProcessorException("failed to transform content ($properties) to type ($classType)") + ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)") } fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { - if (BlueprintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { + if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { return checkJsonNodeValueOfPrimitiveType(type, jsonNode) - } else if (BlueprintTypes.validCollectionTypes().contains(type)) { + } else if (BluePrintTypes.validCollectionTypes().contains(type)) { return checkJsonNodeValueOfCollectionType(type, jsonNode) } return false @@ -205,31 +205,31 @@ class JacksonUtils { fun checkIfPrimitiveType(primitiveType: String): Boolean { return when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_STRING -> true - BlueprintConstants.DATA_TYPE_BOOLEAN -> true - BlueprintConstants.DATA_TYPE_INTEGER -> true - BlueprintConstants.DATA_TYPE_FLOAT -> true - BlueprintConstants.DATA_TYPE_DOUBLE -> true - BlueprintConstants.DATA_TYPE_TIMESTAMP -> true + BluePrintConstants.DATA_TYPE_STRING -> true + BluePrintConstants.DATA_TYPE_BOOLEAN -> true + BluePrintConstants.DATA_TYPE_INTEGER -> true + BluePrintConstants.DATA_TYPE_FLOAT -> true + BluePrintConstants.DATA_TYPE_DOUBLE -> true + BluePrintConstants.DATA_TYPE_TIMESTAMP -> true else -> false } } fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { return when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_STRING -> jsonNode.isTextual - BlueprintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean - BlueprintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt - BlueprintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble - BlueprintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble - BlueprintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual + BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual else -> false } } fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { return when (type.toLowerCase()) { - BlueprintConstants.DATA_TYPE_LIST -> jsonNode.isArray + BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray else -> false } } @@ -247,62 +247,62 @@ class JacksonUtils { fun getValue(value: Any, type: String): Any { return when (type.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN -> (value as BooleanNode).booleanValue() - BlueprintConstants.DATA_TYPE_INTEGER -> (value as IntNode).intValue() - BlueprintConstants.DATA_TYPE_FLOAT -> (value as FloatNode).floatValue() - BlueprintConstants.DATA_TYPE_DOUBLE -> (value as DoubleNode).doubleValue() - BlueprintConstants.DATA_TYPE_STRING -> (value as TextNode).textValue() + BluePrintConstants.DATA_TYPE_BOOLEAN -> (value as BooleanNode).booleanValue() + BluePrintConstants.DATA_TYPE_INTEGER -> (value as IntNode).intValue() + BluePrintConstants.DATA_TYPE_FLOAT -> (value as FloatNode).floatValue() + BluePrintConstants.DATA_TYPE_DOUBLE -> (value as DoubleNode).doubleValue() + BluePrintConstants.DATA_TYPE_STRING -> (value as TextNode).textValue() else -> (value as JsonNode) } } fun populatePrimitiveValues(key: String, value: JsonNode, primitiveType: String, objectNode: ObjectNode) { when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN, - BlueprintConstants.DATA_TYPE_INTEGER, - BlueprintConstants.DATA_TYPE_FLOAT, - BlueprintConstants.DATA_TYPE_DOUBLE, - BlueprintConstants.DATA_TYPE_TIMESTAMP, - BlueprintConstants.DATA_TYPE_STRING, - BlueprintConstants.DATA_TYPE_NULL -> + BluePrintConstants.DATA_TYPE_BOOLEAN, + BluePrintConstants.DATA_TYPE_INTEGER, + BluePrintConstants.DATA_TYPE_FLOAT, + BluePrintConstants.DATA_TYPE_DOUBLE, + BluePrintConstants.DATA_TYPE_TIMESTAMP, + BluePrintConstants.DATA_TYPE_STRING, + BluePrintConstants.DATA_TYPE_NULL -> objectNode.set(key, value) - else -> throw BlueprintException("populatePrimitiveValues expected only primitive values! Received: ($value)") + else -> throw BluePrintException("populatePrimitiveValues expected only primitive values! Received: ($value)") } } fun populatePrimitiveValues(value: JsonNode, primitiveType: String, arrayNode: ArrayNode) { when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN, - BlueprintConstants.DATA_TYPE_INTEGER, - BlueprintConstants.DATA_TYPE_FLOAT, - BlueprintConstants.DATA_TYPE_DOUBLE, - BlueprintConstants.DATA_TYPE_TIMESTAMP, - BlueprintConstants.DATA_TYPE_STRING, - BlueprintConstants.DATA_TYPE_NULL -> + BluePrintConstants.DATA_TYPE_BOOLEAN, + BluePrintConstants.DATA_TYPE_INTEGER, + BluePrintConstants.DATA_TYPE_FLOAT, + BluePrintConstants.DATA_TYPE_DOUBLE, + BluePrintConstants.DATA_TYPE_TIMESTAMP, + BluePrintConstants.DATA_TYPE_STRING, + BluePrintConstants.DATA_TYPE_NULL -> arrayNode.add(value) - else -> throw BlueprintException("populatePrimitiveValues expected only primitive values! Received: ($value)") + else -> throw BluePrintException("populatePrimitiveValues expected only primitive values! Received: ($value)") } } fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType) - ?: throw BlueprintException("populatePrimitiveDefaultValues expected only primitive values! Received type ($primitiveType)") + ?: throw BluePrintException("populatePrimitiveDefaultValues expected only primitive values! Received type ($primitiveType)") objectNode.set<JsonNode>(key, defaultValue) } fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType) - ?: throw BlueprintException("populatePrimitiveDefaultValuesForArrayNode expected only primitive values! Received type ($primitiveType)") + ?: throw BluePrintException("populatePrimitiveDefaultValuesForArrayNode expected only primitive values! Received type ($primitiveType)") arrayNode.add(defaultValue) } private fun getDefaultValueOfPrimitiveAsJsonNode(primitiveType: String): JsonNode? { return when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN -> BooleanNode.valueOf(false) - BlueprintConstants.DATA_TYPE_INTEGER -> IntNode.valueOf(0) - BlueprintConstants.DATA_TYPE_FLOAT -> FloatNode.valueOf(0.0f) - BlueprintConstants.DATA_TYPE_DOUBLE -> DoubleNode.valueOf(0.0) - BlueprintConstants.DATA_TYPE_STRING -> MissingNode.getInstance() + BluePrintConstants.DATA_TYPE_BOOLEAN -> BooleanNode.valueOf(false) + BluePrintConstants.DATA_TYPE_INTEGER -> IntNode.valueOf(0) + BluePrintConstants.DATA_TYPE_FLOAT -> FloatNode.valueOf(0.0f) + BluePrintConstants.DATA_TYPE_DOUBLE -> DoubleNode.valueOf(0.0) + BluePrintConstants.DATA_TYPE_STRING -> MissingNode.getInstance() else -> null } } @@ -310,7 +310,7 @@ class JacksonUtils { fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { if (nodeValue == null || nodeValue is NullNode) { objectNode.set<JsonNode>(key, nodeValue) - } else if (BlueprintTypes.validPrimitiveTypes().contains(type)) { + } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { populatePrimitiveValues(key, nodeValue, type, objectNode) } else { objectNode.set<JsonNode>(key, nodeValue) @@ -319,11 +319,11 @@ class JacksonUtils { fun convertPrimitiveResourceValue(type: String, value: String): JsonNode { return when (type.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(value.toBoolean()) - BlueprintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(value.toInt()) - BlueprintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(value.toFloat()) - BlueprintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(value.toDouble()) - BlueprintConstants.DATA_TYPE_STRING -> jsonNodeFromObject(value) + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(value.toBoolean()) + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(value.toInt()) + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(value.toFloat()) + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(value.toDouble()) + BluePrintConstants.DATA_TYPE_STRING -> jsonNodeFromObject(value) else -> getJsonNode(value) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt index 1a082d353..48319325c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants.LOG_PROTECT +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants.LOG_PROTECT import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition class PropertyDefinitionUtils { diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt index 1b8af5897..c0204af8d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.slf4j.LoggerFactory import java.io.File @@ -56,7 +56,7 @@ object ResourceResolverUtils { // FIXME("Convert into reactive") return JacksonUtils.getContent(resolvedFileName) } catch (e: Exception) { - throw BlueprintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) + throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) } } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt index 6ebe7c11a..fea637f61 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow @@ -36,10 +36,10 @@ object WorkflowGraphUtils { } } graph.startNodes().forEach { rootNode -> - graph.addEdge(BlueprintConstants.GRAPH_START_NODE_NAME, rootNode.id, EdgeLabel.SUCCESS) + graph.addEdge(BluePrintConstants.GRAPH_START_NODE_NAME, rootNode.id, EdgeLabel.SUCCESS) } graph.endNodes().forEach { endNode -> - graph.addEdge(endNode.id, BlueprintConstants.GRAPH_END_NODE_NAME, EdgeLabel.SUCCESS) + graph.addEdge(endNode.id, BluePrintConstants.GRAPH_END_NODE_NAME, EdgeLabel.SUCCESS) } return graph } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BlueprintKotlinScript b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript index e69de29bb..e69de29bb 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BlueprintKotlinScript +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintErrorTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt index 94ba98603..167c0381a 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BlueprintErrorTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt @@ -4,18 +4,18 @@ import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -class BlueprintErrorTest { +class BluePrintErrorTest { @Test - fun testBlueprintErrorIsCreatedWithemptyList() { - val bluePrintError = BlueprintError() + fun testBluePrintErrorIsCreatedWithemptyList() { + val bluePrintError = BluePrintError() assertTrue(bluePrintError.allErrors().isEmpty()) } @Test fun testAddErrorWith3Params() { - val bluePrintError = BlueprintError() + val bluePrintError = BluePrintError() bluePrintError.addError("type", "name", "error", "step") @@ -24,7 +24,7 @@ class BlueprintErrorTest { @Test fun testAddErrorWith2Params() { - val bluePrintError = BlueprintError() + val bluePrintError = BluePrintError() bluePrintError.addError("error", "step") diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt index 8c1e9f65f..7ac9b8649 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt @@ -95,13 +95,13 @@ class CustomFunctionsTest { val returnValueBool: JsonNode = false.asJsonType() assertFalse(returnValueBool.asBoolean()) - val returnValue: JsonNode = BlueprintError().asJsonType() + val returnValue: JsonNode = BluePrintError().asJsonType() assertEquals(JsonNodeType.OBJECT, returnValue.getNodeType()) } @Test fun testMapAsObjectNode() { - val returnValue: ObjectNode = hashMapOf("test" to BlueprintError()).asObjectNode() + val returnValue: ObjectNode = hashMapOf("test" to BluePrintError()).asObjectNode() assertNotNull(returnValue.get("test")) } @@ -121,7 +121,7 @@ class CustomFunctionsTest { assertNull(returnValueString) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testCastValue() { val initMap: Map<String, Double> = hashMapOf("test" to 1.1) val returnValue = initMap.castValue("test", Number::class) @@ -178,7 +178,7 @@ class CustomFunctionsTest { assertTrue("[{\"key\": \"value\"},{\"key\": \"value\"}]".asJsonType().isComplexType()) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testRootFieldsToMap() { 1.asJsonType().rootFieldsToMap() } @@ -192,7 +192,7 @@ class CustomFunctionsTest { assertEquals(3, mutMap["hello"]?.asInt()) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testMapGetAsString() { val initMap = hashMapOf("test" to "hello".asJsonType()) @@ -201,7 +201,7 @@ class CustomFunctionsTest { initMap.getAsString("test2") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testMapGetAsBoolean() { val initMap = hashMapOf("test" to true.asJsonType()) @@ -210,7 +210,7 @@ class CustomFunctionsTest { initMap.getAsBoolean("test2") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testMapGetAsInt() { val initMap = hashMapOf("test" to 1.asJsonType()) @@ -219,7 +219,7 @@ class CustomFunctionsTest { initMap.getAsInt("test2") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testCheckEquals() { assertTrue(checkEquals("hello", "hello", { -> "error" })) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt index 0fe2fbf7f..643549be0 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt @@ -41,14 +41,14 @@ class MDCContextTest { @Test fun testContextCanBePassedBetweenCoroutines() { - MDC.put(BlueprintConstants.ONAP_REQUEST_ID, "12345") + MDC.put(BluePrintConstants.ONAP_REQUEST_ID, "12345") runBlocking { GlobalScope.launch { - assertEquals(null, MDC.get(BlueprintConstants.ONAP_REQUEST_ID)) + assertEquals(null, MDC.get(BluePrintConstants.ONAP_REQUEST_ID)) } launch(MDCContext()) { assertEquals( - "12345", MDC.get(BlueprintConstants.ONAP_REQUEST_ID), + "12345", MDC.get(BluePrintConstants.ONAP_REQUEST_ID), "couldn't get request id" ) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BlueprintsAnnotationsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotationsTest.kt index b19c3502a..a75262f96 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BlueprintsAnnotationsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotationsTest.kt @@ -17,103 +17,103 @@ package org.onap.ccsdk.cds.controllerblueprints.core.annotations import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.asBlueprintsDataTypes +import org.onap.ccsdk.cds.controllerblueprints.core.asBluePrintsDataTypes import org.onap.ccsdk.cds.controllerblueprints.core.asPropertyDefinitionMap import kotlin.test.Test import kotlin.test.assertNotNull -class BlueprintsAnnotationsTest { +class BluePrintsAnnotationsTest { @Test - fun testBlueprintWorkflowData() { - val wfInput = TestBlueprintsWorkflowInput::class.asPropertyDefinitionMap() + fun testBluePrintWorkflowData() { + val wfInput = TestBluePrintsWorkflowInput::class.asPropertyDefinitionMap() // println(wfInput.asJsonString(true)) assertNotNull(wfInput, "failed to generate wfInput property map") - val wfOutput = TestBlueprintsWorkflowOutput::class.asPropertyDefinitionMap() + val wfOutput = TestBluePrintsWorkflowOutput::class.asPropertyDefinitionMap() // println(wfOutput.asJsonString(true)) assertNotNull(wfInput, "failed to generate wfOutput property map") } @Test - fun testBlueprintDataType() { - val dataTypes = TestBlueprintsDataType::class.asBlueprintsDataTypes() + fun testBluePrintDataType() { + val dataTypes = TestBluePrintsDataType::class.asBluePrintsDataTypes() // println(dataTypes.asJsonString(true)) assertNotNull(dataTypes, "failed to generate dataTypes definition") } } -@BlueprintsDataType( +@BluePrintsDataType( name = "dt-test-datatype", description = "I am test", version = "1.0.0", derivedFrom = "tosca.datatypes.root" ) -data class TestBlueprintsDataType( - @BlueprintsProperty(description = "this stringData") +data class TestBluePrintsDataType( + @BluePrintsProperty(description = "this stringData") var stringData: String, - @BlueprintsProperty(description = "this stringDataWithValue") + @BluePrintsProperty(description = "this stringDataWithValue") @PropertyDefaultValue(value = "USA") val stringDataWithValue: String, - @BlueprintsProperty(description = "this intDataWithValue") + @BluePrintsProperty(description = "this intDataWithValue") @PropertyDefaultValue(value = "30") val intDataWithValue: Int, - @BlueprintsProperty(description = "this booleanDataWithValue") + @BluePrintsProperty(description = "this booleanDataWithValue") @PropertyDefaultValue(value = "true") val booleanDataWithValue: Boolean, - @BlueprintsProperty(description = "this anyData") + @BluePrintsProperty(description = "this anyData") val anyData: Any, - @BlueprintsProperty(description = "this jsonDataWithValue") + @BluePrintsProperty(description = "this jsonDataWithValue") @PropertyDefaultValue(value = """{"data" : "1234"}""") val jsonDataWithValue: JsonNode?, - @BlueprintsProperty(description = "listData") + @BluePrintsProperty(description = "listData") val listData: MutableList<String>, - @BlueprintsProperty(description = "this mapData") + @BluePrintsProperty(description = "this mapData") val mapData: MutableMap<String, String> = hashMapOf(), - @BlueprintsProperty(description = "this complexData") - val complexData: TestBlueprintsChildDataType?, - @BlueprintsProperty(description = "this complexDataList") - val complexDataList: MutableList<TestBlueprintsChildDataType> + @BluePrintsProperty(description = "this complexData") + val complexData: TestBluePrintsChildDataType?, + @BluePrintsProperty(description = "this complexDataList") + val complexDataList: MutableList<TestBluePrintsChildDataType> ) -data class TestBlueprintsChildDataType(val name: String) +data class TestBluePrintsChildDataType(val name: String) -@BlueprintsWorkflowInput -data class TestBlueprintsWorkflowInput( - @BlueprintsProperty(description = "this sample name") +@BluePrintsWorkflowInput +data class TestBluePrintsWorkflowInput( + @BluePrintsProperty(description = "this sample name") @PropertyDefaultValue(value = "Brinda") var name: String, - @BlueprintsProperty(description = "this sample name") + @BluePrintsProperty(description = "this sample name") val place: String ) -@BlueprintsWorkflowOutput -data class TestBlueprintsWorkflowOutput( - @BlueprintsProperty(description = "this is dslExpression") +@BluePrintsWorkflowOutput +data class TestBluePrintsWorkflowOutput( + @BluePrintsProperty(description = "this is dslExpression") @DSLExpression("field1") var dslExpression: String, - @BlueprintsProperty(description = "this is withNodeAttributeExpression") + @BluePrintsProperty(description = "this is withNodeAttributeExpression") @AttributeExpression(modelableEntityName = "sample-node", attributeName = "response-data") var withNodeAttributeExpression: String, - @BlueprintsProperty(description = "this is withNodeAttributeExpressionSubAttribute") + @BluePrintsProperty(description = "this is withNodeAttributeExpressionSubAttribute") @AttributeExpression( modelableEntityName = "sample-node", attributeName = "response-data", subAttributeName = ".\$field1" ) var withNodeAttributeExpressionSubAttribute: String, - @BlueprintsProperty(description = "this is withAttributeExpressionSubAttribute") + @BluePrintsProperty(description = "this is withAttributeExpressionSubAttribute") @AttributeExpression(attributeName = "response-data", subAttributeName = ".\$field1") var withAttributeExpressionSubAttribute: String, - @BlueprintsProperty(description = "this is withAttributeExpression") + @BluePrintsProperty(description = "this is withAttributeExpression") @AttributeExpression(attributeName = "response-data") var withAttributeExpression: String, - @BlueprintsProperty(description = "this is withAArtifactExpression") + @BluePrintsProperty(description = "this is withAArtifactExpression") @ArtifactExpression(modelableEntityName = "test-node", artifactName = "content-template") var withAArtifactExpression: String, - @BlueprintsProperty(description = "this status") + @BluePrintsProperty(description = "this status") val status: String = "success" ) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSLTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt index 57f671dc4..f2d95cdc6 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BlueprintDSLTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt @@ -18,13 +18,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import com.fasterxml.jackson.databind.JsonNode import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType import kotlin.test.assertNotNull -class BlueprintDSLTest { +class BluePrintDSLTest { @Test fun testOperationDSLWorkflow() { @@ -34,7 +34,7 @@ class BlueprintDSLTest { "brindasanth@onap.com", "sample, blueprints" ) { - artifactType(BlueprintTypes.artifactTypeTemplateVelocity()) + artifactType(BluePrintTypes.artifactTypeTemplateVelocity()) // For New Component Definition component( @@ -84,7 +84,7 @@ class BlueprintDSLTest { assertNotNull(blueprint.workflows, "failed to get workflows") // println(blueprint.asJsonString(true)) - val serviceTemplateGenerator = BlueprintServiceTemplateGenerator(blueprint) + val serviceTemplateGenerator = BluePrintServiceTemplateGenerator(blueprint) val serviceTemplate = serviceTemplateGenerator.serviceTemplate() assertNotNull(serviceTemplate.topologyTemplate, "failed to get service topology template") // println(serviceTemplate.asJsonString(true)) @@ -249,7 +249,7 @@ class BlueprintDSLTest { @Test fun testNodeTemplateOperationTypes() { - val testNodeTemplateInstance = BlueprintTypes.nodeTemplateComponentTestExecutor( + val testNodeTemplateInstance = BluePrintTypes.nodeTemplateComponentTestExecutor( id = "test-node-template", description = "" ) { @@ -272,7 +272,7 @@ class BlueprintDSLTest { } } -fun BlueprintTypes.nodeTemplateComponentTestExecutor( +fun BluePrintTypes.nodeTemplateComponentTestExecutor( id: String, description: String, block: TestNodeTemplateOperationImplBuilder.() -> Unit diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImplTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt index 7dd980dc7..0803d921b 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImplTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt @@ -20,7 +20,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts import kotlinx.coroutines.runBlocking import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintDefinitions +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import kotlin.script.experimental.jvm.util.classpathFromClass @@ -28,19 +28,19 @@ import kotlin.script.experimental.jvm.util.classpathFromClassloader import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty import kotlin.test.assertNotNull -class BlueprintScriptsServiceImplTest { +class BluePrintScriptsServiceImplTest { private fun viewClassPathInfo() { println(" *********** classpathFromClass *********** ") classpathFromClass( - BlueprintScriptsServiceImplTest::class.java.classLoader, - BlueprintScriptsServiceImplTest::class + BluePrintScriptsServiceImplTest::class.java.classLoader, + BluePrintScriptsServiceImplTest::class )!! .forEach(::println) println(" *********** classpathFromClassloader *********** ") - classpathFromClassloader(BlueprintScriptsServiceImplTest::class.java.classLoader)!! + classpathFromClassloader(BluePrintScriptsServiceImplTest::class.java.classLoader)!! .forEach(::println) println(" *********** classpathFromClasspathProperty *********** ") @@ -52,13 +52,13 @@ class BlueprintScriptsServiceImplTest { fun testCachedService() { runBlocking { - val bluePrintScriptsService = BlueprintScriptsServiceImpl() + val bluePrintScriptsService = BluePrintScriptsServiceImpl() val basePath = normalizedPathName("src/test/resources/compile") /** Load the Definitions */ val bluePrintDefinitions = bluePrintScriptsService - .scriptInstance<BlueprintDefinitions>( + .scriptInstance<BluePrintDefinitions>( basePath, "cba.scripts.ActivateBlueprintDefinitions", true ) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintContextTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt index 4ad4ab403..38f6ea2ec 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintContextTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt @@ -20,8 +20,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import com.fasterxml.jackson.databind.ObjectMapper import kotlinx.coroutines.runBlocking import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.TestConstants import org.onap.ccsdk.cds.controllerblueprints.core.data.Activity import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition @@ -38,7 +38,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.Step import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.slf4j.LoggerFactory import kotlin.test.assertEquals @@ -51,16 +51,16 @@ import kotlin.test.assertTrue * * @author Brinda Santh */ -class BlueprintContextTest { +class BluePrintContextTest { private val log = LoggerFactory.getLogger(this::class.toString()) val blueprintBasePath = TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG @Test - fun testBlueprintContextCreation() { + fun testBluePrintContextCreation() { runBlocking { - val bluePrintContext = BlueprintMetadataUtils.getBlueprintContext(blueprintBasePath) + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) assertNotNull(bluePrintContext, "Failed to populate Blueprint context") } } @@ -68,7 +68,7 @@ class BlueprintContextTest { @Test fun testChainedProperty() { runBlocking { - val bluePrintContext = BlueprintMetadataUtils.getBlueprintContext(blueprintBasePath) + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) val nodeType = bluePrintContext.nodeTypeChained("component-resource-resolution") assertNotNull(nodeType, "Failed to get chained node type") log.trace("Properties {}", JacksonUtils.getJson(nodeType, true)) @@ -79,7 +79,7 @@ class BlueprintContextTest { fun testImports() { val serviceTemplate = ServiceTemplate() serviceTemplate.imports = mutableListOf() - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.imports()!!.isEmpty()) @@ -91,7 +91,7 @@ class BlueprintContextTest { fun testDataTypes() { val serviceTemplate = ServiceTemplate() serviceTemplate.dataTypes = mutableMapOf() - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.dataTypes()!!.isEmpty()) @@ -105,7 +105,7 @@ class BlueprintContextTest { topologyTemplate.inputs = mutableMapOf() val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.inputs()!!.isEmpty()) @@ -115,49 +115,49 @@ class BlueprintContextTest { } @Test - fun testBlueprintJson() { + fun testBluePrintJson() { val serviceTemplate = ServiceTemplate() - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("{\"tosca_definitions_version\":\"controller_blueprint_1_0_0\"}", bluePrintContext.blueprintJson()) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testName() { val serviceTemplate = ServiceTemplate() - serviceTemplate.metadata = mutableMapOf(BlueprintConstants.METADATA_TEMPLATE_NAME to "hello") - val bluePrintContext = BlueprintContext(serviceTemplate) + serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_NAME to "hello") + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.name()) serviceTemplate.metadata = mutableMapOf() - val bluePrintContext2 = BlueprintContext(serviceTemplate) + val bluePrintContext2 = BluePrintContext(serviceTemplate) bluePrintContext2.name() } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testVersion() { val serviceTemplate = ServiceTemplate() - serviceTemplate.metadata = mutableMapOf(BlueprintConstants.METADATA_TEMPLATE_VERSION to "hello") - val bluePrintContext = BlueprintContext(serviceTemplate) + serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_VERSION to "hello") + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.version()) serviceTemplate.metadata = mutableMapOf() - val bluePrintContext2 = BlueprintContext(serviceTemplate) + val bluePrintContext2 = BluePrintContext(serviceTemplate) bluePrintContext2.version() } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testAuthor() { val serviceTemplate = ServiceTemplate() - serviceTemplate.metadata = mutableMapOf(BlueprintConstants.METADATA_TEMPLATE_AUTHOR to "hello") - val bluePrintContext = BlueprintContext(serviceTemplate) + serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_AUTHOR to "hello") + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.author()) serviceTemplate.metadata = mutableMapOf() - val bluePrintContext2 = BlueprintContext(serviceTemplate) + val bluePrintContext2 = BluePrintContext(serviceTemplate) bluePrintContext2.author() } @@ -167,7 +167,7 @@ class BlueprintContextTest { topologyTemplate.workflows = mutableMapOf() val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.workflows()!!.isEmpty()) @@ -175,13 +175,13 @@ class BlueprintContextTest { assertNull(bluePrintContext.workflows()) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testWorkFlowsByName() { val topologyTemplate = TopologyTemplate() topologyTemplate.workflows = mutableMapOf("workflow" to Workflow()) val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.workflowByName("workflow")) @@ -196,7 +196,7 @@ class BlueprintContextTest { topologyTemplate.workflows = mutableMapOf("workflow" to workflow) val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.workflowInputs("workflow")!!.isEmpty()) @@ -205,7 +205,7 @@ class BlueprintContextTest { assertNull(bluePrintContext.workflowInputs("workflow")) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testWorkflowStepByName() { val topologyTemplate = TopologyTemplate() val workflow = Workflow() @@ -213,14 +213,14 @@ class BlueprintContextTest { topologyTemplate.workflows = mutableMapOf("workflow" to workflow) val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.workflowStepByName("workflow", "step")) bluePrintContext.workflowStepByName("workflow", "") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testWorkflowStepNodeTemplate() { val topologyTemplate = TopologyTemplate() val workflow = Workflow() @@ -230,14 +230,14 @@ class BlueprintContextTest { topologyTemplate.workflows = mutableMapOf("workflow" to workflow) val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.workflowStepNodeTemplate("workflow", "step")) bluePrintContext.workflowStepNodeTemplate("workflow", "") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testWorkflowFirstStepNodeTemplate() { val topologyTemplate = TopologyTemplate() val workflow = Workflow() @@ -247,7 +247,7 @@ class BlueprintContextTest { topologyTemplate.workflows = mutableMapOf("workflow" to workflow) val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.workflowFirstStepNodeTemplate("workflow")) @@ -255,7 +255,7 @@ class BlueprintContextTest { bluePrintContext.workflowFirstStepNodeTemplate("workflow") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testWorkflowStepFirstCallOperation() { val topologyTemplate = TopologyTemplate() val workflow = Workflow() @@ -267,7 +267,7 @@ class BlueprintContextTest { topologyTemplate.workflows = mutableMapOf("workflow" to workflow) val serviceTemplate = ServiceTemplate() serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.workflowStepFirstCallOperation("workflow", "step")) @@ -278,7 +278,7 @@ class BlueprintContextTest { fun testDatatypeByName() { val serviceTemplate = ServiceTemplate() serviceTemplate.dataTypes = mutableMapOf("data" to DataType()) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.dataTypeByName("data")) assertNull(bluePrintContext.dataTypeByName("")) @@ -288,7 +288,7 @@ class BlueprintContextTest { fun testArtifactTypes() { val serviceTemplate = ServiceTemplate() serviceTemplate.artifactTypes = mutableMapOf() - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.artifactTypes()!!.isEmpty()) @@ -300,7 +300,7 @@ class BlueprintContextTest { fun testPolicyTypes() { val serviceTemplate = ServiceTemplate() serviceTemplate.policyTypes = mutableMapOf() - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.policyTypes()!!.isEmpty()) @@ -308,11 +308,11 @@ class BlueprintContextTest { assertNull(bluePrintContext.policyTypes()) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testPolicyTypeByName() { val serviceTemplate = ServiceTemplate() serviceTemplate.policyTypes = mutableMapOf("policy" to PolicyType()) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.policyTypeByName("policy")) @@ -327,7 +327,7 @@ class BlueprintContextTest { val policyType2 = PolicyType() policyType2.derivedFrom = "hello" serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals(1, bluePrintContext.policyTypesDerivedFrom("hi")!!.size) @@ -343,7 +343,7 @@ class BlueprintContextTest { val policyType2 = PolicyType() policyType2.targets = mutableListOf() serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals(1, bluePrintContext.policyTypesTarget("hi")!!.size) @@ -361,7 +361,7 @@ class BlueprintContextTest { policyType2.targets = mutableListOf() policyType2.derivedFrom = "hi" serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals(1, bluePrintContext.policyTypesTargetNDerivedFrom("hi", "hi")!!.size) @@ -377,7 +377,7 @@ class BlueprintContextTest { val nodeType2 = NodeType() nodeType2.derivedFrom = "hiii" serviceTemplate.nodeTypes = mutableMapOf("node" to nodeType, "node2" to nodeType2) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals(1, bluePrintContext.nodeTypeDerivedFrom("hi")!!.size) @@ -385,13 +385,13 @@ class BlueprintContextTest { assertNull(bluePrintContext.nodeTypeDerivedFrom("hi")) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testInterfaceNameForNodeType() { val serviceTemplate = ServiceTemplate() val nodeType = NodeType() nodeType.interfaces = mutableMapOf("hello" to InterfaceDefinition(), "hi" to InterfaceDefinition()) serviceTemplate.nodeTypes = mutableMapOf("node" to nodeType) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("hello", bluePrintContext.interfaceNameForNodeType("node")) @@ -408,7 +408,7 @@ class BlueprintContextTest { serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate, "node2" to nodeTemplate2) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals(1, bluePrintContext.nodeTemplateForNodeType("hello")!!.size) @@ -423,7 +423,7 @@ class BlueprintContextTest { nodeTemplate.properties = mutableMapOf("prop" to ObjectMapper().createObjectNode()) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateProperty("node", "prop")) @@ -440,26 +440,26 @@ class BlueprintContextTest { nodeTemplate.artifacts = mutableMapOf() serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertTrue(bluePrintContext.nodeTemplateArtifacts("node")!!.isEmpty()) } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateArtifact() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() nodeTemplate.artifacts = mutableMapOf("art" to ArtifactDefinition()) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateArtifact("node", "art")) bluePrintContext.nodeTemplateArtifact("node", "") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateArtifactForArtifactType() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() @@ -470,21 +470,21 @@ class BlueprintContextTest { nodeTemplate.artifacts = mutableMapOf("art" to artifactDefinition, "art2" to artifactDefinition2) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateArtifactForArtifactType("node", "type")) bluePrintContext.nodeTemplateArtifactForArtifactType("", "") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateFirstInterface() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() nodeTemplate.interfaces = mutableMapOf("interface" to InterfaceAssignment(), "interf" to InterfaceAssignment()) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateFirstInterface("node")) @@ -492,14 +492,14 @@ class BlueprintContextTest { bluePrintContext.nodeTemplateFirstInterface("node") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateFirstInterfaceName() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() nodeTemplate.interfaces = mutableMapOf("interface" to InterfaceAssignment(), "interf" to InterfaceAssignment()) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("interface", bluePrintContext.nodeTemplateFirstInterfaceName("node")) @@ -507,7 +507,7 @@ class BlueprintContextTest { bluePrintContext.nodeTemplateFirstInterfaceName("node") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateFirstInterfaceFirstOperationName() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() @@ -516,7 +516,7 @@ class BlueprintContextTest { nodeTemplate.interfaces = mutableMapOf("intf" to interfaceAssignment) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertEquals("op", bluePrintContext.nodeTemplateFirstInterfaceFirstOperationName("node")) @@ -524,35 +524,35 @@ class BlueprintContextTest { bluePrintContext.nodeTemplateFirstInterfaceFirstOperationName("node") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateCapability() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() nodeTemplate.capabilities = mutableMapOf("cap" to CapabilityAssignment()) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateCapability("node", "cap")) bluePrintContext.nodeTemplateCapability("node", "") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateRequirement() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() nodeTemplate.requirements = mutableMapOf("req" to RequirementAssignment()) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateRequirement("node", "req")) bluePrintContext.nodeTemplateRequirement("node", "") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testNodeTemplateRequirementNode() { val serviceTemplate = ServiceTemplate() val nodeTemplate = NodeTemplate() @@ -561,7 +561,7 @@ class BlueprintContextTest { nodeTemplate.requirements = mutableMapOf("req" to requirementAssignment) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateRequirementNode("node", "req")) @@ -577,7 +577,7 @@ class BlueprintContextTest { nodeTemplate.capabilities = mutableMapOf("cap" to capabilityAssignment) serviceTemplate.topologyTemplate = TopologyTemplate() serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) assertNotNull(bluePrintContext.nodeTemplateCapabilityProperty("node", "cap", "prop")) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintExpressionServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt index 552f7b6f8..4f645270d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintExpressionServiceTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt @@ -30,12 +30,12 @@ import kotlin.test.assertNotNull * * @author Brinda Santh */ -class BlueprintExpressionServiceTest { +class BluePrintExpressionServiceTest { @Test fun testInputExpression() { val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }") - val expressionData: ExpressionData = BlueprintExpressionService.getExpressionData(node) + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.inputExpression, " Failed to populate input expression data") @@ -45,7 +45,7 @@ class BlueprintExpressionServiceTest { @Test fun testPropertyExpression() { val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }") - val expressionData: ExpressionData = BlueprintExpressionService.getExpressionData(node) + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data") @@ -53,7 +53,7 @@ class BlueprintExpressionServiceTest { assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName") val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }") - val expressionData1: ExpressionData = BlueprintExpressionService.getExpressionData(node1) + val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1) assertNotNull(expressionData1, " Failed to populate expression data") assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression") assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data") @@ -69,7 +69,7 @@ class BlueprintExpressionServiceTest { @Test fun testAttributeExpression() { val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }") - val expressionData: ExpressionData = BlueprintExpressionService.getExpressionData(node) + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data") @@ -77,7 +77,7 @@ class BlueprintExpressionServiceTest { assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName") val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }") - val expressionData1: ExpressionData = BlueprintExpressionService.getExpressionData(node1) + val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1) assertNotNull(expressionData1, " Failed to populate expression data") assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data") @@ -94,7 +94,7 @@ class BlueprintExpressionServiceTest { fun testOutputOperationExpression() { val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }") - val expressionData: ExpressionData = BlueprintExpressionService.getExpressionData(node) + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data") @@ -107,7 +107,7 @@ class BlueprintExpressionServiceTest { @Test fun testArtifactExpression() { val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }") - val expressionData: ExpressionData = BlueprintExpressionService.getExpressionData(node) + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data") @@ -115,7 +115,7 @@ class BlueprintExpressionServiceTest { assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName") val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }") - val expressionData1: ExpressionData = BlueprintExpressionService.getExpressionData(node1) + val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1) assertNotNull(expressionData1, " Failed to populate expression data") assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data") @@ -128,7 +128,7 @@ class BlueprintExpressionServiceTest { @Test fun testDSLExpression() { val node: JsonNode = "*dynamic-rest-source".asJsonPrimitive() - val expressionData: ExpressionData = BlueprintExpressionService.getExpressionData(node) + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.dslExpression, " Failed to populate dsl expression data") diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRepoFileServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index 5ef28cce2..265175165 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRepoFileServiceTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -18,19 +18,19 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.TestConstants import kotlin.test.assertNotNull /** - * BlueprintRepoFileServiceTest + * BluePrintRepoFileServiceTest * @author Brinda Santh * */ -class BlueprintRepoFileServiceTest { +class BluePrintRepoFileServiceTest { private val basePath = TestConstants.PATH_TEST_DEFINITION_TYPE_STARTER - private val bluePrintRepoFileService = BlueprintRepoFileService(basePath) + private val bluePrintRepoFileService = BluePrintRepoFileService(basePath) @Test fun testGetDataType() { @@ -50,7 +50,7 @@ class BlueprintRepoFileServiceTest { assertNotNull(nodeType, "Failed to get ArtifactType from repo") } - @Test(expected = BlueprintException::class) + @Test(expected = BluePrintException::class) fun testModelNotFound() { val dataType = bluePrintRepoFileService.getDataType("dt-not-found") assertNotNull(dataType, "Failed to get DataType from repo") diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRuntimeServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 268811091..4fcbb2d98 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintRuntimeServiceTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -20,13 +20,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.TestConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintRuntimeUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintRuntimeUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.slf4j.LoggerFactory import kotlin.test.assertEquals @@ -37,7 +37,7 @@ import kotlin.test.assertNotNull * * @author Brinda Santh */ -class BlueprintRuntimeServiceTest { +class BluePrintRuntimeServiceTest { private val log = LoggerFactory.getLogger(this::class.toString()) @@ -45,7 +45,7 @@ class BlueprintRuntimeServiceTest { fun `test Resolve NodeTemplate Properties`() { log.info("************************ testResolveNodeTemplateProperties **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() val inputDataPath = "src/test/resources/data/default-context.json" @@ -62,7 +62,7 @@ class BlueprintRuntimeServiceTest { fun `test Resolve Relationship Properties`() { log.info("************************ testResolveRelationshipTemplateProperties **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() val inputDataPath = "src/test/resources/data/default-context.json" @@ -83,11 +83,11 @@ class BlueprintRuntimeServiceTest { @Test fun `test resolve NodeTemplate Capability Properties`() { log.info("************************ testResolveNodeTemplateRequirementProperties **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() val executionContext = bluePrintRuntimeService.getExecutionContext() - BlueprintRuntimeUtils.assignInputsFromClassPathFile( + BluePrintRuntimeUtils.assignInputsFromClassPathFile( bluePrintRuntimeService.bluePrintContext(), "data/default-context.json", executionContext ) @@ -123,11 +123,11 @@ class BlueprintRuntimeServiceTest { fun `test Resolve NodeTemplate Interface Operation Inputs`() { log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() val executionContext = bluePrintRuntimeService.getExecutionContext() - BlueprintRuntimeUtils.assignInputsFromClassPathFile( + BluePrintRuntimeUtils.assignInputsFromClassPathFile( bluePrintRuntimeService.bluePrintContext(), "data/default-context.json", executionContext ) @@ -155,7 +155,7 @@ class BlueprintRuntimeServiceTest { fun `test Resolve NodeTemplate Interface Operation Outputs`() { log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() bluePrintRuntimeService.setNodeTemplateAttributeValue( "resource-assignment", @@ -188,7 +188,7 @@ class BlueprintRuntimeServiceTest { @Test fun `test NodeTemplate Context Property`() { log.info("************************ testNodeTemplateContextProperty **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() bluePrintRuntimeService.setNodeTemplateAttributeValue( "resource-assignment-ra-component", "context1", @@ -211,7 +211,7 @@ class BlueprintRuntimeServiceTest { fun `test Resolve DSL Properties`() { log.info("************************ resolveDSLExpression **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() bluePrintRuntimeService.setInputValue("rest-user-name", "sample-username".asJsonPrimitive()) @@ -222,7 +222,7 @@ class BlueprintRuntimeServiceTest { @Test fun `test Resolve Workflow Outputs`() { log.info("************************ resolvePropertyAssignments **********************") - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() val assignmentParams = "{\"ipAddress\": \"127.0.0.1\", \"hostName\": \"vnf-host\"}" @@ -237,7 +237,7 @@ class BlueprintRuntimeServiceTest { @Test fun `test resolvePropertyDefinitions using sub attributes`() { - val bluePrintRuntimeService = getBlueprintRuntimeService() + val bluePrintRuntimeService = getBluePrintRuntimeService() bluePrintRuntimeService.setNodeTemplateAttributeValue( "resource-assignment", "assignment-map", @@ -279,11 +279,11 @@ class BlueprintRuntimeServiceTest { assertEquals("123", result["resolution"]!!.asText()) } - private fun getBlueprintRuntimeService(): BlueprintRuntimeService<MutableMap<String, JsonNode>> { + private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> { val blueprintBasePath = normalizedPathName(TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG) - val blueprintRuntime = BlueprintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath) - val checkProcessId = blueprintRuntime.get(BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID) - val checkBasePath = blueprintRuntime.get(BlueprintConstants.PROPERTY_BLUEPRINT_BASE_PATH) + val blueprintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath) + val checkProcessId = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID) + val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) assertEquals( "1234".asJsonPrimitive(), diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt index 6ebb6b7ff..0e93ccf6b 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateServiceTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt @@ -21,20 +21,20 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import kotlinx.coroutines.runBlocking import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.TestConstants -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import kotlin.test.BeforeTest import kotlin.test.assertEquals import kotlin.test.assertNotNull -class BlueprintTemplateServiceTest { +class BluePrintTemplateServiceTest { - lateinit var blueprintRuntime: BlueprintRuntimeService<*> + lateinit var blueprintRuntime: BluePrintRuntimeService<*> @BeforeTest fun setup() { val blueprintBasePath = TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG - blueprintRuntime = BlueprintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath) + blueprintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath) } @Test @@ -43,7 +43,7 @@ class BlueprintTemplateServiceTest { val template = JacksonUtils.getClassPathFileContent("templates/base-config-velocity-template.vtl") val json = JacksonUtils.getClassPathFileContent("templates/base-config-data-velocity.json") - val content = BlueprintVelocityTemplateService.generateContent(template, json) + val content = BluePrintVelocityTemplateService.generateContent(template, json) assertNotNull(content, "failed to generate content for velocity template") } } @@ -60,7 +60,7 @@ class BlueprintTemplateServiceTest { hashMapOf("name" to "Element2", "location" to "Region1") ) - val content = BlueprintJinjaTemplateService.generateContent(template, json, false, element) + val content = BluePrintJinjaTemplateService.generateContent(template, json, false, element) assertNotNull(content, "failed to generate content for velocity template") } } @@ -72,7 +72,7 @@ class BlueprintTemplateServiceTest { JacksonUtils.getClassPathFileContent("templates/default-variable-value-velocity-template.vtl") val json = JacksonUtils.getClassPathFileContent("templates/default-variable-value-data.json") - val content = BlueprintVelocityTemplateService.generateContent(template, json) + val content = BluePrintVelocityTemplateService.generateContent(template, json) // first line represents a variable whose value was successfully retrieved, second line contains a variable // whose value could not be evaluated val expected = "sample-hostname\n\${node0_backup_router_address}" diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintWorkflowServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowServiceTest.kt index 291a81f28..eb6246989 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintWorkflowServiceTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowServiceTest.kt @@ -25,25 +25,25 @@ import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeout import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph import org.onap.ccsdk.cds.controllerblueprints.core.logger import org.onap.ccsdk.cds.controllerblueprints.core.toGraph import kotlin.test.assertNotNull -class BlueprintWorkflowServiceTest { +class BluePrintWorkflowServiceTest { @Test fun testSimpleFlow() { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>E/SUCCESS, E>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } @@ -56,9 +56,9 @@ class BlueprintWorkflowServiceTest { async { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D"), null) - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(it), it) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(it), it) assertNotNull(response, "failed to get response") } } @@ -72,10 +72,10 @@ class BlueprintWorkflowServiceTest { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "C", "D", "E"), arrayListOf("B")) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } @@ -85,10 +85,10 @@ class BlueprintWorkflowServiceTest { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "C", "D", "E"), null) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } @@ -98,10 +98,10 @@ class BlueprintWorkflowServiceTest { runBlocking { val graph = "[START>A/SUCCESS, A>TO/SUCCESS, TO>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "TO", "C", "D", "E"), null) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } @@ -111,10 +111,10 @@ class BlueprintWorkflowServiceTest { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } @@ -125,13 +125,13 @@ class BlueprintWorkflowServiceTest { // Failure Flow val failurePatGraph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val failurePathWorkflow = TestBlueprintWorkFlowService() + val failurePathWorkflow = TestBluePrintWorkFlowService() failurePathWorkflow.simulatedState = prepareSimulation( arrayListOf("B", "C", "D", "E"), arrayListOf("A") ) val failurePathWorkflowInput = "123456" - val failurePathResponse = failurePathWorkflow.executeWorkflow(failurePatGraph, mockBlueprintRuntimeService(), failurePathWorkflowInput) + val failurePathResponse = failurePathWorkflow.executeWorkflow(failurePatGraph, mockBluePrintRuntimeService(), failurePathWorkflowInput) assertNotNull(failurePathResponse, "failed to get response") } } @@ -141,10 +141,10 @@ class BlueprintWorkflowServiceTest { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, C>D/SUCCESS, D>E/SUCCESS, B>E/SUCCESS, E>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } @@ -154,20 +154,20 @@ class BlueprintWorkflowServiceTest { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/SUCCESS, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" .toGraph() - val simpleWorkflow = TestBlueprintWorkFlowService() + val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D"), null) val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBlueprintRuntimeService(), input) + val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) assertNotNull(response, "failed to get response") } } - private fun mockBlueprintRuntimeService(): BlueprintRuntimeService<*> { - return mockBlueprintRuntimeService("123456") + private fun mockBluePrintRuntimeService(): BluePrintRuntimeService<*> { + return mockBluePrintRuntimeService("123456") } - private fun mockBlueprintRuntimeService(id: String): BlueprintRuntimeService<*> { - val bluePrintRuntimeService = mockk<BlueprintRuntimeService<*>>() + private fun mockBluePrintRuntimeService(id: String): BluePrintRuntimeService<*> { + val bluePrintRuntimeService = mockk<BluePrintRuntimeService<*>>() every { bluePrintRuntimeService.id() } returns id return bluePrintRuntimeService } @@ -184,10 +184,10 @@ class BlueprintWorkflowServiceTest { } } -class TestBlueprintWorkFlowService : - AbstractBlueprintWorkFlowService<String, String>() { +class TestBluePrintWorkFlowService : + AbstractBluePrintWorkFlowService<String, String>() { - val log = logger(TestBlueprintWorkFlowService::class) + val log = logger(TestBluePrintWorkFlowService::class) lateinit var simulatedState: MutableMap<String, EdgeLabel> @@ -195,7 +195,7 @@ class TestBlueprintWorkFlowService : return EdgeLabel.SUCCESS } - override suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BlueprintRuntimeService<*>, input: String): String { + override suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: String): String { log.info("Executing Graph : $graph") this.graph = graph this.workflowId = bluePrintRuntimeService.id() @@ -205,7 +205,7 @@ class TestBlueprintWorkFlowService : if (!workflowActor.isClosedForSend) { workflowActor().send(startMessage) } else { - throw BlueprintProcessorException("workflow actor is closed for send $workflowActor") + throw BluePrintProcessorException("workflow actor is closed for send $workflowActor") } return startMessage.output.await() } @@ -229,7 +229,7 @@ class TestBlueprintWorkFlowService : kotlinx.coroutines.delay(2) } } - return simulatedState[node.id] ?: throw BlueprintException("failed to get status for the node($node)") + return simulatedState[node.id] ?: throw BluePrintException("failed to get status for the node($node)") } override suspend fun prepareNodeSkipMessage(node: Graph.Node): NodeSkipMessage<String, String> { @@ -242,7 +242,7 @@ class TestBlueprintWorkFlowService : nodeInput: String, nodeOutput: String ): EdgeLabel { - return simulatedState[node.id] ?: throw BlueprintException("failed to get status for the node($node)") + return simulatedState[node.id] ?: throw BluePrintException("failed to get status for the node($node)") } override suspend fun cancelNode( diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintFileUtilsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt index ac74f7ab1..6e19656ec 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintFileUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt @@ -24,12 +24,12 @@ import java.io.File import java.nio.file.Paths import kotlin.test.assertTrue -class BlueprintFileUtilsTest { +class BluePrintFileUtilsTest { @Test fun testNewBlueprint() = runBlocking { val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-new-test") - BlueprintFileUtils.createEmptyBlueprint(targetPath) + BluePrintFileUtils.createEmptyBluePrint(targetPath) } @Test @@ -41,17 +41,17 @@ class BlueprintFileUtilsTest { val targetDir = File(targetPath) targetDir.deleteOnExit() // Copy the BP file - BlueprintFileUtils.copyBlueprint(sourcePath, targetDir.absolutePath) + BluePrintFileUtils.copyBluePrint(sourcePath, targetDir.absolutePath) assertTrue(targetDir.exists(), "faield to copy blueprint to ${targetDir.absolutePath}") // Delete Type Files - BlueprintFileUtils.deleteBlueprintTypes(targetDir.absolutePath) + BluePrintFileUtils.deleteBluePrintTypes(targetDir.absolutePath) // Generate the Type Files - val bluePrintContext = BlueprintMetadataUtils.getBlueprintContext(sourcePath) + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(sourcePath) bluePrintContext.rootPath = targetDir.absolutePath - BlueprintFileUtils.writeBlueprintTypes(bluePrintContext) + BluePrintFileUtils.writeBluePrintTypes(bluePrintContext) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintIOUtilsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt index d0c32cc39..62bb0afcb 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintIOUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt @@ -18,9 +18,9 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import kotlinx.coroutines.runBlocking import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintRetryException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintRetryException -class BlueprintIOUtilsTest { +class BluePrintIOUtilsTest { @Test fun testRetry() { @@ -29,13 +29,13 @@ class BlueprintIOUtilsTest { "success" } val exceptionBlock = { e: Exception -> - if (e is BlueprintRetryException) { + if (e is BluePrintRetryException) { println("this is blueprint error") } else { throw e } } - BlueprintIOUtils.retry<String>(4, 0, 500, executionBlock, exceptionBlock) + BluePrintIOUtils.retry<String>(4, 0, 500, executionBlock, exceptionBlock) } } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintMetadataUtilsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt index b03fb9fc1..6ccfe1e95 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintMetadataUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt @@ -22,13 +22,13 @@ import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.TestConstants import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintCompileCache +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue -class BlueprintMetadataUtilsTest { +class BluePrintMetadataUtilsTest { @Test fun testToscaMetaData() { @@ -36,7 +36,7 @@ class BlueprintMetadataUtilsTest { runBlocking { val basePath = TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG - val toscaMetaData: ToscaMetaData = BlueprintMetadataUtils.toscaMetaData(basePath) + val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath) assertNotNull(toscaMetaData, "Missing Tosca Definition Object") assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version") assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version") @@ -47,21 +47,21 @@ class BlueprintMetadataUtilsTest { } @Test - fun testKotlinBlueprintContext() { + fun testKotlinBluePrintContext() { runBlocking { val path = normalizedPathName("src/test/resources/compile") - val blueprintContext = BlueprintMetadataUtils.getBlueprintContext(path) + val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(path) assertNotNull(blueprintContext, "failed to get blueprint context") assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template") assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template") assertNotNull(blueprintContext.otherDefinitions, "failed to get blueprint contextother definitions") - var cachePresent = BlueprintCompileCache.hasClassLoader(path) + var cachePresent = BluePrintCompileCache.hasClassLoader(path) assertTrue(cachePresent, "failed to generate cache key ($path)") /** Cleaning Cache */ - BlueprintCompileCache.cleanClassLoader(path) - cachePresent = BlueprintCompileCache.hasClassLoader(path) + BluePrintCompileCache.cleanClassLoader(path) + cachePresent = BluePrintCompileCache.hasClassLoader(path) assertTrue(!cachePresent, "failed to remove cache key ($path)") } } @@ -70,7 +70,7 @@ class BlueprintMetadataUtilsTest { fun environmentDataTest() { val environmentPath = "./src/test/resources/environments" - val properties = BlueprintMetadataUtils.bluePrintEnvProperties(environmentPath) + val properties = BluePrintMetadataUtils.bluePrintEnvProperties(environmentPath) assertNotNull(properties, "Could not read the properties") assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.username"), "username1", "failed 1") diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt index ec12639fb..d78e62f28 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.slf4j.LoggerFactory import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -57,19 +57,19 @@ class JacksonUtilsTest { val rootJson = JacksonUtils.jsonNodeFromClassPathFile(filePath) assertNotNull(rootJson, "Failed to get all type data json node") val intValue = rootJson.get("intValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value") val floatValue = rootJson.get("floatValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value") val stringValue = rootJson.get("stringValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value") val booleanValue = rootJson.get("booleanValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value") val arrayStringValue = rootJson.get("arrayStringValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value") // FIX needed for ("complex type JSON & MAP") // val mapValue = rootJson.get("mapValue") - // assertTrue(JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value") + // assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value") - assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BlueprintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed") + assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed") } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtilsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtilsTest.kt index f2d63531d..83764c517 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtilsTest.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants.LOG_PROTECT +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants.LOG_PROTECT import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.utils.PropertyDefinitionUtils.Companion.hasLogProtect import kotlin.test.assertFalse diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt index 4ba7694ee..5dd1937f8 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt @@ -16,13 +16,13 @@ package cba.scripts -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.dsl.dataType import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.AbstractBlueprintDefinitions +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.AbstractBluePrintDefinitions -class ActivateBlueprintDefinitions : AbstractBlueprintDefinitions() { +class ActivateBlueprintDefinitions : AbstractBluePrintDefinitions() { override fun serviceTemplate(): ServiceTemplate { @@ -46,10 +46,10 @@ class ActivateBlueprintDefinitions : AbstractBlueprintDefinitions() { /** Sample Definitions */ val customDataType = dataType( "custom-datatype", "1.0.0", - BlueprintConstants.MODEL_TYPE_DATATYPES_ROOT, "" + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, "" ) { - property("name", BlueprintConstants.DATA_TYPE_STRING, true, "") - property("value", BlueprintConstants.DATA_TYPE_STRING, true, "") + property("name", BluePrintConstants.DATA_TYPE_STRING, true, "") + property("value", BluePrintConstants.DATA_TYPE_STRING, true, "") } /** Loading to definitions */ addOtherDefinition("datatype-custom-datatype", customDataType) |