diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2019-01-18 12:04:42 -0500 |
---|---|---|
committer | Singal, Kapil (ks220y) <ks220y@att.com> | 2019-01-18 12:11:33 -0500 |
commit | 2d9b6df9822b522c4094aeba54edc888badb58ae (patch) | |
tree | 9af882212ffd16e807431d18dfc5934cc887e72b /ms/blueprintsprocessor/functions/resource-resolution | |
parent | 78702c12bd0b6cb8ec0fd621f27fa61c9a017fbe (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.kt | 32 |
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 |