diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds')
62 files changed, 662 insertions, 477 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorHandling.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorHandling.kt index e742e6375..1103a1b5b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorHandling.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorHandling.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.configs.api object ConfigsApiDomains { + // ConfigsApi Domains Constants const val CONFIGS_API = "org.onap.ccsdk.cds.blueprintsprocessor.configs.api" } diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotController.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotController.kt index 05f43c151..d285fe52d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotController.kt @@ -74,7 +74,7 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe @ApiOperation( value = "Retrieve a resource configuration snapshot.", notes = "Retrieve a config snapshot, identified by its Resource Id and Type. " + - "An extra 'format' parameter can be passed to tell what content-type is expected." + "An extra 'format' parameter can be passed to tell what content-type is expected." ) @ResponseBody @PreAuthorize("hasRole('USER')") @@ -95,38 +95,44 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe @RequestParam(value = "format", required = false, defaultValue = MediaType.TEXT_PLAIN_VALUE) format: String ): - ResponseEntity<String> = runBlocking { + ResponseEntity<String> = runBlocking { - var configSnapshot = "" + var configSnapshot = "" - if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { - try { - configSnapshot = resourceConfigSnapshotService.findByResourceIdAndResourceTypeAndStatus( - resourceId, - resourceType, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase()) - ) - } catch (ex: NoSuchElementException) { - throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, ConfigsApiDomains.CONFIGS_API, + if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { + try { + configSnapshot = resourceConfigSnapshotService.findByResourceIdAndResourceTypeAndStatus( + resourceId, + resourceType, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase()) + ) + } catch (ex: NoSuchElementException) { + throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, ConfigsApiDomains.CONFIGS_API, "Could not find configuration snapshot entry for type $resourceType and Id $resourceId", - ex.errorCauseOrDefault()) - } catch (ex: Exception) { - throw httpProcessorException(ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, + ex.errorCauseOrDefault() + ) + } catch (ex: Exception) { + throw httpProcessorException( + ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, "Could not find configuration snapshot entry for type $resourceType and Id $resourceId", - ex.errorCauseOrDefault()) + ex.errorCauseOrDefault() + ) + } + } else { + throw httpProcessorException( + ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, + "Missing param. You must specify resource-id and resource-type." + ) } - } else { - throw httpProcessorException(ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, - "Missing param. You must specify resource-id and resource-type.") - } - var expectedContentType = format - if (expectedContentType.indexOf('/') < 0) { - expectedContentType = "application/$expectedContentType" - } - val expectedMediaType: MediaType = MediaType.valueOf(expectedContentType) + var expectedContentType = format + if (expectedContentType.indexOf('/') < 0) { + expectedContentType = "application/$expectedContentType" + } + val expectedMediaType: MediaType = MediaType.valueOf(expectedContentType) - ResponseEntity.ok().contentType(expectedMediaType).body(configSnapshot) - } + ResponseEntity.ok().contentType(expectedMediaType).body(configSnapshot) + } @PostMapping( "/{resourceType}/{resourceId}/{status}", @@ -135,7 +141,7 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe @ApiOperation( value = "Store a resource configuration snapshot identified by resourceId, resourceType, status.", notes = "Store a resource configuration snapshot, identified by its resourceId and resourceType, " + - "and optionally its status, either RUNNING or CANDIDATE.", + "and optionally its status, either RUNNING or CANDIDATE.", response = ResourceConfigSnapshot::class, produces = MediaType.APPLICATION_JSON_VALUE ) @ResponseBody @@ -161,13 +167,13 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe } @RequestMapping( - path = ["/allByID"], - method = [RequestMethod.GET], - produces = [MediaType.APPLICATION_JSON_VALUE] + path = ["/allByID"], + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE] ) @ApiOperation( - value = "Retrieve all resource configuration snapshots identified by a given resource_id", - notes = "Retrieve all config snapshots, identified by its Resource Id, ordered by most recently created/modified date. " + value = "Retrieve all resource configuration snapshots identified by a given resource_id", + notes = "Retrieve all config snapshots, identified by its Resource Id, ordered by most recently created/modified date. " ) @ResponseBody @PreAuthorize("hasRole('USER')") @@ -184,16 +190,21 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe configSnapshots = resourceConfigSnapshotService.findAllByResourceId(resourceId) } else { configSnapshots = resourceConfigSnapshotService.findAllByResourceIdForStatus( - resourceId, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase())) + resourceId, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase()) + ) } } catch (ex: NoSuchElementException) { - throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, ConfigsApiDomains.CONFIGS_API, - "Could not find configuration snapshot entry for ID $resourceId", - ex.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, ConfigsApiDomains.CONFIGS_API, + "Could not find configuration snapshot entry for ID $resourceId", + ex.errorCauseOrDefault() + ) } catch (ex: Exception) { - throw httpProcessorException(ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, - "Unexpected error while finding configuration snapshot entries for ID $resourceId", - ex.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, + "Unexpected error while finding configuration snapshot entries for ID $resourceId", + ex.errorCauseOrDefault() + ) } val expectedMediaType: MediaType = MediaType.valueOf(JSON_MIME_TYPE) @@ -201,13 +212,13 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe } @RequestMapping( - path = ["allByType"], - method = [RequestMethod.GET], - produces = [MediaType.APPLICATION_JSON_VALUE] + path = ["allByType"], + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE] ) @ApiOperation( - value = "Retrieve all resource configuration snapshots for a given resource type.", - notes = "Retrieve all config snapshots matching a specified Resource Type, ordered by most recently created/modified date. " + value = "Retrieve all resource configuration snapshots for a given resource type.", + notes = "Retrieve all config snapshots matching a specified Resource Type, ordered by most recently created/modified date. " ) @ResponseBody @PreAuthorize("hasRole('USER')") @@ -224,16 +235,21 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe configSnapshots = resourceConfigSnapshotService.findAllByResourceType(resourceType) } else { configSnapshots = resourceConfigSnapshotService.findAllByResourceTypeForStatus( - resourceType, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase())) + resourceType, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase()) + ) } } catch (ex: NoSuchElementException) { - throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, ConfigsApiDomains.CONFIGS_API, - "Could not find configuration snapshot entry for ID $resourceType", - ex.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, ConfigsApiDomains.CONFIGS_API, + "Could not find configuration snapshot entry for ID $resourceType", + ex.errorCauseOrDefault() + ) } catch (ex: Exception) { - throw httpProcessorException(ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, - "Unexpected error while finding configuration snapshot entries for type $resourceType", - ex.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.INVALID_REQUEST_FORMAT, ConfigsApiDomains.CONFIGS_API, + "Unexpected error while finding configuration snapshot entries for type $resourceType", + ex.errorCauseOrDefault() + ) } val expectedMediaType: MediaType = MediaType.valueOf(JSON_MIME_TYPE) diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotExceptionHandler.kt index 2b9bb31f6..8cd8dbd9a 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotExceptionHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotExceptionHandler.kt @@ -28,4 +28,4 @@ import org.springframework.web.bind.annotation.RestControllerAdvice */ @RestControllerAdvice("org.onap.ccsdk.cds.blueprintsprocessor.configs.api") open class ResourceConfigSnapshotExceptionHandler(private val errorCatalogService: ErrorCatalogService) : - ErrorCatalogExceptionHandler(errorCatalogService) + ErrorCatalogExceptionHandler(errorCatalogService) diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorCatalogTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorCatalogTestConfiguration.kt index 66fc3b2ed..5a000d157 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorCatalogTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ErrorCatalogTestConfiguration.kt @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.error.catalog"] + basePackages = ["org.onap.ccsdk.cds.error.catalog"] ) @EnableAutoConfiguration open class ErrorCatalogTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt index e2fa5ca44..634c3368b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt @@ -148,13 +148,13 @@ class ResourceConfigSnapshotControllerTest { post(resourceType, resourceId, "RUNNING") webTestClient - .get() - .uri("/api/v1/configs/allByID?resourceId=$resourceId") - .exchange() - .expectStatus().is2xxSuccessful - .expectBody() - .jsonPath("$.length()") - .isEqualTo(1) + .get() + .uri("/api/v1/configs/allByID?resourceId=$resourceId") + .exchange() + .expectStatus().is2xxSuccessful + .expectBody() + .jsonPath("$.length()") + .isEqualTo(1) } } @@ -166,13 +166,13 @@ class ResourceConfigSnapshotControllerTest { post(resourceType, resourceId, "CANDIDATE") webTestClient - .get() - .uri("/api/v1/configs/allByID?resourceId=$resourceId&status=CANDIDATE") - .exchange() - .expectStatus().is2xxSuccessful - .expectBody() - .jsonPath("$.length()") - .isEqualTo(1) + .get() + .uri("/api/v1/configs/allByID?resourceId=$resourceId&status=CANDIDATE") + .exchange() + .expectStatus().is2xxSuccessful + .expectBody() + .jsonPath("$.length()") + .isEqualTo(1) } } @@ -181,11 +181,11 @@ class ResourceConfigSnapshotControllerTest { runBlocking { webTestClient - .get() - .uri("/api/v1/configs/allByID") - .exchange() - .expectStatus().is4xxClientError - .expectBody() + .get() + .uri("/api/v1/configs/allByID") + .exchange() + .expectStatus().is4xxClientError + .expectBody() } } @@ -194,11 +194,11 @@ class ResourceConfigSnapshotControllerTest { runBlocking { webTestClient - .get() - .uri("/api/v1/configs/allByID?resourceId=$resourceId&status=NOTGOOD") - .exchange() - .expectStatus().is4xxClientError - .expectBody() + .get() + .uri("/api/v1/configs/allByID?resourceId=$resourceId&status=NOTGOOD") + .exchange() + .expectStatus().is4xxClientError + .expectBody() } } @@ -210,13 +210,13 @@ class ResourceConfigSnapshotControllerTest { post(resourceType, "1", "RUNNING") webTestClient - .get() - .uri("/api/v1/configs/allByType?resourceType=$resourceType") - .exchange() - .expectStatus().is2xxSuccessful - .expectBody() - .jsonPath("$.length()") - .isEqualTo(3) + .get() + .uri("/api/v1/configs/allByType?resourceType=$resourceType") + .exchange() + .expectStatus().is2xxSuccessful + .expectBody() + .jsonPath("$.length()") + .isEqualTo(3) } } @@ -225,11 +225,11 @@ class ResourceConfigSnapshotControllerTest { runBlocking { webTestClient - .get() - .uri("/api/v1/configs/allByType") - .exchange() - .expectStatus().is4xxClientError - .expectBody() + .get() + .uri("/api/v1/configs/allByType") + .exchange() + .expectStatus().is4xxClientError + .expectBody() } } @@ -238,11 +238,11 @@ class ResourceConfigSnapshotControllerTest { runBlocking { webTestClient - .get() - .uri("/api/v1/configs/allByType?resourceType=$resourceType&status=NOTGOOD") - .exchange() - .expectStatus().is4xxClientError - .expectBody() + .get() + .uri("/api/v1/configs/allByType?resourceType=$resourceType&status=NOTGOOD") + .exchange() + .expectStatus().is4xxClientError + .expectBody() } } diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/TestDatabaseConfiguration.kt index 661e28def..ee4c0a544 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/TestDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/TestDatabaseConfiguration.kt @@ -31,9 +31,11 @@ import javax.sql.DataSource @Configuration @Import(BluePrintDBLibConfiguration::class) @EnableJpaRepositories( - basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution", + basePackages = [ + "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution", "org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots", - "org.onap.ccsdk.cds.blueprintsprocessor.db.primary"], + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary" + ], entityManagerFactoryRef = "primaryEntityManager", transactionManagerRef = "primaryTransactionManager" ) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt index 714cf3a46..54f8dbc9d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt @@ -71,6 +71,7 @@ open class BluePrintManagementGRPCHandler( try { /** Get the file byte array */ val byteArray = request.fileChunk.chunk.toByteArray() + /** Get the Upload Action */ val uploadAction = request.actionIdentifiers?.actionName.emptyTONull() ?: UploadAction.DRAFT.toString() @@ -169,7 +170,7 @@ open class BluePrintManagementGRPCHandler( override fun removeBlueprint( request: BluePrintRemoveInput, responseObserver: - StreamObserver<BluePrintManagementOutput> + StreamObserver<BluePrintManagementOutput> ) { runBlocking { @@ -282,38 +283,38 @@ open class BluePrintManagementGRPCHandler( private fun onError(header: CommonHeader, message: String, error: Exception): BluePrintManagementOutput { val code = GrpcErrorCodes.code(ErrorCatalogCodes.GENERIC_FAILURE) return BluePrintManagementOutput.newBuilder() - .setCommonHeader(header) - .setStatus( - Status.newBuilder() - .setTimestamp(currentTimestamp()) - .setMessage(BluePrintConstants.STATUS_FAILURE) - .setEventType(EventType.EVENT_COMPONENT_FAILURE) - .setErrorMessage("Error : $message \n Details: ${error.errorMessageOrDefault()}") - .setCode(code) - .build() - ) - .build() + .setCommonHeader(header) + .setStatus( + Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_FAILURE) + .setEventType(EventType.EVENT_COMPONENT_FAILURE) + .setErrorMessage("Error : $message \n Details: ${error.errorMessageOrDefault()}") + .setCode(code) + .build() + ) + .build() } private fun onErrorCatalog(header: CommonHeader, message: String, error: BluePrintProcessorException): - BluePrintManagementOutput { - val err = if (error.protocol == "") { - error.grpc(ErrorCatalogCodes.GENERIC_FAILURE) - } else { - error.convertToGrpc() - } - val errorPayload = errorCatalogService.errorPayload(err.addErrorPayloadMessage(message)) - return BluePrintManagementOutput.newBuilder() + BluePrintManagementOutput { + val err = if (error.protocol == "") { + error.grpc(ErrorCatalogCodes.GENERIC_FAILURE) + } else { + error.convertToGrpc() + } + val errorPayload = errorCatalogService.errorPayload(err.addErrorPayloadMessage(message)) + return BluePrintManagementOutput.newBuilder() .setCommonHeader(header) .setStatus( - Status.newBuilder() - .setTimestamp(currentTimestamp()) - .setMessage(BluePrintConstants.STATUS_FAILURE) - .setEventType(EventType.EVENT_COMPONENT_FAILURE) - .setErrorMessage("Error : ${errorPayload.message}") - .setCode(errorPayload.code) - .build() + Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_FAILURE) + .setEventType(EventType.EVENT_COMPONENT_FAILURE) + .setErrorMessage("Error : ${errorPayload.message}") + .setCode(errorPayload.code) + .build() ) .build() - } + } } 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 bb7a4b15c..0de298c62 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 @@ -92,8 +92,10 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption, @RequestParam(defaultValue = "ASC") sortType: String ): Page<BlueprintModelSearch> { - val pageRequest = PageRequest.of(offset, limit, - Sort.Direction.fromString(sortType), sort.columnName) + val pageRequest = PageRequest.of( + offset, limit, + Sort.Direction.fromString(sortType), sort.columnName + ) return this.bluePrintModelHandler.allBlueprintModel(pageRequest) } @@ -115,8 +117,10 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption, @RequestParam(defaultValue = "ASC") sortType: String ): Page<BlueprintModelSearch> { - val pageRequest = PageRequest.of(offset, limit, - Sort.Direction.fromString(sortType), sort.columnName) + val pageRequest = PageRequest.of( + offset, limit, + Sort.Direction.fromString(sortType), sort.columnName + ) return this.bluePrintModelHandler.searchBluePrintModelsByKeyWordPaged(keyWord, pageRequest) } @@ -172,8 +176,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint } @PostMapping( - "/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType - .MULTIPART_FORM_DATA_VALUE] + "/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], + consumes = [ + MediaType + .MULTIPART_FORM_DATA_VALUE + ] ) @ResponseBody @Throws(BluePrintException::class) @@ -183,8 +190,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint } @PostMapping( - "/enrichandpublish", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType - .MULTIPART_FORM_DATA_VALUE] + "/enrichandpublish", produces = [MediaType.APPLICATION_JSON_VALUE], + consumes = [ + MediaType + .MULTIPART_FORM_DATA_VALUE + ] ) @ResponseBody @Throws(BluePrintException::class) @@ -226,7 +236,8 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint } @PostMapping( - path = arrayOf("/workflow-spec"), produces = arrayOf( + path = arrayOf("/workflow-spec"), + produces = arrayOf( MediaType .APPLICATION_JSON_VALUE ), @@ -237,10 +248,10 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @PreAuthorize("hasRole('USER')") suspend fun workflowSpec(@RequestBody workFlowSpecReq: WorkFlowSpecRequest): ResponseEntity<String> = mdcWebCoroutineScope { - var json = bluePrintModelHandler.prepareWorkFlowSpec(workFlowSpecReq) - .asJsonString() - ResponseEntity(json, HttpStatus.OK) - } + var json = bluePrintModelHandler.prepareWorkFlowSpec(workFlowSpecReq) + .asJsonString() + ResponseEntity(json, HttpStatus.OK) + } @GetMapping( path = arrayOf( diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt index 1d61c7f0c..1d32b9493 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt @@ -26,18 +26,21 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment class BootstrapRequest { + var loadModelType: Boolean = false var loadResourceDictionary: Boolean = false var loadCBA: Boolean = false } class WorkFlowsResponse { + lateinit var blueprintName: String var version: String = DEFAULT_VERSION_NUMBER var workflows: MutableSet<String> = mutableSetOf() } class WorkFlowSpecRequest { + lateinit var blueprintName: String var version: String = DEFAULT_VERSION_NUMBER var returnContent: String = DATA_TYPE_JSON @@ -46,6 +49,7 @@ class WorkFlowSpecRequest { } class WorkFlowSpecResponse { + lateinit var blueprintName: String var version: String = DEFAULT_VERSION_NUMBER lateinit var workFlowData: WorkFlowData @@ -53,6 +57,7 @@ class WorkFlowSpecResponse { } class WorkFlowData { + lateinit var workFlowName: String var inputs: MutableMap<String, PropertyDefinition>? = null var outputs: MutableMap<String, PropertyDefinition>? = null diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt index a083d7a8b..ffb383e6c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerBlueprintExceptionHandler.kt @@ -28,4 +28,4 @@ import org.springframework.web.bind.annotation.RestControllerAdvice @RestControllerAdvice("org.onap.ccsdk.cds.blueprintsprocessor.designer.api") open class DesignerBlueprintExceptionHandler(private val errorCatalogService: ErrorCatalogService) : - ErrorCatalogExceptionHandler(errorCatalogService) + ErrorCatalogExceptionHandler(errorCatalogService) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorHandling.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorHandling.kt index ae91246fe..ef1c3b103 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorHandling.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorHandling.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api object DesignerApiDomains { + // Designer Api Domains Constants const val DESIGNER_API = "org.onap.ccsdk.cds.blueprintsprocessor.designer.api" const val DESIGNER_API_ENHANCER = "org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer" diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt index 6e277e5c8..b00e5a0a6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt @@ -89,17 +89,18 @@ class ModelType : Serializable { override fun toString(): String { return "[" + "modelName = " + modelName + - ", derivedFrom = " + derivedFrom + - ", definitionType = " + definitionType + - ", description = " + description + - ", creationDate = " + creationDate + - ", version = " + version + - ", updatedBy = " + updatedBy + - ", tags = " + tags + - "]" + ", derivedFrom = " + derivedFrom + + ", definitionType = " + definitionType + + ", description = " + description + + ", creationDate = " + creationDate + + ", version = " + version + + ", updatedBy = " + updatedBy + + ", tags = " + tags + + "]" } companion object { + private const val serialVersionUID = 1L } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt index e91d9e136..eaa63ddee 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt @@ -88,18 +88,19 @@ class ResourceDictionary : Serializable { override fun toString(): String { return "[" + ", name = " + name + - ", dataType = " + dataType + - ", entrySchema = " + entrySchema + - ", resourceDictionaryGroup = " + resourceDictionaryGroup + - ", definition =" + definition + - ", description = " + description + - ", updatedBy = " + updatedBy + - ", tags = " + tags + - ", creationDate = " + creationDate + - "]" + ", dataType = " + dataType + + ", entrySchema = " + entrySchema + + ", resourceDictionaryGroup = " + resourceDictionaryGroup + + ", definition =" + definition + + ", description = " + description + + ", updatedBy = " + updatedBy + + ", tags = " + tags + + ", creationDate = " + creationDate + + "]" } companion object { + private const val serialVersionUID = 1L } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt index f954df7ac..c63c7260d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt @@ -40,6 +40,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl( BluePrintArtifactDefinitionEnhancer { companion object { + const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" } @@ -79,7 +80,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl( if (!alreadyEnhanced) { val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(artifactFilePath, ResourceAssignment::class.java) - as? MutableList<ResourceAssignment> + as? MutableList<ResourceAssignment> ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)") // Call Resource Assignment Enhancer diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt index 1d534bb73..c163cc0d4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt @@ -20,12 +20,12 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiDomains import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService +import org.onap.ccsdk.cds.controllerblueprints.core.logger import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils @@ -83,15 +83,21 @@ open class BluePrintEnhancerServiceImpl( } } catch (e: BluePrintProcessorException) { val errorMsg = "Error while enriching the CBA package." - throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg, - "Wrong blueprint definitions or resource definitions.") + throw e.updateErrorMessage( + DesignerApiDomains.DESIGNER_API, errorMsg, + "Wrong blueprint definitions or resource definitions." + ) } catch (e: IOException) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "IO Error: CBA file failed enrichment - ${e.message}", e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "IO Error: CBA file failed enrichment - ${e.message}", e.errorCauseOrDefault() + ) } catch (e: Exception) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "Error in Enriching CBA: ${e.message}", e.errorCauseOrDefault()) - } - return blueprintRuntimeService.bluePrintContext() + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "Error in Enriching CBA: ${e.message}", e.errorCauseOrDefault() + ) } + return blueprintRuntimeService.bluePrintContext() + } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt index d28084e40..bb178b1e6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt @@ -101,7 +101,7 @@ open class BluePrintNodeTypeEnhancerImpl( val relationShipTypeName = requirementDefinition.relationship ?: throw BluePrintException( "couldn't get relationship name for the NodeType($nodeTypeName) " + - "Requirement($requirementName)" + "Requirement($requirementName)" ) enrichRelationShipType(relationShipTypeName) } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt index 88127e3ca..dd60acac1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt @@ -48,6 +48,7 @@ open class BluePrintWorkflowEnhancerImpl( private val log = logger(BluePrintWorkflowEnhancerImpl::class) companion object { + const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" const val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates" } @@ -109,7 +110,7 @@ open class BluePrintWorkflowEnhancerImpl( else -> { throw BluePrintProcessorException( "couldn't execute workflow($name) step mapped " + - "to node template($firstNodeTemplateName) derived from($derivedFrom)" + "to node template($firstNodeTemplateName) derived from($derivedFrom)" ) } } @@ -139,11 +140,11 @@ open class BluePrintWorkflowEnhancerImpl( val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName) .artifacts?.filter { - it.value.type == ARTIFACT_TYPE_MAPPING_SOURCE - }?.map { - log.info("resource assignment artifacts(${it.key}) for NodeType($componentNodeTemplateName)") - it.value.file - } + it.value.type == ARTIFACT_TYPE_MAPPING_SOURCE + }?.map { + log.info("resource assignment artifacts(${it.key}) for NodeType($componentNodeTemplateName)") + it.value.file + } resourceAssignmentArtifacts }?.flatten() @@ -173,7 +174,7 @@ open class BluePrintWorkflowEnhancerImpl( val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf() val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) - as? MutableList<ResourceAssignment> + as? MutableList<ResourceAssignment> ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") val alreadyEnhancedKey = "enhanced-$fileName" diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt index 94e183405..621b046e6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt @@ -105,9 +105,13 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR } private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean { - return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT) || - resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT)) && - BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!)) + return !( + ( + resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT) || + resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT) + ) && + BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!) + ) } private fun getResourceDefinition(name: String): ResourceDefinition { diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt index 042c76805..bbec8e685 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt @@ -48,6 +48,7 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe private val log = logger(ResourceDefinitionEnhancerService::class) companion object { + const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" } @@ -112,15 +113,15 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe // Read the Resource Definitions from the Database and write to type file. private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>): - List<ResourceDefinition> { - val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted() - log.info("distinct resource keys ($resourceKeys)") + List<ResourceDefinition> { + val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted() + log.info("distinct resource keys ($resourceKeys)") - // TODO("Optimise DB single Query to multiple Query") - return resourceKeys.map { resourceKey -> - getResourceDefinition(resourceKey) + // TODO("Optimise DB single Query to multiple Query") + return resourceKeys.map { resourceKey -> + getResourceDefinition(resourceKey) + } } - } private fun enrichResourceDefinitionSources( bluePrintContext: BluePrintContext, 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 3140abfb3..7bbaa8c59 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 @@ -24,29 +24,29 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSe import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelContentRepository import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelRepository import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelSearchRepository -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiDomains import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.BootstrapRequest +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiDomains +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowData import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowSpecRequest import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowSpecResponse -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowData import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.WorkFlowsResponse import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.BluePrintDatabaseLoadService import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile -import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir +import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -92,8 +92,8 @@ open class BluePrintModelHandler( open suspend fun bootstrapBlueprint(bootstrapRequest: BootstrapRequest) { log.info( "Bootstrap request with type load(${bootstrapRequest.loadModelType}), " + - "resource dictionary load(${bootstrapRequest.loadResourceDictionary}) and " + - "cba load(${bootstrapRequest.loadCBA})" + "resource dictionary load(${bootstrapRequest.loadResourceDictionary}) and " + + "cba load(${bootstrapRequest.loadCBA})" ) if (bootstrapRequest.loadModelType) { bluePrintDatabaseLoadService.initModelTypes() @@ -108,38 +108,41 @@ open class BluePrintModelHandler( @Throws(BluePrintException::class) open suspend fun prepareWorkFlowSpec(req: WorkFlowSpecRequest): - WorkFlowSpecResponse { - val basePath = blueprintsProcessorCatalogService.getFromDatabase(req - .blueprintName, req.version) - log.info("blueprint base path $basePath") - - val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(basePath.toString()) - val workFlow = blueprintContext.workflowByName(req.workflowName) - - val wfRes = WorkFlowSpecResponse() - wfRes.blueprintName = req.blueprintName - wfRes.version = req.version - - val workFlowData = WorkFlowData() - workFlowData.workFlowName = req.workflowName - workFlowData.inputs = workFlow.inputs - workFlowData.outputs = workFlow.outputs - wfRes.workFlowData = workFlowData - - if (workFlow.inputs != null) { - for ((k, v) in workFlow.inputs!!) { - addPropertyInfo(k, v, blueprintContext, wfRes) + WorkFlowSpecResponse { + val basePath = blueprintsProcessorCatalogService.getFromDatabase( + req + .blueprintName, + req.version + ) + log.info("blueprint base path $basePath") + + val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(basePath.toString()) + val workFlow = blueprintContext.workflowByName(req.workflowName) + + val wfRes = WorkFlowSpecResponse() + wfRes.blueprintName = req.blueprintName + wfRes.version = req.version + + val workFlowData = WorkFlowData() + workFlowData.workFlowName = req.workflowName + workFlowData.inputs = workFlow.inputs + workFlowData.outputs = workFlow.outputs + wfRes.workFlowData = workFlowData + + if (workFlow.inputs != null) { + for ((k, v) in workFlow.inputs!!) { + addPropertyInfo(k, v, blueprintContext, wfRes) + } } - } - if (workFlow.outputs != null) { - for ((k, v) in workFlow.outputs!!) { - addPropertyInfo(k, v, blueprintContext, wfRes) + if (workFlow.outputs != null) { + for ((k, v) in workFlow.outputs!!) { + addPropertyInfo(k, v, blueprintContext, wfRes) + } } - } - return wfRes - } + return wfRes + } private fun addPropertyInfo(propName: String, prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) { updatePropertyInfo(propName, prop, ctx, res) @@ -172,6 +175,7 @@ open class BluePrintModelHandler( } } } + private fun addDataType(name: String, ctx: BluePrintContext, res: WorkFlowSpecResponse) { var data = ctx.dataTypeByName(name) if (data != null) { @@ -191,7 +195,8 @@ open class BluePrintModelHandler( @Throws(BluePrintException::class) open suspend fun getWorkflowNames(name: String, version: String): WorkFlowsResponse { val basePath = blueprintsProcessorCatalogService.getFromDatabase( - name, version) + name, version + ) log.info("blueprint base path $basePath") var res = WorkFlowsResponse() @@ -199,7 +204,8 @@ open class BluePrintModelHandler( res.version = version val blueprintContext = BluePrintMetadataUtils.getBluePrintContext( - basePath.toString()) + basePath.toString() + ) if (blueprintContext.workflows() != null) { res.workflows = blueprintContext.workflows()!!.keys } @@ -210,7 +216,7 @@ open class BluePrintModelHandler( * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database * * @return List<BlueprintModelSearch> list of the controller blueprint archives - </BlueprintModelSearch> */ + </BlueprintModelSearch> */ open fun allBlueprintModel(): List<BlueprintModelSearch> { return blueprintModelSearchRepository.findAll() } @@ -219,7 +225,7 @@ open class BluePrintModelHandler( * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database * * @return List<BlueprintModelSearch> list of the controller blueprint archives - </BlueprintModelSearch> */ + </BlueprintModelSearch> */ open fun allBlueprintModel(pageRequest: Pageable): Page<BlueprintModelSearch> { return blueprintModelSearchRepository.findAll(pageRequest) } @@ -230,14 +236,16 @@ open class BluePrintModelHandler( * @param filePart filePart * @return Mono<BlueprintModelSearch> * @throws BluePrintException BluePrintException - </BlueprintModelSearch> */ + </BlueprintModelSearch> */ @Throws(BluePrintException::class) open suspend fun saveBlueprintModel(filePart: FilePart): BlueprintModelSearch { try { return upload(filePart, false) } catch (e: IOException) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "Error in Save CBA: ${e.message}", e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "Error in Save CBA: ${e.message}", e.errorCauseOrDefault() + ) } } @@ -246,7 +254,7 @@ open class BluePrintModelHandler( * * @param tags tags * @return List<BlueprintModelSearch> - </BlueprintModelSearch> */ + </BlueprintModelSearch> */ open fun searchBlueprintModels(tags: String): List<BlueprintModelSearch> { return blueprintModelSearchRepository.findByTagsContainingIgnoreCase(tags) } @@ -262,10 +270,10 @@ open class BluePrintModelHandler( @Throws(BluePrintException::class) open fun getBlueprintModelSearchByNameAndVersion(name: String, version: String): BlueprintModelSearch? { return blueprintModelSearchRepository.findByArtifactNameAndArtifactVersion(name, version) - /*?: throw BluePrintException( - ErrorCode.RESOURCE_NOT_FOUND.value, - String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version) - )*/ + /*?: throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version) + )*/ } /** @@ -275,7 +283,7 @@ open class BluePrintModelHandler( * @param version version * @return ResponseEntity<Resource> * @throws BluePrintException BluePrintException - </Resource> */ + </Resource> */ @Throws(BluePrintException::class) open fun downloadBlueprintModelFileByNameAndVersion( name: String, @@ -288,8 +296,10 @@ open class BluePrintModelHandler( } catch (e: BluePrintProcessorException) { e.http(ErrorCatalogCodes.RESOURCE_NOT_FOUND) val errorMsg = "Error while downloading the CBA file by Blueprint Name ($name) and Version ($version)." - throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg, - "Wrong resource definition or resolution failed.") + throw e.updateErrorMessage( + DesignerApiDomains.DESIGNER_API, errorMsg, + "Wrong resource definition or resolution failed." + ) } } @@ -298,28 +308,32 @@ open class BluePrintModelHandler( * * @return ResponseEntity<Resource> * @throws BluePrintException BluePrintException - </Resource> */ + </Resource> */ @Throws(BluePrintException::class) open fun downloadBlueprintModelFile(id: String): ResponseEntity<Resource> { val blueprintModel: BlueprintModel try { blueprintModel = getBlueprintModel(id) } catch (e: BluePrintException) { - throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - "Error while downloading the CBA file: couldn't get blueprint modelby ID ($id)", - e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + "Error while downloading the CBA file: couldn't get blueprint modelby ID ($id)", + e.errorCauseOrDefault() + ) } val fileName = "${blueprintModel.artifactName}_${blueprintModel.artifactVersion}.zip" val file = blueprintModel.blueprintModelContent?.content - ?: throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - "Error while downloading the CBA file: couldn't get model content") + ?: throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + "Error while downloading the CBA file: couldn't get model content" + ) return prepareResourceEntity(fileName, file) } /** * @return ResponseEntity<Resource> - </Resource> */ + </Resource> */ private fun prepareResourceEntity(fileName: String, file: ByteArray): ResponseEntity<Resource> { return ResponseEntity.ok() .contentType(MediaType.parseMediaType("text/plain")) @@ -377,8 +391,10 @@ open class BluePrintModelHandler( @Throws(BluePrintException::class) open fun getBlueprintModelSearch(id: String): BlueprintModelSearch { return blueprintModelSearchRepository.findById(id) - ?: throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id)) + ?: throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id) + ) } /** @@ -388,7 +404,7 @@ open class BluePrintModelHandler( * @param keyWord * * @return List<BlueprintModelSearch> list of the controller blueprint - </BlueprintModelSearch> */ + </BlueprintModelSearch> */ open fun searchBluePrintModelsByKeyWord(keyWord: String): List<BlueprintModelSearch> { return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType( keyWord, keyWord, keyWord, keyWord, keyWord @@ -402,7 +418,7 @@ open class BluePrintModelHandler( * @param keyWord * * @return List<BlueprintModelSearch> list of the controller blueprint - </BlueprintModelSearch> */ + </BlueprintModelSearch> */ open fun searchBluePrintModelsByKeyWordPaged(keyWord: String, pageRequest: PageRequest): Page<BlueprintModelSearch> { return blueprintModelSearchRepository.findByUpdatedByContainingIgnoreCaseOrTagsContainingIgnoreCaseOrArtifactNameContainingIgnoreCaseOrArtifactVersionContainingIgnoreCaseOrArtifactTypeContainingIgnoreCase( keyWord, @@ -457,11 +473,15 @@ open class BluePrintModelHandler( } catch (e: BluePrintProcessorException) { e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT) val errorMsg = "Error while enhancing the CBA package." - throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg, - "Wrong CBA file provided, please verify and enrich Again.") + throw e.updateErrorMessage( + DesignerApiDomains.DESIGNER_API, errorMsg, + "Wrong CBA file provided, please verify and enrich Again." + ) } catch (e: Exception) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "EnrichBlueprint: ${e.message}", e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "EnrichBlueprint: ${e.message}", e.errorCauseOrDefault() + ) } } @@ -480,11 +500,15 @@ open class BluePrintModelHandler( } catch (e: BluePrintProcessorException) { e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT) val errorMsg = "Error in Publishing CBA." - throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg, - "Wrong CBA provided, please verify and enrich your CBA.") + throw e.updateErrorMessage( + DesignerApiDomains.DESIGNER_API, errorMsg, + "Wrong CBA provided, please verify and enrich your CBA." + ) } catch (e: Exception) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "Error in Publishing CBA: ${e.message}", e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "Error in Publishing CBA: ${e.message}", e.errorCauseOrDefault() + ) } } @@ -505,11 +529,15 @@ open class BluePrintModelHandler( } 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.") + 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()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "EnrichBlueprint: ${e.message}", e.errorCauseOrDefault() + ) } } @@ -529,16 +557,22 @@ open class BluePrintModelHandler( val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(saveId, compressedFile, validate) return blueprintModelSearchRepository.findById(blueprintId) - ?: throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId)) + ?: throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId) + ) } catch (e: BluePrintException) { e.http(ErrorCatalogCodes.IO_FILE_INTERRUPT) val errorMsg = "Error in Upload CBA." - throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg, - "Wrong enriched CBA.") + throw e.updateErrorMessage( + DesignerApiDomains.DESIGNER_API, errorMsg, + "Wrong enriched CBA." + ) } catch (e: IOException) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "Error in Upload CBA: ${e.errorMessageOrDefault()}", e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "Error in Upload CBA: ${e.errorMessageOrDefault()}", e.errorCauseOrDefault() + ) } finally { // Clean blueprint script cache val cacheKey = BluePrintFileUtils @@ -555,13 +589,17 @@ open class BluePrintModelHandler( try { val blueprintModel = getBlueprintModelByNameAndVersion(name, version) return blueprintModel.blueprintModelContent?.content - ?: throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - "Error while downloading the CBA file: couldn't get model content") + ?: throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + "Error while downloading the CBA file: couldn't get model content" + ) } catch (e: BluePrintException) { e.http(ErrorCatalogCodes.RESOURCE_NOT_FOUND) val errorMsg = "Fail to get Blueprint Model content." - throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg, - "Wrong name and version was provide.") + throw e.updateErrorMessage( + DesignerApiDomains.DESIGNER_API, errorMsg, + "Wrong name and version was provide." + ) } } @@ -573,10 +611,12 @@ open class BluePrintModelHandler( val blueprintWorkingDir = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, enhanceId) try { when (fileSource) { - is FilePart -> BluePrintEnhancerUtils - .copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) - is ByteArray -> BluePrintEnhancerUtils - .copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) + is FilePart -> + BluePrintEnhancerUtils + .copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) + is ByteArray -> + BluePrintEnhancerUtils + .copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) } // Enhance the Blue Prints bluePrintEnhancerService.enhance(blueprintWorkingDir) @@ -586,8 +626,10 @@ open class BluePrintModelHandler( val errorMsg = "Fail Enriching the CBA." throw e.updateErrorMessage(DesignerApiDomains.DESIGNER_API, errorMsg) } catch (e: IOException) { - throw httpProcessorException(ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, - "Error while Enriching the CBA file.", e.errorCauseOrDefault()) + throw httpProcessorException( + ErrorCatalogCodes.IO_FILE_INTERRUPT, DesignerApiDomains.DESIGNER_API, + "Error while Enriching the CBA file.", e.errorCauseOrDefault() + ) } finally { BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir) } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt index d11c128f0..0d94aab27 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt @@ -45,8 +45,10 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository return if (modelType != null) { modelType } else { - throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - "couldn't get modelType($modelTypeName)") + throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + "couldn't get modelType($modelTypeName)" + ) } } @@ -55,7 +57,7 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository * * @param tags tags * @return List<ModelType> - </ModelType> */ + </ModelType> */ suspend fun searchModelTypes(tags: String): List<ModelType> { check(tags.isNotBlank()) { "No Search Information provide" } return modelTypeRepository.findByTagsContainingIgnoreCase(tags) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt index 20895efce..3f06a4a98 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt @@ -49,8 +49,10 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour return if (resourceDictionaryDb != null) { resourceDictionaryDb } else { - throw httpProcessorException(ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, - String.format("couldn't get resource dictionary for name (%s)", name)) + throw httpProcessorException( + ErrorCatalogCodes.RESOURCE_NOT_FOUND, DesignerApiDomains.DESIGNER_API, + String.format("couldn't get resource dictionary for name (%s)", name) + ) } } @@ -59,7 +61,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour * * @param names names * @return List<ResourceDictionary> - </ResourceDictionary> */ + </ResourceDictionary> */ suspend fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> { Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide") return resourceDictionaryRepository.findByNameIn(names) @@ -70,7 +72,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour * * @param tags tags * @return List<ResourceDictionary> - </ResourceDictionary> */ + </ResourceDictionary> */ suspend fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> { Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide") return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags) @@ -139,8 +141,10 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour resourceDictionary.resourceDictionaryGroup = resourceDefinition.group resourceDictionary.entrySchema = resourceDefinition.property.entrySchema?.type if (StringUtils.isBlank(resourceDefinition.tags)) { - resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy + - ", " + resourceDefinition.updatedBy) + resourceDictionary.tags = ( + resourceDefinition.name + ", " + resourceDefinition.updatedBy + + ", " + resourceDefinition.updatedBy + ) } else { resourceDictionary.tags = resourceDefinition.tags!! } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt index fea01992b..703542f60 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt @@ -35,7 +35,7 @@ interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, Strin * * @param name name * @return Optional<ResourceMapping> - </ResourceMapping> */ + </ResourceMapping> */ fun findByName(name: String): ResourceDictionary? /** @@ -43,7 +43,7 @@ interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, Strin * * @param names names * @return Optional<ResourceMapping> - </ResourceMapping> */ + </ResourceMapping> */ fun findByNameIn(names: List<String>): List<ResourceDictionary> /** @@ -51,7 +51,7 @@ interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, Strin * * @param tags tags * @return Optional<ModelType> - </ModelType> */ + </ModelType> */ fun findByTagsContainingIgnoreCase(tags: String): List<ResourceDictionary> /** diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt index edf4c8cf6..db2e06eb5 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt @@ -49,6 +49,7 @@ class ApplicationRegistrationService { } companion object { + private val log = LoggerFactory.getLogger(ApplicationRegistrationService::class.java) } } 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 4affd3b3f..6d72c2741 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 @@ -44,6 +44,7 @@ import java.nio.file.Paths class BluePrintEnhancerUtils { companion object { + val log = logger(BluePrintEnhancerUtils) fun populateDataTypes( @@ -164,10 +165,10 @@ class BluePrintEnhancerUtils { outputFileName: String = "enhanced-cba.zip" ): ResponseEntity<Resource> { - val compressedFile = normalizedFile(archiveDir, outputFileName) - BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) - return prepareResourceEntity(compressedFile) - } + val compressedFile = normalizedFile(archiveDir, outputFileName) + BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) + return prepareResourceEntity(compressedFile) + } /** convert [file] to ResourceEntity */ suspend fun prepareResourceEntity(file: File): ResponseEntity<Resource> { diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt index 6b9ea28f0..08de136d8 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt @@ -30,6 +30,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils class ModelTypeValidator { companion object { + /** * This is a validateModelTypeDefinition * diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt index 9489f2882..a42ac05e7 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt @@ -72,6 +72,7 @@ class BlueprintModelControllerTest { private val log = logger(BlueprintModelControllerTest::class) companion object { + private var bp: BlueprintModelSearch? = null } @@ -115,11 +116,14 @@ class BlueprintModelControllerTest { fun test01_saveBluePrint() { bp = runBlocking { val body = MultipartBodyBuilder().apply { - part("file", object : ByteArrayResource(testZipFile!!.readBytes()) { - override fun getFilename(): String { - return "test.zip" + part( + "file", + object : ByteArrayResource(testZipFile!!.readBytes()) { + override fun getFilename(): String { + return "test.zip" + } } - }) + ) }.build() val saveBP = webTestClient @@ -184,11 +188,14 @@ class BlueprintModelControllerTest { fun test07_publishBlueprintModel() { bp = runBlocking { val body = MultipartBodyBuilder().apply { - part("file", object : ByteArrayResource(testZipFile!!.readBytes()) { - override fun getFilename(): String { - return "test.zip" + part( + "file", + object : ByteArrayResource(testZipFile!!.readBytes()) { + override fun getFilename(): String { + return "test.zip" + } } - }) + ) }.build() val publishBP = webTestClient @@ -239,7 +246,8 @@ class BlueprintModelControllerTest { webTestClient.delete().uri("/api/v1/blueprint-model/name/${bp!!.artifactName}/version/${bp!!.artifactVersion}") .header( - "Authorization", "Basic " + Base64Utils + "Authorization", + "Basic " + Base64Utils .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)) ) .exchange() @@ -259,7 +267,8 @@ class BlueprintModelControllerTest { webTestClient.method(requestMethod).uri(uri) .header( - "Authorization", "Basic " + Base64Utils + "Authorization", + "Basic " + Base64Utils .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)) ) .body(body) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt index 33a2bd778..5b4463d36 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt @@ -22,9 +22,11 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.controllerblueprints", + basePackages = [ + "org.onap.ccsdk.cds.controllerblueprints", "org.onap.ccsdk.cds.blueprintsprocessor.designer.api", - "org.onap.ccsdk.cds.blueprintsprocessor.db.primary"] + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary" + ] ) @EnableAutoConfiguration open class DesignerApiTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorCatalogTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorCatalogTestConfiguration.kt index d081dc5ab..9520f0e8c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorCatalogTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ErrorCatalogTestConfiguration.kt @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.error.catalog"] + basePackages = ["org.onap.ccsdk.cds.error.catalog"] ) @EnableAutoConfiguration open class ErrorCatalogTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt index c5bcd467b..8226aaad0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt @@ -62,8 +62,10 @@ class ModelTypeControllerTest { modelType.definition = JacksonUtils.jsonNode(content) modelType.modelName = modelName modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + - BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + modelType.tags = ( + "test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE + ) modelType.updatedBy = "xxxxxx@xxx.com" modelType = modelTypeController.saveModelType(modelType) log.info("Saved Mode {}", modelType.toString()) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/TestDatabaseConfiguration.kt index be012bbc0..6808a2717 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/TestDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/TestDatabaseConfiguration.kt @@ -31,8 +31,10 @@ import javax.sql.DataSource @Configuration @Import(BluePrintDBLibConfiguration::class) @EnableJpaRepositories( - basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.db.primary", - "org.onap.ccsdk.cds.blueprintsprocessor.designer.api"], + basePackages = [ + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary", + "org.onap.ccsdk.cds.blueprintsprocessor.designer.api" + ], entityManagerFactoryRef = "primaryEntityManager", transactionManagerRef = "primaryTransactionManager" ) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt index c4a77e565..8ee2eb3a2 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt @@ -63,8 +63,10 @@ class ModelTypeServiceTest { modelType.definition = JacksonUtils.jsonNode(content) modelType.modelName = modelName modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + - BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + modelType.tags = ( + "test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE + ) modelType.updatedBy = "xxxxxx@xxx.com" modelType = modelTypeHandler!!.saveModel(modelType) log.info("Saved Mode {}", modelType.toString()) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandlerTest.kt index db25b6c35..7b752266d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandlerTest.kt @@ -39,10 +39,10 @@ class ResourceDictionaryHandlerTest { @Test fun testSaveResourceDictionary() { val resourceDefinition: ResourceDefinition = JacksonUtils - .readValueFromFile( - "./../../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", - ResourceDefinition::class.java - )!! + .readValueFromFile( + "./../../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", + ResourceDefinition::class.java + )!! val expectedResourceDictionary = ResourceDictionary() expectedResourceDictionary.name = resourceDefinition.name @@ -57,7 +57,7 @@ class ResourceDictionaryHandlerTest { val mockReturnValue = ResourceDictionary() mockReturnValue.definition = ResourceDefinition() Mockito.`when`(mockRepository.save(any(ResourceDictionary::class.java))) - .thenReturn(mockReturnValue) + .thenReturn(mockReturnValue) runBlocking { resourceDictionaryHandler.saveResourceDefinition(resourceDefinition) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt index 27949901c..a7d166f5e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt @@ -28,6 +28,7 @@ import java.io.File import java.nio.file.Path class MockFilePart(private val fileName: String) : FilePart { + val log = LoggerFactory.getLogger(MockFilePart::class.java)!! override fun content(): Flux<DataBuffer> { TODO("not implemented") // To change body of created functions use File | Settings | File Templates. diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt index 4c05f6009..ca85ed22f 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt @@ -65,8 +65,10 @@ class ModelTypeReactRepositoryTest { modelType.definition = JacksonUtils.jsonNode(content) modelType.modelName = modelName modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + - BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + modelType.tags = ( + "test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE + ) modelType.updatedBy = "xxxxxx@xxx.com" val dbModelType = modelTypeReactRepository!!.save(modelType).block() diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt index b37cd0eda..76e0346f4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.resource.api object ResourceApiDomains { + // Resource Api Domains Constants const val RESOURCE_API = "org.onap.ccsdk.cds.blueprintsprocessor.resource.api" } diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt index 1aae8aa1c..e7c11e306 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt @@ -61,7 +61,7 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR @ApiOperation( value = "Get all resolved resources using the resolution key. ", notes = "Retrieve all stored resolved resources using the blueprint name, blueprint version, " + - "artifact name and the resolution-key.", + "artifact name and the resolution-key.", response = ResourceResolution::class, responseContainer = "List", produces = MediaType.APPLICATION_JSON_VALUE @@ -82,37 +82,43 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR @ApiParam(value = "Resource Id associated with the resolution.", required = false) @RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String ): - ResponseEntity<List<ResourceResolution>> = runBlocking { + ResponseEntity<List<ResourceResolution>> = runBlocking { - if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) { - throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, - "Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.") - } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) { - ResponseEntity.ok() - .body(resourceResolutionDBService.readWithResolutionKey(bpName, bpVersion, artifactName, resolutionKey)) - } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { - ResponseEntity.ok() - .body( - resourceResolutionDBService.readWithResourceIdAndResourceType( - bpName, - bpVersion, - resourceId, - resourceType + if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) { + throw httpProcessorException( + ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, + "Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type." + ) + } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) { + ResponseEntity.ok() + .body(resourceResolutionDBService.readWithResolutionKey(bpName, bpVersion, artifactName, resolutionKey)) + } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { + ResponseEntity.ok() + .body( + resourceResolutionDBService.readWithResourceIdAndResourceType( + bpName, + bpVersion, + resourceId, + resourceType + ) ) + } else { + throw httpProcessorException( + ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, + "Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type." ) - } else { - throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, - "Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.") + } } - } @RequestMapping( - path = [""], - method = [RequestMethod.DELETE], produces = [MediaType.APPLICATION_JSON_VALUE] + path = [""], + method = [RequestMethod.DELETE], produces = [MediaType.APPLICATION_JSON_VALUE] + ) + @ApiOperation( + value = "Delete resources using resolution key", + notes = "Delete all the resources associated to a resolution-key using blueprint metadata, artifact name and the resolution-key.", + produces = MediaType.APPLICATION_JSON_VALUE ) - @ApiOperation(value = "Delete resources using resolution key", - notes = "Delete all the resources associated to a resolution-key using blueprint metadata, artifact name and the resolution-key.", - produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("hasRole('USER')") fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( @ApiParam(value = "Name of the CBA.", required = true) @@ -125,7 +131,14 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR @RequestParam(value = "resolutionKey", required = true) resolutionKey: String ) = runBlocking { ResponseEntity.ok() - .body(resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(bpName, bpVersion, artifactName, resolutionKey)) + .body( + resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey( + bpName, + bpVersion, + artifactName, + resolutionKey + ) + ) } @RequestMapping( @@ -152,9 +165,9 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR @ApiParam(value = "Name of the resource to retrieve.", required = true) @RequestParam(value = "name", required = true) name: String ): - ResponseEntity<ResourceResolution> = runBlocking { + ResponseEntity<ResourceResolution> = runBlocking { - ResponseEntity.ok() - .body(resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name)) - } + ResponseEntity.ok() + .body(resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name)) + } } diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt index 9c09bd819..baaa858d1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt @@ -27,4 +27,4 @@ import org.springframework.web.bind.annotation.RestControllerAdvice */ @RestControllerAdvice("org.onap.ccsdk.cds.blueprintsprocessor.resource.api") open class ResourceExceptionHandler(private val errorCatalogService: ErrorCatalogService) : - ErrorCatalogExceptionHandler(errorCatalogService) + ErrorCatalogExceptionHandler(errorCatalogService) diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt index bd52bfee6..b56a63b17 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt @@ -71,8 +71,8 @@ open class TemplateController(private val templateResolutionService: TemplateRes @ApiOperation( value = "Retrieve a resolved template.", notes = "Retrieve a config template for a given CBA's action, identified by its blueprint name, blueprint version, " + - "artifact name and resolution key. An extra 'format' parameter can be passed to tell what content-type" + - " to expect in return" + "artifact name and resolution key. An extra 'format' parameter can be passed to tell what content-type" + + " to expect in return" ) @ResponseBody @PreAuthorize("hasRole('USER')") @@ -98,50 +98,54 @@ open class TemplateController(private val templateResolutionService: TemplateRes @ApiParam(value = "Occurrence of the template resolution (1-n).", required = false) @RequestParam(value = "occurrence", required = false, defaultValue = "1") occurrence: Int = 1 ): - ResponseEntity<String> = runBlocking { + ResponseEntity<String> = runBlocking { - var result = "" + var result = "" - if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) { - throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, - "Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type.") - } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) { - result = templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName( - bpName, - bpVersion, - artifactName, - resolutionKey, - occurrence - ) - } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { - result = - templateResolutionService.findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName( + if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) { + throw httpProcessorException( + ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, + "Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type." + ) + } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) { + result = templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName( bpName, bpVersion, artifactName, - resourceId, - resourceType, + resolutionKey, occurrence ) - } else { - throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, - "Missing param. Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type.") - } + } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { + result = + templateResolutionService.findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName( + bpName, + bpVersion, + artifactName, + resourceId, + resourceType, + occurrence + ) + } else { + throw httpProcessorException( + ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, + "Missing param. Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type." + ) + } - var expectedContentType = format - if (expectedContentType.indexOf('/') < 0) { - expectedContentType = "application/$expectedContentType" - } - val expectedMediaType: MediaType = MediaType.valueOf(expectedContentType) + var expectedContentType = format + if (expectedContentType.indexOf('/') < 0) { + expectedContentType = "application/$expectedContentType" + } + val expectedMediaType: MediaType = MediaType.valueOf(expectedContentType) - ResponseEntity.ok().contentType(expectedMediaType).body(result) - } + ResponseEntity.ok().contentType(expectedMediaType).body(result) + } @PostMapping("/{bpName}/{bpVersion}/{artifactName}/{resolutionKey}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ApiOperation( value = "Store a resolved template w/ resolution-key", notes = "Store a template for a given CBA's action, identified by its blueprint name, blueprint version, " + - "artifact name and resolution key.", + "artifact name and resolution key.", response = TemplateResolution::class, produces = MediaType.APPLICATION_JSON_VALUE ) @@ -173,7 +177,7 @@ open class TemplateController(private val templateResolutionService: TemplateRes @ApiOperation( value = "Store a resolved template w/ resourceId and resourceType", notes = "Store a template for a given CBA's action, identified by its blueprint name, blueprint version, " + - "artifact name, resourceId and resourceType.", + "artifact name, resourceId and resourceType.", response = TemplateResolution::class, produces = MediaType.APPLICATION_JSON_VALUE ) diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorCatalogTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorCatalogTestConfiguration.kt index 5b0d1980b..8a52884ac 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorCatalogTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorCatalogTestConfiguration.kt @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.error.catalog"] + basePackages = ["org.onap.ccsdk.cds.error.catalog"] ) @EnableAutoConfiguration open class ErrorCatalogTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceControllerTest.kt index c5e002f08..40d6f56cb 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceControllerTest.kt @@ -40,13 +40,17 @@ import org.springframework.test.web.reactive.server.WebTestClient @RunWith(SpringRunner::class) @WebFluxTest @ContextConfiguration( - classes = [TestDatabaseConfiguration::class, ErrorCatalogTestConfiguration::class, - ResourceController::class, ResourceResolutionDBService::class] + classes = [ + TestDatabaseConfiguration::class, ErrorCatalogTestConfiguration::class, + ResourceController::class, ResourceResolutionDBService::class + ] ) @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.controllerblueprints.core.service", + basePackages = [ + "org.onap.ccsdk.cds.controllerblueprints.core.service", "org.onap.ccsdk.cds.blueprintsprocessor.resource.api", - "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"] + "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution" + ] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) class ResourceControllerTest { @@ -55,6 +59,7 @@ class ResourceControllerTest { @Autowired lateinit var resourceResolutionDBService: ResourceResolutionDBService + @Autowired lateinit var webTestClient: WebTestClient @@ -150,9 +155,9 @@ class ResourceControllerTest { .consumeWith { val r = JacksonUtils.objectMapper.readValue(it.responseBody, ErrorPayload::class.java) Assert.assertEquals( - "Cause: Missing param. Either retrieve resolved value using artifact name and " + - "resolution-key OR using resource-id and resource-type. \n" + - " Action : Please verify your request.", + "Cause: Missing param. Either retrieve resolved value using artifact name and " + + "resolution-key OR using resource-id and resource-type. \n" + + " Action : Please verify your request.", r.message ) } @@ -172,7 +177,7 @@ class ResourceControllerTest { val r = JacksonUtils.objectMapper.readValue(it.responseBody, ErrorPayload::class.java) Assert.assertEquals( "Cause: Either retrieve resolved value using artifact name and resolution-key OR using " + - "resource-id and resource-type. \n Action : Please verify your request.", + "resource-id and resource-type. \n Action : Please verify your request.", r.message ) } diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt index 098423540..945a30c64 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt @@ -37,8 +37,10 @@ import kotlin.test.AfterTest @RunWith(SpringRunner::class) @WebFluxTest @ContextConfiguration( - classes = [TestDatabaseConfiguration::class, BluePrintCoreConfiguration::class, - BluePrintCatalogService::class, ErrorCatalogTestConfiguration::class] + classes = [ + TestDatabaseConfiguration::class, BluePrintCoreConfiguration::class, + BluePrintCatalogService::class, ErrorCatalogTestConfiguration::class + ] ) @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) @TestPropertySource(locations = ["classpath:application-test.properties"]) diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TestDatabaseConfiguration.kt index 0ab3b5b21..6d87d2735 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TestDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TestDatabaseConfiguration.kt @@ -31,8 +31,10 @@ import javax.sql.DataSource @Configuration @Import(BluePrintDBLibConfiguration::class) @EnableJpaRepositories( - basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.db.primary", - "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"], + basePackages = [ + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary", + "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution" + ], entityManagerFactoryRef = "primaryEntityManager", transactionManagerRef = "primaryTransactionManager" ) diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt index 46d91e57c..79106c24a 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt @@ -74,10 +74,10 @@ open class BluePrintProcessingGRPCHandler( fun onError(error: Exception) { responseObserver.onError( - Status.INTERNAL - .withDescription(error.errorMessageOrDefault()) - .withCause(error.errorCauseOrDefault()) - .asException() + Status.INTERNAL + .withDescription(error.errorMessageOrDefault()) + .withCause(error.errorCauseOrDefault()) + .asException() ) } @@ -88,10 +88,10 @@ open class BluePrintProcessingGRPCHandler( val errorPayload = errorCatalogService.errorPayload(error) val grpcCode = Status.fromCodeValue(errorPayload.code) responseObserver.onError( - grpcCode - .withDescription(errorPayload.message) - .withCause(error.errorCauseOrDefault()) - .asException() + grpcCode + .withDescription(errorPayload.message) + .withCause(error.errorCauseOrDefault()) + .asException() ) } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt index 1ccf230d7..c4de90755 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt @@ -53,6 +53,7 @@ open class BluePrintProcessingKafkaConsumer( private lateinit var blueprintMessageConsumerService: BlueprintMessageConsumerService companion object { + const val CONSUMER_SELECTOR = "self-service-api" const val PRODUCER_SELECTOR = "self-service-api" } @@ -62,7 +63,7 @@ open class BluePrintProcessingKafkaConsumer( try { log.info( "Setting up message consumer($CONSUMER_SELECTOR)" + - "message producer($PRODUCER_SELECTOR)..." + "message producer($PRODUCER_SELECTOR)..." ) /** Get the Message Consumer Service **/ @@ -71,8 +72,10 @@ open class BluePrintProcessingKafkaConsumer( .blueprintMessageConsumerService(CONSUMER_SELECTOR) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed creating Kafka consumer message service." - throw e.updateErrorMessage(SelfServiceApiDomains.SELF_SERVICE_API, errorMsg, - "Wrong Kafka selector provided or internal error in Kafka service.") + throw e.updateErrorMessage( + SelfServiceApiDomains.SELF_SERVICE_API, errorMsg, + "Wrong Kafka selector provided or internal error in Kafka service." + ) } catch (e: Exception) { throw BluePrintProcessorException("failed to create consumer service ${e.message}") } @@ -80,11 +83,13 @@ open class BluePrintProcessingKafkaConsumer( /** Get the Message Producer Service **/ val blueprintMessageProducerService = try { bluePrintMessageLibPropertyService - .blueprintMessageProducerService(PRODUCER_SELECTOR) + .blueprintMessageProducerService(PRODUCER_SELECTOR) } catch (e: BluePrintProcessorException) { val errorMsg = "Failed creating Kafka producer message service." - throw e.updateErrorMessage(SelfServiceApiDomains.SELF_SERVICE_API, errorMsg, - "Wrong Kafka selector provided or internal error in Kafka service.") + throw e.updateErrorMessage( + SelfServiceApiDomains.SELF_SERVICE_API, errorMsg, + "Wrong Kafka selector provided or internal error in Kafka service." + ) } catch (e: Exception) { throw BluePrintProcessorException("failed to create producer service ${e.message}") } @@ -114,7 +119,8 @@ open class BluePrintProcessingKafkaConsumer( } catch (e: Exception) { log.error( "failed to start message consumer($CONSUMER_SELECTOR) " + - "message producer($PRODUCER_SELECTOR) ", e + "message producer($PRODUCER_SELECTOR) ", + e ) } } @@ -124,7 +130,7 @@ open class BluePrintProcessingKafkaConsumer( try { log.info( "Shutting down message consumer($CONSUMER_SELECTOR)" + - "message producer($PRODUCER_SELECTOR)..." + "message producer($PRODUCER_SELECTOR)..." ) blueprintMessageConsumerService.shutDown() ph.arriveAndAwaitAdvance() diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorHandling.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorHandling.kt index c4baa854c..94b107e9d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorHandling.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorHandling.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api object SelfServiceApiDomains { + // SelfServiceApi Domains Constants const val BLUEPRINT_PROCESSOR = "org.onap.ccsdk.cds.blueprintsprocessor" const val SELF_SERVICE_API = "org.onap.ccsdk.cds.blueprintsprocessor.resource.api" diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt index e5daecede..7628da214 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt @@ -83,9 +83,11 @@ open class ExecutionServiceController { ): ResponseEntity<ExecutionServiceOutput> = mdcWebCoroutineScope { if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) { - throw httpProcessorException(ErrorCatalogCodes.GENERIC_FAILURE, - SelfServiceApiDomains.BLUEPRINT_PROCESSOR, - "Can't process async request through the REST endpoint. Use gRPC for async processing.") + throw httpProcessorException( + ErrorCatalogCodes.GENERIC_FAILURE, + SelfServiceApiDomains.BLUEPRINT_PROCESSOR, + "Can't process async request through the REST endpoint. Use gRPC for async processing." + ) } ph.register() val processResult = executionServiceHandler.doProcess(executionServiceInput) diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceExceptionHandler.kt index 57c02fe6a..0c0466f3c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceExceptionHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceExceptionHandler.kt @@ -29,4 +29,4 @@ import org.springframework.web.bind.annotation.RestControllerAdvice */ @RestControllerAdvice("org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api") class ExecutionServiceExceptionHandler(private val errorCatalogService: ErrorCatalogService) : - ErrorCatalogExceptionHandler(errorCatalogService) + ErrorCatalogExceptionHandler(errorCatalogService) diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt index 6c62aae88..4a7171ceb 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt @@ -44,7 +44,7 @@ class ExecutionServiceHandler( private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val blueprintsProcessorCatalogService: BluePrintCatalogService, private val bluePrintWorkflowExecutionService: - BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>, + BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>, private val publishAuditService: PublishAuditService ) { @@ -71,13 +71,13 @@ class ExecutionServiceHandler( else -> { publishAuditService.publishExecutionInput(executionServiceInput) val executionServiceOutput = response( - executionServiceInput, - "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", - true + executionServiceInput, + "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", + true ) publishAuditService.publishExecutionOutput(executionServiceInput.correlationUUID, executionServiceOutput) responseObserver.onNext( - executionServiceOutput.toProto() + executionServiceOutput.toProto() ) } } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/KafkaPublishAuditService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/KafkaPublishAuditService.kt index 145c37b01..bd1b9ad48 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/KafkaPublishAuditService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/KafkaPublishAuditService.kt @@ -52,19 +52,21 @@ import javax.annotation.PostConstruct * @property log Audit Service logger */ @ConditionalOnProperty( - name = ["blueprintsprocessor.messageproducer.self-service-api.audit.kafkaEnable"], - havingValue = "true" + name = ["blueprintsprocessor.messageproducer.self-service-api.audit.kafkaEnable"], + havingValue = "true" ) @Service class KafkaPublishAuditService( private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService, private val blueprintsProcessorCatalogService: BluePrintCatalogService ) : PublishAuditService { + private var inputInstance: BlueprintMessageProducerService? = null private var outputInstance: BlueprintMessageProducerService? = null private val log = LoggerFactory.getLogger(KafkaPublishAuditService::class.toString()) companion object { + const val INPUT_SELECTOR = "self-service-api.audit.request" const val OUTPUT_SELECTOR = "self-service-api.audit.response" } @@ -88,8 +90,8 @@ class KafkaPublishAuditService( this.inputInstance!!.sendMessage(key, secureExecutionServiceInput) } catch (e: Exception) { var errMsg = - if (e.message != null) "ERROR : ${e.message}" - else "ERROR : Failed to send execution request to Kafka." + if (e.message != null) "ERROR : ${e.message}" + else "ERROR : Failed to send execution request to Kafka." log.error(errMsg) } } @@ -109,8 +111,8 @@ class KafkaPublishAuditService( this.outputInstance!!.sendMessage(key, executionServiceOutput) } catch (e: Exception) { var errMsg = - if (e.message != null) "ERROR : $e" - else "ERROR : Failed to send execution request to Kafka." + if (e.message != null) "ERROR : $e" + else "ERROR : Failed to send execution request to Kafka." log.error(errMsg) } } @@ -161,7 +163,8 @@ class KafkaPublishAuditService( try { if (clonedExecutionServiceInput.payload - .path("$workflowName-request").has("$workflowName-properties")) { + .path("$workflowName-request").has("$workflowName-properties") + ) { /** Retrieving sensitive input parameters */ val requestId = clonedExecutionServiceInput.commonHeader.requestId @@ -181,23 +184,24 @@ class KafkaPublishAuditService( /** We need to check in his Node Template Dependencies is case of a Node Template DG */ if (nodeTemplate.type == BluePrintConstants.NODE_TEMPLATE_TYPE_DG) { - val dependencyNodeTemplate = nodeTemplate.properties?.get(BluePrintConstants.PROPERTY_DG_DEPENDENCY_NODE_TEMPLATE) as ArrayNode + val dependencyNodeTemplate = + nodeTemplate.properties?.get(BluePrintConstants.PROPERTY_DG_DEPENDENCY_NODE_TEMPLATE) as ArrayNode dependencyNodeTemplate.forEach { dependencyNodeTemplateName -> clonedExecutionServiceInput = hideSensitiveDataFromResourceResolution( - blueprintRuntimeService, - blueprintContext, - clonedExecutionServiceInput, - workflowName, - dependencyNodeTemplateName.asText() - ) - } - } else { - clonedExecutionServiceInput = hideSensitiveDataFromResourceResolution( blueprintRuntimeService, blueprintContext, clonedExecutionServiceInput, workflowName, - nodeTemplateName + dependencyNodeTemplateName.asText() + ) + } + } else { + clonedExecutionServiceInput = hideSensitiveDataFromResourceResolution( + blueprintRuntimeService, + blueprintContext, + clonedExecutionServiceInput, + workflowName, + nodeTemplateName ) } } @@ -206,8 +210,9 @@ class KafkaPublishAuditService( val errMsg = "ERROR : Couldn't hide sensitive data in the execution request." log.error(errMsg, e) clonedExecutionServiceInput.payload.replace( - "$workflowName-request", - "$errMsg $e".asJsonPrimitive()) + "$workflowName-request", + "$errMsg $e".asJsonPrimitive() + ) } return clonedExecutionServiceInput } @@ -236,8 +241,8 @@ class KafkaPublishAuditService( val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName) val propertyAssignments: MutableMap<String, JsonNode> = - blueprintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) - ?: hashMapOf() + blueprintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) + ?: hashMapOf() /** Getting values define in artifact-prefix-names */ val input = executionServiceInput.payload.get("$workflowName-request") @@ -245,25 +250,26 @@ class KafkaPublishAuditService( val artifactPrefixNamesNode = propertyAssignments[ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES] val propertyAssignmentService = PropertyAssignmentService(blueprintRuntimeService) val artifactPrefixNamesNodeValue = propertyAssignmentService.resolveAssignmentExpression( - BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, - nodeTemplateName, - ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES, - artifactPrefixNamesNode!!) + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, + nodeTemplateName, + ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES, + artifactPrefixNamesNode!! + ) val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNodeValue!!, String::class.java) /** Storing mapping entries with metadata log-protect set to true */ val sensitiveParameters: List<String> = artifactPrefixNames - .map { "$it-mapping" } - .map { blueprintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, it) } - .flatMap { JacksonUtils.getListFromJson(it, ResourceAssignment::class.java) } - .filter { PropertyDefinitionUtils.hasLogProtect(it.property) } - .map { it.name } + .map { "$it-mapping" } + .map { blueprintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, it) } + .flatMap { JacksonUtils.getListFromJson(it, ResourceAssignment::class.java) } + .filter { PropertyDefinitionUtils.hasLogProtect(it.property) } + .map { it.name } /** Hiding sensitive input parameters from the request */ var workflowProperties: ObjectNode = executionServiceInput.payload - .path("$workflowName-request") - .path("$workflowName-properties") as ObjectNode + .path("$workflowName-request") + .path("$workflowName-properties") as ObjectNode sensitiveParameters.forEach { sensitiveParameter -> if (workflowProperties.has(sensitiveParameter)) { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/NoPublishAuditService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/NoPublishAuditService.kt index 6ad73d88a..aea9b7bc2 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/NoPublishAuditService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/NoPublishAuditService.kt @@ -26,8 +26,8 @@ import javax.annotation.PostConstruct * Default audit service when no audit publisher is defined, message aren't sent */ @ConditionalOnProperty( - name = ["blueprintsprocessor.messageproducer.self-service-api.audit.kafkaEnable"], - havingValue = "false" + name = ["blueprintsprocessor.messageproducer.self-service-api.audit.kafkaEnable"], + havingValue = "false" ) @Service class NoPublishAuditService : PublishAuditService { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/PublishAuditService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/PublishAuditService.kt index 67473c807..0b392e215 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/PublishAuditService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/PublishAuditService.kt @@ -20,6 +20,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput interface PublishAuditService { + suspend fun publishExecutionInput(executionServiceInput: ExecutionServiceInput) suspend fun publishExecutionOutput(correlationUUID: String, executionServiceOutput: ExecutionServiceOutput) } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt index f33f1149f..8cfd562d1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt @@ -42,8 +42,10 @@ import kotlin.test.BeforeTest @RunWith(SpringRunner::class) @DirtiesContext @ContextConfiguration( - classes = [SelfServiceApiTestConfiguration::class, TestDatabaseConfiguration::class, - ErrorCatalogTestConfiguration::class] + classes = [ + SelfServiceApiTestConfiguration::class, TestDatabaseConfiguration::class, + ErrorCatalogTestConfiguration::class + ] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintProcessingGRPCHandlerTest { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt index 825b0c82a..80e953822 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt @@ -33,7 +33,7 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOu import org.springframework.test.context.ContextConfiguration @ContextConfiguration( - classes = [SelfServiceApiTestConfiguration::class, ErrorCatalogTestConfiguration::class] + classes = [SelfServiceApiTestConfiguration::class, ErrorCatalogTestConfiguration::class] ) class BluePrintProcessingIntegrationTest { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt index ed573d72f..4a11aeebd 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt @@ -35,8 +35,10 @@ import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [BluePrintMessageLibConfiguration::class, SelfServiceApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, ErrorCatalogTestConfiguration::class] + classes = [ + BluePrintMessageLibConfiguration::class, SelfServiceApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, ErrorCatalogTestConfiguration::class + ] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintProcessingKafkaConsumerTest { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorCatalogTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorCatalogTestConfiguration.kt index a773b4cc5..8fd5e6ba0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorCatalogTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ErrorCatalogTestConfiguration.kt @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.error.catalog"] + basePackages = ["org.onap.ccsdk.cds.error.catalog"] ) @EnableAutoConfiguration open class ErrorCatalogTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt index f2c77d6f8..ce78aab0e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt @@ -43,14 +43,17 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @WebFluxTest @ContextConfiguration( - classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, - BluePrintCatalogService::class, SelfServiceApiTestConfiguration::class, ErrorCatalogTestConfiguration::class] + classes = [ + ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, + BluePrintCatalogService::class, SelfServiceApiTestConfiguration::class, ErrorCatalogTestConfiguration::class + ] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) class ExecutionServiceControllerTest { @Autowired lateinit var blueprintsProcessorCatalogService: BluePrintCatalogService + @Autowired lateinit var webTestClient: WebTestClient diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt index 70e1ed0fd..86ed0eab6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt @@ -16,9 +16,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api -import io.mockk.coVerify import io.mockk.Runs import io.mockk.coEvery +import io.mockk.coVerify import io.mockk.just import io.mockk.mockk import kotlinx.coroutines.runBlocking @@ -42,8 +42,12 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [MockServiceAction::class, SelfServiceApiTestConfiguration::class, - ErrorCatalogTestConfiguration::class]) +@ContextConfiguration( + classes = [ + MockServiceAction::class, SelfServiceApiTestConfiguration::class, + ErrorCatalogTestConfiguration::class + ] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) class ExecutionServiceHandlerTest { @@ -95,10 +99,10 @@ class ExecutionServiceHandlerTest { val publishAuditService = mockk<KafkaPublishAuditService>(relaxed = true) val executionServiceHandler = ExecutionServiceHandler( - mockk(), - mockk(), - mockk(), - publishAuditService + mockk(), + mockk(), + mockk(), + publishAuditService ) coEvery { publishAuditService.publishExecutionInput(ExecutionServiceInput()) } just Runs diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceApiTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceApiTestConfiguration.kt index 98b882934..7bcf55f82 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceApiTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/SelfServiceApiTestConfiguration.kt @@ -22,8 +22,10 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan( - basePackages = ["org.onap.ccsdk.cds.controllerblueprints", - "org.onap.ccsdk.cds.blueprintsprocessor"] + basePackages = [ + "org.onap.ccsdk.cds.controllerblueprints", + "org.onap.ccsdk.cds.blueprintsprocessor" + ] ) @EnableAutoConfiguration open class SelfServiceApiTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt index 94da0f574..bca05f68b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt @@ -31,8 +31,10 @@ import javax.sql.DataSource @Configuration @Import(BluePrintDBLibConfiguration::class) @EnableJpaRepositories( - basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.db.primary", - "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"], + basePackages = [ + "org.onap.ccsdk.cds.blueprintsprocessor.db.primary", + "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution" + ], entityManagerFactoryRef = "primaryEntityManager", transactionManagerRef = "primaryTransactionManager" ) diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt index 9f5cc6097..0deb9c91b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt @@ -53,12 +53,14 @@ class MockComponentFunction : AbstractComponentFunction() { } open class MockResourceSource { + @Bean( name = [ "rr-processor-source-input", "rr-processor-source-default", "rr-processor-source-db", - "rr-processor-source-rest"] + "rr-processor-source-rest" + ] ) open fun sourceInstance(): ResourceAssignmentProcessor { return mockk<ResourceAssignmentProcessor>() diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt index a367c8d36..84d057f55 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt @@ -28,8 +28,10 @@ import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [BluePrintRuntimeValidatorService::class, - BluePrintValidationConfiguration::class, MockResourceSource::class] + classes = [ + BluePrintRuntimeValidatorService::class, + BluePrintValidationConfiguration::class, MockResourceSource::class + ] ) class BluePrintRuntimeValidatorServiceTest { |