RestResourceResolutionProcessor should always set Status
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / resource-resolution / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / resource / resolution / processor / RestResourceResolutionProcessor.kt
index 8f933c1..c60bc76 100644 (file)
@@ -24,6 +24,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPrope
 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.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
 import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
 import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
@@ -78,8 +79,7 @@ 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) }
+                inputKeyMapping?.mapValues { raRuntimeService.getDictionaryStore(it.value) }
                         ?.map { KeyIdentifier(it.key, it.value) }
                         ?.let { resourceAssignment.keyIdentifiers.addAll(it) }
 
@@ -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,6 +119,7 @@ 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."
+            ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, errorMsg)
             throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg,
                     "Wrong resource definition or resolution failed.")
         } catch (e: Exception) {