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
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
) {
}
fun enhanceTopologyTemplate(
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ bluePrintRuntimeService: BlueprintRuntimeService<*>,
name: String,
topologyTemplate: TopologyTemplate
) {
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
) {
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
) {
}
fun enhanceRelationshipType(
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ bluePrintRuntimeService: BlueprintRuntimeService<*>,
name: String,
relationshipType: RelationshipType
) {
}
fun enhanceArtifactDefinition(
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ bluePrintRuntimeService: BlueprintRuntimeService<*>,
name: String,
artifactDefinition: ArtifactDefinition
) {
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
) {
}
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
) {
@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
}
}
val nestedErrors = errorMap.keys.map {
"${errorMap[it]?.message ?: errorMap[it].toString()}"
}.joinToString(";")
- throw BluePrintException("$name-->$nestedErrors")
+ throw BlueprintException("$name-->$nestedErrors")
}
}
}