From fb0e9f71db43ffaa05d987b03c857887c520e739 Mon Sep 17 00:00:00 2001 From: Oleg Mitsura Date: Tue, 13 Oct 2020 12:20:44 -0400 Subject: master: missing input shouldn't fail process Issue-ID: CCSDK-2876 Signed-off-by: Oleg Mitsura Change-Id: I76279fee8adc91a3aed72c624c24e93c9cf9dea4 --- .../resolution/ResourceSourceProperties.kt | 2 +- .../processor/InputResourceResolutionProcessor.kt | 35 ++++++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'ms/blueprintsprocessor') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt index e2fef746b..4c38517a7 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt @@ -53,7 +53,7 @@ open class DatabaseResourceSource : ResourceSourceProperties() { var outputKeyMapping: MutableMap? = null @get:JsonProperty("key-dependencies") - lateinit var keyDependencies: MutableList + var keyDependencies: MutableList? = null } open class RestResourceSource : ResourceSourceProperties() { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt index 131e2ae9a..21098797b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt @@ -20,12 +20,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.pro import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty -import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope import org.springframework.stereotype.Service @@ -38,6 +37,9 @@ import org.springframework.stereotype.Service @Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() { + companion object InputResourceResolutionProcessor { + private val logger = LoggerFactory.getLogger(InputResourceResolutionProcessor::class.toString()) + } override fun getName(): String { return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input" @@ -52,10 +54,8 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() { ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed to process input resource resolution in template key ($resourceAssignment) assignments." - throw e.updateErrorMessage( - ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, - "Wrong input value was set." - ) + ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) + logger.error(errorMsg) } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with : (${e.message})", e) @@ -72,17 +72,22 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() { val resourceSource = resourceAssignment.dictionarySourceDefinition ?: resourceDefinition?.sources?.get(dSource) ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)") - val resourceSourceProperties = checkNotNull(resourceSource.properties) { - "failed to get source properties for $dName " - } - val sourceProperties = - JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java) + try { - val keyDependency = checkNotNull(sourceProperties.keyDependencies) { - "failed to get input-key-mappings for $dName under $dSource properties" + val resourceSourceProperties = checkNotNull(resourceSource.properties) { + "failed to get source properties for $dName " + } + val sourceProperties = + JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java) + + val keyDependency = checkNotNull(sourceProperties.keyDependencies) { + "failed to get input-key-mappings for $dName under $dSource properties" + } + // keyDependency = service-instance.service-instance-id + setFromInputKeyDependencies(keyDependency, resourceAssignment); // New API which picks attribute from Input + } catch (e: IllegalStateException) { + throw BluePrintProcessorException(e) } - // keyDependency = service-instance.service-instance-id - setFromInputKeyDependencies(keyDependency, resourceAssignment); // New API which picks arrtibute from Input } override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { -- cgit 1.2.3-korg