diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2020-09-22 12:16:46 -0400 |
---|---|---|
committer | Singal, Kapil (ks220y) <ks220y@att.com> | 2020-09-22 13:49:05 -0400 |
commit | 1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch) | |
tree | 4a821659cf3b50cf946cbb535d528be8508e9fff /ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main | |
parent | d97021cd756d63402545fdc2e14ac7611c3da118 (diff) |
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation
Issue-ID: CCSDK-2852
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main')
9 files changed, 76 insertions, 60 deletions
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) } |