From: Oleg Mitsura Date: Wed, 22 Jan 2020 19:23:17 +0000 (-0500) Subject: Enhancement better error messages. X-Git-Tag: 0.7.0~69^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F22%2F100622%2F1;p=ccsdk%2Fcds.git Enhancement better error messages. Issue-ID: CCSDK-2036 rev1: initial commit. Signed-off-by: Oleg Mitsura Change-Id: I0bc31a2a17a6dfedbb1870470e8bf6304be782b5 --- diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt index 535021b34..b657199c7 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -164,8 +164,17 @@ interface BluePrintTypeEnhancerService { bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap ) { + val errorMap = linkedMapOf() properties.forEach { propertyName, propertyDefinition -> - enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) + try { + enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) + } catch (e: BluePrintException) { + errorMap[propertyName] = e + } + } + if (errorMap.isNotEmpty()) { + val nestedErrors = errorMap.keys.map { "[ property: ${errorMap[it]?.message} ]" }.joinToString(";") + throw BluePrintException("Failed to enhance properties $nestedErrors") } } @@ -182,8 +191,17 @@ interface BluePrintTypeEnhancerService { bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap ) { + val errorMap = linkedMapOf() attributes.forEach { attributeName, attributeDefinition -> - enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) + try { + enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) + } catch (e: BluePrintException) { + errorMap[attributeName] = e + } + } + if (errorMap.isNotEmpty()) { + val nestedErrors = errorMap.keys.map { "[ attribute: ${errorMap[it]?.message} ]" }.joinToString(";") + throw BluePrintException("Failed to enhance attributes $nestedErrors") } } @@ -204,8 +222,19 @@ interface BluePrintTypeEnhancerService { enhancers: List> ) { if (enhancers.isNotEmpty()) { + val errorMap = linkedMapOf() enhancers.forEach { - it.enhance(bluePrintRuntimeService, name, definition as T) + try { + it.enhance(bluePrintRuntimeService, name, definition as T) + } catch (e: BluePrintException) { + errorMap[name] = e + } + } + if (errorMap.isNotEmpty()) { + val nestedErrors = errorMap.keys.map { + "${errorMap[it]?.message ?: errorMap[it].toString()}" + }.joinToString(";") + throw BluePrintException("$name-->$nestedErrors") } } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt index 4d5ca36cf..4affd3b3f 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt @@ -163,7 +163,7 @@ class BluePrintEnhancerUtils { archiveDir: String, outputFileName: String = "enhanced-cba.zip" ): - ResponseEntity { + ResponseEntity { val compressedFile = normalizedFile(archiveDir, outputFileName) BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) return prepareResourceEntity(compressedFile)