diff options
author | Dan Timoney <dtimoney@att.com> | 2019-03-18 18:30:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-18 18:30:49 +0000 |
commit | f24666c55d17ef296746ea103218d1c489380a00 (patch) | |
tree | d5096fda46c8a32f411abbae7018213a76873e78 /ms | |
parent | a0f6c597b54f42e141be6f41c6b228f4dc3ee988 (diff) | |
parent | d60057a77e7ac601d3796096f36c4b9ca585d1a5 (diff) |
Merge "Propagate exceptions correctly"0.4.1
Diffstat (limited to 'ms')
11 files changed, 51 insertions, 16 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt index 819fe3f8..98d8c65d 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt @@ -57,6 +57,6 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re } override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + bluePrintRuntimeService.getBluePrintError().addError(runtimeException.message!!) } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt index 335aea1e..620696f8 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt @@ -182,6 +182,9 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries // Invoke Apply Method resourceAssignmentProcessor.apply(resourceAssignment) + + // Set errors from RA + blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError()) } catch (e: RuntimeException) { throw BluePrintProcessorException(e) } 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 c76bff32..e38a1cca 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 @@ -170,5 +170,6 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: } override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError(runtimeException.message!!) } }
\ No newline at end of file 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 d487eab6..0f51e4bf 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 @@ -60,5 +60,6 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() { } override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError(runtimeException.message!!) } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt index a6622228..579989a6 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt @@ -63,5 +63,6 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() { } override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError(runtimeException.message!!) } }
\ No newline at end of file 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 8e9606c4..3f0c1b4f 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 @@ -30,7 +30,7 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import org.slf4j.LoggerFactory import java.util.* -abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> { +abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, Boolean> { private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java) @@ -89,12 +89,12 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig return resourceAssignment } - override fun prepareResponse(): ResourceAssignment { + override fun prepareResponse(): Boolean { log.info("Preparing Response...") - return ResourceAssignment() + return true } - override fun apply(resourceAssignment: ResourceAssignment): ResourceAssignment { + override fun apply(resourceAssignment: ResourceAssignment): Boolean { try { prepareRequest(resourceAssignment) process(resourceAssignment) @@ -104,4 +104,12 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig return prepareResponse() } + fun addError(type: String, name: String, error: String) { + raRuntimeService.getBluePrintError().addError(type, name, error) + } + + fun addError(error: String) { + raRuntimeService.getBluePrintError().addError(error) + } + }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt index f279f544..091220b5 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt @@ -197,6 +197,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS } override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError(runtimeException.message!!) } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt index 6da3fd71..5a14a296 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService @@ -48,6 +49,7 @@ class CapabilityResourceResolutionProcessorTest { @Autowired lateinit var capabilityResourceResolutionProcessor: CapabilityResourceResolutionProcessor + @Ignore @Test fun `test kotlin capability`() { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt index d8afe168..05a569cb 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt @@ -23,7 +23,11 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration -import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.* +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.saveCBAFile import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType @@ -37,6 +41,7 @@ import org.slf4j.LoggerFactory import org.springframework.http.codec.multipart.FilePart import org.springframework.stereotype.Service import reactor.core.publisher.Mono +import java.util.stream.Collectors @Service class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration, @@ -75,8 +80,8 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC responseObserver.onCompleted() } else -> responseObserver.onNext(response(executionServiceInput, - "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", - true).toProto()); + "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", + true).toProto()); } } @@ -94,8 +99,23 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString()) - return bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService, - executionServiceInput, hashMapOf()) + val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService, + executionServiceInput, hashMapOf()) + + val errors = blueprintRuntimeService.getBluePrintError().errors + if (errors.isNotEmpty()) { + val errorMessage = errors.stream().map { it.toString() }.collect(Collectors.joining(", ")) + setErrorStatus(errorMessage, output.status) + } + + return output + } + + private fun setErrorStatus(errorMessage: String, status: Status) { + status.errorMessage = errorMessage + status.eventType = EventType.EVENT_COMPONENT_FAILURE.name + status.code = 500 + status.message = BluePrintConstants.STATUS_FAILURE } private fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "", @@ -106,11 +126,8 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC executionServiceOutput.payload = JsonNodeFactory.instance.objectNode() val status = Status() - status.errorMessage = errorMessage if (failure) { - status.eventType = EventType.EVENT_COMPONENT_FAILURE.name - status.code = 500 - status.message = BluePrintConstants.STATUS_FAILURE + setErrorStatus(errorMessage, status) } else { status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name status.code = 200 @@ -121,4 +138,5 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC return executionServiceOutput } + }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt index 8778b1fc..4c381706 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt @@ -138,7 +138,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic }
fun addError(type: String, name: String, error: String) {
- bluePrintRuntimeService.getBluePrintError().addError(type, name, type)
+ bluePrintRuntimeService.getBluePrintError().addError(type, name, error)
}
fun addError(error: String) {
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index 62ed4047..d33a2f04 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -24,7 +24,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict object ResourceDictionaryConstants { const val SOURCE_INPUT = "input" const val SOURCE_DEFAULT = "default" - const val SOURCE_PRIMARY_CONFIG_DATA = "rest" + const val SOURCE_PRIMARY_CONFIG_DATA = "primary-config-data" const val SOURCE_PRIMARY_DB = "primary-db" const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" |