diff options
author | Brinda Santh Muthuramalingam <brindasanth@in.ibm.com> | 2020-01-24 14:46:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-24 14:46:52 +0000 |
commit | 95000d792e2e5001c7f566b0dedff997dc649ab8 (patch) | |
tree | 8151414c564a153052a71850a16d1b75e091481f /ms/blueprintsprocessor | |
parent | 2ca4e2c946b59a4f748bf538f49d93bd78d2da54 (diff) | |
parent | 7093027dcaaaf7311a4f1fbf4b679032ba232e30 (diff) |
Merge "Enhancement better error messages."
Diffstat (limited to 'ms/blueprintsprocessor')
2 files changed, 33 insertions, 4 deletions
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<String, PropertyDefinition> ) { + val errorMap = linkedMapOf<String, BluePrintException>() 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<String, AttributeDefinition> ) { + val errorMap = linkedMapOf<String, BluePrintException>() 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<BluePrintEnhancer<T>> ) { if (enhancers.isNotEmpty()) { + val errorMap = linkedMapOf<String, BluePrintException>() 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<Resource> { + ResponseEntity<Resource> { val compressedFile = normalizedFile(archiveDir, outputFileName) BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) return prepareResourceEntity(compressedFile) |