summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-01-18 12:04:42 -0500
committerSingal, Kapil (ks220y) <ks220y@att.com>2019-01-18 12:11:33 -0500
commite49d988bf86cf4a7cc35088f489cbea9db2316c2 (patch)
treeee75fdbaf0a4c4d2d30dede6948789b172de46ab /ms/blueprintsprocessor/functions/resource-resolution
parent2412483e9da46895f05ba118802759580e7a926e (diff)
Resource Resolution Service: Source Default
Complex Data Processing for Default DataSource Resource Resolution Service Change-Id: Idc2007695cb65e76e128d7abd75bdbfd37138be6 Issue-ID: CCSDK-676 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt32
1 files changed, 29 insertions, 3 deletions
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/DefaultResourceAssignmentProcessor.kt
index 1c5455fd1..e389f362a 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/DefaultResourceAssignmentProcessor.kt
@@ -17,24 +17,50 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.node.NullNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
/**
* DefaultResourceAssignmentProcessor
*
- * @author Brinda Santh
+ * @author Kapil Singal
*/
@Service("resource-assignment-processor-default")
open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+ private val logger = LoggerFactory.getLogger(DefaultResourceAssignmentProcessor::class.java)
+
override fun getName(): String {
return "resource-assignment-processor-default"
}
- override fun process(executionRequest: ResourceAssignment) {
+ override fun process(resourceAssignment: ResourceAssignment) {
+ try {
+ // Check if It has Input
+ var value: Any? = raRuntimeService.getInputValue(resourceAssignment.name)
+
+ // If value is null get it from default source
+ if (value == null || value is NullNode) {
+ logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})")
+ value = resourceAssignment.property?.defaultValue
+ }
+
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($value)")
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+
+ // Check the value has populated for mandatory case
+ ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: Exception) {
+ ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ }
+
}
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
}
} \ No newline at end of file