From 75607716182fe6b0dbf333bdfe1271a6398e827a Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 12 Mar 2019 15:53:55 -0400 Subject: Empty MissingNode from input during RR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib09e5403b17d62d61272e64a6c990de42b1aa58f Issue-ID: CCSDK-1137 Signed-off-by: Alexis de Talhouët --- .../processor/DatabaseResourceAssignmentProcessor.kt | 8 +++----- .../processor/DefaultResourceResolutionProcessor.kt | 16 ++++------------ .../resolution/processor/ResourceAssignmentProcessor.kt | 13 +++++++++++++ .../processor/RestResourceResolutionProcessor.kt | 10 ++++------ 4 files changed, 24 insertions(+), 23 deletions(-) (limited to 'ms') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt index bac76e72..c76bff32 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import com.fasterxml.jackson.databind.node.JsonNodeFactory +import com.fasterxml.jackson.databind.node.MissingNode import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR @@ -59,11 +60,8 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: validate(resourceAssignment) // Check if It has Input - try { - val value = raRuntimeService.getInputValue(resourceAssignment.name) - logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)") - ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value) - } catch (e: BluePrintProcessorException) { + val value = getFromInput(resourceAssignment) + if (value == null || value is MissingNode) { val dName = resourceAssignment.dictionaryName val dSource = resourceAssignment.dictionarySource val resourceDefinition = resourceDictionaries[dName] diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt index 528705f1..d487eab6 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor -import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.MissingNode import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException @@ -44,19 +44,11 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() { override fun process(resourceAssignment: ResourceAssignment) { try { - // Check if It has Input - var value: JsonNode? - try { - value = raRuntimeService.getInputValue(resourceAssignment.name) - } catch (e: BluePrintProcessorException) { - // If value is null get it from default source - logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})") + var value = getFromInput(resourceAssignment) + if (value == null || value is MissingNode) { value = resourceAssignment.property?.defaultValue + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value) } - - 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) { 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 3022ca52..64cc1d2d 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 @@ -17,8 +17,10 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor +import com.fasterxml.jackson.databind.JsonNode import org.apache.commons.collections.MapUtils import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService +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.core.interfaces.BlueprintFunctionNode import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService @@ -45,6 +47,17 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode { // Complex Types entrySchemaType = - returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" } + returnNotEmptyOrThrow(resourceAssignment.property?.type) { "Entry schema is not defined for dictionary ($dName) info" } val objectNode = JsonNodeFactory.instance.objectNode() outputKeyMapping.map { val responseKeyValue = responseNode.get(it.key) -- cgit 1.2.3-korg