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)
/**
* 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
}
}
+ /**
+ * 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 {