summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2020-07-09 11:19:44 -0400
committerOleg Mitsura <omitsura@gmail.com>2020-07-09 19:49:18 +0000
commiteab2ad65a153a22ebc48ecc1d1a6a4db3ef367f5 (patch)
treec55fccd1e04817ba91ecc29b29957044d7d379d7 /ms
parentc9e0479354544baab2e7cfc19691eff8ae8b7a18 (diff)
single /enrichandupload endpoint.
Issue-ID: CCSDK-2540 rev1. initial commit rev2. spacing Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com> Change-Id: I14c8ffa42214faf064d8697b00190dee80f5da1c (cherry picked from commit 90b49b479b13ffb17baf6de0ca73d1442da9c423)
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt26
2 files changed, 37 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt
index 1f01d1ce3..63d6d44cf 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt
@@ -178,6 +178,17 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
bluePrintModelHandler.enrichBlueprint(file)
}
+ @PostMapping(
+ "/enrichandpublish", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType
+ .MULTIPART_FORM_DATA_VALUE]
+ )
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ @PreAuthorize("hasRole('USER')")
+ suspend fun enrichAndPubishlueprint(@RequestPart("file") file: FilePart): BlueprintModelSearch = mdcWebCoroutineScope {
+ bluePrintModelHandler.enrichAndPublishBlueprint(file)
+ }
+
@PostMapping("/publish", produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
@Throws(BluePrintException::class)
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt
index 48ca912da..c6c8e960a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt
@@ -440,6 +440,7 @@ open class BluePrintModelHandler(
/**
* This is a publishBlueprintModel method to change the status published to YES
+ * NOTE: this method is meant for enriched blueprints only.
*
* @param filePart filePart
* @return BlueprintModelSearch
@@ -460,6 +461,31 @@ open class BluePrintModelHandler(
}
}
+ /**
+ * Enrich and publish the blueprint.
+ * NOTE: this method is meant for the unenriched vs publishBlueprint(filePart)
+ * which is used for enriched blueprints.
+ *
+ * @param filePart filePart
+ * @return BlueprintModelSearch
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open suspend fun enrichAndPublishBlueprint(filePart: FilePart): BlueprintModelSearch {
+ try {
+ val enhancedByteArray = enrichBlueprintFileSource(filePart)
+ return upload(enhancedByteArray, true)
+ } catch (e: BluePrintProcessorException) {
+ e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT)
+ val errorMsg = "Error while enhancing and uploading the CBA package."
+ throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg,
+ "Wrong CBA file provided, please verify the source CBA.")
+ } catch (e: Exception) {
+ throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API,
+ "EnrichBlueprint: ${e.message}", e.errorCauseOrDefault())
+ }
+ }
+
/** Common CBA Save and Publish function for RestController and GRPC Handler, the [fileSource] may be
* byteArray or File Part type.*/
open suspend fun upload(fileSource: Any, validate: Boolean): BlueprintModelSearch {