diff options
author | Dan Timoney <dtimoney@att.com> | 2019-01-19 22:48:57 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-19 22:48:57 +0000 |
commit | ee33dbe0c997273cb3e2c43776af975ae6fc3c88 (patch) | |
tree | d866b8b4833f15c89a0cde96ee6f4fe90cf434be /ms | |
parent | 278ed8924d2d1e1a1b1bfc84b6d0408383c8c939 (diff) | |
parent | 2d9b6df9822b522c4094aeba54edc888badb58ae (diff) |
Merge "Resource Resolution Service: Source Default"
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.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 |