diff options
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main')
21 files changed, 239 insertions, 187 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt index 7c6ba603b..c755e89bf 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt @@ -25,9 +25,9 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition /** Resource Definition DSL **/ fun BluePrintTypes.resourceDefinitions(block: ResourceDefinitionsBuilder.() -> Unit): - MutableMap<String, ResourceDefinition> { - return ResourceDefinitionsBuilder().apply(block).build() -} + MutableMap<String, ResourceDefinition> { + return ResourceDefinitionsBuilder().apply(block).build() + } fun BluePrintTypes.resourceDefinition( name: String, @@ -39,9 +39,9 @@ fun BluePrintTypes.resourceDefinition( /** Resource Mapping DSL **/ fun BluePrintTypes.resourceAssignments(block: ResourceAssignmentsBuilder.() -> Unit): - MutableMap<String, ResourceAssignment> { - return ResourceAssignmentsBuilder().apply(block).build() -} + MutableMap<String, ResourceAssignment> { + return ResourceAssignmentsBuilder().apply(block).build() + } fun BluePrintTypes.resourceAssignment( name: String, @@ -53,6 +53,7 @@ fun BluePrintTypes.resourceAssignment( } class ResourceDefinitionsBuilder() { + private val resourceDefinitions: MutableMap<String, ResourceDefinition> = hashMapOf() fun resourceDefinition( @@ -74,6 +75,7 @@ class ResourceDefinitionsBuilder() { } class ResourceDefinitionBuilder(private val name: String, private val description: String) { + private val resourceDefinition = ResourceDefinition() fun updatedBy(updatedBy: String) { @@ -115,6 +117,7 @@ class ResourceDefinitionBuilder(private val name: String, private val descriptio } class ResourceDefinitionSourcesBuilder { + var sources: MutableMap<String, NodeTemplate> = hashMapOf() fun source(source: NodeTemplate) { @@ -147,6 +150,7 @@ class ResourceDefinitionSourcesBuilder { } class ResourceAssignmentsBuilder() { + private val resourceAssignments: MutableMap<String, ResourceAssignment> = hashMapOf() fun resourceAssignment( diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt index 3ebd2f893..dac237fc5 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt @@ -37,6 +37,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re AbstractComponentFunction() { companion object { + const val INPUT_REQUEST_ID = "request-id" const val INPUT_RESOURCE_ID = "resource-id" const val INPUT_ACTION_NAME = "action-name" @@ -68,7 +69,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re val resourceType = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE)?.returnNullIfMissing()?.textValue() ?: "" val resolutionSummary = - getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY)?.asBoolean() ?: false + getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY)?.asBoolean() ?: false val properties: MutableMap<String, Any> = mutableMapOf() properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult @@ -99,7 +100,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re } else if (resourceType.isEmpty() && resourceId.isEmpty() && resolutionKey.isEmpty()) { throw BluePrintProcessorException( "Can't proceed with the resolution: can't persist resolution without a correlation key. " + - "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false." + "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false." ) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt index 8c854b840..774873a43 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt @@ -83,7 +83,7 @@ fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType { property( ResourceResolutionComponent.INPUT_RESOLUTION_SUMMARY, BluePrintConstants.DATA_TYPE_BOOLEAN, - false, "Enables ResolutionSummary output" + false, "Enables ResolutionSummary output" ) property( diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt index 0f04ea38e..6451b8fc8 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt @@ -48,9 +48,9 @@ suspend fun AbstractComponentFunction.contentFromResolvedArtifactNB(artifactPref */ fun AbstractComponentFunction.storedContentFromResolvedArtifact(resolutionKey: String, artifactName: String): - String = runBlocking { - storedContentFromResolvedArtifactNB(resolutionKey, artifactName) -} + String = runBlocking { + storedContentFromResolvedArtifactNB(resolutionKey, artifactName) + } fun AbstractComponentFunction.contentFromResolvedArtifact(artifactPrefix: String): String = runBlocking { contentFromResolvedArtifactNB(artifactPrefix) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt index 836db4c70..07eb15dda 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt @@ -197,8 +197,8 @@ open class ResourceResolutionServiceImpl( false ) as Boolean val assignmentMap = resourceAssignments - .associateBy({ it.name }, { it.property?.value }) - .asJsonNode() + .associateBy({ it.name }, { it.property?.value }) + .asJsonNode() val resolvedParamJsonContent = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList()) val artifactTemplateDefinition = @@ -213,7 +213,7 @@ open class ResourceResolutionServiceImpl( ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] .asJsonPrimitive() - ) + ) ) } resolutionSummary -> { @@ -443,10 +443,12 @@ open class ResourceResolutionServiceImpl( // Comparision between what we have in the database vs what we have to assign. private fun compareOne(resourceResolution: ResourceResolution, resourceAssignment: ResourceAssignment): Boolean { - return (resourceResolution.name == resourceAssignment.name && - resourceResolution.dictionaryName == resourceAssignment.dictionaryName && - resourceResolution.dictionarySource == resourceAssignment.dictionarySource && - resourceResolution.dictionaryVersion == resourceAssignment.version) + return ( + resourceResolution.name == resourceAssignment.name && + resourceResolution.dictionaryName == resourceAssignment.dictionaryName && + resourceResolution.dictionarySource == resourceAssignment.dictionarySource && + resourceResolution.dictionaryVersion == resourceAssignment.version + ) } private fun exposeOccurrencePropertyInResourceAssignments( diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt index d541fe60c..62ec2bdf4 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt @@ -247,6 +247,7 @@ class SourceDbNodeTemplateBuilder(id: String, description: String) : ) { class PropertiesBuilder : PropertiesAssignmentBuilder() { + fun type(type: String) = type(type.asJsonPrimitive()) fun type(type: JsonNode) { @@ -286,6 +287,7 @@ class SourceDbNodeTemplateBuilder(id: String, description: String) : } class KeyMappingBuilder() { + val map: MutableMap<String, String> = hashMapOf() fun map(key: String, value: String) { map[key] = value @@ -312,6 +314,7 @@ class SourceRestNodeTemplateBuilder(id: String, description: String) : ) { class PropertiesBuilder : PropertiesAssignmentBuilder() { + fun type(type: String) = type(type.asJsonPrimitive()) fun type(type: JsonNode) { @@ -390,6 +393,7 @@ class SourceCapabilityNodeTemplateBuilder(id: String, description: String) : ) { class PropertiesBuilder : PropertiesAssignmentBuilder() { + fun type(type: String) = type(type.asJsonPrimitive()) fun type(type: JsonNode) { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt index 7a7edc92b..e2fef746b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt @@ -23,61 +23,84 @@ import com.fasterxml.jackson.annotation.JsonProperty open class ResourceSourceProperties open class InputResourceSource : ResourceSourceProperties() { + lateinit var key: String + @get:JsonProperty("key-dependencies") lateinit var keyDependencies: MutableList<String> } open class DefaultResourceSource : ResourceSourceProperties() { + lateinit var key: String + @get:JsonProperty("key-dependencies") lateinit var keyDependencies: MutableList<String> } open class DatabaseResourceSource : ResourceSourceProperties() { + lateinit var type: String + @get:JsonProperty("endpoint-selector") var endpointSelector: String? = null lateinit var query: String + @get:JsonProperty("input-key-mapping") var inputKeyMapping: MutableMap<String, String>? = null + @get:JsonProperty("output-key-mapping") var outputKeyMapping: MutableMap<String, String>? = null + @get:JsonProperty("key-dependencies") lateinit var keyDependencies: MutableList<String> } open class RestResourceSource : ResourceSourceProperties() { + lateinit var verb: String + @get:JsonProperty("payload") var payload: String? = null + @get:JsonProperty("resolved-payload") var resolvedPayload: String? = null lateinit var type: String + @get:JsonProperty("endpoint-selector") var endpointSelector: String? = null + @get:JsonProperty("url-path") lateinit var urlPath: String lateinit var path: String + @get:JsonProperty("expression-type") lateinit var expressionType: String + @get:JsonProperty("input-key-mapping") var inputKeyMapping: MutableMap<String, String>? = null + @get:JsonProperty("output-key-mapping") var outputKeyMapping: MutableMap<String, String>? = null + @get:JsonProperty("headers") var headers: Map<String, String> = emptyMap() + @get:JsonProperty("key-dependencies") lateinit var keyDependencies: MutableList<String> } open class CapabilityResourceSource : ResourceSourceProperties() { + @get:JsonProperty("script-type") lateinit var scriptType: String + @get:JsonProperty("script-class-reference") lateinit var scriptClassReference: String + @get:JsonProperty("instance-dependencies") var instanceDependencies: List<String>? = null + @get:JsonProperty("key-dependencies") lateinit var keyDependencies: MutableList<String> } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt index b38c32056..03a90d134 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt @@ -122,21 +122,21 @@ open class IpAssignResolutionCapability : ResourceAssignmentProcessor() { /** Generates aggregated request payload for Ip Assign mS. Parses the resourceassignments of * sourceCapability "ipassign-ms". It generates below sample payload * { - "requests": [{ - "name": "fixed_ipv4_Address_01", - "property": { - "CloudRegionId": "abcd123", - "IpServiceName": "MobilityPlan", - } - }, { - "name": "fixed_ipv4_Address_02", - "property": { - "CloudRegionId": "abcd123", - "IpServiceName": "MobilityPlan", - } - } - ] - } */ + "requests": [{ + "name": "fixed_ipv4_Address_01", + "property": { + "CloudRegionId": "abcd123", + "IpServiceName": "MobilityPlan", + } + }, { + "name": "fixed_ipv4_Address_02", + "property": { + "CloudRegionId": "abcd123", + "IpServiceName": "MobilityPlan", + } + } + ] + } */ private fun generatePayload( input: Map<String, Any>, groupResourceAssignments: MutableList<ResourceAssignment> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt index dbac70a39..7a5986aa6 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt @@ -125,25 +125,25 @@ open class NamingResolutionCapability : ResourceAssignmentProcessor() { * sourceCapability "naming-ms". "naming-type" should be provides as property metadata for * each resourceassigment of sourceCapability "naming-ms". It generates below sample payload * { - "elements": [{ - "vf-module-name": "${vf-module-name}", - "naming-type": "VF-MODULE", - "naming-code": "dbc", - "vf-module-label": "adsf", - "policy-instance-name": "SDNC_Policy.Config_Json.xml", - "vnf-name": "vnf-123", - "vf-module-type": "base" - }, { - "vnfc-name": "${vnfc-name}", - "naming-type": "VNFC", - "naming-code": "dbc", - "vf-module-label": "adsf", - "policy-instance-name": "SDNC_Policy.Config_Json.xml", - "vnf-name": "vnf-123", - "vf-module-type": "base" - } - ] - } */ + "elements": [{ + "vf-module-name": "${vf-module-name}", + "naming-type": "VF-MODULE", + "naming-code": "dbc", + "vf-module-label": "adsf", + "policy-instance-name": "SDNC_Policy.Config_Json.xml", + "vnf-name": "vnf-123", + "vf-module-type": "base" + }, { + "vnfc-name": "${vnfc-name}", + "naming-type": "VNFC", + "naming-code": "dbc", + "vf-module-label": "adsf", + "policy-instance-name": "SDNC_Policy.Config_Json.xml", + "vnf-name": "vnf-123", + "vf-module-type": "base" + } + ] + } */ private fun generatePayload( input: Map<String, Any>, groupResourceAssignments: MutableList<ResourceAssignment> @@ -158,7 +158,8 @@ open class NamingResolutionCapability : ResourceAssignmentProcessor() { val moduleValue = "\${".plus(moduleName.plus("}")) val request: MutableMap<String, String> = input.mapValues { - it.value.toString().removeSurrounding("\"") } as MutableMap<String, String> + it.value.toString().removeSurrounding("\"") + } as MutableMap<String, String> if (namingType != null) { request["naming-type"] = namingType } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt index db023acfb..55a4d1120 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt @@ -112,6 +112,7 @@ class ResourceResolution : Serializable { var createdDate = Date() companion object { + private const val serialVersionUID = 1L } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt index 1a5d062a3..5958c7899 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt @@ -215,10 +215,10 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso resolutionKey: String ) { resourceResolutionRepository.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( - blueprintName, - blueprintVersion, - artifactName, - resolutionKey + blueprintName, + blueprintVersion, + artifactName, + resolutionKey ) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt index 8b235925b..971caa338 100755 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt @@ -89,6 +89,7 @@ class TemplateResolution : Serializable { var createdDate = Date() companion object { + private const val serialVersionUID = 1L } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt index 895bc993f..4bdd5d985 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt @@ -147,7 +147,7 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa )?.let { log.info( "Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " + - "artifactName=($artifactPrefix) and resolutionKey=($resolutionKey)" + "artifactName=($artifactPrefix) and resolutionKey=($resolutionKey)" ) templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence( resolutionKey, @@ -163,7 +163,7 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa )?.let { log.info( "Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " + - "artifactName=($artifactPrefix), resourceId=($resourceId) and resourceType=($resourceType)" + "artifactName=($artifactPrefix), resourceId=($resourceId) and resourceType=($resourceType)" ) templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence( resourceId, @@ -178,13 +178,14 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa try { log.info( "Writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" + - " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence" + " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence" ) templateResolutionRepository.saveAndFlush(resourceResolutionResult) } catch (ex: DataIntegrityViolationException) { log.error( "Error writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" + - " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", ex.message + " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", + ex.message ) throw BluePrintException("Failed to store resource api result.", ex) } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt index 42e086137..b1dc14091 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt @@ -97,14 +97,14 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>): ResourceAssignmentProcessor { - log.info("creating resource resolution of script type($scriptType), reference name($scriptClassReference)") + log.info("creating resource resolution of script type($scriptType), reference name($scriptClassReference)") - val scriptComponent = componentFunctionScriptingService - .scriptInstance<ResourceAssignmentProcessor>( - raRuntimeService.bluePrintContext(), scriptType, - scriptClassReference - ) + val scriptComponent = componentFunctionScriptingService + .scriptInstance<ResourceAssignmentProcessor>( + raRuntimeService.bluePrintContext(), scriptType, + scriptClassReference + ) - return scriptComponent - } + return scriptComponent + } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt index 2640b5b85..0417024d3 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt @@ -18,15 +18,15 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService -import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty +import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -68,8 +68,10 @@ open class DatabaseResourceAssignmentProcessor( ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed to process Database resource resolution in template key ($resourceAssignment) assignments." - throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, - "Wrong resource definition or DB resolution failed.") + throw e.updateErrorMessage( + ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, + "Wrong resource definition or DB resolution failed." + ) } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e) @@ -99,13 +101,13 @@ open class DatabaseResourceAssignmentProcessor( } sourceProperties.inputKeyMapping - ?.mapValues { raRuntimeService.getDictionaryStore(it.value) } - ?.map { KeyIdentifier(it.key, it.value) } - ?.let { resourceAssignment.keyIdentifiers.addAll(it) } + ?.mapValues { raRuntimeService.getDictionaryStore(it.value) } + ?.map { KeyIdentifier(it.key, it.value) } + ?.let { resourceAssignment.keyIdentifiers.addAll(it) } logger.info( "DatabaseResource ($dSource) dictionary information: " + - "Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" + "Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" ) val jdbcTemplate = blueprintDBLibService(sourceProperties, dSource) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt index 2921cb6fb..892d8fbc9 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt @@ -53,8 +53,10 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() { ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed to process default resource resolution in template key ($resourceAssignment) assignments." - throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, - "Wrong default value was set.") + throw e.updateErrorMessage( + ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, + "Wrong default value was set." + ) } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt index d078a2d70..131e2ae9a 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt @@ -52,8 +52,10 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() { ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed to process input resource resolution in template key ($resourceAssignment) assignments." - throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, - "Wrong input value was set.") + throw e.updateErrorMessage( + ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, + "Wrong input value was set." + ) } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with : (${e.message})", e) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt index 0c0735ff0..cffc5e3bf 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt @@ -106,12 +106,12 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig open suspend fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: MutableMap<String, JsonNode>): String { - if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) { - return valueToResolve + if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) { + return valueToResolve + } + // TODO("Optimize to JSON Node directly without velocity").asJsonNode().toString() + return BluePrintVelocityTemplateService.generateContent(valueToResolve, keyMapping.asJsonNode().toString()) } - // TODO("Optimize to JSON Node directly without velocity").asJsonNode().toString() - return BluePrintVelocityTemplateService.generateContent(valueToResolve, keyMapping.asJsonNode().toString()) - } final override suspend fun applyNB(resourceAssignment: ResourceAssignment): Boolean { try { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt index c60bc7648..c2cf30247 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt @@ -23,10 +23,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.util import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty +import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -80,8 +80,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping).toMutableMap() inputKeyMapping?.mapValues { raRuntimeService.getDictionaryStore(it.value) } - ?.map { KeyIdentifier(it.key, it.value) } - ?.let { resourceAssignment.keyIdentifiers.addAll(it) } + ?.map { KeyIdentifier(it.key, it.value) } + ?.let { resourceAssignment.keyIdentifiers.addAll(it) } // Resolving content Variables val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping) @@ -92,7 +92,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS logger.info( "RestResource ($dSource) dictionary information: " + - "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" + "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" ) val requestHeaders = sourceProperties.headers logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") @@ -120,8 +120,10 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS } catch (e: BluePrintProcessorException) { val errorMsg = "Failed to process REST resource resolution in template key ($resourceAssignment) assignments." ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, errorMsg) - throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, - "Wrong resource definition or resolution failed.") + throw e.updateErrorMessage( + ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, + "Wrong resource definition or resolution failed." + ) } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt index 1be9649b9..54231da61 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt @@ -93,7 +93,7 @@ class ResourceAssignmentUtils { resourceAssignment.dictionaryName = resourceAssignment.name logger.warn( "Missing dictionary key, setting with template key (${resourceAssignment.name}) " + - "as dictionary key (${resourceAssignment.dictionaryName})" + "as dictionary key (${resourceAssignment.dictionaryName})" ) } @@ -103,8 +103,8 @@ class ResourceAssignmentUtils { val valueToPrint = getValueToLog(metadata, value) logger.info( "Setting Resource Value ($valueToPrint) for Resource Name " + - "(${resourceAssignment.name}), definition(${resourceAssignment.dictionaryName}) " + - "of type (${resourceProp.type})" + "(${resourceAssignment.name}), definition(${resourceAssignment.dictionaryName}) " + + "of type (${resourceProp.type})" ) setResourceValue(resourceAssignment, raRuntimeService, value) resourceAssignment.updatedDate = Date() @@ -114,8 +114,9 @@ class ResourceAssignmentUtils { } catch (e: Exception) { throw BluePrintProcessorException( "Failed in setting value for template key " + - "(${resourceAssignment.name}) and dictionary key (${resourceAssignment.dictionaryName}) of " + - "type (${resourceProp.type}) with error message (${e.message})", e + "(${resourceAssignment.name}) and dictionary key (${resourceAssignment.dictionaryName}) of " + + "type (${resourceProp.type}) with error message (${e.message})", + e ) } } @@ -132,29 +133,32 @@ class ResourceAssignmentUtils { val metadata = resourceAssignment.property?.metadata metadata?.get(ResourceResolutionConstants.METADATA_TRANSFORM_TEMPLATE) - ?.let { if (it.contains("$")) it else null } - ?.let { template -> - val resolutionStore = raRuntimeService.getResolutionStore() - .mapValues { e -> e.value.asText() } as MutableMap<String, Any> - val newValue: JsonNode - try { - newValue = BluePrintVelocityTemplateService - .generateContent(template, null, true, resolutionStore) - .also { if (hasLogProtect(metadata)) - logger.info("Transformed value: $resourceAssignment.name") - else - logger.info("Transformed value: $value -> $it") } - .let { v -> v.asJsonType() } - } catch (e: Exception) { - throw BluePrintProcessorException( - "transform-template failed: $template", e) - } - with(resourceAssignment) { - raRuntimeService.putResolutionStore(this.name, newValue) - raRuntimeService.putDictionaryStore(this.dictionaryName!!, newValue) - this.property!!.value = newValue - } + ?.let { if (it.contains("$")) it else null } + ?.let { template -> + val resolutionStore = raRuntimeService.getResolutionStore() + .mapValues { e -> e.value.asText() } as MutableMap<String, Any> + val newValue: JsonNode + try { + newValue = BluePrintVelocityTemplateService + .generateContent(template, null, true, resolutionStore) + .also { + if (hasLogProtect(metadata)) + logger.info("Transformed value: $resourceAssignment.name") + else + logger.info("Transformed value: $value -> $it") + } + .let { v -> v.asJsonType() } + } catch (e: Exception) { + throw BluePrintProcessorException( + "transform-template failed: $template", e + ) } + with(resourceAssignment) { + raRuntimeService.putResolutionStore(this.name, newValue) + raRuntimeService.putDictionaryStore(this.dictionaryName!!, newValue) + this.property!!.value = newValue + } + } } fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) { @@ -199,7 +203,7 @@ class ResourceAssignmentUtils { } } result = mapper.writerWithDefaultPrettyPrinter() - .writeValueAsString(mapper.treeToValue(root, Object::class.java)) + .writeValueAsString(mapper.treeToValue(root, Object::class.java)) if (!containsLogProtected) { logger.info("Generated Resource Param Data ($result)") @@ -238,35 +242,35 @@ class ResourceAssignmentUtils { val definition = resourceDefinitions[it.name] val description = definition?.property?.description ?: "" val value = it.property?.value - ?.let { v -> if (v.isNullOrMissing()) emptyTextNode else v } - ?: emptyTextNode + ?.let { v -> if (v.isNullOrMissing()) emptyTextNode else v } + ?: emptyTextNode var payload: JsonNode = definition?.sources?.get(it.dictionarySource) - ?.properties?.get("resolved-payload") - ?.let { p -> if (p.isNullOrMissing()) emptyTextNode else p } - ?: emptyTextNode + ?.properties?.get("resolved-payload") + ?.let { p -> if (p.isNullOrMissing()) emptyTextNode else p } + ?: emptyTextNode val metadata = definition?.property?.metadata - ?.map { e -> DictionaryMetadataEntry(e.key, e.value) } - ?.toMutableList() ?: mutableListOf() + ?.map { e -> DictionaryMetadataEntry(e.key, e.value) } + ?.toMutableList() ?: mutableListOf() val keyIdentifiers: MutableList<KeyIdentifier> = it.keyIdentifiers.map { k -> if (k.value.isNullOrMissing()) KeyIdentifier(k.name, emptyTextNode) else k }.toMutableList() ResolutionSummary( - it.name, - value, - it.property?.required ?: false, - it.property?.type ?: "", - keyIdentifiers, - description, - metadata, - it.dictionaryName ?: "", - it.dictionarySource ?: "", - payload, - it.status ?: "", - it.message ?: "" + it.name, + value, + it.property?.required ?: false, + it.property?.type ?: "", + keyIdentifiers, + description, + metadata, + it.dictionaryName ?: "", + it.dictionarySource ?: "", + payload, + it.status ?: "", + it.message ?: "" ) } // Wrapper needed for integration with SDNC @@ -409,7 +413,7 @@ class ResourceAssignmentUtils { if ((resourceAssignment.property?.entrySchema?.type).isNullOrEmpty()) { throw BluePrintProcessorException( "Couldn't get data type for dictionary type " + - "(${resourceAssignment.property!!.type}) and dictionary name ($dName)" + "(${resourceAssignment.property!!.type}) and dictionary name ($dName)" ) } val entrySchemaType = resourceAssignment.property!!.entrySchema!!.type @@ -487,7 +491,7 @@ class ResourceAssignmentUtils { val outputKeyMap = outputKeyMapping.entries.first() if (resourceAssignment.keyIdentifiers.none { it.name == outputKeyMap.key }) { resourceAssignment.keyIdentifiers.add( - KeyIdentifier(outputKeyMap.key, JacksonUtils.objectMapper.createArrayNode()) + KeyIdentifier(outputKeyMap.key, JacksonUtils.objectMapper.createArrayNode()) ) } return parseSingleElementNodeWithOneOutputKeyMapping( @@ -576,13 +580,14 @@ class ResourceAssignmentUtils { logKeyValueResolvedResource(metadata, outputKeyMappingKey, responseKeyValue, type) JacksonUtils.populateJsonNodeValues(outputKeyMappingKey, responseKeyValue, type, arrayChildNode) resourceAssignment.keyIdentifiers.find { it.name == outputKeyMappingKey && it.value.isArray } - .let { - if (it != null) - (it.value as ArrayNode).add(responseKeyValue) - else - resourceAssignment.keyIdentifiers.add( - KeyIdentifier(outputKeyMappingKey, responseKeyValue)) - } + .let { + if (it != null) + (it.value as ArrayNode).add(responseKeyValue) + else + resourceAssignment.keyIdentifiers.add( + KeyIdentifier(outputKeyMappingKey, responseKeyValue) + ) + } return arrayChildNode } @@ -694,7 +699,7 @@ class ResourceAssignmentUtils { logger.info( "For List Type Resource: key ($key), value ($valueToPrint), " + - "type ({$type})" + "type ({$type})" ) } @@ -703,6 +708,6 @@ class ResourceAssignmentUtils { } fun getValueToLog(metadata: MutableMap<String, String>?, value: Any): Any = - if (hasLogProtect(metadata)) LOG_REDACTED else value + if (hasLogProtect(metadata)) LOG_REDACTED else value } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt index d3641a850..1bf854cbd 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt @@ -45,47 +45,48 @@ object ResourceDefinitionUtils { resolveDefinition: String, sources: List<String> ): - MutableList<ResourceAssignment> { - /** Check if resolve definition is defined in the resource definition Map */ - val resourceDefinition = resourceDefinitions[resolveDefinition] - ?: throw BluePrintProcessorException("failed to get resolve definition($resolveDefinition)") + MutableList<ResourceAssignment> { + /** Check if resolve definition is defined in the resource definition Map */ + val resourceDefinition = resourceDefinitions[resolveDefinition] + ?: throw BluePrintProcessorException("failed to get resolve definition($resolveDefinition)") - val resourceAssignments: MutableList<ResourceAssignment> = arrayListOf() - /** Get the dependency property fields for the the resource definition to resolve */ - val definitionDependencies = definitionDependencies(resourceDefinition, sources) - definitionDependencies.forEach { definitionDependencyName -> - val definitionDependency = resourceDefinitions[definitionDependencyName] - ?: throw BluePrintProcessorException("failed to get dependency definition($definitionDependencyName)") + val resourceAssignments: MutableList<ResourceAssignment> = arrayListOf() - val resourceAssignment = ResourceAssignment().apply { - name = definitionDependency.name - dictionaryName = definitionDependency.name - /** The assumption is al resource are already resolved and shall get as input source */ - dictionarySource = "input" - property = definitionDependency.property - } - resourceAssignments.add(resourceAssignment) - } + /** Get the dependency property fields for the the resource definition to resolve */ + val definitionDependencies = definitionDependencies(resourceDefinition, sources) + definitionDependencies.forEach { definitionDependencyName -> + val definitionDependency = resourceDefinitions[definitionDependencyName] + ?: throw BluePrintProcessorException("failed to get dependency definition($definitionDependencyName)") - resourceDefinition.sources.forEach { (sourceName, source) -> - if (sources.contains(sourceName)) { val resourceAssignment = ResourceAssignment().apply { - name = "$sourceName:${resourceDefinition.name}" - dictionaryName = resourceDefinition.name - dictionarySource = sourceName - dictionarySourceDefinition = source - // Clone the PropertyDefinition, otherwise property value will be overridden - property = JacksonUtils - .readValue(resourceDefinition.property.asJsonString(), PropertyDefinition::class.java) - val keyDependenciesExists = source.properties?.containsKey("key-dependencies") ?: false - if (keyDependenciesExists) { - dependencies = source.properties!!["key-dependencies"]!!.asListOfString().toMutableList() - } + name = definitionDependency.name + dictionaryName = definitionDependency.name + /** The assumption is al resource are already resolved and shall get as input source */ + dictionarySource = "input" + property = definitionDependency.property } resourceAssignments.add(resourceAssignment) } + + resourceDefinition.sources.forEach { (sourceName, source) -> + if (sources.contains(sourceName)) { + val resourceAssignment = ResourceAssignment().apply { + name = "$sourceName:${resourceDefinition.name}" + dictionaryName = resourceDefinition.name + dictionarySource = sourceName + dictionarySourceDefinition = source + // Clone the PropertyDefinition, otherwise property value will be overridden + property = JacksonUtils + .readValue(resourceDefinition.property.asJsonString(), PropertyDefinition::class.java) + val keyDependenciesExists = source.properties?.containsKey("key-dependencies") ?: false + if (keyDependenciesExists) { + dependencies = source.properties!!["key-dependencies"]!!.asListOfString().toMutableList() + } + } + resourceAssignments.add(resourceAssignment) + } + } + // Populate Resource Definition's dependencies as Input Resource Assignment + return resourceAssignments } - // Populate Resource Definition's dependencies as Input Resource Assignment - return resourceAssignments - } } |