summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-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 1c5455fd..e389f362 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