diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints')
54 files changed, 391 insertions, 218 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 a0ef565cc..0eba001c2 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 @@ -116,6 +116,7 @@ object BluePrintConstants { const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" + // CDS Defined Relationship Types const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB = "tosca.relationships.ConnectsTo.Db" const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_REST_CLIENT = "tosca.relationships.ConnectsTo.RestClient" @@ -154,6 +155,7 @@ object BluePrintConstants { const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" + // Custom capabilities const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" 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 66d54f52e..71a107171 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 @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core class BluePrintError { + var errors: MutableList<String> = arrayListOf() fun addError(type: String, name: String, error: String) { 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 310c9b05b..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 @@ -130,40 +130,40 @@ fun grpcProcessorException(type: String, domain: String, message: String): BlueP } fun httpProcessorException(type: String, domain: String, message: String, cause: Throwable): - BluePrintProcessorException { - val bluePrintProcessorException = processorException(message, cause).http(type) - return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) -} + 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 { - val bluePrintProcessorException = processorException(message, cause).grpc(type) - return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) -} + 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 { - val bluePrintProcessorException = processorException(cause, message, args).http(type) - return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) -} + 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 { - val bluePrintProcessorException = processorException(cause, message, args).grpc(type) - return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) -} + 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 { - return this.addDomainAndErrorMessage(domain, message, cause).domain(domain) + BluePrintProcessorException { + return this.addDomainAndErrorMessage(domain, message, cause).domain(domain) .addErrorPayloadMessage(message) .payloadMessage(message) -} + } fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String): BluePrintProcessorException { return this.addDomainAndErrorMessage(domain, message).domain(domain) - .addErrorPayloadMessage(message) - .payloadMessage(message) + .addErrorPayloadMessage(message) + .payloadMessage(message) } private fun BluePrintProcessorException.addDomainAndErrorMessage( 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 4ab3d6f86..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 @@ -61,8 +61,10 @@ fun String.splitCommaAsList(): List<String> { } fun String.isJson(): Boolean { - return ((this.trim().startsWith("{") && this.trim().endsWith("}")) || - (this.trim().startsWith("[") && this.trim().endsWith("]"))) + return ( + (this.trim().startsWith("{") && this.trim().endsWith("}")) || + (this.trim().startsWith("[") && this.trim().endsWith("]")) + ) } fun Any.asJsonString(intend: Boolean? = false): String { diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/common/ApplicationConstants.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/common/ApplicationConstants.kt index 35f7ef184..229fc7cc6 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/common/ApplicationConstants.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/common/ApplicationConstants.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.common object ApplicationConstants { + const val ACTIVE_Y = "Y" const val ACTIVE_N = "N" const val ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL" 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 0128f64a5..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 @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.config open class BluePrintLoadConfiguration { + lateinit var blueprintDeployPath: String lateinit var blueprintArchivePath: String lateinit var blueprintWorkingPath: String 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 9c9b1f9bf..b833db755 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 @@ -38,6 +38,7 @@ enum class NodeStatus(val id: String) { } class Graph { + val nodes: MutableMap<String, Node> = hashMapOf() val edges: MutableSet<Edge> = mutableSetOf() @@ -93,6 +94,7 @@ class Graph { } data class Node(val id: String, var status: NodeStatus = NodeStatus.NOT_STARTED) { + val edges: MutableList<Edge> = ArrayList() fun neighbors(): List<Node> = edges.map { edge -> edge.target(this) } @@ -116,7 +118,7 @@ class Graph { fun equivalentTo(other: Edge) = (source == other.source && target == other.target) || - (source == other.target && target == other.source) + (source == other.target && target == other.source) override fun toString() = "${source.id}>${target.id}/$label($status)" @@ -125,6 +127,7 @@ class Graph { data class TermForm(val nodes: Collection<String>, val edges: List<Term>) { data class Term(val source: String, val target: String, val label: EdgeLabel) { + override fun toString() = "Term($source, $target, $label)" } } @@ -141,6 +144,7 @@ class Graph { } data class Link<out String, out EdgeLabel>(val node: String, val label: EdgeLabel) { + override fun toString() = if (label == null) "$node" else "$node/$label" } } 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 8968ce3ef..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 @@ -38,6 +38,7 @@ open class EntityType { var description: String? = null var version: String = "1.0.0" var metadata: MutableMap<String, String>? = null + @get:JsonProperty("derived_from") lateinit var derivedFrom: String var attributes: MutableMap<String, AttributeDefinition>? = null @@ -54,6 +55,7 @@ class Credential { @get:JsonIgnore var id: String? = null var protocol: String? = null + @get:JsonProperty("token_type") lateinit var tokenType: String lateinit var token: String @@ -68,21 +70,29 @@ A constraint clause defines an operation along with one or more compatible value class ConstraintClause { var equal: JsonNode? = null + @get:JsonProperty("greater_than") var greaterThan: JsonNode? = null + @get:JsonProperty("greater_or_equal") var greaterOrEqual: JsonNode? = null + @get:JsonProperty("less_than") var lessThan: JsonNode? = null + @get:JsonProperty("less_or_equal") var lessOrEqual: JsonNode? = null + @get:JsonProperty("in_range") var inRange: MutableList<JsonNode>? = null + @get:JsonProperty("valid_values") var validValues: MutableList<JsonNode>? = null var length: JsonNode? = null + @get:JsonProperty("min_length") var minLength: JsonNode? = null + @get:JsonProperty("max_length") var maxLength: JsonNode? = null var pattern: String? = null @@ -95,6 +105,7 @@ A node filter definition defines criteria for selection of a TOSCA Node Template */ class NodeFilterDefinition { + var properties: MutableMap<String, PropertyDefinition>? = null var capabilities: MutableList<String>? = null } @@ -126,6 +137,7 @@ class ArtifactDefinition { lateinit var file: String var repository: String? = null var description: String? = null + @get:JsonProperty("deploy_Path") var deployPath: String? = null var properties: MutableMap<String, JsonNode>? = null @@ -143,8 +155,10 @@ class ImportDefinition { var id: String? = null lateinit var file: String var repository: String? = null + @get:JsonProperty("namespace_uri") var namespaceUri: String? = null + @get:JsonProperty("namespace_prefix") var namespacePrefix: String? = null } @@ -162,17 +176,22 @@ class PropertyDefinition { var description: String? = null var required: Boolean? = null lateinit var type: String + @get:JsonProperty("input-param") var inputparam: Boolean? = null + @get:JsonProperty("default") var defaultValue: JsonNode? = null var status: String? = null var constraints: MutableList<ConstraintClause>? = null + @get:JsonProperty("entry_schema") var entrySchema: EntrySchema? = null + @get:JsonProperty("external-schema") var externalSchema: String? = null var metadata: MutableMap<String, String>? = null + // Mainly used in Workflow Outputs @get:ApiModelProperty(notes = "Property Value, It may be Expression or Json type values") var value: JsonNode? = null @@ -189,17 +208,21 @@ from the instance model and used as values to other entities within TOSCA Servic */ class AttributeDefinition { + @get:JsonIgnore var id: String? = null var description: String? = null var required: Boolean? = null lateinit var type: String + @JsonProperty("default") var defaultValue: JsonNode? = null var status: String? = null var constraints: MutableList<ConstraintClause>? = null + @JsonProperty("entry_schema") var entrySchema: EntrySchema? = null + // Mainly used in DSL definitions @get:ApiModelProperty(notes = "Attribute Value, It may be Expression or Json type values") var value: JsonNode? = null @@ -220,16 +243,20 @@ class OperationDefinition { } class Implementation { + var primary: String? = null var dependencies: MutableList<String>? = null + @get:JsonProperty("operation_host") var operationHost: String = BluePrintConstants.PROPERTY_SELF + // Timeout value in seconds var timeout: Int = 180 var lock: LockAssignment? = null } class LockAssignment { + lateinit var key: JsonNode var acquireTimeout: JsonNode = Integer(180).asJsonType() } @@ -269,8 +296,10 @@ class TriggerDefinition { @get:JsonIgnore var id: String? = null var description: String? = null + @get:JsonProperty("event_type") lateinit var eventType: String + @get:JsonProperty("target_filter") var targetFilter: EventFilterDefinition? = null var condition: ConditionClause? = null @@ -290,8 +319,10 @@ class TriggerDefinition { class Activity { var delegate: String? = null + @get:JsonProperty("set_state") var setState: String? = null + @get:JsonProperty("call_operation") var callOperation: String? = null var inlines: ArrayList<String>? = null @@ -306,6 +337,7 @@ class PreConditionDefinition { @get:JsonIgnore var id: String? = null lateinit var target: String + @get:JsonProperty("target_relationship") lateinit var targetRelationship: String lateinit var condition: ArrayList<ConditionClause> @@ -321,13 +353,17 @@ class Step { var id: String? = null var description: String? = null var target: String? = null + @JsonProperty("target_relationship") var targetRelationship: String? = null + @JsonProperty("operation_host") var operationHost: String? = null var activities: ArrayList<Activity>? = null + @get:JsonProperty("on_success") var onSuccess: ArrayList<String>? = null + @get:JsonProperty("on_failure") var onFailure: ArrayList<String>? = null } @@ -338,11 +374,13 @@ A capability definition defines a named, typed set of data that can be associate */ class CapabilityDefinition { + @get:JsonIgnore var id: String? = null lateinit var type: String var description: String? = null var properties: MutableMap<String, PropertyDefinition>? = null + @get:JsonProperty("valid_source_types") var validSourceTypes: MutableList<String>? = null var occurrences: MutableList<Any>? = null @@ -371,6 +409,7 @@ class ArtifactType : EntityType() { @get:JsonProperty("mime_type") var mimeType: String? = null + @get:JsonProperty("file_ext") var fileExt: MutableList<String>? = null } @@ -381,6 +420,7 @@ A Data Type definition defines the schema for new named datatypes in TOSCA. */ class DataType : EntityType() { + var constraints: MutableList<ConstraintClause>? = null } @@ -391,6 +431,7 @@ A Node Type is a reusable entity that defines the type of one or more Node Templ */ class NodeType : EntityType() { + var capabilities: MutableMap<String, CapabilityDefinition>? = null var requirements: MutableMap<String, RequirementDefinition>? = null var interfaces: MutableMap<String, InterfaceDefinition>? = null @@ -406,6 +447,7 @@ along with a named Feature notation. */ class RequirementType : EntityType() { + var requirements: MutableMap<String, RequirementDefinition>? = null var capabilities: MutableMap<String, CapabilityDefinition>? = null var interfaces: MutableMap<String, InterfaceDefinition>? = null @@ -418,7 +460,9 @@ A Relationship Type is a reusable entity that defines the type of one or more re */ class RelationshipType : EntityType() { + var interfaces: MutableMap<String, InterfaceDefinition>? = null + @get:JsonProperty("valid_target_types") var validTargetTypes: MutableList<String>? = null } @@ -432,6 +476,7 @@ Groups can effectively be viewed as logical nodes that are not part of the physi */ class GroupType : EntityType() { + var members: MutableList<String>? = null var requirements: ArrayList<RequirementDefinition>? = null var capabilities: MutableMap<String, CapabilityDefinition>? = null @@ -502,18 +547,22 @@ class TopologyTemplate { var id: String? = null var description: String? = null var inputs: MutableMap<String, PropertyDefinition>? = null + @get:JsonProperty("node_templates") var nodeTemplates: MutableMap<String, NodeTemplate>? = null + @get:JsonProperty("relationship_templates") var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null var policies: MutableMap<String, PolicyDefinition>? = null var outputs: MutableMap<String, PropertyDefinition>? = null + @get:JsonProperty("substitution_mappings") var substitutionMappings: Any? = null var workflows: MutableMap<String, Workflow>? = null } class SubstitutionMapping { + @get:JsonProperty("node_type") lateinit var nodeType: String lateinit var capabilities: ArrayList<String> @@ -521,11 +570,13 @@ class SubstitutionMapping { } class EntrySchema { + lateinit var type: String var constraints: MutableList<ConstraintClause>? = null } class InterfaceAssignment { + @get:JsonIgnore var id: String? = null var operations: MutableMap<String, OperationAssignment>? = null @@ -538,12 +589,14 @@ A Node Template specifies the occurrence of a manageable software component as p */ open class NodeTemplate { + @get:JsonIgnore var id: String? = null var description: String? = null lateinit var type: String var metadata: MutableMap<String, String>? = null var directives: MutableList<String>? = null + // @get:JsonSerialize(using = PropertyDefinitionValueSerializer::class) var properties: MutableMap<String, JsonNode>? = null var attributes: MutableMap<String, JsonNode>? = null @@ -551,12 +604,14 @@ open class NodeTemplate { var requirements: MutableMap<String, RequirementAssignment>? = null var interfaces: MutableMap<String, InterfaceAssignment>? = null var artifacts: MutableMap<String, ArtifactDefinition>? = null + @get:JsonProperty("node_filter") var nodeFilter: NodeFilterDefinition? = null var copy: String? = null } class OperationAssignment { + @get:JsonIgnore var id: String? = null var description: String? = null @@ -571,6 +626,7 @@ A Relationship Template specifies the occurrence of a manageable relationship be */ class RelationshipTemplate { + @get:JsonIgnore var id: String? = null lateinit var type: String @@ -588,15 +644,18 @@ A Requirement assignment allows template authors to provide either concrete name */ class RequirementAssignment { + @get:JsonIgnore var id: String? = null var capability: String? = null var node: String? = null + // Relationship Type or Relationship Template var relationship: String? = null } class Workflow { + @get:JsonIgnore var id: String? = null var description: String? = null @@ -607,8 +666,10 @@ class Workflow { } class ConditionClause { + var and: ArrayList<MutableMap<String, Any>>? = null var or: ArrayList<MutableMap<String, Any>>? = null + @get:JsonProperty("assert") var assertConditions: ArrayList<MutableMap<String, Any>>? = null } @@ -619,31 +680,41 @@ A TOSCA Service Template (YAML) document contains element definitions of buildin */ @JsonPropertyOrder( - value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions", - "topologyTemplate"] + value = [ + "toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions", + "topologyTemplate" + ] ) class ServiceTemplate : Cloneable { @get:JsonIgnore var id: String? = null + @get:JsonProperty("tosca_definitions_version") var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0" var metadata: MutableMap<String, String>? = null var description: String? = null + @get:JsonProperty("dsl_definitions") var dslDefinitions: MutableMap<String, JsonNode>? = null var repositories: MutableMap<String, RepositoryDefinition>? = null var imports: MutableList<ImportDefinition>? = null + @get:JsonProperty("artifact_types") var artifactTypes: MutableMap<String, ArtifactType>? = null + @get:JsonProperty("data_types") var dataTypes: MutableMap<String, DataType>? = null + @get:JsonProperty("relationship_types") var relationshipTypes: MutableMap<String, RelationshipType>? = null + @get:JsonProperty("node_types") var nodeTypes: MutableMap<String, NodeType>? = null + @get:JsonProperty("policy_types") var policyTypes: MutableMap<String, PolicyType>? = null + @get:JsonProperty("topology_template") var topologyTemplate: TopologyTemplate? = null @@ -653,6 +724,7 @@ class ServiceTemplate : Cloneable { } class ToscaMetaData { + lateinit var toscaMetaFileVersion: String lateinit var csarVersion: String lateinit var createdBy: String diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt index 8bdedd429..50f5becca 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt @@ -34,51 +34,61 @@ enum class ErrorCode(val value: Int, val httpCode: Int) { } }, INVALID_FILE_EXTENSION(2, 415) { + override fun message(detailMsg: String): String { return "Unexpected file extension. Details : {$detailMsg}" } }, BLUEPRINT_PATH_MISSING(3, 503) { + override fun message(detailMsg: String): String { return "Blueprint path missing or wrong. Details : {$detailMsg}" } }, BLUEPRINT_WRITING_FAIL(4, 503) { + override fun message(detailMsg: String): String { return "Fail to write blueprint files. Details : {$detailMsg}" } }, IO_FILE_INTERRUPT(5, 503) { + override fun message(detailMsg: String): String { return "IO file system interruption. Details : {$detailMsg}" } }, INVALID_REQUEST_FORMAT(6, 400) { + override fun message(detailMsg: String): String { return "Bad request. Details : {$detailMsg}" } }, UNAUTHORIZED_REQUEST(7, 401) { + override fun message(detailMsg: String): String { return "The request requires user authentication. Details : {$detailMsg}" } }, REQUEST_NOT_FOUND(8, 404) { + override fun message(detailMsg: String): String { return "Request mapping doesn't exist. Details : {$detailMsg}" } }, RESOURCE_NOT_FOUND(9, 404) { + override fun message(detailMsg: String): String { return "No response was found for this request in the server. Details : {$detailMsg}" } }, CONFLICT_ADDING_RESOURCE(10, 409) { + override fun message(detailMsg: String): String { return "Duplicated entry while saving Blueprint. Details : {$detailMsg}" } }, DUPLICATE_DATA(11, 409) { + override fun message(detailMsg: String): String { return "Duplicated data - was expecting one result, got more than one. Details : {$detailMsg}" } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt index 13e9f0e5a..bb426049f 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt @@ -16,13 +16,12 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl -abstract class AbstractNodeTemplateOperationImplBuilder<Prop : PropertiesAssignmentBuilder, - In : PropertiesAssignmentBuilder, Out : PropertiesAssignmentBuilder>( - id: String, - type: String, - private val interfaceName: String, - description: String - ) : AbstractNodeTemplatePropertyImplBuilder<Prop>(id, type, description) { +abstract class AbstractNodeTemplateOperationImplBuilder<Prop : PropertiesAssignmentBuilder, In : PropertiesAssignmentBuilder, Out : PropertiesAssignmentBuilder>( + id: String, + type: String, + private val interfaceName: String, + description: String +) : AbstractNodeTemplatePropertyImplBuilder<Prop>(id, type, description) { open fun definedOperation(description: String, block: OperationAssignmentBuilder<In, Out>.() -> Unit) { typedOperation<In, Out>(interfaceName, description, block) 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 64553230a..88f852d41 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 @@ -319,10 +319,10 @@ fun ServiceTemplateBuilder.artifactTypeK8sProfileFolder() { 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, - description = "K8s Profile Folder Artifact" + id = BluePrintConstants.MODEL_TYPE_ARTIFACT_K8S_PROFILE, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION, + description = "K8s Profile Folder Artifact" ) { } } 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 f2e964a1d..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 @@ -338,6 +338,7 @@ class DSLRegistryComponentBuilder( } class DSLWorkflowBuilder(private val actionName: String, private val description: String) { + private val dslWorkflow = DSLWorkflow() private var steps: MutableMap<String, Step>? = null private var inputs: MutableMap<String, PropertyDefinition>? = null 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 8b5c4151a..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 @@ -43,6 +43,7 @@ class DSLBluePrint { } class DSLWorkflow { + @get:JsonIgnore var id: String? = null lateinit var description: String @@ -53,6 +54,7 @@ class DSLWorkflow { } class DSLComponent { + @get:JsonIgnore lateinit var id: String lateinit var type: String @@ -67,6 +69,7 @@ class DSLComponent { } class DSLRegistryComponent { + lateinit var id: String lateinit var type: String lateinit var version: String 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 a89267387..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 @@ -35,6 +35,7 @@ import kotlin.reflect.full.createInstance import kotlin.reflect.jvm.reflect open class TopologyTemplateBuilder { + private var topologyTemplate = TopologyTemplate() var nodeTemplates: MutableMap<String, NodeTemplate>? = null var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null @@ -222,6 +223,7 @@ open class RelationshipTemplateBuilder( private val type: String, private val description: String? = "" ) { + var relationshipTemplate: RelationshipTemplate = RelationshipTemplate() var properties: MutableMap<String, JsonNode>? = null @@ -293,6 +295,7 @@ class ArtifactDefinitionBuilder(private val id: String, private val type: String } open class CapabilityAssignmentBuilder(private val id: String) { + var capabilityAssignment: CapabilityAssignment = CapabilityAssignment() var attributes: MutableMap<String, JsonNode>? = null var properties: MutableMap<String, JsonNode>? = null @@ -418,6 +421,7 @@ class OperationAssignmentBuilder<In : PropertiesAssignmentBuilder, Out : Propert } class ImplementationBuilder(private val timeout: Int, private val operationHost: String) { + private val implementation = Implementation() fun primary(primary: String) { @@ -440,6 +444,7 @@ class ImplementationBuilder(private val timeout: Int, private val operationHost: } open class PropertiesAssignmentBuilder { + var properties: MutableMap<String, JsonNode> = hashMapOf() fun property(id: String, value: Any) { @@ -460,6 +465,7 @@ open class PropertiesAssignmentBuilder { } open class AttributesAssignmentBuilder { + var attributes: MutableMap<String, JsonNode> = hashMapOf() fun attribute(id: String, value: String) { 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 e183b8090..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 @@ -402,6 +402,7 @@ class AttributeDefinitionBuilder( } class PropertiesDefinitionBuilder { + private val properties: MutableMap<String, PropertyDefinition> = hashMapOf() fun property(id: String, property: PropertyDefinition) { @@ -487,6 +488,7 @@ class PropertyDefinitionBuilder( } class ConstraintsClauseBuilder { + val constraints: MutableList<ConstraintClause> = mutableListOf() fun constrain(block: ConstraintClauseBuilder.() -> Unit) { @@ -500,6 +502,7 @@ class ConstraintsClauseBuilder { } class ConstraintClauseBuilder { + private val constraintClause = ConstraintClause() fun equal(equal: Any) = equal(equal.asJsonType()) @@ -564,6 +567,7 @@ class ConstraintClauseBuilder { } class EntrySchemaBuilder(private val type: String) { + private var entrySchema: EntrySchema = EntrySchema() fun constrain(block: ConstraintClauseBuilder.() -> Unit) { 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 b657199c7..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 @@ -33,6 +33,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService interface BluePrintEnhancer<T> { + fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) } 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 6f6979772..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 @@ -55,6 +55,7 @@ open class BluePrintJsonNodeFactory : JsonNodeFactory() { } open class BluePrintTextNode(v: String) : TextNode(v) { + override fun toString(): String { var len = this._value.length len = len + 2 + (len shr 4) 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 a9684a14d..d1b42ffe5 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 @@ -36,9 +36,11 @@ import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty import kotlin.system.measureTimeMillis open class BluePrintCompileService { + val log = logger(BluePrintCompileService::class) companion object { + val classPaths = classpathFromClasspathProperty()?.joinToString(File.pathSeparator) { it.absolutePath } @@ -85,10 +87,12 @@ open class BluePrintCompileService { } val deferredCompile = async { val k2jvmCompiler = K2JVMCompiler() + /** Construct Arguments */ val arguments = k2jvmCompiler.createArguments() parseCommandLineArguments(args, arguments) val messageCollector = CompilationMessageCollector() + /** Compile with arguments */ val exitCode: ExitCode = k2jvmCompiler.exec(messageCollector, Services.EMPTY, arguments) when (exitCode) { 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 cb6616f38..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 @@ -25,6 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import java.net.URLClassLoader object BluePrintCompileCache { + val log = logger(BluePrintCompileCache::class) private val classLoaderCache: LoadingCache<String, URLClassLoader> = CacheBuilder.newBuilder() 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 7c0970202..7b11f71a2 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 @@ -57,6 +57,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { * Blueprint CBA extracted file location */ var rootPath = "." + /** * Root Definition file path */ @@ -262,8 +263,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { fun nodeTemplateOperationImplementation(nodeTemplateName: String, interfaceName: String, operationName: String): Implementation? { - return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).implementation - } + return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).implementation + } fun nodeTemplateInterfaceOperationInputs( nodeTemplateName: String, 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 b6c432b4d..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 @@ -46,9 +46,11 @@ object BluePrintExpressionService { fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean { val json = propertyAssignmentNode.toString() // FIXME("Check if any Optimisation needed") - return (json.contains(BluePrintConstants.EXPRESSION_GET_INPUT) || + return ( + json.contains(BluePrintConstants.EXPRESSION_GET_INPUT) || json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE) || - json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY)) + json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY) + ) } @JvmStatic @@ -110,8 +112,9 @@ object BluePrintExpressionService { throw BluePrintException( String.format( "missing property expression, " + - "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " + - "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", jsonNode + "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " + + "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", + jsonNode ) ) } @@ -149,8 +152,9 @@ object BluePrintExpressionService { throw BluePrintException( String.format( "missing attribute expression, " + - "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," + - " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", jsonNode + "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," + + " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", + jsonNode ) ) } @@ -189,7 +193,7 @@ object BluePrintExpressionService { throw BluePrintException( String.format( "missing operation output expression, " + - "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", + "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode ) ) @@ -216,7 +220,8 @@ object BluePrintExpressionService { throw BluePrintException( String.format( "missing artifact expression, " + - "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", jsonNode + "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", + jsonNode ) ) } 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 24b7e261c..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 @@ -30,6 +30,7 @@ import java.nio.charset.Charset class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { companion object { + private const val PARENT_SERVICE_TEMPLATE: String = "parent" } 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 53af9f7cb..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 @@ -450,19 +450,19 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): MutableMap<String, JsonNode> { - log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability($capabilityName)") - val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability($capabilityName)") + val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - val propertyAssignments = nodeTemplate.capabilities?.get(capabilityName)?.properties ?: hashMapOf() + val propertyAssignments = nodeTemplate.capabilities?.get(capabilityName)?.properties ?: hashMapOf() - val propertyDefinitions = bluePrintContext.nodeTemplateNodeType(nodeTemplateName) - .capabilities?.get(capabilityName)?.properties ?: hashMapOf() + val propertyDefinitions = bluePrintContext.nodeTemplateNodeType(nodeTemplateName) + .capabilities?.get(capabilityName)?.properties ?: hashMapOf() - /** - * Resolve the Capability Property Assignment Values. - */ - return resolveNodeTemplatePropertyAssignments(nodeTemplateName, propertyDefinitions, propertyAssignments) - } + /** + * Resolve the Capability Property Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, propertyDefinitions, propertyAssignments) + } override fun resolveNodeTemplateInterfaceOperationInputs( nodeTemplateName: String, @@ -515,6 +515,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val nodeTypeInterfaceOperationOutputs: MutableMap<String, PropertyDefinition> = bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName) ?: hashMapOf() + /** * Resolve the Property Output Assignment Values. */ 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 51a6e10ee..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 @@ -57,7 +57,7 @@ class BluePrintTemplateService(private val bluePrintLoadConfiguration: BluePrint else -> { throw BluePrintProcessorException( "Unknown Artifact type, expecting ${BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA}" + - "or ${BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY}" + "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 f492c2bc6..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 @@ -331,7 +331,8 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) capability definition ({}) " + - "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type + "from NodeType({}) ", + nodeTemplateName, capabilityName, nodeTemplate.type ) ) @@ -363,7 +364,8 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) requirement definition ({}) from" + - " NodeType({}) ", nodeTemplateName, requirementName, nodeTemplate.type + " NodeType({}) ", + nodeTemplateName, requirementName, nodeTemplate.type ) ) // Validate Requirement Assignment @@ -422,7 +424,8 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) interface definition ({}) from" + - " NodeType({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type + " NodeType({}) ", + nodeTemplateName, interfaceAssignmentName, nodeTemplate.type ) ) @@ -485,7 +488,8 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) operation definition ({}) " + - "property definition({})", nodeTemplateName, operationAssignmentName, propertyName + "property definition({})", + nodeTemplateName, operationAssignmentName, propertyName ) ) // Check the property values with property definition @@ -497,7 +501,8 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { ?: throw BluePrintException( format( "Failed to get NodeTemplate({}) operation definition ({}) " + - "output property definition({})", nodeTemplateName, operationAssignmentName, + "output property definition({})", + nodeTemplateName, operationAssignmentName, propertyName ) ) 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 0444bbeef..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 @@ -298,7 +298,8 @@ open class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRunti ?: throw BluePrintException( format( "failed to get artifact definitions for node template ({})'s " + - "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName + "artifact name ({}) ", + nodeTemplateName, artifactExpression.artifactName ) ) 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 595dbce6b..1a7c23cf1 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 @@ -19,6 +19,17 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import com.google.common.base.Predicates +import org.apache.commons.compress.archivers.ArchiveEntry +import org.apache.commons.compress.archivers.ArchiveInputStream +import org.apache.commons.compress.archivers.ArchiveOutputStream +import org.apache.commons.compress.archivers.tar.TarArchiveEntry +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream +import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry +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.slf4j.LoggerFactory import java.io.BufferedInputStream @@ -27,28 +38,17 @@ import java.io.ByteArrayOutputStream import java.io.Closeable import java.io.File import java.io.FileOutputStream +import java.io.IOException import java.io.InputStream import java.io.InputStreamReader -import java.io.IOException import java.io.OutputStream import java.nio.file.FileVisitResult import java.nio.file.Files import java.nio.file.Path import java.nio.file.SimpleFileVisitor import java.nio.file.attribute.BasicFileAttributes -import java.util.function.Predicate -import org.apache.commons.compress.archivers.ArchiveEntry -import org.apache.commons.compress.archivers.ArchiveInputStream -import org.apache.commons.compress.archivers.ArchiveOutputStream -import org.apache.commons.compress.archivers.tar.TarArchiveEntry -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream -import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream -import org.apache.commons.compress.archivers.zip.ZipArchiveEntry -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 java.util.Enumeration +import java.util.function.Predicate import java.util.zip.Deflater enum class ArchiveType { @@ -59,6 +59,7 @@ enum class ArchiveType { class BluePrintArchiveUtils { companion object { + private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) /** @@ -115,49 +116,54 @@ class BluePrintArchiveUtils { compressionLevel: Int = Deflater.DEFAULT_COMPRESSION, fixedModificationTime: Long? = null ): T - where T : OutputStream { + where T : OutputStream { val stream: ArchiveOutputStream = if (archiveType == ArchiveType.Zip) ZipArchiveOutputStream(output).apply { setLevel(compressionLevel) } else TarArchiveOutputStream(GzipCompressorOutputStream(output)) stream .use { aos -> - Files.walkFileTree(baseDir, object : SimpleFileVisitor<Path>() { - @Throws(IOException::class) - override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult { - if (pathFilter.test(file)) { - var archiveEntry: ArchiveEntry = aos.createArchiveEntry(file.toFile(), - baseDir.relativize(file).toString()) + Files.walkFileTree( + baseDir, + object : SimpleFileVisitor<Path>() { + @Throws(IOException::class) + override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult { + if (pathFilter.test(file)) { + var archiveEntry: ArchiveEntry = aos.createArchiveEntry( + file.toFile(), + baseDir.relativize(file).toString() + ) + if (archiveType == ArchiveType.Zip) { + val entry = archiveEntry as ZipArchiveEntry + fixedModificationTime?.let { + entry.time = it + } + entry.time = 0 + } + aos.putArchiveEntry(archiveEntry) + Files.copy(file, aos) + aos.closeArchiveEntry() + } + return FileVisitResult.CONTINUE + } + + @Throws(IOException::class) + override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult { + var archiveEntry: ArchiveEntry? if (archiveType == ArchiveType.Zip) { - val entry = archiveEntry as ZipArchiveEntry + val entry = ZipArchiveEntry(baseDir.relativize(dir).toString() + "/") fixedModificationTime?.let { entry.time = it } - entry.time = 0 - } + archiveEntry = entry + } else + archiveEntry = TarArchiveEntry(baseDir.relativize(dir).toString() + "/") aos.putArchiveEntry(archiveEntry) - Files.copy(file, aos) aos.closeArchiveEntry() + return FileVisitResult.CONTINUE } - return FileVisitResult.CONTINUE } - - @Throws(IOException::class) - override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult { - var archiveEntry: ArchiveEntry? - if (archiveType == ArchiveType.Zip) { - val entry = ZipArchiveEntry(baseDir.relativize(dir).toString() + "/") - fixedModificationTime?.let { - entry.time = it - } - archiveEntry = entry - } else - archiveEntry = TarArchiveEntry(baseDir.relativize(dir).toString() + "/") - aos.putArchiveEntry(archiveEntry) - aos.closeArchiveEntry() - return FileVisitResult.CONTINUE - } - }) + ) } return output } @@ -210,6 +216,7 @@ class BluePrintArchiveUtils { } class ArchiveEnumerator : Enumeration<ArchiveEntry>, Closeable { + private val zipArchive: ZipFile? private val zipEnumeration: Enumeration<ZipArchiveEntry>? private val archiveStream: ArchiveInputStream? 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 60d26a703..292eca92e 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 @@ -116,8 +116,9 @@ class BluePrintFileUtils { check(definitionDir.exists()) { throw BluePrintException( - ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + - "path(${definitionDir.absolutePath})" + ErrorCode.BLUEPRINT_PATH_MISSING.value, + "couldn't get definition file under " + + "path(${definitionDir.absolutePath})" ) } @@ -208,8 +209,9 @@ class BluePrintFileUtils { Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(definitionFile.exists()) { throw BluePrintException( - ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " + - "path(${definitionFile.absolutePath})" + ErrorCode.BLUEPRINT_WRITING_FAIL.value, + "couldn't write definition file under " + + "path(${definitionFile.absolutePath})" ) } } @@ -220,21 +222,22 @@ class BluePrintFileUtils { Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(typeFile.exists()) { throw BluePrintException( - ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " + - "path(${typeFile.absolutePath})" + ErrorCode.BLUEPRINT_WRITING_FAIL.value, + "couldn't write $type.json file under " + + "path(${typeFile.absolutePath})" ) } } private fun getMetaDataContent(): String { return "TOSCA-Meta-File-Version: 1.0.0" + - "\nCSAR-Version: <VERSION>" + - "\nCreated-By: <AUTHOR NAME>" + - "\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" + - "\nTemplate-Name: <BLUEPRINT_NAME>" + - "\nTemplate-Version: <BLUEPRINT_VERSION>" + - "\nTemplate-Type: <BLUEPRINT_TYPE>" + - "\nTemplate-Tags: <TAGS>" + "\nCSAR-Version: <VERSION>" + + "\nCreated-By: <AUTHOR NAME>" + + "\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" + + "\nTemplate-Name: <BLUEPRINT_NAME>" + + "\nTemplate-Version: <BLUEPRINT_VERSION>" + + "\nTemplate-Type: <BLUEPRINT_TYPE>" + + "\nTemplate-Tags: <TAGS>" } fun getBluePrintFile(fileName: String, targetPath: Path): File { @@ -242,8 +245,9 @@ class BluePrintFileUtils { val file = File(filePath) check(file.exists()) { throw BluePrintException( - ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + - "path(${file.absolutePath})" + ErrorCode.BLUEPRINT_PATH_MISSING.value, + "couldn't get definition file under " + + "path(${file.absolutePath})" ) } return file @@ -252,8 +256,9 @@ class BluePrintFileUtils { fun getCbaStorageDirectory(path: String): Path { check(StringUtils.isNotBlank(path)) { throw BluePrintException( - ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " + - "Blueprint folder under path($path)" + ErrorCode.BLUEPRINT_PATH_MISSING.value, + "couldn't get " + + "Blueprint folder under path($path)" ) } @@ -305,12 +310,12 @@ class BluePrintFileUtils { val urls = arrayListOf<URL>() directory.walkTopDown() - .filter { it.name.endsWith(COMPILED_JAR_SUFFIX) } - .forEach { - log.debug("Adding (${it.absolutePath}) to classLoader (${directory.absolutePath})") + .filter { it.name.endsWith(COMPILED_JAR_SUFFIX) } + .forEach { + log.debug("Adding (${it.absolutePath}) to classLoader (${directory.absolutePath})") - urls.add(it.toURI().toURL()) - } + urls.add(it.toURI().toURL()) + } return URLClassLoader(urls.toTypedArray(), this.javaClass.classLoader) } 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 64be5897a..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 @@ -40,6 +40,7 @@ import java.util.Properties class BluePrintMetadataUtils { companion object { + private val log = LoggerFactory.getLogger(this::class.toString()) suspend fun toscaMetaData(basePath: String): ToscaMetaData { @@ -104,47 +105,47 @@ 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) - } + 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) - } + 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>> { - 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) - bluePrintRuntimeService.put( - BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, - blueprintBasePath.asJsonPrimitive() - ) - bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) - return bluePrintRuntimeService - } + 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) + bluePrintRuntimeService.put( + BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, + blueprintBasePath.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>> { - val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) + val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.put( - BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, - blueprintBasePath.asJsonPrimitive() - ) - bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.put( + BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, + blueprintBasePath.asJsonPrimitive() + ) + bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) - return bluePrintRuntimeService - } + return bluePrintRuntimeService + } /** Get the default blueprint runtime for enhancement start for [id], [blueprintBasePath] and [executionContext] */ suspend fun getBluePrintRuntime( @@ -153,15 +154,15 @@ class BluePrintMetadataUtils { executionContext: MutableMap<String, JsonNode> ): BluePrintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - executionContext.forEach { - bluePrintRuntimeService.put(it.key, it.value) - } + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + executionContext.forEach { + bluePrintRuntimeService.put(it.key, it.value) + } - bluePrintRuntimeService.setExecutionContext(executionContext) - return bluePrintRuntimeService - } + bluePrintRuntimeService.setExecutionContext(executionContext) + return bluePrintRuntimeService + } /** Get the default blueprint context for [blueprintBasePath]*/ suspend fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { 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 c44355070..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 @@ -40,7 +40,7 @@ object BluePrintRuntimeUtils { bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, - JsonNode> + JsonNode> ) { val jsonNode = JacksonUtils.jsonNodeFromClassPathFile(fileName) return assignInputs(bluePrintContext, jsonNode, context) diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt index 6645ff7b4..ad30bfb2f 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt @@ -45,7 +45,8 @@ class JacksonReactorUtils { // log.trace("Reading Classpath File($fileName)") IOUtils.toString( JacksonUtils::class.java.classLoader - .getResourceAsStream(fileName), Charset.defaultCharset() + .getResourceAsStream(fileName), + Charset.defaultCharset() ) } 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 573fc17d2..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 @@ -85,7 +85,8 @@ class JacksonUtils { withContext(Dispatchers.Default) { IOUtils.toString( JacksonUtils::class.java.classLoader - .getResourceAsStream(fileName), Charset.defaultCharset() + .getResourceAsStream(fileName), + Charset.defaultCharset() ) } } 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 35f2f6d83..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 @@ -21,17 +21,18 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition class PropertyDefinitionUtils { companion object { + fun hasLogProtect(metadata: MutableMap<String, String>?) = metadata?.get(LOG_PROTECT) - ?.let { - when (it.toLowerCase()) { - "true" -> true - "yes" -> true - "y" -> true - else -> false - } - } ?: false + ?.let { + when (it.toLowerCase()) { + "true" -> true + "yes" -> true + "y" -> true + else -> false + } + } ?: false fun hasLogProtect(propertyDefinition: PropertyDefinition?) = propertyDefinition - ?.let { p -> hasLogProtect(p.metadata) } ?: false + ?.let { p -> hasLogProtect(p.metadata) } ?: false } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt index 9903b57f1..453193596 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt @@ -92,14 +92,14 @@ object ServiceTemplateUtils { toMerge.topologyTemplate?.nodeTemplates?.let { parentServiceTemplate.topologyTemplate?.nodeTemplates = parentServiceTemplate.topologyTemplate?.nodeTemplates - ?: hashMapOf() + ?: hashMapOf() parentServiceTemplate.topologyTemplate?.nodeTemplates?.putAll(parentServiceTemplate.topologyTemplate?.nodeTemplates as MutableMap) } toMerge.topologyTemplate?.relationshipTemplates?.let { parentServiceTemplate.topologyTemplate?.relationshipTemplates = parentServiceTemplate.topologyTemplate?.relationshipTemplates - ?: hashMapOf() + ?: hashMapOf() parentServiceTemplate.topologyTemplate?.relationshipTemplates?.putAll(parentServiceTemplate.topologyTemplate?.relationshipTemplates as MutableMap) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt index 6383fb4a8..8aa295071 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt @@ -20,6 +20,7 @@ import org.junit.Test import kotlin.test.assertTrue class FileExtensionFunctionTest { + val blueprintBasePath = TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG @Test 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 498a85239..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 @@ -26,7 +26,9 @@ import kotlin.test.Test import kotlin.test.assertEquals class MDCContextTest { + val log = logger(MDCContextTest::class) + @Before fun setup() { MDC.clear() diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/TestConstants.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/TestConstants.kt index 4182a3fcd..d5c19c184 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/TestConstants.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/TestConstants.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core object TestConstants { + const val PATH_TEST_BLUEPRINTS = "./../../../../../components/model-catalog/blueprint-model/test-blueprint" const val PATH_TEST_BLUEPRINTS_BASECONFIG = "$PATH_TEST_BLUEPRINTS/baseconfiguration" 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 824d7ddec..9aea47a9e 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 @@ -277,8 +277,8 @@ fun BluePrintTypes.nodeTemplateComponentTestExecutor( block: TestNodeTemplateOperationImplBuilder.() -> Unit ): NodeTemplate { - return TestNodeTemplateOperationImplBuilder(id, description).apply(block).build() -} + return TestNodeTemplateOperationImplBuilder(id, description).apply(block).build() + } class TestNodeTemplateOperationImplBuilder(id: String, description: String) : AbstractNodeTemplateOperationImplBuilder<TestProperty, TestInput, TestOutput>( @@ -288,6 +288,7 @@ class TestNodeTemplateOperationImplBuilder(id: String, description: String) : ) class TestProperty : PropertiesAssignmentBuilder() { + fun prop1(prop1: String) { property("prop1", prop1.asJsonPrimitive()) } @@ -298,12 +299,14 @@ class TestProperty : PropertiesAssignmentBuilder() { } class TestInput : PropertiesAssignmentBuilder() { + fun request(request: String) { property("request", request.asJsonPrimitive()) } } class TestOutput : PropertiesAssignmentBuilder() { + fun response(response: String) { response(response.asJsonPrimitive()) } 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 60bef8a8d..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 @@ -55,6 +55,7 @@ class BluePrintScriptsServiceImplTest { val bluePrintScriptsService = BluePrintScriptsServiceImpl() val basePath = normalizedPathName("src/test/resources/compile") + /** Load the Definitions */ val bluePrintDefinitions = bluePrintScriptsService .scriptInstance<BluePrintDefinitions>( 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 79979b949..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 @@ -240,8 +240,9 @@ class BluePrintRuntimeServiceTest { val bluePrintRuntimeService = getBluePrintRuntimeService() bluePrintRuntimeService.setNodeTemplateAttributeValue( - "resource-assignment", "assignment-map", - JacksonUtils.jsonNode(""" + "resource-assignment", "assignment-map", + JacksonUtils.jsonNode( + """ { "a-prefix":{ "an-object":{ @@ -249,13 +250,15 @@ class BluePrintRuntimeServiceTest { } } } - """.trimIndent()) + """.trimIndent() + ) ) val propertyDefinitions = mutableMapOf<String, PropertyDefinition>( - "resolution" to PropertyDefinition().apply { - this.type = "json" - this.value = JacksonUtils.jsonNode(""" + "resolution" to PropertyDefinition().apply { + this.type = "json" + this.value = JacksonUtils.jsonNode( + """ { "get_attribute":[ "resource-assignment", @@ -266,8 +269,9 @@ class BluePrintRuntimeServiceTest { "a-key" ] } - """.trimIndent()) - } + """.trimIndent() + ) + } ) val result = bluePrintRuntimeService.resolvePropertyDefinitions("workflow", "WORKFLOW", propertyDefinitions) 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 72fa3e1eb..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 @@ -34,6 +34,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.toGraph import kotlin.test.assertNotNull class BluePrintWorkflowServiceTest { + @Test fun testSimpleFlow() { runBlocking { @@ -210,9 +211,9 @@ class TestBluePrintWorkFlowService : } override suspend fun prepareNodeExecutionMessage(node: Graph.Node): - NodeExecuteMessage<String, String> { - return NodeExecuteMessage(node, "$node Input", "") - } + NodeExecuteMessage<String, String> { + return NodeExecuteMessage(node, "$node Input", "") + } override suspend fun executeNode( node: Graph.Node, diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt index fc11947de..4334bce2e 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt @@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory class TopologicalSortingUtilsTest { private val log = LoggerFactory.getLogger(TopologicalSortingUtilsTest::class.java) + @Test fun testSorting() { val graph: TopologicalSortingUtils<String> = TopologicalSortingUtils() diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt index 2dfc09be6..6fa83119e 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -102,7 +102,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val capabilityDefinition = nodeType.capabilities?.get(capabilityName) ?: throw BluePrintException( "Failed to get NodeTemplate($nodeTemplateName) capability definition ($capabilityName) " + - "from NodeType(${nodeTemplate.type})" + "from NodeType(${nodeTemplate.type})" ) validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) @@ -135,7 +135,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val requirementDefinition = nodeType.requirements?.get(requirementName) ?: throw BluePrintException( "Failed to get NodeTemplate($nodeTemplateName) requirement definition ($requirementName) from" + - " NodeType(${nodeTemplate.type})" + " NodeType(${nodeTemplate.type})" ) // Validate Requirement Assignment validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) @@ -166,13 +166,13 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val relationShipNodeTemplate = bluePrintContext.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) ?: throw BluePrintException( "Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + - "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)" + "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)" ) relationShipNodeTemplate.capabilities?.get(capabilityName) ?: throw BluePrintException( "Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + - "capability($capabilityName) for NodeTemplate ($nodeTemplateName)'s requirement($requirementAssignmentName)" + "capability($capabilityName) for NodeTemplate ($nodeTemplateName)'s requirement($requirementAssignmentName)" ) } @@ -186,7 +186,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) ?: throw BluePrintException( "Failed to get NodeTemplate($nodeTemplateName) interface definition ($interfaceAssignmentName) from" + - " NodeType(${nodeTemplate.type})" + " NodeType(${nodeTemplate.type})" ) validateInterfaceAssignment( @@ -232,7 +232,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator log.debug( "Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation " + - "($operationAssignmentName)" + "($operationAssignmentName)" ) val inputs = operationAssignments.inputs @@ -242,7 +242,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val propertyDefinition = operationDefinition.inputs?.get(propertyName) ?: throw BluePrintException( "Failed to get NodeTemplate($nodeTemplateName) operation " + - "definition ($operationAssignmentName) property definition($propertyName)" + "definition ($operationAssignmentName) property definition($propertyName)" ) // Check the property values with property definition propertyAssignmentValidationUtils @@ -253,7 +253,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val propertyDefinition = operationDefinition.outputs?.get(propertyName) ?: throw BluePrintException( "Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " + - "output property definition($propertyName)" + "output property definition($propertyName)" ) // Check the property values with property definition propertyAssignmentValidationUtils diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt index 5384744ee..04a3fd046 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt @@ -141,7 +141,7 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ relationShipNodeType.capabilities?.get(capabilityName) ?: throw BluePrintException( "failed to get requirement NodeType($requirementNodeTypeName)'s " + - "capability($nodeTypeName) for NodeType ($capabilityName)'s requirement($requirementDefinitionName) " + "capability($nodeTypeName) for NodeType ($capabilityName)'s requirement($requirementDefinitionName) " ) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt index 1fb70503f..db7d91a22 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { companion object { + const val PREFIX_DEFAULT = "default" } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt index a2b598017..25b5af0b2 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt @@ -66,16 +66,17 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ check( nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW || - nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_COMPONENT + nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_COMPONENT ) { "NodeType(${nodeTemplate.type}) derived from is '$nodeTypeDerivedFrom', Expected " + - "'${BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW}' or '${BluePrintConstants.MODEL_TYPE_NODE_COMPONENT}'" + "'${BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW}' or '${BluePrintConstants.MODEL_TYPE_NODE_COMPONENT}'" } } catch (e: Exception) { bluePrintRuntimeService.getBluePrintError() .addError( "Failed to validate Workflow($workflowName)'s step($stepName)'s " + - "definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!! + "definition", + paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!! ) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt index 70f151b66..556f4a3da 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -101,12 +101,13 @@ open class ResourceAssignment { dictionaryName = $dictionaryName dictionarySource = $dictionarySource ] - """.trimIndent() + """.trimIndent() } } data class KeyIdentifier(val name: String, val value: JsonNode) data class DictionaryMetadataEntry(val name: String, val value: String) + /** * Data class for exposing summary of resource resolution */ @@ -132,6 +133,7 @@ data class ResolutionSummary( @JsonProperty("message") val message: String ) + /** * Interface for Source Definitions (ex Input Source, * Default Source, Database Source, Rest Sources, etc) @@ -139,5 +141,6 @@ data class ResolutionSummary( interface ResourceSource : Serializable open class ResourceSourceMapping { + lateinit var resourceSourceMappings: MutableMap<String, String> } diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index a5171d25c..b97492dc8 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -122,7 +122,7 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio for (resourceAssignment in vs) { s.append( "(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + - ")," + ")," ) } s.append("]") @@ -131,7 +131,7 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio for (resourceAssignment in vs) { s.append( "(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + - ")," + ")," ) } s.append("]") diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt index 422f65157..5117c4388 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -60,8 +60,10 @@ object BulkResourceSequencingUtils { } else if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { for (dependency in resourceAssignment.dependencies!!) { val ra = resourceAssignmentMap[dependency] - ?: throw BluePrintProcessorException("Couldn't get Resource Assignment dependency " + - "Key($dependency)") + ?: throw BluePrintProcessorException( + "Couldn't get Resource Assignment dependency " + + "Key($dependency)" + ) topologySorting.add(ra, resourceAssignment) } } else { diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index f26c5098f..c09474a2b 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory import java.io.File object ResourceDictionaryUtils { + private val log = LoggerFactory.getLogger(ResourceDictionaryUtils::class.java) @JvmStatic diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java index b8e1d519b..3e9965f5e 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -31,7 +31,8 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionInputSource() { String fileName = basePath + "/input-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = + JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); } @@ -39,7 +40,8 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionDefaultSource() { String fileName = basePath + "/default-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = + JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); } @@ -47,14 +49,16 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionDBSource() { String fileName = basePath + "/db-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = + JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for processor-db type", resourceDefinition); } @Test public void testDictionaryDefinitionMDSALSource() { String fileName = basePath + "/mdsal-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = + JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); } diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index 77af5dbe0..66df5078c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory class ResourceAssignmentValidationServiceTest { private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java) + @Before fun setUp() { // Setup dummy Source Instance Mapping diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java index 30b4d4544..904dbc2c3 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java @@ -32,9 +32,10 @@ public class BulkResourceSequencingUtilsTest { @Test public void testProcess() { - List<ResourceAssignment> assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); + List<ResourceAssignment> assignments = + JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); BulkResourceSequencingUtils.process(assignments); } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index 8004d2ca2..862f1892d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/ms/blueprintsprocessor/modules/blueprints/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -50,26 +50,27 @@ public class ResourceDictionaryUtilsTest { resourceDefinition.setSources(sources); // To Check Empty Source ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource()); + Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, + resourceAssignment.getDictionarySource()); // To Check First Source resourceAssignment.setDictionarySource(null); sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate()); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected First source Default, but.", - ResourceDictionaryConstants.SOURCE_DEFAULT, + Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); // To Check Assigned Source resourceAssignment.setDictionarySource(ResourceDictionaryConstants.PROCESSOR_DB); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.PROCESSOR_DB, resourceAssignment.getDictionarySource()); + Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.PROCESSOR_DB, + resourceAssignment.getDictionarySource()); } @Test public void testFindFirstSource() { - //To check if Empty Source + // To check if Empty Source Map<String, NodeTemplate> sources = new HashMap<>(); String firstSource = ResourceDictionaryUtils.findFirstSource(sources); Assert.assertNull("Source populated, which is not expected.", firstSource); @@ -82,7 +83,8 @@ public class ResourceDictionaryUtilsTest { // TO check the multiple Source sources.put(ResourceDictionaryConstants.PROCESSOR_DB, new NodeTemplate()); String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, + multipleFirstSource); } |