X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ms%2Fblueprintsprocessor%2Ffunctions%2Fresource-resolution%2Fsrc%2Fmain%2Fkotlin%2Forg%2Fonap%2Fccsdk%2Fcds%2Fblueprintsprocessor%2Ffunctions%2Fresource%2Fresolution%2Fprocessor%2FRestResourceResolutionProcessor.kt;h=c2cf302473483a66b2857b4753c7c62610129ece;hb=1072867dfac0df993cbd3e44bcc11a5cac7465fd;hp=8f933c1cb6fe8caae5dc6307787b37c9d711e4a8;hpb=efb012bfb4f951ed2619baecdfcfa4b412dfb71d;p=ccsdk%2Fcds.git diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt index 8f933c1cb..c2cf30247 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt @@ -23,9 +23,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.util import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty +import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -78,10 +79,9 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" } val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping).toMutableMap() - sourceProperties.inputKeyMapping - ?.mapValues { raRuntimeService.getDictionaryStore(it.value) } - ?.map { KeyIdentifier(it.key, it.value) } - ?.let { resourceAssignment.keyIdentifiers.addAll(it) } + inputKeyMapping?.mapValues { raRuntimeService.getDictionaryStore(it.value) } + ?.map { KeyIdentifier(it.key, it.value) } + ?.let { resourceAssignment.keyIdentifiers.addAll(it) } // Resolving content Variables val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping) @@ -92,7 +92,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS logger.info( "RestResource ($dSource) dictionary information: " + - "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" + "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})" ) val requestHeaders = sourceProperties.headers logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") @@ -104,6 +104,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS val responseBody = response.body val outputKeyMapping = sourceProperties.outputKeyMapping if (responseStatusCode in 200..299 && outputKeyMapping.isNullOrEmpty()) { + resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS logger.info("AS>> outputKeyMapping==null, will not populateResource") } else if (responseStatusCode in 200..299 && !responseBody.isBlank()) { populateResource(resourceAssignment, sourceProperties, responseBody, path) @@ -118,8 +119,11 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed to process REST resource resolution in template key ($resourceAssignment) assignments." - throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, - "Wrong resource definition or resolution failed.") + ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, errorMsg) + throw e.updateErrorMessage( + ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg, + "Wrong resource definition or resolution failed." + ) } catch (e: Exception) { ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)