aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/main
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-03-04 19:41:14 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-04 19:41:14 +0000
commit15a0d9eac08da12e82eaf07b7d50a48f1d87039c (patch)
tree4143f2958adc9f1288e751bed016cf2438b95dbd /ms/blueprintsprocessor/functions/resource-resolution/src/main
parent8981bb7fdd7b567a85992d295275ec6cf9467daf (diff)
parent50fb805cd04593426f6c8e23a40f51398099e183 (diff)
Merge "Get DSL Property in Resource Resolution"
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt58
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt11
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt)37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt)28
9 files changed, 129 insertions, 56 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index 5765609b..ca92e96d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -20,7 +20,7 @@ class ResourceResolutionConstants {
companion object {
const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
- const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 24401ccf..48415efa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -21,6 +21,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pro
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -59,8 +60,8 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
@@ -123,6 +124,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedContent
}
+ /**
+ * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the
+ * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
+ * request.
+ */
override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
resourceDictionaries: MutableMap<String, ResourceDefinition>,
resourceAssignments: MutableList<ResourceAssignment>,
@@ -133,12 +139,17 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .map { resourceAssignment ->
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
val dictionarySource = resourceAssignment.dictionarySource
- val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
-
- val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!,
+ resourceDictionaries)
+
+ val resourceAssignmentProcessor = applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
"for resource assignment(${resourceAssignment.name})")
try {
// Set BluePrint Runtime Service
@@ -155,4 +166,37 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
}
+
+ /**
+ * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
+ * derive the default input processor.
+ */
+ private fun processorName(dictionaryName: String, dictionarySource: String,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
+ var processorName: String? = null
+ when (dictionarySource) {
+ "input" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+ }
+ "default" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+ }
+ else -> {
+ val resourceDefinition = resourceDictionaries[dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+
+ val resourceSource = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+
+ processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
+ .plus(resourceSource.type)
+ }
+ }
+ checkNotEmptyOrThrow(processorName,
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
+
+ return processorName
+
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 0f1267cb..1c357446 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -36,6 +36,8 @@ open class DefaultResourceSource : ResourceSourceProperties() {
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
@@ -47,6 +49,8 @@ open class DatabaseResourceSource : ResourceSourceProperties() {
open class RestResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
@get:JsonProperty("url-path")
lateinit var urlPath: String
lateinit var path: String
@@ -61,9 +65,10 @@ open class RestResourceSource : ResourceSourceProperties() {
}
open class CapabilityResourceSource : ResourceSourceProperties() {
- lateinit var type: String
- @get:JsonProperty("instance-name")
- lateinit var instanceName: String
+ @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")
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index 489645fd..c6b7d77e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -18,30 +18,27 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.io.File
-@Service("resource-assignment-processor-capability")
-open class CapabilityResourceAssignmentProcessor(private var applicationContext: ApplicationContext,
+@Service("rr-processor-source-capability")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class CapabilityResourceResolutionProcessor(private var applicationContext: ApplicationContext,
private val bluePrintScriptsService: BluePrintScriptsService,
private val bluePrintJythonService: BlueprintJythonService) :
ResourceAssignmentProcessor() {
- companion object {
- const val CAPABILITY_TYPE_KOTLIN_COMPONENT = "KOTLIN-COMPONENT"
- const val CAPABILITY_TYPE_JAVA_COMPONENT = "JAVA-COMPONENT"
- const val CAPABILITY_TYPE_JYTHON_COMPONENT = "JYTHON-COMPONENT"
- }
-
override fun getName(): String {
return "resource-assignment-processor-capability"
}
@@ -62,28 +59,28 @@ open class CapabilityResourceAssignmentProcessor(private var applicationContext:
val capabilityResourceSourceProperty = JacksonUtils
.getInstanceFromMap(resourceSourceProps, CapabilityResourceSource::class.java)
- val instanceType = capabilityResourceSourceProperty.type
- val instanceName = capabilityResourceSourceProperty.instanceName
+ val scriptType = capabilityResourceSourceProperty.scriptType
+ val scriptClassReference = capabilityResourceSourceProperty.scriptClassReference
var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
- when (instanceType) {
- CAPABILITY_TYPE_KOTLIN_COMPONENT -> {
- componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(instanceName,
+ when (scriptType) {
+ BluePrintConstants.SCRIPT_KOTLIN -> {
+ componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(scriptClassReference,
capabilityResourceSourceProperty.instanceDependencies)
}
- CAPABILITY_TYPE_JAVA_COMPONENT -> {
+ BluePrintConstants.SCRIPT_INTERNAL -> {
// Initialize Capability Resource Assignment Processor
- componentResourceAssignmentProcessor = applicationContext.getBean(instanceName, ResourceAssignmentProcessor::class.java)
+ componentResourceAssignmentProcessor = applicationContext.getBean(scriptClassReference, ResourceAssignmentProcessor::class.java)
}
- CAPABILITY_TYPE_JYTHON_COMPONENT -> {
- val content = getJythonContent(instanceName)
- componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(instanceName,
+ BluePrintConstants.SCRIPT_JYTHON -> {
+ val content = getJythonContent(scriptClassReference)
+ componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(scriptClassReference,
content, capabilityResourceSourceProperty.instanceDependencies)
}
}
- checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
+ checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($scriptClassReference)" }
// Assign Current Blueprint runtime and ResourceDictionaries
componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index e389f362..f23ada98 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -22,20 +22,23 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.uti
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * DefaultResourceAssignmentProcessor
+ * DefaultResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-default")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(DefaultResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(DefaultResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-default"
+ return "rr-processor-source-default"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index 5757de2a..ed6b09fc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -23,20 +23,23 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * InputResourceAssignmentProcessor
+ * InputResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-input")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(InputResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(InputResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-input"
+ return "rr-processor-source-input"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
index 876c75fa..7da22b03 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
@@ -28,22 +28,25 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.util.*
/**
- * PrimaryDataResourceAssignmentProcessor
+ * PrimaryDataResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-db")
-open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
+@Service("rr-processor-source-primary-db")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(PrimaryDataResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(PrimaryDataResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-db"
+ return "rr-processor-source-primary-db"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index b07155a3..9b7c70aa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -57,9 +57,13 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return ResourceAssignment()
}
- override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
- prepareRequest(executionServiceInput)
- process(executionServiceInput)
+ override fun apply(resourceAssignment: ResourceAssignment): ResourceAssignment {
+ try {
+ prepareRequest(resourceAssignment)
+ process(resourceAssignment)
+ } catch (runtimeException: RuntimeException) {
+ recover(runtimeException, resourceAssignment)
+ }
return prepareResponse()
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index a264ba50..4daa46e5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -24,26 +24,30 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * SimpleRestResourceAssignmentProcessor
+ * RestResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-config-data")
-open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
+@Service("rr-processor-source-rest")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(SimpleRestResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(RestResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-config-data"
+ return "rr-processor-source-rest"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -70,8 +74,8 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
- // TODO("Dynamic Rest Client Service, call (blueprintDynamicWebClientService || blueprintWebClientService")
- val restClientService = blueprintRestLibPropertyService.blueprintWebClientService("primary-config-data")
+ // Get the Rest Client Service
+ val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
val response = restClientService.getResource(urlPath, String::class.java)
if (response.isNotBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
@@ -87,6 +91,16 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
}
}
+ open fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
+ restResourceSource: RestResourceSource): BlueprintWebClientService {
+ return if (checkNotEmpty(restResourceSource.endpointSelector)) {
+ val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!)
+ blueprintRestLibPropertyService.blueprintWebClientService(restPropertiesJson)
+ } else {
+ blueprintRestLibPropertyService.blueprintWebClientService(resourceAssignment.dictionarySource!!)
+ }
+ }
+
@Throws(BluePrintProcessorException::class)
private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, restResponse: String, path: String) {
val dName = resourceAssignment.dictionaryName