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
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
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)
*
* @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
}
}
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 {
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())
}
}
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)
}
/**
*/
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()
val propertyAssignmentExpression = PropertyAssignmentService(this)
propertyAssignmentValue[propertyName] = propertyAssignmentExpression
.resolveAssignmentExpression(
- BluePrintConstants.MODEL_DEFINITION_TYPE_DSL,
+ BlueprintConstants.MODEL_DEFINITION_TYPE_DSL,
"DSL",
propertyName,
propertyValue
}
/** 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(
propertyAssignments: MutableMap<String, JsonNode>
): MutableMap<String, JsonNode> {
return resolvePropertyAssignments(
- BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE,
+ BlueprintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE,
nodeTemplateName, propertyDefinitions, propertyAssignments
)
}
val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)
return nodeTemplate.artifacts?.get(artifactName)
- ?: throw BluePrintProcessorException(
+ ?: throw BlueprintProcessorException(
"failed to get artifact definition($artifactName) from the node template"
)
}
// 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.
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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()
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 {