summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules
parentd274e5fc552cf9ae25500f504f0434981cf3accf (diff)
Formatting Code base with ktlint
No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt19
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt6
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt12
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt6
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt26
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt16
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt19
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt10
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt18
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt5
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintCatalogServiceImpl.kt22
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt50
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt30
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt8
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt15
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt13
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt48
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt12
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt86
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcExtensions.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt4
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt4
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt20
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt34
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BasicAuthGrpcClientService.kt17
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcClientService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcServerService.kt18
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TokenAuthGrpcClientService.kt30
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt114
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt39
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt35
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageExtensions.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt6
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/kafka/AbstractKafkaTopologyComponents.kt6
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt24
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerService.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt13
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt20
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerService.kt8
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerService.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt81
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerServiceTest.kt65
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerServiceTest.kt5
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MockKafkaTopologyComponents.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/ApiDataExtensions.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt41
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt49
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/factory/ComponentNodeFactory.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappings.kt10
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/PayloadUtils.kt5
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintPropertiesTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappingsTest.kt (renamed from ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappingTests.kt)10
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt5
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt6
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/filters/RestServerLoggingWebFilter.kt6
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt59
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt100
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt13
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/utils/WebClientUtils.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt134
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt4
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt221
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt11
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt20
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt12
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientService.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyServiceTest.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientServiceTest.kt27
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotController.kt82
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/configs-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotExceptionHandler.kt17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt48
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt179
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt76
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt8
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt25
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt40
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt18
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt9
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt10
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt39
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt42
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt52
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt145
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt15
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt12
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt10
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt9
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepository.kt (renamed from ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt)16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt36
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt86
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt (renamed from ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt)2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt142
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt136
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt23
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt9
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt29
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt8
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt26
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt (renamed from ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt)12
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt7
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt8
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt99
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt23
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt28
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt18
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt85
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt76
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceControllerTest.kt51
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt23
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt41
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt40
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt44
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt8
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt46
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingIntegrationTest.kt28
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt48
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/mock/Mock.kt19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/UtilsTest.kt (renamed from ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt)3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt9
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt20
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt4
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt47
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt15
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt70
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt77
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt31
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt48
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt6
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt5
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt11
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt50
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt62
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt28
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt33
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt13
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt24
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt22
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt84
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt18
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt20
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt59
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt39
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt24
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt48
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt23
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt14
216 files changed, 3243 insertions, 2266 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
index a7ad921de..d990f397d 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
@@ -17,7 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.db
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
import org.springframework.boot.context.properties.EnableConfigurationProperties
@@ -30,33 +30,34 @@ open class BluePrintDBLibConfiguration(private var bluePrintPropertiesService: B
@Bean("primary-database-properties")
open fun getPrimaryProperties(): PrimaryDataSourceProperties {
- return bluePrintPropertiesService.propertyBeanType(DBLibConstants.PREFIX_DB,
- PrimaryDataSourceProperties::class.java)
+ return bluePrintPropertiesService.propertyBeanType(
+ DBLibConstants.PREFIX_DB,
+ PrimaryDataSourceProperties::class.java
+ )
}
}
/**
* Exposed Dependency Service by this SSH Lib Module
*/
-fun BluePrintDependencyService.dbLibPropertyService(): BluePrintDBLibPropertySevice =
- instance(BluePrintDBLibPropertySevice::class)
+fun BluePrintDependencyService.dbLibPropertyService(): BluePrintDBLibPropertyService =
+ instance(BluePrintDBLibPropertyService::class)
fun BluePrintDependencyService.primaryDBLibGenericService(): BluePrintDBLibGenericService =
- instance(PrimaryDBLibGenericService::class)
-
+ instance(PrimaryDBLibGenericService::class)
class DBLibConstants {
companion object {
const val PREFIX_DB: String = "blueprintsprocessor.db"
- //list of database
+ // list of database
const val MARIA_DB: String = "maria-db"
const val PRIMARY_DB: String = "processor-db"
const val MYSQL_DB: String = "mysql-db"
const val ORACLE_DB: String = "oracle-db"
const val POSTGRES_DB: String = "postgres-db"
- //List of database drivers
+ // List of database drivers
const val DRIVER_MARIA_DB = "org.mariadb.jdbc.Driver"
const val DRIVER_MYSQL_DB = "com.mysql.jdbc.Driver"
const val DRIVER_ORACLE_DB = "oracle.jdbc.driver.OracleDriver"
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt
index fc43ce34d..d4d804857 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.db
-
open class DBDataSourceProperties {
lateinit var url: String
lateinit var username: String
@@ -24,14 +23,14 @@ open class DBDataSourceProperties {
open lateinit var driverClassName: String
}
-open class PrimaryDataSourceProperties: DBDataSourceProperties() {
+open class PrimaryDataSourceProperties : DBDataSourceProperties() {
lateinit var hibernateHbm2ddlAuto: String
lateinit var hibernateDDLAuto: String
lateinit var hibernateNamingStrategy: String
lateinit var hibernateDialect: String
}
-open class MariaDataSourceProperties: DBDataSourceProperties() {
+open class MariaDataSourceProperties : DBDataSourceProperties() {
lateinit var hibernateHbm2ddlAuto: String
lateinit var hibernateDDLAuto: String
lateinit var hibernateNamingStrategy: String
@@ -40,7 +39,7 @@ open class MariaDataSourceProperties: DBDataSourceProperties() {
override var driverClassName = DBLibConstants.DRIVER_MARIA_DB
}
-open class MySqlDataSourceProperties: DBDataSourceProperties() {
+open class MySqlDataSourceProperties : DBDataSourceProperties() {
lateinit var hibernateHbm2ddlAuto: String
lateinit var hibernateDDLAuto: String
lateinit var hibernateNamingStrategy: String
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
index 0f6314685..aeb87fd66 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
@@ -27,8 +27,8 @@ interface BluePrintDBLibGenericService {
fun update(sql: String, params: Map<String, Any>): Int
}
-abstract class AbstractDBLibGenericService(private val namedParameterJdbcTemplate: NamedParameterJdbcTemplate)
- : BluePrintDBLibGenericService {
+abstract class AbstractDBLibGenericService(private val namedParameterJdbcTemplate: NamedParameterJdbcTemplate) :
+ BluePrintDBLibGenericService {
override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
return namedParameterJdbcTemplate
@@ -41,4 +41,4 @@ abstract class AbstractDBLibGenericService(private val namedParameterJdbcTemplat
override fun update(sql: String, params: Map<String, Any>): Int {
return namedParameterJdbcTemplate.update(sql, params)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt
index ff53de89f..35baf9314 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt
@@ -18,13 +18,18 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
-import org.onap.ccsdk.cds.blueprintsprocessor.db.*
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
+import org.onap.ccsdk.cds.blueprintsprocessor.db.DBDataSourceProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants
+import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDataSourceProperties
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@Service
-class BluePrintDBLibPropertySevice(private var bluePrintPropertiesService: BluePrintPropertiesService) {
+class BluePrintDBLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) {
fun JdbcTemplate(jsonNode: JsonNode): BluePrintDBLibGenericService {
val dBConnetionProperties = dBDataSourceProperties(jsonNode)
@@ -101,5 +106,4 @@ class BluePrintDBLibPropertySevice(private var bluePrintPropertiesService: BlueP
private fun primaryDBConnectionProperties(prefix: String): PrimaryDataSourceProperties {
return bluePrintPropertiesService.propertyBeanType(prefix, PrimaryDataSourceProperties::class.java)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt
index 6a0d4a0c5..4faaa2eef 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt
@@ -51,4 +51,4 @@ class MariaDatabaseConfiguration(private val mariaDataSourceProperties: MariaDat
fun mariaNamedParameterJdbcTemplate(mariaDataSource: DataSource): NamedParameterJdbcTemplate {
return NamedParameterJdbcTemplate(mariaDataSource)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt
index 3091674f0..49b7ec9eb 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt
@@ -50,6 +50,4 @@ class MySqlDatabaseConfiguration(private val mySqlDataSourceProperties: MySqlDat
fun mySqlNamedParameterJdbcTemplate(mySqlDataSource: DataSource): NamedParameterJdbcTemplate {
return NamedParameterJdbcTemplate(mySqlDataSource)
}
-
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
index 896929fbb..4363feb2b 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
@@ -21,7 +21,5 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
import org.springframework.stereotype.Service
@Service
-open class PrimaryDBLibGenericService(primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
- : AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate) {
-
-} \ No newline at end of file
+open class PrimaryDBLibGenericService(primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate) :
+ AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate)
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
index 82b77da47..4223ed31c 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
@@ -30,29 +30,34 @@ import org.springframework.orm.jpa.JpaTransactionManager
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
import org.springframework.transaction.PlatformTransactionManager
-import java.util.*
+import java.util.HashMap
import javax.sql.DataSource
@Configuration
-@ConditionalOnProperty(name = ["blueprintsprocessor.db.primary.defaultConfig"], havingValue = "true",
- matchIfMissing = true)
+@ConditionalOnProperty(
+ name = ["blueprintsprocessor.db.primary.defaultConfig"], havingValue = "true",
+ matchIfMissing = true
+)
@ComponentScan
@EnableJpaRepositories(
- basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.*",
- "org.onap.ccsdk.cds.controllerblueprints.*"],
- entityManagerFactoryRef = "primaryEntityManager",
- transactionManagerRef = "primaryTransactionManager"
+ basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.*",
+ "org.onap.ccsdk.cds.controllerblueprints.*"],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
)
@EnableJpaAuditing
open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
+
private val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
@Bean("primaryEntityManager")
open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
val em = LocalContainerEntityManagerFactoryBean()
em.dataSource = primaryDataSource()
- em.setPackagesToScan("org.onap.ccsdk.cds.blueprintsprocessor.*",
- "org.onap.ccsdk.cds.controllerblueprints.*")
+ em.setPackagesToScan(
+ "org.onap.ccsdk.cds.blueprintsprocessor.*",
+ "org.onap.ccsdk.cds.controllerblueprints.*"
+ )
em.jpaVendorAdapter = HibernateJpaVendorAdapter()
val properties = HashMap<String, Any>()
properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
@@ -83,5 +88,4 @@ open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties:
open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
return NamedParameterJdbcTemplate(primaryDataSource)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt
index 74a611fbb..43bcb6741 100755
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt
@@ -22,8 +22,19 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.CascadeType
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.FetchType
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.OneToOne
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
+import javax.persistence.UniqueConstraint
/**
* Provide BlueprintModel Entity
@@ -37,6 +48,7 @@ import javax.persistence.*
@Table(name = "BLUEPRINT_MODEL", uniqueConstraints = [UniqueConstraint(columnNames = ["artifact_name", "artifact_version"])])
@Proxy(lazy = false)
class BlueprintModel : Serializable {
+
@Id
@Column(name = "blueprint_model_id")
var id: String? = null
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt
index bed6e4e38..a18ae8b1d 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt
@@ -21,8 +21,18 @@ import io.swagger.annotations.ApiModelProperty
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import java.util.Objects
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.JoinColumn
+import javax.persistence.Lob
+import javax.persistence.OneToOne
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
/**
* Provide Blueprint Model Content Entity
@@ -82,8 +92,8 @@ class BlueprintModelContent : Serializable {
return false
}
val blueprintModelContent = o as BlueprintModelContent?
- return (id == blueprintModelContent!!.id && name == blueprintModelContent.name
- && contentType == blueprintModelContent.contentType)
+ return (id == blueprintModelContent!!.id && name == blueprintModelContent.name &&
+ contentType == blueprintModelContent.contentType)
}
override fun hashCode(): Int {
@@ -94,5 +104,4 @@ class BlueprintModelContent : Serializable {
private const val serialVersionUID = 1L
}
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt
index f47124dd0..b1c006793 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt
@@ -21,8 +21,14 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeName
import org.springframework.data.annotation.LastModifiedDate
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
/**
* Provide Blueprint Model Search Entity
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt
index 7bbfbce79..59ace723a 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt
@@ -22,7 +22,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
-import java.util.*
+import java.util.Optional
/**
* @param <T> Model
@@ -47,8 +47,8 @@ interface BlueprintModelContentRepository : JpaRepository<BlueprintModelContent,
* @param contentType contentType
* @return B?
*/
- fun findTopByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String)
- : BlueprintModelContent?
+ fun findTopByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String):
+ BlueprintModelContent?
/**
* This is a findByBlueprintModelAndContentType method
@@ -57,8 +57,8 @@ interface BlueprintModelContentRepository : JpaRepository<BlueprintModelContent,
* @param contentType contentType
* @return List<B>
*/
- fun findByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String)
- : List<BlueprintModelContent>
+ fun findByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String):
+ List<BlueprintModelContent>
/**
* This is a findByBlueprintModel method
@@ -76,8 +76,11 @@ interface BlueprintModelContentRepository : JpaRepository<BlueprintModelContent,
* @param name name
* @return B?
*/
- fun findByBlueprintModelAndContentTypeAndName(blueprintModel: BlueprintModel,
- contentType: String, name: String): BlueprintModelContent?
+ fun findByBlueprintModelAndContentTypeAndName(
+ blueprintModel: BlueprintModel,
+ contentType: String,
+ name: String
+ ): BlueprintModelContent?
/**
* This is a deleteByMdeleteByBlueprintModelodelName method
@@ -92,5 +95,4 @@ interface BlueprintModelContentRepository : JpaRepository<BlueprintModelContent,
* @param id id
*/
override fun deleteById(@NotNull id: String)
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt
index 8ef352852..a7891f6a7 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
-import java.util.*
+import java.util.Optional
import javax.transaction.Transactional
/**
@@ -86,5 +86,4 @@ interface BlueprintModelRepository : JpaRepository<BlueprintModel, String> {
* @param id id
*/
override fun deleteById(@NotNull id: String)
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt
index 5c7a94034..4451283cb 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt
@@ -19,7 +19,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
import org.springframework.data.domain.Page
-import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
@@ -77,9 +76,13 @@ interface BlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, L
* @return Optional<BlueprintModelSearch>
</BlueprintModelSearch>
*/
- fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(updatedBy: String, tags: String, artifactName: String, artifactVersion: String,
- artifactType: String): List<BlueprintModelSearch>
-
+ fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
+ updatedBy: String,
+ tags: String,
+ artifactName: String,
+ artifactVersion: String,
+ artifactType: String
+ ): List<BlueprintModelSearch>
/**
* This is a findby some attributes method
@@ -94,10 +97,12 @@ interface BlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, L
* @param pageRequest
* @return Page<BlueprintModelSearch>
*/
- fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(updatedBy: String, tags: String, artifactName: String, artifactVersion: String,
- artifactType: String,pageRequest: Pageable): Page<BlueprintModelSearch>
-
-
-
-
+ fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
+ updatedBy: String,
+ tags: String,
+ artifactName: String,
+ artifactVersion: String,
+ artifactType: String,
+ pageRequest: Pageable
+ ): Page<BlueprintModelSearch>
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintCatalogServiceImpl.kt
index 5700c2a46..9d1826395 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintCatalogServiceImpl.kt
@@ -18,10 +18,14 @@
package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.deCompress
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
@@ -31,8 +35,9 @@ import javax.persistence.MappedSuperclass
@MappedSuperclass
abstract class BlueprintCatalogServiceImpl(
- private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val blueprintValidator: BluePrintValidatorService) : BluePrintCatalogService {
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val blueprintValidator: BluePrintValidatorService
+) : BluePrintCatalogService {
private val log = LoggerFactory.getLogger(BlueprintCatalogServiceImpl::class.java)!!
@@ -74,14 +79,15 @@ abstract class BlueprintCatalogServiceImpl(
return processingId
}
- override suspend fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(name, version,
- extract)
- ?: throw BluePrintException("Could not find blueprint $name:$version from database")
+ override suspend fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(
+ name, version,
+ extract
+ )
+ ?: throw BluePrintException("Could not find blueprint $name:$version from database")
override suspend fun deleteFromDatabase(name: String, version: String) = delete(name, version)
abstract suspend fun save(metadata: MutableMap<String, String>, archiveFile: File)
abstract suspend fun get(name: String, version: String, extract: Boolean): Path?
abstract suspend fun delete(name: String, version: String)
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt
index 3ba25d8de..0c407ecdf 100755
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt
@@ -21,11 +21,18 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelRepository
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
+import org.onap.ccsdk.cds.controllerblueprints.core.deCompress
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.onap.ccsdk.cds.controllerblueprints.core.reCreateNBDirs
import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
import org.slf4j.LoggerFactory
@@ -33,24 +40,26 @@ import org.springframework.dao.DataIntegrityViolationException
import org.springframework.stereotype.Service
import java.io.File
import java.nio.file.Path
-import java.util.*
+import java.util.UUID
// TODO("Duplicate : Merge BlueprintProcessorCatalogServiceImpl and ControllerBlueprintCatalogServiceImpl")
/**
* Similar/Duplicate implementation in [org.onap.ccsdk.cds.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
*/
@Service("blueprintsProcessorCatalogService")
-class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
- private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val blueprintModelRepository: BlueprintModelRepository)
- : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintRuntimeValidatorService) {
+class BlueprintProcessorCatalogServiceImpl(
+ bluePrintRuntimeValidatorService: BluePrintValidatorService,
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val blueprintModelRepository: BlueprintModelRepository
+) :
+ BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintRuntimeValidatorService) {
private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
override suspend fun delete(name: String, version: String) {
// Clean blueprint script cache
val cacheKey = BluePrintFileUtils
- .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, name, version))
+ .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, name, version))
BluePrintCompileCache.cleanClassLoader(cacheKey)
log.info("removed cba file name($name), version($version) from cache")
// Cleaning Deployed Blueprint
@@ -58,16 +67,17 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
log.info("removed cba file name($name), version($version) from deploy location")
// Cleaning Data Base
blueprintModelRepository
- .deleteByArtifactNameAndArtifactVersion(name, version)
+ .deleteByArtifactNameAndArtifactVersion(name, version)
log.info("removed cba file name($name), version($version) from database")
}
-
override suspend fun get(name: String, version: String, extract: Boolean): Path? {
val deployFile = normalizedFile(bluePrintLoadConfiguration.blueprintDeployPath, name, version)
- val cbaFile = normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath,
- UUID.randomUUID().toString(), "cba.zip")
+ val cbaFile = normalizedFile(
+ bluePrintLoadConfiguration.blueprintArchivePath,
+ UUID.randomUUID().toString(), "cba.zip"
+ )
if (extract && deployFile.exists()) {
log.info("cba file name($name), version($version) already present(${deployFile.absolutePath})")
@@ -91,8 +101,10 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
}
} catch (e: Exception) {
deleteNBDir(deployFile.absolutePath)
- throw BluePrintProcessorException("failed to get get cba file name($name), version($version) from db" +
- " : ${e.message}")
+ throw BluePrintProcessorException(
+ "failed to get get cba file name($name), version($version) from db" +
+ " : ${e.message}"
+ )
} finally {
deleteNBDir(cbaFile.parentFile.absolutePath)
}
@@ -117,7 +129,7 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
log.info("Overwriting blueprint model :$artifactName::$artifactVersion")
blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion)
val deployFile =
- normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, artifactName, artifactVersion)
+ normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, artifactName, artifactVersion)
val cacheKey = BluePrintFileUtils.compileCacheKey(deployFile)
BluePrintCompileCache.cleanClassLoader(cacheKey)
@@ -132,7 +144,7 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
blueprintModel.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID]
blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
blueprintModel.published = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID]
- ?: BluePrintConstants.FLAG_N
+ ?: BluePrintConstants.FLAG_N
blueprintModel.artifactName = artifactName
blueprintModel.artifactVersion = artifactVersion
blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]!!
@@ -152,8 +164,10 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
try {
blueprintModelRepository.saveAndFlush(blueprintModel)
} catch (ex: DataIntegrityViolationException) {
- throw BluePrintException(ErrorCode.CONFLICT_ADDING_RESOURCE.value, "The blueprint entry " +
- "is already exist in database: ${ex.message}", ex)
+ throw BluePrintException(
+ ErrorCode.CONFLICT_ADDING_RESOURCE.value, "The blueprint entry " +
+ "is already exist in database: ${ex.message}", ex
+ )
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
index d912d8eae..e86dfab72 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
@@ -43,8 +43,10 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@EnableAutoConfiguration
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor"])
-@ContextConfiguration(classes = [BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class,
- MockBlueprintProcessorCatalogServiceImpl::class])
+@ContextConfiguration(
+ classes = [BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class,
+ MockBlueprintProcessorCatalogServiceImpl::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BlueprintProcessorCatalogServiceImplTest {
@@ -61,8 +63,10 @@ class BlueprintProcessorCatalogServiceImplTest {
@BeforeTest
fun setup() {
deleteDir("target", "blueprints")
- bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(blueprintId,
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ blueprintId,
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
}
@AfterTest
@@ -72,9 +76,9 @@ class BlueprintProcessorCatalogServiceImplTest {
@Test
fun `test catalog service`() {
- //TODO: I thing this test function should be remve and replace by the other one.
+ // TODO: I thing this test function should be remve and replace by the other one.
runBlocking {
- //FIXME("Create ZIP from test blueprints")
+ // FIXME("Create ZIP from test blueprints")
val file = normalizedFile("./src/test/resources/test-cba.zip")
assertTrue(file.exists(), "couldn't get file ${file.absolutePath}")
@@ -110,10 +114,14 @@ class BlueprintProcessorCatalogServiceImplTest {
blueprintsProcessorCatalogService.get("baseconfiguration", "1.0.0", true)
}
- assertTrue(File(blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath +
- "/baseconfiguration").deleteRecursively(),"Couldn't get blueprint archive " +
- "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " +
- "from data base.")
+ assertTrue(
+ File(
+ blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath +
+ "/baseconfiguration"
+ ).deleteRecursively(), "Couldn't get blueprint archive " +
+ "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " +
+ "from data base."
+ )
}
@Test
@@ -122,4 +130,4 @@ class BlueprintProcessorCatalogServiceImplTest {
blueprintsProcessorCatalogService.delete("baseconfiguration", "1.0.0")
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt
index b98fc0c44..8dcf42668 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt
@@ -32,4 +32,4 @@ open class MockBlueprintProcessorCatalogServiceImpl {
every { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
return bluePrintValidatorService
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt
index 2ab1c5d48..185b2e327 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt
@@ -32,8 +32,10 @@ import javax.sql.DataSource
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
- BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
+@ContextConfiguration(
+ classes = [BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
+ BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@EnableAutoConfiguration
@@ -46,4 +48,4 @@ class PrimaryDatabaseConfigurationTest {
fun testPrimaryDatabaseConfiguration() {
assertNotNull(primaryDataSource, " failed to create primary data source")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt
index 2dbea8fc9..8ccd8cd56 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt
@@ -27,16 +27,17 @@ import com.att.nsa.mr.client.impl.MRSimplerBatchPublisher
/**
* Representation of DMAAP client service for AAF auth type.
*/
-class AafAuthDmaapClientService(private val clientProps:
- AafAuthDmaapClientProperties)
- : BluePrintDmaapClientService {
+class AafAuthDmaapClientService(
+ private val clientProps:
+ AafAuthDmaapClientProperties
+) :
+ BluePrintDmaapClientService {
/**
* The constructed DMAAP client.
*/
var clients: MutableList<MRBatchingPublisher> = mutableListOf()
-
/**
* Returns the DMAAP client after constructing it properly with the data
* that is required for AAF auth connection.
@@ -52,12 +53,12 @@ class AafAuthDmaapClientService(private val clientProps:
val client = MRClientFactory.createBatchingPublisher(
clientProps.host, t, clientProps.username,
clientProps.password, 1, 1, false,
- clientProps.type, "")
+ clientProps.type, ""
+ )
val batchPublisher = client as MRSimplerBatchPublisher
batchPublisher.props = clientProps.props
clients.add(client)
}
return clients
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt
index a4cb5a3e6..cbde4d003 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt
@@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory
import java.io.IOException
import java.util.concurrent.TimeUnit
-
/**
* Abstraction of DMAAP client services that could form DMAAP client from the
* properties provided. This abstraction also provides a mechanism to send
@@ -38,14 +37,16 @@ interface BluePrintDmaapClientService {
* Static variable for logging.
*/
companion object {
+
var log = LoggerFactory.getLogger(
- BluePrintDmaapClientService::class.java)!!
+ BluePrintDmaapClientService::class.java
+ )!!
}
/**
* Returns the properly constructed DMAAP client with the type.
*/
- fun getDmaapClient(): MutableList<MRBatchingPublisher>
+ fun getDmaapClient(): MutableList<MRBatchingPublisher>
/**
* Sends messages to the sessions created by the information provided from
@@ -93,8 +94,10 @@ interface BluePrintDmaapClientService {
var ms = client.close(timeout, TimeUnit.SECONDS)
msgs.add(ms)
} catch (e: IOException) {
- log.warn("Unable to cleanly close the connection from the " +
- "client $client", e)
+ log.warn(
+ "Unable to cleanly close the connection from the " +
+ "client $client", e
+ )
}
}
return msgs
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt
index 51cd3bf0a..44ed5316b 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt
@@ -37,10 +37,11 @@ open class BluePrintDmaapLibConfiguration
* Util constants required for DMAAP library to use.
*/
class DmaapLibConstants {
+
companion object {
const val SERVICE_BLUEPRINT_DMAAP_LIB_PROPERTY = "blueprint" +
"-dmaap-lib-property-service"
const val TYPE_HTTP_NO_AUTH = "HTTPNOAUTH"
const val TYPE_HTTP_AAF_AUTH = "HTTPAAF"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt
index cde4987ff..a3eed159f 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt
@@ -36,7 +36,7 @@ import org.springframework.core.env.ConfigurableEnvironment
import org.springframework.core.env.Environment
import org.springframework.core.io.support.ResourcePropertySource
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.Properties
/**
* Representation of DMAAP lib property service to load the properties
@@ -52,8 +52,10 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
* Static variable for logging.
*/
companion object {
+
var log = LoggerFactory.getLogger(
- BluePrintDmaapLibPropertyService::class.java)!!
+ BluePrintDmaapLibPropertyService::class.java
+ )!!
}
/**
@@ -90,25 +92,30 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
*/
fun dmaapClientProperties(prefix: String): DmaapClientProperties {
val type = bluePrintPropertiesService.propertyBeanType(
- "$prefix.type", String::class.java)
+ "$prefix.type", String::class.java
+ )
val clientProps: DmaapClientProperties
when (type) {
TYPE_HTTP_NO_AUTH -> {
clientProps = bluePrintPropertiesService.propertyBeanType(
- prefix, HttpNoAuthDmaapClientProperties::class.java)
+ prefix, HttpNoAuthDmaapClientProperties::class.java
+ )
clientProps.props = parseEventProps()
}
TYPE_HTTP_AAF_AUTH -> {
clientProps = bluePrintPropertiesService.propertyBeanType(
- prefix, AafAuthDmaapClientProperties::class.java)
+ prefix, AafAuthDmaapClientProperties::class.java
+ )
clientProps.props = parseEventProps()
}
else -> {
- throw BluePrintProcessorException("DMAAP adaptor($type) is " +
- "not supported")
+ throw BluePrintProcessorException(
+ "DMAAP adaptor($type) is " +
+ "not supported"
+ )
}
}
return clientProps
@@ -124,20 +131,26 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
when (type) {
TYPE_HTTP_NO_AUTH -> {
- clientProps = JacksonUtils.readValue(jsonNode,
- HttpNoAuthDmaapClientProperties::class.java)!!
+ clientProps = JacksonUtils.readValue(
+ jsonNode,
+ HttpNoAuthDmaapClientProperties::class.java
+ )!!
clientProps.props = parseEventProps()
}
TYPE_HTTP_AAF_AUTH -> {
- clientProps = JacksonUtils.readValue(jsonNode,
- AafAuthDmaapClientProperties::class.java)!!
+ clientProps = JacksonUtils.readValue(
+ jsonNode,
+ AafAuthDmaapClientProperties::class.java
+ )!!
clientProps.props = parseEventProps()
}
else -> {
- throw BluePrintProcessorException("DMAAP adaptor($type) is " +
- "not supported")
+ throw BluePrintProcessorException(
+ "DMAAP adaptor($type) is " +
+ "not supported"
+ )
}
}
return clientProps
@@ -158,8 +171,10 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
}
else -> {
- throw BluePrintProcessorException("Unable to get the DMAAP " +
- "client")
+ throw BluePrintProcessorException(
+ "Unable to get the DMAAP " +
+ "client"
+ )
}
}
}
@@ -171,7 +186,8 @@ open class BluePrintDmaapLibPropertyService(private var bluePrintPropertiesServi
private fun parseEventProps(): Properties {
val prodProps = Properties()
val proProps = (env as ConfigurableEnvironment).propertySources.get(
- "class path resource [event.properties]")
+ "class path resource [event.properties]"
+ )
if (proProps != null) {
val entries = (proProps as ResourcePropertySource).source.entries
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt
index 9d942943e..aa4c40ae6 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/DmaapClientProperties.kt
@@ -26,6 +26,7 @@ import java.util.Properties
* Representation of data required for all DMAAP client.
*/
open class DmaapClientProperties {
+
lateinit var props: Properties
lateinit var type: String
lateinit var host: String
@@ -41,6 +42,7 @@ open class HttpNoAuthDmaapClientProperties : DmaapClientProperties()
* Representation of data required for AAF auth DMAAP client.
*/
open class AafAuthDmaapClientProperties : DmaapClientProperties() {
+
lateinit var username: String
lateinit var password: String
}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt
index 8bf50a944..a3e347adc 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt
@@ -27,16 +27,17 @@ import com.att.nsa.mr.client.impl.MRSimplerBatchPublisher
/**
* Representation of DMAAP client service for HTTP no auth type.
*/
-class HttpNoAuthDmaapClientService(private val clientProps:
- HttpNoAuthDmaapClientProperties)
- : BluePrintDmaapClientService {
+class HttpNoAuthDmaapClientService(
+ private val clientProps:
+ HttpNoAuthDmaapClientProperties
+) :
+ BluePrintDmaapClientService {
/**
* The constructed DMAAP client.
*/
var clients: MutableList<MRBatchingPublisher> = mutableListOf()
-
/**
* Returns the DMAAP client after constructing it properly with the data
* that is required for HTTP no auth connection.
@@ -58,5 +59,4 @@ class HttpNoAuthDmaapClientService(private val clientProps:
return clients
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
index 4e91d59f9..3fb7f6802 100644
--- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/cds/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
@@ -49,19 +49,23 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
-@ContextConfiguration(classes = [BluePrintDmaapLibConfiguration::class, TestController::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties = ["server.port=9111",
- "blueprintsprocessor.dmaapclient.aai.topic=cds_aai",
- "blueprintsprocessor.dmaapclient.aai.type=HTTPNOAUTH",
- "blueprintsprocessor.dmaapclient.aai.host=127.0.0.1:9111",
- "blueprintsprocessor.dmaapclient.multi.topic=cds_multi1,cds_multi2",
- "blueprintsprocessor.dmaapclient.multi.type=HTTPNOAUTH",
- "blueprintsprocessor.dmaapclient.multi.host=127.0.0.1:9111"])
+@ContextConfiguration(
+ classes = [BluePrintDmaapLibConfiguration::class, TestController::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties = ["server.port=9111",
+ "blueprintsprocessor.dmaapclient.aai.topic=cds_aai",
+ "blueprintsprocessor.dmaapclient.aai.type=HTTPNOAUTH",
+ "blueprintsprocessor.dmaapclient.aai.host=127.0.0.1:9111",
+ "blueprintsprocessor.dmaapclient.multi.topic=cds_multi1,cds_multi2",
+ "blueprintsprocessor.dmaapclient.multi.type=HTTPNOAUTH",
+ "blueprintsprocessor.dmaapclient.multi.host=127.0.0.1:9111"]
+)
class TestDmaapEventPublisher {
@Autowired
- lateinit var dmaapService : BluePrintDmaapLibPropertyService
+ lateinit var dmaapService: BluePrintDmaapLibPropertyService
/**
* Tests the event properties being set properly and sent as request.
@@ -71,9 +75,11 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService("aai")
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 1)
@@ -88,7 +94,7 @@ class TestDmaapEventPublisher {
@Test
fun testEventPropertiesWithSingleMsg() {
val dmaapClient = dmaapService.blueprintDmaapClientService("aai")
- val str : String = "{\n" +
+ val str: String = "{\n" +
" \"a\" : \"hello\"\n" +
"}"
dmaapClient.sendMessage(str)
@@ -106,9 +112,11 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService("multi")
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 2)
@@ -118,7 +126,6 @@ class TestDmaapEventPublisher {
assertEquals(topic2!!.size, 0)
}
-
/**
* Tests the event properties with multiple topics with JSON node as input.
*/
@@ -134,9 +141,11 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService(node)
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 2)
@@ -146,7 +155,6 @@ class TestDmaapEventPublisher {
assertEquals(topic2!!.size, 0)
}
-
/**
* Tests the event properties with multiple messages.
*/
@@ -155,12 +163,16 @@ class TestDmaapEventPublisher {
val strList = mutableListOf<String>()
val dmaapClient = dmaapService.blueprintDmaapClientService("aai")
- strList.add("{\n" +
- " \"a\" : \"hello\"\n" +
- "}")
- strList.add("{\n" +
- " \"a\" : \"second\"\n" +
- "}")
+ strList.add(
+ "{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}"
+ )
+ strList.add(
+ "{\n" +
+ " \"a\" : \"second\"\n" +
+ "}"
+ )
dmaapClient.sendMessage(strList)
val msgs = dmaapClient.close(2)
assertEquals(msgs!!.size, 1)
@@ -174,10 +186,13 @@ class TestDmaapEventPublisher {
@Test
fun testDmaapClientProperties() {
val properties = dmaapService.dmaapClientProperties(
- "blueprintsprocessor.dmaapclient.aai")
+ "blueprintsprocessor.dmaapclient.aai"
+ )
assertNotNull(properties, "failed to create property bean")
- assertNotNull(properties.host, "failed to get url property" +
- " in property bean")
+ assertNotNull(
+ properties.host, "failed to get url property" +
+ " in property bean"
+ )
}
/**
@@ -187,10 +202,11 @@ class TestDmaapEventPublisher {
fun testBlueprintDmaapClientService() {
val blueprintDmaapClientService =
dmaapService.blueprintDmaapClientService("aai")
- assertNotNull(blueprintDmaapClientService,
- "failed to create blueprintDmaapClientService")
+ assertNotNull(
+ blueprintDmaapClientService,
+ "failed to create blueprintDmaapClientService"
+ )
}
-
}
/**
@@ -204,7 +220,7 @@ open class TestController {
* Accepts request for a topic and sends a message as response.
*/
@PostMapping(path = ["/{topic}"])
- fun postTopic(@PathVariable(value = "topic") topic : String):
+ fun postTopic(@PathVariable(value = "topic") topic: String):
ResponseEntity<Any> {
var a = "{\n" +
" \"message\" : \"The message is published into $topic " +
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcExtensions.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcExtensions.kt
index 55cf0941d..97b462a3c 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcExtensions.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcExtensions.kt
@@ -24,4 +24,4 @@ fun Metadata.getStringKey(key: String): String? {
fun Metadata.putStringKeyValue(key: String, value: String) {
this.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value)
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
index c37c6263a..a3823c6ac 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
@@ -32,7 +32,7 @@ open class BluePrintGrpcLibConfiguration
* Exposed Dependency Service by this GRPC Lib Module
*/
fun BluePrintDependencyService.grpcLibPropertyService(): BluePrintGrpcLibPropertyService =
- instance(GRPCLibConstants.SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY)
+ instance(GRPCLibConstants.SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY)
fun BluePrintDependencyService.grpcClientService(selector: String): BluePrintGrpcClientService {
return grpcLibPropertyService().blueprintGrpcClientService(selector)
@@ -51,4 +51,4 @@ class GRPCLibConstants {
const val TYPE_BASIC_AUTH = "basic-auth"
const val TYPE_TLS_AUTH = "tls-auth"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt
index 47d16fbc7..f94d918a2 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt
@@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.grpc
/** GRPC Server Properties */
open class GrpcServerProperties {
+
lateinit var type: String
var port: Int = -1
}
@@ -36,6 +37,7 @@ open class TLSAuthGrpcServerProperties : GrpcServerProperties() {
/** GRPC Client Properties */
open class GrpcClientProperties {
+
lateinit var type: String
lateinit var host: String
var port: Int = -1
@@ -55,4 +57,4 @@ open class TLSAuthGrpcClientProperties : GrpcClientProperties() {
open class BasicAuthGrpcClientProperties : GrpcClientProperties() {
lateinit var username: String
lateinit var password: String
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt
index f3b14b59f..99ac74070 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt
@@ -16,18 +16,27 @@
package org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor
-import io.grpc.*
+import io.grpc.CallOptions
+import io.grpc.Channel
+import io.grpc.ClientCall
+import io.grpc.ClientInterceptor
+import io.grpc.ForwardingClientCall
+import io.grpc.ForwardingClientCallListener
+import io.grpc.Metadata
+import io.grpc.MethodDescriptor
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.GrpcLoggerService
import org.onap.ccsdk.cds.controllerblueprints.core.logger
-
class GrpcClientLoggingInterceptor : ClientInterceptor {
val log = logger(GrpcClientLoggingInterceptor::class)
val loggingService = GrpcLoggerService()
- override fun <ReqT, RespT> interceptCall(method: MethodDescriptor<ReqT, RespT>,
- callOptions: CallOptions, channel: Channel): ClientCall<ReqT, RespT> {
+ override fun <ReqT, RespT> interceptCall(
+ method: MethodDescriptor<ReqT, RespT>,
+ callOptions: CallOptions,
+ channel: Channel
+ ): ClientCall<ReqT, RespT> {
return object : ForwardingClientCall
.SimpleForwardingClientCall<ReqT, RespT>(channel.newCall(method, callOptions)) {
@@ -42,6 +51,5 @@ class GrpcClientLoggingInterceptor : ClientInterceptor {
super.start(listener, headers)
}
}
-
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt
index e21d5d3ce..ec0761af4 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt
@@ -16,7 +16,12 @@
package org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor
-import io.grpc.*
+import io.grpc.ForwardingServerCall
+import io.grpc.ForwardingServerCallListener
+import io.grpc.Metadata
+import io.grpc.ServerCall
+import io.grpc.ServerCallHandler
+import io.grpc.ServerInterceptor
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.GrpcLoggerService
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.logger
@@ -30,9 +35,12 @@ class GrpcServerLoggingInterceptor : ServerInterceptor {
val log = logger(GrpcServerLoggingInterceptor::class)
val loggingService = GrpcLoggerService()
- override fun <ReqT : Any, RespT : Any> interceptCall(call: ServerCall<ReqT, RespT>,
- requestHeaders: Metadata, next: ServerCallHandler<ReqT, RespT>)
- : ServerCall.Listener<ReqT> {
+ override fun <ReqT : Any, RespT : Any> interceptCall(
+ call: ServerCall<ReqT, RespT>,
+ requestHeaders: Metadata,
+ next: ServerCallHandler<ReqT, RespT>
+ ):
+ ServerCall.Listener<ReqT> {
val forwardingServerCall = object : ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(call) {
override fun sendHeaders(responseHeaders: Metadata) {
@@ -41,9 +49,10 @@ class GrpcServerLoggingInterceptor : ServerInterceptor {
}
}
- return object
- : ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(
- next.startCall(forwardingServerCall, requestHeaders)) {
+ return object :
+ ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(
+ next.startCall(forwardingServerCall, requestHeaders)
+ ) {
override fun onMessage(message: ReqT) {
/** Get the requestId, SubRequestId and Originator Id and set in MDS context
@@ -52,22 +61,22 @@ class GrpcServerLoggingInterceptor : ServerInterceptor {
when (message) {
is ExecutionServiceInput -> {
val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
+ ?: throw BluePrintProcessorException("missing common header in request")
loggingService.grpcRequesting(call, commonHeader, next)
}
is BluePrintUploadInput -> {
val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
+ ?: throw BluePrintProcessorException("missing common header in request")
loggingService.grpcRequesting(call, commonHeader, next)
}
is BluePrintDownloadInput -> {
val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
+ ?: throw BluePrintProcessorException("missing common header in request")
loggingService.grpcRequesting(call, commonHeader, next)
}
is BluePrintRemoveInput -> {
val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
+ ?: throw BluePrintProcessorException("missing common header in request")
loggingService.grpcRequesting(call, commonHeader, next)
}
else -> {
@@ -86,7 +95,6 @@ class GrpcServerLoggingInterceptor : ServerInterceptor {
MDC.clear()
super.onCancel()
}
-
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BasicAuthGrpcClientService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BasicAuthGrpcClientService.kt
index a175d8b3a..e3fd14c1e 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BasicAuthGrpcClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BasicAuthGrpcClientService.kt
@@ -22,19 +22,16 @@ import io.grpc.internal.PickFirstLoadBalancerProvider
import io.grpc.netty.NettyChannelBuilder
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties
-
-open class BasicAuthGrpcClientService(private val basicAuthGrpcClientProperties: BasicAuthGrpcClientProperties)
- : BluePrintGrpcClientService {
+open class BasicAuthGrpcClientService(private val basicAuthGrpcClientProperties: BasicAuthGrpcClientProperties) :
+ BluePrintGrpcClientService {
override suspend fun channel(): ManagedChannel {
val managedChannel = NettyChannelBuilder
- .forAddress(basicAuthGrpcClientProperties.host, basicAuthGrpcClientProperties.port)
- .nameResolverFactory(DnsNameResolverProvider())
- .loadBalancerFactory(PickFirstLoadBalancerProvider())
- // .intercept(BasicAuthClientInterceptor(basicAuthGrpcClientProperties)).usePlaintext()
- .build()
+ .forAddress(basicAuthGrpcClientProperties.host, basicAuthGrpcClientProperties.port)
+ .nameResolverFactory(DnsNameResolverProvider())
+ .loadBalancerFactory(PickFirstLoadBalancerProvider())
+ // .intercept(BasicAuthClientInterceptor(basicAuthGrpcClientProperties)).usePlaintext()
+ .build()
return managedChannel
}
-
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
index 02d5cc695..8a3c5a6a7 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
@@ -19,7 +19,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.grpc.service
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
-import org.onap.ccsdk.cds.blueprintsprocessor.grpc.*
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GRPCLibConstants
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GrpcClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GrpcServerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcServerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcServerProperties
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.returnNullIfMissing
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -39,7 +46,6 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
return blueprintGrpcServerService(grpcServerProperties)
}
-
/** GRPC Server Lib Property Service */
fun grpcServerProperties(jsonNode: JsonNode): GrpcServerProperties {
return when (val type = jsonNode.get("type").textValue()) {
@@ -57,7 +63,8 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
fun grpcServerProperties(prefix: String): GrpcServerProperties {
val type = bluePrintPropertiesService.propertyBeanType(
- "$prefix.type", String::class.java)
+ "$prefix.type", String::class.java
+ )
return when (type) {
GRPCLibConstants.TYPE_TOKEN_AUTH -> {
tokenAuthGrpcServerProperties(prefix)
@@ -79,8 +86,8 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
return bluePrintPropertiesService.propertyBeanType(prefix, TLSAuthGrpcServerProperties::class.java)
}
- private fun blueprintGrpcServerService(grpcServerProperties: GrpcServerProperties)
- : BluePrintGrpcServerService {
+ private fun blueprintGrpcServerService(grpcServerProperties: GrpcServerProperties):
+ BluePrintGrpcServerService {
when (grpcServerProperties) {
is TLSAuthGrpcServerProperties -> {
return TLSAuthGrpcServerService(grpcServerProperties)
@@ -91,7 +98,6 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
}
}
-
/** GRPC Client Lib Property Service */
fun blueprintGrpcClientService(jsonNode: JsonNode): BluePrintGrpcClientService {
@@ -105,10 +111,9 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
return blueprintGrpcClientService(restClientProperties)
}
-
fun grpcClientProperties(jsonNode: JsonNode): GrpcClientProperties {
val type = jsonNode.get("type").returnNullIfMissing()?.textValue()
- ?: BluePrintProcessorException("missing type property")
+ ?: BluePrintProcessorException("missing type property")
return when (type) {
GRPCLibConstants.TYPE_TOKEN_AUTH -> {
JacksonUtils.readValue(jsonNode, TokenAuthGrpcClientProperties::class.java)!!
@@ -127,7 +132,8 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
fun grpcClientProperties(prefix: String): GrpcClientProperties {
val type = bluePrintPropertiesService.propertyBeanType(
- "$prefix.type", String::class.java)
+ "$prefix.type", String::class.java
+ )
return when (type) {
GRPCLibConstants.TYPE_TOKEN_AUTH -> {
tokenAuthGrpcClientProperties(prefix)
@@ -140,7 +146,6 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
}
else -> {
throw BluePrintProcessorException("Grpc type($type) not supported")
-
}
}
}
@@ -174,4 +179,4 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
private fun basicAuthGrpcClientProperties(prefix: String): BasicAuthGrpcClientProperties {
return bluePrintPropertiesService.propertyBeanType(prefix, BasicAuthGrpcClientProperties::class.java)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt
index 0d9291615..e71525f0a 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt
@@ -26,4 +26,4 @@ interface BluePrintGrpcServerService {
interface BluePrintGrpcClientService {
suspend fun channel(): ManagedChannel
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt
index 6d2ba43cc..510a21581 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/GrpcLoggerService.kt
@@ -36,35 +36,45 @@ import java.net.InetSocketAddress
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
-import java.util.*
+import java.util.UUID
class GrpcLoggerService {
private val log = logger(GrpcLoggerService::class)
/** Used when server receives request */
- fun <ReqT : Any, RespT : Any> grpcRequesting(call: ServerCall<ReqT, RespT>,
- headers: Metadata, next: ServerCallHandler<ReqT, RespT>) {
+ fun <ReqT : Any, RespT : Any> grpcRequesting(
+ call: ServerCall<ReqT, RespT>,
+ headers: Metadata,
+ next: ServerCallHandler<ReqT, RespT>
+ ) {
val requestID = headers.getStringKey(ONAP_REQUEST_ID).defaultToUUID()
val invocationID = headers.getStringKey(ONAP_INVOCATION_ID).defaultToUUID()
val partnerName = headers.getStringKey(ONAP_PARTNER_NAME) ?: "UNKNOWN"
grpcRequesting(requestID, invocationID, partnerName, call)
}
- fun <ReqT : Any, RespT : Any> grpcRequesting(call: ServerCall<ReqT, RespT>,
- headers: CommonHeader, next: ServerCallHandler<ReqT, RespT>) {
+ fun <ReqT : Any, RespT : Any> grpcRequesting(
+ call: ServerCall<ReqT, RespT>,
+ headers: CommonHeader,
+ next: ServerCallHandler<ReqT, RespT>
+ ) {
val requestID = headers.requestId.defaultToUUID()
val invocationID = headers.subRequestId.defaultToUUID()
val partnerName = headers.originatorId ?: "UNKNOWN"
grpcRequesting(requestID, invocationID, partnerName, call)
}
- fun <ReqT : Any, RespT : Any> grpcRequesting(requestID: String, invocationID: String, partnerName: String,
- call: ServerCall<ReqT, RespT>) {
+ fun <ReqT : Any, RespT : Any> grpcRequesting(
+ requestID: String,
+ invocationID: String,
+ partnerName: String,
+ call: ServerCall<ReqT, RespT>
+ ) {
val localhost = InetAddress.getLocalHost()
val clientSocketAddress = call.attributes.get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR) as? InetSocketAddress
- ?: throw BluePrintProcessorException("failed to get client address")
+ ?: throw BluePrintProcessorException("failed to get client address")
val serviceName = call.methodDescriptor.fullMethodName
MDC.put("InvokeTimestamp", ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT))
@@ -77,7 +87,6 @@ class GrpcLoggerService {
log.trace("MDC Properties : ${MDC.getCopyOfContextMap()}")
}
-
/** Used before invoking any GRPC outbound request, Inbound Invocation ID is used as request Id
* for outbound Request, If invocation Id is missing then default Request Id will be generated.
*/
@@ -98,4 +107,4 @@ class GrpcLoggerService {
log.warn("couldn't set grpc response headers", e)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcClientService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcClientService.kt
index a70cbbce0..68ca3c16b 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcClientService.kt
@@ -26,17 +26,17 @@ import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor.GrpcClientLoggingInterceptor
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
-class TLSAuthGrpcClientService(private val tlsAuthGrpcClientProperties: TLSAuthGrpcClientProperties)
- : BluePrintGrpcClientService {
+class TLSAuthGrpcClientService(private val tlsAuthGrpcClientProperties: TLSAuthGrpcClientProperties) :
+ BluePrintGrpcClientService {
override suspend fun channel(): ManagedChannel {
return NettyChannelBuilder
- .forAddress(tlsAuthGrpcClientProperties.host, tlsAuthGrpcClientProperties.port)
- .nameResolverFactory(DnsNameResolverProvider())
- .loadBalancerFactory(PickFirstLoadBalancerProvider())
- .intercept(GrpcClientLoggingInterceptor())
- .sslContext(sslContext())
- .build()
+ .forAddress(tlsAuthGrpcClientProperties.host, tlsAuthGrpcClientProperties.port)
+ .nameResolverFactory(DnsNameResolverProvider())
+ .loadBalancerFactory(PickFirstLoadBalancerProvider())
+ .intercept(GrpcClientLoggingInterceptor())
+ .sslContext(sslContext())
+ .build()
}
fun sslContext(): SslContext {
@@ -44,11 +44,14 @@ class TLSAuthGrpcClientService(private val tlsAuthGrpcClientProperties: TLSAuthG
if (tlsAuthGrpcClientProperties.trustCertCollection != null) {
builder.trustManager(normalizedFile(tlsAuthGrpcClientProperties.trustCertCollection!!))
}
- if (tlsAuthGrpcClientProperties.clientCertChain != null
- && tlsAuthGrpcClientProperties.clientPrivateKey != null) {
- builder.keyManager(normalizedFile(tlsAuthGrpcClientProperties.clientCertChain!!),
- normalizedFile(tlsAuthGrpcClientProperties.clientPrivateKey!!))
+ if (tlsAuthGrpcClientProperties.clientCertChain != null &&
+ tlsAuthGrpcClientProperties.clientPrivateKey != null
+ ) {
+ builder.keyManager(
+ normalizedFile(tlsAuthGrpcClientProperties.clientCertChain!!),
+ normalizedFile(tlsAuthGrpcClientProperties.clientPrivateKey!!)
+ )
}
return builder.build()
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcServerService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcServerService.kt
index fc73d43f9..915ea1730 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcServerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TLSAuthGrpcServerService.kt
@@ -24,20 +24,21 @@ import io.netty.handler.ssl.SslContextBuilder
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcServerProperties
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
-
-class TLSAuthGrpcServerService(private val tlsAuthGrpcServerProperties: TLSAuthGrpcServerProperties)
- : BluePrintGrpcServerService {
+class TLSAuthGrpcServerService(private val tlsAuthGrpcServerProperties: TLSAuthGrpcServerProperties) :
+ BluePrintGrpcServerService {
override fun serverBuilder(): NettyServerBuilder {
return NettyServerBuilder
- .forPort(tlsAuthGrpcServerProperties.port)
- .sslContext(sslContext())
+ .forPort(tlsAuthGrpcServerProperties.port)
+ .sslContext(sslContext())
}
fun sslContext(): SslContext {
val sslClientContextBuilder = SslContextBuilder
- .forServer(normalizedFile(tlsAuthGrpcServerProperties.certChain),
- normalizedFile(tlsAuthGrpcServerProperties.privateKey))
+ .forServer(
+ normalizedFile(tlsAuthGrpcServerProperties.certChain),
+ normalizedFile(tlsAuthGrpcServerProperties.privateKey)
+ )
tlsAuthGrpcServerProperties.trustCertCollection?.let { trustCertFile ->
sslClientContextBuilder.trustManager(normalizedFile(trustCertFile))
@@ -45,5 +46,4 @@ class TLSAuthGrpcServerService(private val tlsAuthGrpcServerProperties: TLSAuthG
}
return GrpcSslContexts.configure(sslClientContextBuilder).build()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TokenAuthGrpcClientService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TokenAuthGrpcClientService.kt
index 601dc0e33..371353db2 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TokenAuthGrpcClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/TokenAuthGrpcClientService.kt
@@ -16,31 +16,41 @@
package org.onap.ccsdk.cds.blueprintsprocessor.grpc.service
-import io.grpc.*
+import io.grpc.CallOptions
+import io.grpc.Channel
+import io.grpc.ClientCall
+import io.grpc.ClientInterceptor
+import io.grpc.ForwardingClientCall
+import io.grpc.ManagedChannel
+import io.grpc.Metadata
+import io.grpc.MethodDescriptor
import io.grpc.internal.DnsNameResolverProvider
import io.grpc.internal.PickFirstLoadBalancerProvider
import io.grpc.netty.NettyChannelBuilder
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor.GrpcClientLoggingInterceptor
-class TokenAuthGrpcClientService(private val tokenAuthGrpcClientProperties: TokenAuthGrpcClientProperties)
- : BluePrintGrpcClientService {
+class TokenAuthGrpcClientService(private val tokenAuthGrpcClientProperties: TokenAuthGrpcClientProperties) :
+ BluePrintGrpcClientService {
override suspend fun channel(): ManagedChannel {
val managedChannel = NettyChannelBuilder
- .forAddress(tokenAuthGrpcClientProperties.host, tokenAuthGrpcClientProperties.port)
- .nameResolverFactory(DnsNameResolverProvider())
- .loadBalancerFactory(PickFirstLoadBalancerProvider())
- .intercept(GrpcClientLoggingInterceptor())
- .intercept(TokenAuthClientInterceptor(tokenAuthGrpcClientProperties)).usePlaintext().build()
+ .forAddress(tokenAuthGrpcClientProperties.host, tokenAuthGrpcClientProperties.port)
+ .nameResolverFactory(DnsNameResolverProvider())
+ .loadBalancerFactory(PickFirstLoadBalancerProvider())
+ .intercept(GrpcClientLoggingInterceptor())
+ .intercept(TokenAuthClientInterceptor(tokenAuthGrpcClientProperties)).usePlaintext().build()
return managedChannel
}
}
class TokenAuthClientInterceptor(private val tokenAuthGrpcClientProperties: TokenAuthGrpcClientProperties) : ClientInterceptor {
- override fun <ReqT, RespT> interceptCall(method: MethodDescriptor<ReqT, RespT>,
- callOptions: CallOptions, channel: Channel): ClientCall<ReqT, RespT> {
+ override fun <ReqT, RespT> interceptCall(
+ method: MethodDescriptor<ReqT, RespT>,
+ callOptions: CallOptions,
+ channel: Channel
+ ): ClientCall<ReqT, RespT> {
val authHeader = Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER)
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
index 13432c043..ea17b94a1 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
@@ -24,7 +24,11 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.grpc.*
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BluePrintGrpcLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcServerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
@@ -35,34 +39,38 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintGrpcLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.grpcclient.sample.type=basic-auth",
- "blueprintsprocessor.grpcclient.sample.host=127.0.0.1",
- "blueprintsprocessor.grpcclient.sample.port=50505",
- "blueprintsprocessor.grpcclient.sample.username=sampleuser",
- "blueprintsprocessor.grpcclient.sample.password=sampleuser",
-
- "blueprintsprocessor.grpcclient.token.type=token-auth",
- "blueprintsprocessor.grpcclient.token.host=127.0.0.1",
- "blueprintsprocessor.grpcclient.token.port=50505",
- "blueprintsprocessor.grpcclient.token.username=sampleuser",
- "blueprintsprocessor.grpcclient.token.password=sampleuser",
-
- "blueprintsprocessor.grpcserver.tls-sample.type=tls-auth",
- "blueprintsprocessor.grpcserver.tls-sample.port=50505",
- "blueprintsprocessor.grpcserver.tls-sample.certChain=server1.pem",
- "blueprintsprocessor.grpcserver.tls-sample.privateKey=server1.key",
- "blueprintsprocessor.grpcserver.tls-sample.trustCertCollection=ca.pem",
-
- "blueprintsprocessor.grpcclient.tls-sample.type=tls-auth",
- "blueprintsprocessor.grpcclient.tls-sample.host=127.0.0.1",
- "blueprintsprocessor.grpcclient.tls-sample.port=50505",
- "blueprintsprocessor.grpcclient.tls-sample.trustCertCollection=ca.pem",
- "blueprintsprocessor.grpcclient.tls-sample.clientCertChain=client.pem",
- "blueprintsprocessor.grpcclient.tls-sample.clientPrivateKey=client.key"
-])
+@ContextConfiguration(
+ classes = [BluePrintGrpcLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprintsprocessor.grpcclient.sample.type=basic-auth",
+ "blueprintsprocessor.grpcclient.sample.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.sample.port=50505",
+ "blueprintsprocessor.grpcclient.sample.username=sampleuser",
+ "blueprintsprocessor.grpcclient.sample.password=sampleuser",
+
+ "blueprintsprocessor.grpcclient.token.type=token-auth",
+ "blueprintsprocessor.grpcclient.token.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.token.port=50505",
+ "blueprintsprocessor.grpcclient.token.username=sampleuser",
+ "blueprintsprocessor.grpcclient.token.password=sampleuser",
+
+ "blueprintsprocessor.grpcserver.tls-sample.type=tls-auth",
+ "blueprintsprocessor.grpcserver.tls-sample.port=50505",
+ "blueprintsprocessor.grpcserver.tls-sample.certChain=server1.pem",
+ "blueprintsprocessor.grpcserver.tls-sample.privateKey=server1.key",
+ "blueprintsprocessor.grpcserver.tls-sample.trustCertCollection=ca.pem",
+
+ "blueprintsprocessor.grpcclient.tls-sample.type=tls-auth",
+ "blueprintsprocessor.grpcclient.tls-sample.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.tls-sample.port=50505",
+ "blueprintsprocessor.grpcclient.tls-sample.trustCertCollection=ca.pem",
+ "blueprintsprocessor.grpcclient.tls-sample.clientCertChain=client.pem",
+ "blueprintsprocessor.grpcclient.tls-sample.clientPrivateKey=client.key"
+ ]
+)
class BluePrintGrpcLibPropertyServiceTest {
@Autowired
@@ -74,17 +82,26 @@ class BluePrintGrpcLibPropertyServiceTest {
@Test
fun testGrpcClientProperties() {
val properties = bluePrintGrpcLibPropertyService.grpcClientProperties(
- "blueprintsprocessor.grpcclient.sample")
+ "blueprintsprocessor.grpcclient.sample"
+ )
as BasicAuthGrpcClientProperties
assertNotNull(properties, "failed to create property bean")
- assertNotNull(properties.host, "failed to get host property" +
- " in property bean")
- assertNotNull(properties.port, "failed to get host property" +
- " in property bean")
- assertNotNull(properties.username, "failed to get host pro" +
- "perty in property bean")
- assertNotNull(properties.password, "failed to get host pr" +
- "operty in property bean")
+ assertNotNull(
+ properties.host, "failed to get host property" +
+ " in property bean"
+ )
+ assertNotNull(
+ properties.port, "failed to get host property" +
+ " in property bean"
+ )
+ assertNotNull(
+ properties.username, "failed to get host pro" +
+ "perty in property bean"
+ )
+ assertNotNull(
+ properties.password, "failed to get host pr" +
+ "operty in property bean"
+ )
}
/**
@@ -100,7 +117,8 @@ class BluePrintGrpcLibPropertyServiceTest {
val mapper = ObjectMapper()
val actualObj: JsonNode = mapper.readTree(json)
val properties = bluePrintGrpcLibPropertyService.grpcClientProperties(
- actualObj) as TokenAuthGrpcClientProperties
+ actualObj
+ ) as TokenAuthGrpcClientProperties
assertNotNull(properties, "failed to create property bean")
assertEquals(properties.host, "127.0.0.1")
assertNotNull(properties.port, "50505")
@@ -112,7 +130,8 @@ class BluePrintGrpcLibPropertyServiceTest {
@Test
fun testGrpcClientServiceBasic() {
val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(
- "sample")
+ "sample"
+ )
assertTrue(svc is BasicAuthGrpcClientService)
}
@@ -122,7 +141,8 @@ class BluePrintGrpcLibPropertyServiceTest {
@Test
fun testGrpcClientServiceToken() {
val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(
- "token")
+ "token"
+ )
assertTrue(svc is TokenAuthGrpcClientService)
}
@@ -141,14 +161,14 @@ class BluePrintGrpcLibPropertyServiceTest {
val mapper = ObjectMapper()
val actualObj: JsonNode = mapper.readTree(json)
val svc = bluePrintGrpcLibPropertyService
- .blueprintGrpcClientService(actualObj)
+ .blueprintGrpcClientService(actualObj)
assertTrue(svc is BasicAuthGrpcClientService)
}
@Test
fun testGrpcClientTLSProperties() {
val properties = bluePrintGrpcLibPropertyService
- .grpcClientProperties("blueprintsprocessor.grpcclient.tls-sample") as TLSAuthGrpcClientProperties
+ .grpcClientProperties("blueprintsprocessor.grpcclient.tls-sample") as TLSAuthGrpcClientProperties
assertNotNull(properties, "failed to create property bean")
assertNotNull(properties.host, "failed to get host property in property bean")
assertNotNull(properties.port, "failed to get host property in property bean")
@@ -166,14 +186,14 @@ class BluePrintGrpcLibPropertyServiceTest {
}
""".trimIndent()
val jsonProperties = bluePrintGrpcLibPropertyService
- .grpcClientProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcClientProperties
+ .grpcClientProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcClientProperties
assertNotNull(jsonProperties, "failed to create property bean from json")
}
@Test
fun testGrpcServerTLSProperties() {
val properties = bluePrintGrpcLibPropertyService
- .grpcServerProperties("blueprintsprocessor.grpcserver.tls-sample") as TLSAuthGrpcServerProperties
+ .grpcServerProperties("blueprintsprocessor.grpcserver.tls-sample") as TLSAuthGrpcServerProperties
assertNotNull(properties, "failed to create property bean")
assertNotNull(properties.port, "failed to get host property in property bean")
assertNotNull(properties.trustCertCollection, "failed to get trustCertCollection property in property bean")
@@ -189,11 +209,11 @@ class BluePrintGrpcLibPropertyServiceTest {
}
""".trimIndent()
val jsonProperties = bluePrintGrpcLibPropertyService
- .grpcServerProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcServerProperties
+ .grpcServerProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcServerProperties
assertNotNull(jsonProperties, "failed to create property bean from json")
val grpcServerService = bluePrintGrpcLibPropertyService.blueprintGrpcServerService("tls-sample")
assertNotNull(grpcServerService, "failed to get grpc server service")
Assert.assertEquals(TLSAuthGrpcServerService::class.java, grpcServerService.javaClass)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt
index 8154d3747..026fe5af5 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt
@@ -30,7 +30,7 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput
-import java.util.*
+import java.util.UUID
import kotlin.test.Test
import kotlin.test.assertNotNull
@@ -62,14 +62,16 @@ class BluePrintGrpcServerTest {
}
/** TLS Client Integration testing, GRPC TLS Junit testing is not supported. */
- //@Test
+ // @Test
fun testGrpcTLSServerIntegration() {
runBlocking {
val tlsAuthGrpcClientService = TLSAuthGrpcClientService(tlsAuthGrpcClientProperties)
val grpcChannel = tlsAuthGrpcClientService.channel()
/** Get Send and Receive Channel for bidirectional process method*/
- val (reqChannel, resChannel) = clientCallBidiStreaming(BluePrintProcessingServiceGrpc.getProcessMethod(),
- grpcChannel)
+ val (reqChannel, resChannel) = clientCallBidiStreaming(
+ BluePrintProcessingServiceGrpc.getProcessMethod(),
+ grpcChannel
+ )
launch {
resChannel.consumeEach {
log.info("Received Response")
@@ -85,25 +87,24 @@ class BluePrintGrpcServerTest {
private fun getRequest(requestId: String): ExecutionServiceInput {
val commonHeader = CommonHeader.newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(requestId)
- .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(requestId)
+ .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build()
val actionIdentifier = ActionIdentifiers.newBuilder()
- .setActionName("SampleScript")
- .setBlueprintName("sample-cba")
- .setBlueprintVersion("1.0.0")
- .setMode(ACTION_MODE_SYNC)
- .build()
+ .setActionName("SampleScript")
+ .setBlueprintName("sample-cba")
+ .setBlueprintVersion("1.0.0")
+ .setMode(ACTION_MODE_SYNC)
+ .build()
val jsonContent = """{ "key1" : "value1" }"""
val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
JsonFormat.parser().merge(jsonContent, payloadBuilder)
return ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(actionIdentifier)
- .setPayload(payloadBuilder.build())
- .build()
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(actionIdentifier)
+ .setPayload(payloadBuilder.build())
+ .build()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt
index d5bc70c48..25828b15e 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt
@@ -27,7 +27,6 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessin
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput
-
val log = logger(MockTLSBluePrintProcessingServer::class)
/** For Integration testing stat this server, Set the working path to run this method */
@@ -40,16 +39,15 @@ fun main() {
privateKey = "src/test/resources/tls-manual/py-executor-key.pem"
}
val server = TLSAuthGrpcServerService(tlsAuthGrpcServerProperties).serverBuilder()
- .intercept(GrpcServerLoggingInterceptor())
- .addService(MockTLSBluePrintProcessingServer())
- .build()
+ .intercept(GrpcServerLoggingInterceptor())
+ .addService(MockTLSBluePrintProcessingServer())
+ .build()
server.start()
log.info("GRPC Serve started(${server.isShutdown}) on port(${server.port})...")
server.awaitTermination()
} catch (e: Exception) {
log.error("Failed to start tls grpc integration server", e)
}
-
}
class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
@@ -57,17 +55,21 @@ class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrin
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
- log.info("Received requestId(${executionServiceInput.commonHeader.requestId}) " +
- "subRequestId(${executionServiceInput.commonHeader.subRequestId})")
+ log.info(
+ "Received requestId(${executionServiceInput.commonHeader.requestId}) " +
+ "subRequestId(${executionServiceInput.commonHeader.subRequestId})"
+ )
responseObserver.onNext(buildResponse(executionServiceInput))
responseObserver.onCompleted()
}
override fun onError(error: Throwable) {
log.debug("Fail to process message", error)
- responseObserver.onError(io.grpc.Status.INTERNAL
+ responseObserver.onError(
+ io.grpc.Status.INTERNAL
.withDescription(error.message)
- .asException())
+ .asException()
+ )
}
override fun onCompleted() {
@@ -78,13 +80,12 @@ class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrin
private fun buildResponse(input: ExecutionServiceInput): ExecutionServiceOutput {
val status = Status.newBuilder().setCode(200)
- .setEventType(EventType.EVENT_COMPONENT_EXECUTED)
- .build()
+ .setEventType(EventType.EVENT_COMPONENT_EXECUTED)
+ .build()
return ExecutionServiceOutput.newBuilder()
- .setCommonHeader(input.commonHeader)
- .setActionIdentifiers(input.actionIdentifiers)
- .setStatus(status)
- .build()
-
+ .setCommonHeader(input.commonHeader)
+ .setActionIdentifiers(input.actionIdentifiers)
+ .setStatus(status)
+ .build()
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageExtensions.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageExtensions.kt
index a817c0c74..509689eca 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageExtensions.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageExtensions.kt
@@ -20,7 +20,6 @@ import org.apache.kafka.common.header.Headers
import org.apache.kafka.common.header.internals.RecordHeader
import java.nio.charset.Charset
-
fun <T : Headers> T?.toMap(): MutableMap<String, String> {
val map: MutableMap<String, String> = hashMapOf()
this?.forEach { map[it.key()] = String(it.value(), Charset.defaultCharset()) }
@@ -29,4 +28,4 @@ fun <T : Headers> T?.toMap(): MutableMap<String, String> {
fun Headers.addHeader(key: String, value: String) {
this.add(RecordHeader(key, value.toByteArray()))
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt
index ecffa280f..cc4c7fa4a 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.message
-
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageConsumerService
@@ -36,14 +35,13 @@ open class BluePrintMessageLibConfiguration
* Exposed Dependency Service by this Message Lib Module
*/
fun BluePrintDependencyService.messageLibPropertyService(): BluePrintMessageLibPropertyService =
- instance(MessageLibConstants.SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY)
+ instance(MessageLibConstants.SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY)
/** Extension functions for message producer service **/
fun BluePrintDependencyService.messageProducerService(selector: String): BlueprintMessageProducerService {
return messageLibPropertyService().blueprintMessageProducerService(selector)
}
-
fun BluePrintDependencyService.messageProducerService(jsonNode: JsonNode): BlueprintMessageProducerService {
return messageLibPropertyService().blueprintMessageProducerService(jsonNode)
}
@@ -65,4 +63,4 @@ class MessageLibConstants {
const val TYPE_KAFKA_BASIC_AUTH = "kafka-basic-auth"
const val TYPE_KAFKA_STREAMS_BASIC_AUTH = "kafka-streams-basic-auth"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt
index d0c3d5ae1..59e3606ea 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt
@@ -22,7 +22,6 @@ import org.apache.kafka.streams.StreamsConfig
/** Producer Properties **/
open class MessageProducerProperties
-
open class KafkaBasicAuthMessageProducerProperties : MessageProducerProperties() {
lateinit var bootstrapServers: String
var topic: String? = null
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/kafka/AbstractKafkaTopologyComponents.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/kafka/AbstractKafkaTopologyComponents.kt
index 4c6c0acdd..72a70893a 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/kafka/AbstractKafkaTopologyComponents.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/kafka/AbstractKafkaTopologyComponents.kt
@@ -30,7 +30,6 @@ abstract class AbstractBluePrintMessageProcessor<K, V> : Processor<K, V> {
lateinit var processorContext: ProcessorContext
-
override fun process(key: K, value: V) = runBlocking(Dispatchers.IO) {
try {
processNB(key, value)
@@ -42,7 +41,6 @@ abstract class AbstractBluePrintMessageProcessor<K, V> : Processor<K, V> {
override fun init(context: ProcessorContext) {
log.info("initializing processor (${this.javaClass.simpleName})")
this.processorContext = context
-
}
override fun close() {
@@ -54,12 +52,12 @@ abstract class AbstractBluePrintMessageProcessor<K, V> : Processor<K, V> {
/** CDS Kafka Stream Punctuator abstract class to implement */
abstract class AbstractBluePrintMessagePunctuator : Punctuator {
- lateinit var processorContext: ProcessorContext
+ lateinit var processorContext: ProcessorContext
override fun punctuate(timestamp: Long) = runBlocking(Dispatchers.IO) {
punctuateNB(timestamp)
}
abstract suspend fun punctuateNB(timestamp: Long)
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt
index 853b88bc9..44b50af44 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt
@@ -19,7 +19,12 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message.service
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
-import org.onap.ccsdk.cds.blueprintsprocessor.message.*
+import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaBasicAuthMessageConsumerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaBasicAuthMessageProducerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaStreamsBasicAuthConsumerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.message.MessageConsumerProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.message.MessageLibConstants
+import org.onap.ccsdk.cds.blueprintsprocessor.message.MessageProducerProperties
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@@ -62,8 +67,8 @@ open class BluePrintMessageLibPropertyService(private var bluePrintPropertiesSer
}
}
- private fun blueprintMessageProducerService(MessageProducerProperties: MessageProducerProperties)
- : BlueprintMessageProducerService {
+ private fun blueprintMessageProducerService(MessageProducerProperties: MessageProducerProperties):
+ BlueprintMessageProducerService {
when (MessageProducerProperties) {
is KafkaBasicAuthMessageProducerProperties -> {
@@ -77,7 +82,8 @@ open class BluePrintMessageLibPropertyService(private var bluePrintPropertiesSer
private fun kafkaBasicAuthMessageProducerProperties(prefix: String): KafkaBasicAuthMessageProducerProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, KafkaBasicAuthMessageProducerProperties::class.java)
+ prefix, KafkaBasicAuthMessageProducerProperties::class.java
+ )
}
/** Consumer Property Lib Service Implementation **/
@@ -126,8 +132,8 @@ open class BluePrintMessageLibPropertyService(private var bluePrintPropertiesSer
}
}
- private fun blueprintMessageConsumerService(messageConsumerProperties: MessageConsumerProperties)
- : BlueprintMessageConsumerService {
+ private fun blueprintMessageConsumerService(messageConsumerProperties: MessageConsumerProperties):
+ BlueprintMessageConsumerService {
when (messageConsumerProperties) {
is KafkaBasicAuthMessageConsumerProperties -> {
@@ -144,12 +150,13 @@ open class BluePrintMessageLibPropertyService(private var bluePrintPropertiesSer
private fun kafkaBasicAuthMessageConsumerProperties(prefix: String): KafkaBasicAuthMessageConsumerProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, KafkaBasicAuthMessageConsumerProperties::class.java)
+ prefix, KafkaBasicAuthMessageConsumerProperties::class.java
+ )
}
private fun kafkaStreamsBasicAuthMessageConsumerProperties(prefix: String): KafkaStreamsBasicAuthConsumerProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, KafkaStreamsBasicAuthConsumerProperties::class.java)
+ prefix, KafkaStreamsBasicAuthConsumerProperties::class.java
+ )
}
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt
index 716fda609..f74abcdb7 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt
@@ -50,21 +50,31 @@ interface BlueprintMessageConsumerService {
}
/** Consume the [topics] with [additionalConfig], so that we can execute dynamic function [consumerFunction] */
- suspend fun consume(topics: List<String>, additionalConfig: Map<String, Any>?,
- consumerFunction: ConsumerFunction) {
+ suspend fun consume(
+ topics: List<String>,
+ additionalConfig: Map<String, Any>?,
+ consumerFunction: ConsumerFunction
+ ) {
throw BluePrintProcessorException("Not Implemented")
}
/** close the channel, consumer and other resources */
suspend fun shutDown()
}
+
/** Consumer dynamic implementation interface */
interface KafkaConsumerRecordsFunction : ConsumerFunction {
- suspend fun invoke(messageConsumerProperties: MessageConsumerProperties, consumer: Consumer<*, *>,
- consumerRecords: ConsumerRecords<*, *>)
+
+ suspend fun invoke(
+ messageConsumerProperties: MessageConsumerProperties,
+ consumer: Consumer<*, *>,
+ consumerRecords: ConsumerRecords<*, *>
+ )
}
interface KafkaStreamConsumerFunction : ConsumerFunction {
- suspend fun createTopology(messageConsumerProperties: MessageConsumerProperties,
- additionalConfig: Map<String, Any>?): Topology
-} \ No newline at end of file
+ suspend fun createTopology(
+ messageConsumerProperties: MessageConsumerProperties,
+ additionalConfig: Map<String, Any>?
+ ): Topology
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerService.kt
index 7d8138639..cdc65a1c6 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerService.kt
@@ -47,4 +47,4 @@ interface BlueprintMessageProducerService {
}
suspend fun sendMessageNB(topic: String, message: Any, headers: MutableMap<String, String>?): Boolean
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt
index 757846c81..3415c8d0d 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt
@@ -34,8 +34,9 @@ import java.time.Duration
import kotlin.concurrent.thread
open class KafkaBasicAuthMessageConsumerService(
- private val messageConsumerProperties: KafkaBasicAuthMessageConsumerProperties)
- : BlueprintMessageConsumerService {
+ private val messageConsumerProperties: KafkaBasicAuthMessageConsumerProperties
+) :
+ BlueprintMessageConsumerService {
val log = logger(KafkaBasicAuthMessageConsumerService::class)
val channel = Channel<String>()
@@ -76,7 +77,6 @@ open class KafkaBasicAuthMessageConsumerService(
return subscribe(consumerTopic, additionalConfig)
}
-
override suspend fun subscribe(topics: List<String>, additionalConfig: Map<String, Any>?): Channel<String> {
/** Create Kafka consumer */
kafkaConsumer = kafkaConsumer(additionalConfig)
@@ -124,8 +124,11 @@ open class KafkaBasicAuthMessageConsumerService(
return consume(topics = consumerTopic, additionalConfig = additionalConfig, consumerFunction = consumerFunction)
}
- override suspend fun consume(topics: List<String>, additionalConfig: Map<String, Any>?,
- consumerFunction: ConsumerFunction) {
+ override suspend fun consume(
+ topics: List<String>,
+ additionalConfig: Map<String, Any>?,
+ consumerFunction: ConsumerFunction
+ ) {
val kafkaConsumerFunction = consumerFunction as KafkaConsumerRecordsFunction
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt
index ad9a594b0..8416282af 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt
@@ -20,7 +20,12 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message.service
import org.apache.commons.lang.builder.ToStringBuilder
import org.apache.kafka.clients.producer.Callback
import org.apache.kafka.clients.producer.KafkaProducer
-import org.apache.kafka.clients.producer.ProducerConfig.*
+import org.apache.kafka.clients.producer.ProducerConfig.ACKS_CONFIG
+import org.apache.kafka.clients.producer.ProducerConfig.BOOTSTRAP_SERVERS_CONFIG
+import org.apache.kafka.clients.producer.ProducerConfig.CLIENT_ID_CONFIG
+import org.apache.kafka.clients.producer.ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG
+import org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG
+import org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG
import org.apache.kafka.clients.producer.ProducerRecord
import org.apache.kafka.common.header.internals.RecordHeader
import org.apache.kafka.common.serialization.ByteArraySerializer
@@ -32,8 +37,9 @@ import org.slf4j.LoggerFactory
import java.nio.charset.Charset
class KafkaBasicAuthMessageProducerService(
- private val messageProducerProperties: KafkaBasicAuthMessageProducerProperties)
- : BlueprintMessageProducerService {
+ private val messageProducerProperties: KafkaBasicAuthMessageProducerProperties
+) :
+ BlueprintMessageProducerService {
private val log = LoggerFactory.getLogger(KafkaBasicAuthMessageProducerService::class.java)!!
@@ -51,8 +57,11 @@ class KafkaBasicAuthMessageProducerService(
return sendMessageNB(messageProducerProperties.topic!!, message, headers)
}
- override suspend fun sendMessageNB(topic: String, message: Any,
- headers: MutableMap<String, String>?): Boolean {
+ override suspend fun sendMessageNB(
+ topic: String,
+ message: Any,
+ headers: MutableMap<String, String>?
+ ): Boolean {
val byteArrayMessage = when (message) {
is String -> message.toByteArray(Charset.defaultCharset())
else -> message.asJsonString().toByteArray(Charset.defaultCharset())
@@ -95,4 +104,3 @@ class KafkaBasicAuthMessageProducerService(
return kafkaProducer!!
}
}
-
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerService.kt
index d0297df4c..0b353d58b 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerService.kt
@@ -23,10 +23,10 @@ import org.apache.kafka.streams.StreamsConfig
import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaStreamsBasicAuthConsumerProperties
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.logger
-import java.util.*
+import java.util.Properties
-open class KafkaStreamsBasicAuthConsumerService(private val messageConsumerProperties: KafkaStreamsBasicAuthConsumerProperties)
- : BlueprintMessageConsumerService {
+open class KafkaStreamsBasicAuthConsumerService(private val messageConsumerProperties: KafkaStreamsBasicAuthConsumerProperties) :
+ BlueprintMessageConsumerService {
val log = logger(KafkaStreamsBasicAuthConsumerService::class)
lateinit var kafkaStreams: KafkaStreams
@@ -68,4 +68,4 @@ open class KafkaStreamsBasicAuthConsumerService(private val messageConsumerPrope
kafkaStreams.close()
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerService.kt
index 21bf1b76c..7ec70d91b 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerService.kt
@@ -31,15 +31,17 @@ import java.time.Instant
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
-import java.util.*
+import java.util.UUID
class MessageLoggerService {
private val log = logger(MessageLoggerService::class)
fun messageConsuming(headers: CommonHeader, consumerRecord: ConsumerRecord<*, *>) {
- messageConsuming(headers.requestId, headers.subRequestId,
- headers.originatorId, consumerRecord)
+ messageConsuming(
+ headers.requestId, headers.subRequestId,
+ headers.originatorId, consumerRecord
+ )
}
fun messageConsuming(consumerRecord: ConsumerRecord<*, *>) {
@@ -50,14 +52,19 @@ class MessageLoggerService {
messageConsuming(requestID, invocationID, partnerName, consumerRecord)
}
-
- fun messageConsuming(requestID: String, invocationID: String, partnerName: String,
- consumerRecord: ConsumerRecord<*, *>) {
+ fun messageConsuming(
+ requestID: String,
+ invocationID: String,
+ partnerName: String,
+ consumerRecord: ConsumerRecord<*, *>
+ ) {
val headers = consumerRecord.headers().toMap()
val localhost = InetAddress.getLocalHost()
- MDC.put("InvokeTimestamp", ZonedDateTime
+ MDC.put(
+ "InvokeTimestamp", ZonedDateTime
.ofInstant(Instant.ofEpochMilli(consumerRecord.timestamp()), ZoneOffset.UTC)
- .format(DateTimeFormatter.ISO_INSTANT))
+ .format(DateTimeFormatter.ISO_INSTANT)
+ )
MDC.put("RequestID", requestID)
MDC.put("InvocationID", invocationID)
MDC.put("PartnerName", partnerName)
@@ -85,4 +92,4 @@ class MessageLoggerService {
fun messageConsumingExisting() {
MDC.clear()
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt
index b2accfb4d..823ba7dee 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt
@@ -23,7 +23,11 @@ import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
-import org.apache.kafka.clients.consumer.*
+import org.apache.kafka.clients.consumer.Consumer
+import org.apache.kafka.clients.consumer.ConsumerRecord
+import org.apache.kafka.clients.consumer.ConsumerRecords
+import org.apache.kafka.clients.consumer.MockConsumer
+import org.apache.kafka.clients.consumer.OffsetResetStrategy
import org.apache.kafka.common.TopicPartition
import org.junit.Test
import org.junit.runner.RunWith
@@ -40,26 +44,30 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
-
@RunWith(SpringRunner::class)
@DirtiesContext
-@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.messageconsumer.sample.type=kafka-basic-auth",
- "blueprintsprocessor.messageconsumer.sample.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageconsumer.sample.groupId=sample-group",
- "blueprintsprocessor.messageconsumer.sample.topic=default-topic",
- "blueprintsprocessor.messageconsumer.sample.clientId=default-client-id",
- "blueprintsprocessor.messageconsumer.sample.pollMillSec=10",
- "blueprintsprocessor.messageconsumer.sample.pollRecords=1",
-
- "blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth",
- "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageproducer.sample.topic=default-topic",
- "blueprintsprocessor.messageproducer.sample.clientId=default-client-id"
-])
+@ContextConfiguration(
+ classes = [BluePrintMessageLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprintsprocessor.messageconsumer.sample.type=kafka-basic-auth",
+ "blueprintsprocessor.messageconsumer.sample.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageconsumer.sample.groupId=sample-group",
+ "blueprintsprocessor.messageconsumer.sample.topic=default-topic",
+ "blueprintsprocessor.messageconsumer.sample.clientId=default-client-id",
+ "blueprintsprocessor.messageconsumer.sample.pollMillSec=10",
+ "blueprintsprocessor.messageconsumer.sample.pollRecords=1",
+
+ "blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth",
+ "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageproducer.sample.topic=default-topic",
+ "blueprintsprocessor.messageproducer.sample.clientId=default-client-id"
+ ]
+)
open class BlueprintMessageConsumerServiceTest {
+
val log = logger(BlueprintMessageConsumerServiceTest::class)
@Autowired
@@ -69,7 +77,7 @@ open class BlueprintMessageConsumerServiceTest {
fun testKafkaBasicAuthConsumerService() {
runBlocking {
val blueprintMessageConsumerService = bluePrintMessageLibPropertyService
- .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService
+ .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService
assertNotNull(blueprintMessageConsumerService, "failed to get blueprintMessageConsumerService")
val spyBlueprintMessageConsumerService = spyk(blueprintMessageConsumerService, recordPrivateCalls = true)
@@ -93,8 +101,10 @@ open class BlueprintMessageConsumerServiceTest {
mockKafkaConsumer.updateBeginningOffsets(partitionsBeginningMap)
mockKafkaConsumer.updateEndOffsets(partitionsEndMap)
for (i in 1..10) {
- val record = ConsumerRecord<String, ByteArray>(topic, 1, i.toLong(), "key_$i",
- "I am message $i".toByteArray())
+ val record = ConsumerRecord<String, ByteArray>(
+ topic, 1, i.toLong(), "key_$i",
+ "I am message $i".toByteArray()
+ )
mockKafkaConsumer.addRecord(record)
}
@@ -114,7 +124,7 @@ open class BlueprintMessageConsumerServiceTest {
fun testKafkaBasicAuthConsumerWithDynamicFunction() {
runBlocking {
val blueprintMessageConsumerService = bluePrintMessageLibPropertyService
- .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService
+ .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService
assertNotNull(blueprintMessageConsumerService, "failed to get blueprintMessageConsumerService")
val spyBlueprintMessageConsumerService = spyk(blueprintMessageConsumerService, recordPrivateCalls = true)
@@ -138,16 +148,21 @@ open class BlueprintMessageConsumerServiceTest {
mockKafkaConsumer.updateBeginningOffsets(partitionsBeginningMap)
mockKafkaConsumer.updateEndOffsets(partitionsEndMap)
for (i in 1..10) {
- val record = ConsumerRecord<String, ByteArray>(topic, 1, i.toLong(), "key_$i",
- "I am message $i".toByteArray())
+ val record = ConsumerRecord<String, ByteArray>(
+ topic, 1, i.toLong(), "key_$i",
+ "I am message $i".toByteArray()
+ )
mockKafkaConsumer.addRecord(record)
}
every { spyBlueprintMessageConsumerService.kafkaConsumer(any()) } returns mockKafkaConsumer
/** Test Consumer Function implementation */
val consumerFunction = object : KafkaConsumerRecordsFunction {
- override suspend fun invoke(messageConsumerProperties: MessageConsumerProperties,
- consumer: Consumer<*, *>, consumerRecords: ConsumerRecords<*, *>) {
+ override suspend fun invoke(
+ messageConsumerProperties: MessageConsumerProperties,
+ consumer: Consumer<*, *>,
+ consumerRecords: ConsumerRecords<*, *>
+ ) {
val count = consumerRecords.count()
log.trace("Received Message count($count)")
}
@@ -159,11 +174,11 @@ open class BlueprintMessageConsumerServiceTest {
}
/** Integration Kafka Testing, Enable and use this test case only for local desktop testing with real kafka broker */
- //@Test
+ // @Test
fun testKafkaIntegration() {
runBlocking {
val blueprintMessageConsumerService = bluePrintMessageLibPropertyService
- .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService
+ .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService
assertNotNull(blueprintMessageConsumerService, "failed to get blueprintMessageConsumerService")
val channel = blueprintMessageConsumerService.subscribe(null)
@@ -175,18 +190,20 @@ open class BlueprintMessageConsumerServiceTest {
/** Send message with every 1 sec */
val blueprintMessageProducerService = bluePrintMessageLibPropertyService
- .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService
+ .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService
launch {
repeat(5) {
delay(100)
val headers: MutableMap<String, String> = hashMapOf()
headers["id"] = it.toString()
- blueprintMessageProducerService.sendMessageNB(message = "this is my message($it)",
- headers = headers)
+ blueprintMessageProducerService.sendMessageNB(
+ message = "this is my message($it)",
+ headers = headers
+ )
}
}
delay(5000)
blueprintMessageConsumerService.shutDown()
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt
index 4fe5f5dd1..b824189d2 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt
@@ -35,17 +35,20 @@ import java.util.concurrent.Future
import kotlin.test.Test
import kotlin.test.assertTrue
-
@RunWith(SpringRunner::class)
@DirtiesContext
-@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth",
- "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageproducer.sample.topic=default-topic",
- "blueprintsprocessor.messageproducer.sample.clientId=default-client-id"
-])
+@ContextConfiguration(
+ classes = [BluePrintMessageLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth",
+ "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageproducer.sample.topic=default-topic",
+ "blueprintsprocessor.messageproducer.sample.clientId=default-client-id"
+ ]
+)
open class BlueprintMessageProducerServiceTest {
@Autowired
@@ -55,7 +58,7 @@ open class BlueprintMessageProducerServiceTest {
fun testKafkaBasicAuthProducertService() {
runBlocking {
val blueprintMessageProducerService = bluePrintMessageLibPropertyService
- .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService
+ .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService
val mockKafkaTemplate = mockk<KafkaProducer<String, ByteArray>>()
@@ -72,8 +75,4 @@ open class BlueprintMessageProducerServiceTest {
assertTrue(response, "failed to get command response")
}
}
-
}
-
-
-
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerServiceTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerServiceTest.kt
index 9cd974622..1657d70b4 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaStreamsBasicAuthConsumerServiceTest.kt
@@ -38,25 +38,29 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
@DirtiesContext
-@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-[
- "blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth",
- "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageproducer.sample.topic=default-stream-topic",
- "blueprintsprocessor.messageproducer.sample.clientId=default-client-id",
+@ContextConfiguration(
+ classes = [BluePrintMessageLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ [
+ "blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth",
+ "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageproducer.sample.topic=default-stream-topic",
+ "blueprintsprocessor.messageproducer.sample.clientId=default-client-id",
- "blueprintsprocessor.messageconsumer.stream-consumer.type=kafka-streams-basic-auth",
- "blueprintsprocessor.messageconsumer.stream-consumer.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageconsumer.stream-consumer.applicationId=test-streams-application",
- "blueprintsprocessor.messageconsumer.stream-consumer.topic=default-stream-topic"
+ "blueprintsprocessor.messageconsumer.stream-consumer.type=kafka-streams-basic-auth",
+ "blueprintsprocessor.messageconsumer.stream-consumer.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageconsumer.stream-consumer.applicationId=test-streams-application",
+ "blueprintsprocessor.messageconsumer.stream-consumer.topic=default-stream-topic"
-])
+ ]
+)
class KafkaStreamsBasicAuthConsumerServiceTest {
+
@Autowired
lateinit var bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService
@@ -67,15 +71,17 @@ class KafkaStreamsBasicAuthConsumerServiceTest {
}
/** Integration Kafka Testing, Enable and use this test case only for local desktop testing with real kafka broker */
- //@Test
+ // @Test
fun testKafkaStreamingMessageConsumer() {
runBlocking {
val streamingConsumerService = bluePrintMessageLibPropertyService.blueprintMessageConsumerService("stream-consumer")
// Dynamic Consumer Function to create Topology
val consumerFunction = object : KafkaStreamConsumerFunction {
- override suspend fun createTopology(messageConsumerProperties: MessageConsumerProperties,
- additionalConfig: Map<String, Any>?): Topology {
+ override suspend fun createTopology(
+ messageConsumerProperties: MessageConsumerProperties,
+ additionalConfig: Map<String, Any>?
+ ): Topology {
val topology = Topology()
val kafkaStreamsBasicAuthConsumerProperties = messageConsumerProperties
as KafkaStreamsBasicAuthConsumerProperties
@@ -93,29 +99,34 @@ class KafkaStreamsBasicAuthConsumerServiceTest {
// Store Buolder
val countStoreSupplier = Stores.keyValueStoreBuilder(
- Stores.persistentKeyValueStore("PriorityMessageState"),
- Serdes.String(),
- PriorityMessageSerde())
- .withLoggingEnabled(changelogConfig)
+ Stores.persistentKeyValueStore("PriorityMessageState"),
+ Serdes.String(),
+ PriorityMessageSerde()
+ )
+ .withLoggingEnabled(changelogConfig)
topology.addProcessor("FirstProcessor", firstProcessorSupplier, "Source")
topology.addStateStore(countStoreSupplier, "FirstProcessor")
- topology.addSink("SINK", "default-stream-topic-out", Serdes.String().serializer(),
- PriorityMessageSerde().serializer(), "FirstProcessor")
+ topology.addSink(
+ "SINK", "default-stream-topic-out", Serdes.String().serializer(),
+ PriorityMessageSerde().serializer(), "FirstProcessor"
+ )
return topology
}
}
/** Send message with every 1 sec */
val blueprintMessageProducerService = bluePrintMessageLibPropertyService
- .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService
+ .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService
launch {
repeat(5) {
delay(1000)
val headers: MutableMap<String, String> = hashMapOf()
headers["id"] = it.toString()
- blueprintMessageProducerService.sendMessageNB(message = "this is my message($it)",
- headers = headers)
+ blueprintMessageProducerService.sendMessageNB(
+ message = "this is my message($it)",
+ headers = headers
+ )
}
}
streamingConsumerService.consume(null, consumerFunction)
@@ -123,4 +134,4 @@ class KafkaStreamsBasicAuthConsumerServiceTest {
streamingConsumerService.shutDown()
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerServiceTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerServiceTest.kt
index 82e40efd1..3dce3344f 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MessageLoggerServiceTest.kt
@@ -29,7 +29,6 @@ import kotlin.test.assertEquals
class MessageLoggerServiceTest {
-
@Test
fun testMessagingHeaders() {
val messageLoggerService = MessageLoggerService()
@@ -55,7 +54,5 @@ class MessageLoggerServiceTest {
assertEquals("1234-12", map[BluePrintConstants.ONAP_REQUEST_ID])
messageLoggerService.messageConsumingExisting()
-
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MockKafkaTopologyComponents.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MockKafkaTopologyComponents.kt
index 4db9c772e..5d77c3746 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MockKafkaTopologyComponents.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/MockKafkaTopologyComponents.kt
@@ -28,7 +28,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import java.io.Serializable
import java.nio.charset.Charset
-import java.util.*
+import java.util.UUID
class PriorityMessage : Serializable {
lateinit var id: String
@@ -47,7 +47,7 @@ open class PriorityMessageSerde : Serde<PriorityMessage> {
return object : Deserializer<PriorityMessage> {
override fun deserialize(topic: String, data: ByteArray): PriorityMessage {
return JacksonUtils.readValue(String(data), PriorityMessage::class.java)
- ?: throw BluePrintProcessorException("failed to convert")
+ ?: throw BluePrintProcessorException("failed to convert")
}
override fun configure(configs: MutableMap<String, *>?, isKey: Boolean) {
@@ -73,7 +73,6 @@ open class PriorityMessageSerde : Serde<PriorityMessage> {
}
}
-
class FirstProcessor : Processor<ByteArray, ByteArray> {
private val log = logger(FirstProcessor::class)
@@ -100,4 +99,4 @@ class FirstProcessor : Processor<ByteArray, ByteArray> {
override fun close() {
log.info("Close...")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/ApiDataExtensions.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/ApiDataExtensions.kt
index 47b55b018..af7109449 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/ApiDataExtensions.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/ApiDataExtensions.kt
@@ -20,9 +20,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.controllerblueprints.core.asType
import kotlin.reflect.KClass
-
fun <T : Any> ExecutionServiceInput.payloadAsType(clazzType: KClass<T>): T {
val actionName = this.actionIdentifiers.actionName
val requestJsonNode = this.payload.get("$actionName-request")
return requestJsonNode.asType(clazzType.java)
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
index 62dc933f1..76b37a5b4 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
@@ -41,12 +41,13 @@ open class BluePrintCoreConfiguration(private val bluePrintPropertiesService: Bl
@Bean
open fun bluePrintLoadConfiguration(): BluePrintLoadConfiguration {
return bluePrintPropertiesService
- .propertyBeanType(PREFIX_BLUEPRINT_PROCESSOR, BluePrintLoadConfiguration::class.java)
+ .propertyBeanType(PREFIX_BLUEPRINT_PROCESSOR, BluePrintLoadConfiguration::class.java)
}
}
@Configuration
open class BluePrintPropertyConfiguration {
+
@Autowired
lateinit var environment: Environment
@@ -59,6 +60,7 @@ open class BluePrintPropertyConfiguration {
@Service
open class BluePrintPropertiesService(private var bluePrintPropertyBinder: Binder) {
+
fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
}
@@ -74,5 +76,4 @@ open class BlueprintDependencyConfiguration : ApplicationContextAware {
BluePrintDependencyService.inject(applicationContext)
log.info("Dependency Management module created...")
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index dae6eea85..d94985400 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import io.swagger.annotations.ApiModelProperty
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import java.util.*
+import java.util.Date
/**
* BlueprintProcessorData
@@ -33,14 +33,17 @@ import java.util.*
*/
open class ExecutionServiceInput {
+
@get:ApiModelProperty(required = true, value = "Headers providing request context.")
lateinit var commonHeader: CommonHeader
@get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true,
- value = "Contain the information to be passed as input to the action." +
- "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
- " and the input for resource resolution located within the xxx-request block, contained within xxx-properties")
+ @get:ApiModelProperty(
+ required = true,
+ value = "Contain the information to be passed as input to the action." +
+ "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
+ " and the input for resource resolution located within the xxx-request block, contained within xxx-properties"
+ )
lateinit var payload: ObjectNode
@get:ApiModelProperty(hidden = true)
@get:JsonIgnore
@@ -54,10 +57,12 @@ open class ExecutionServiceOutput {
lateinit var actionIdentifiers: ActionIdentifiers
@get:ApiModelProperty(required = true, value = "Status of the request.")
lateinit var status: Status
- @get:ApiModelProperty(required = true,
- value = "Contain the information to be passed as input to the action." +
- "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
- " and the input for resource resolution located within the xxx-request block, contained within xxx-properties")
+ @get:ApiModelProperty(
+ required = true,
+ value = "Contain the information to be passed as input to the action." +
+ "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
+ " and the input for resource resolution located within the xxx-request block, contained within xxx-properties"
+ )
lateinit var payload: ObjectNode
@get:ApiModelProperty(hidden = true)
@get:JsonIgnore
@@ -74,9 +79,11 @@ open class ActionIdentifiers {
lateinit var blueprintVersion: String
@get:ApiModelProperty(required = true, value = "Name of the workflow to execute.")
lateinit var actionName: String
- @get:ApiModelProperty(required = true,
- value = "Async processing is only supported for gRPC client.",
- allowableValues = "sync, async")
+ @get:ApiModelProperty(
+ required = true,
+ value = "Async processing is only supported for gRPC client.",
+ allowableValues = "sync, async"
+ )
lateinit var mode: String
}
@@ -106,9 +113,11 @@ open class Status {
var code: Int = 200
@get:ApiModelProperty(required = true, value = "Type of the event being emitted by CDS.")
var eventType: String = EventType.EVENT_COMPONENT_EXECUTED.name
- @get:ApiModelProperty(required = true,
- value = "Time when the execution ended.",
- example = "2012-04-23T18:25:43.511Z")
+ @get:ApiModelProperty(
+ required = true,
+ value = "Time when the execution ended.",
+ example = "2012-04-23T18:25:43.511Z"
+ )
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
var timestamp: Date = Date()
@get:ApiModelProperty(required = false, value = "Error message when system failed")
@@ -120,4 +129,4 @@ open class Status {
open class StepData {
lateinit var name: String
var properties: MutableMap<String, JsonNode> = mutableMapOf()
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt
index d63f34ced..628b65ea4 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintRemoteProcessorData.kt
@@ -17,34 +17,39 @@
package org.onap.ccsdk.cds.blueprintsprocessor.core.api.data
import com.fasterxml.jackson.databind.JsonNode
-import java.util.*
+import java.util.Date
enum class StatusType {
SUCCESS, FAILURE
}
-data class RemoteIdentifier(var blueprintName: String,
- var blueprintVersion: String)
-
-
-data class RemoteScriptExecutionInput(var requestId: String,
- var correlationId: String? = null,
- var remoteIdentifier: RemoteIdentifier? = null,
- var command: String,
- var timeOut: Long = 30,
- var properties: MutableMap<String, JsonNode> = hashMapOf()
+data class RemoteIdentifier(
+ var blueprintName: String,
+ var blueprintVersion: String
)
+data class RemoteScriptExecutionInput(
+ var requestId: String,
+ var correlationId: String? = null,
+ var remoteIdentifier: RemoteIdentifier? = null,
+ var command: String,
+ var timeOut: Long = 30,
+ var properties: MutableMap<String, JsonNode> = hashMapOf()
+)
-data class RemoteScriptExecutionOutput(var requestId: String,
- var response: List<String>,
- var status: StatusType = StatusType.SUCCESS,
- var timestamp: Date = Date(),
- var payload: JsonNode)
+data class RemoteScriptExecutionOutput(
+ var requestId: String,
+ var response: List<String>,
+ var status: StatusType = StatusType.SUCCESS,
+ var timestamp: Date = Date(),
+ var payload: JsonNode
+)
-data class PrepareRemoteEnvInput(var requestId: String,
- var correlationId: String? = null,
- var remoteIdentifier: RemoteIdentifier? = null,
- var packages: JsonNode,
- var timeOut: Long = 120,
- var properties: MutableMap<String, JsonNode> = hashMapOf())
+data class PrepareRemoteEnvInput(
+ var requestId: String,
+ var correlationId: String? = null,
+ var remoteIdentifier: RemoteIdentifier? = null,
+ var packages: JsonNode,
+ var timeOut: Long = 120,
+ var properties: MutableMap<String, JsonNode> = hashMapOf()
+)
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
index bb2c040f7..2f925dc5b 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
@@ -48,6 +48,7 @@ interface ComponentNode {
* @author Brinda Santh
*/
open class ComponentNodeFactory : ApplicationContextAware {
+
private val log = LoggerFactory.getLogger(ComponentNodeFactory::class.java)
var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
@@ -65,4 +66,4 @@ open class ComponentNodeFactory : ApplicationContextAware {
componentNodes = context.getBeansOfType(ComponentNode::class.java)
log.info("Injected Component Nodes : {}", componentNodes)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappings.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappings.kt
index 9cd00a3ba..59114de86 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappings.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappings.kt
@@ -19,12 +19,16 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import com.google.common.base.Strings
import com.google.protobuf.Struct
import com.google.protobuf.util.JsonFormat
-import org.onap.ccsdk.cds.controllerblueprints.common.api.*
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers
+import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
+import org.onap.ccsdk.cds.controllerblueprints.common.api.Flag
+import org.onap.ccsdk.cds.controllerblueprints.common.api.Status
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput
import java.text.SimpleDateFormat
-import java.util.*
+import java.util.Date
private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@@ -123,4 +127,4 @@ fun org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput.
JsonFormat.parser().merge(JacksonUtils.getJson(this.payload), struct)
executionServiceOuput.payload = struct.build()
return executionServiceOuput.build()
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/PayloadUtils.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/PayloadUtils.kt
index 9eb95e679..d3669f634 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/PayloadUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/PayloadUtils.kt
@@ -20,7 +20,6 @@ import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-
class PayloadUtils {
companion object {
@@ -39,9 +38,9 @@ class PayloadUtils {
fun prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode) {
payload.fields().forEach { property ->
val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
- .append(BluePrintConstants.PATH_DIVIDER).append(property.key).toString()
+ .append(BluePrintConstants.PATH_DIVIDER).append(property.key).toString()
bluePrintRuntimeService.put(path, property.value)
}
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintPropertiesTest.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintPropertiesTest.kt
index 3dd629c13..c27285020 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintPropertiesTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintPropertiesTest.kt
@@ -17,4 +17,4 @@
package org.onap.ccsdk.cds.blueprintsprocessor.core
// TODO
-open class BluePrintPropertiesTest \ No newline at end of file
+open class BluePrintPropertiesTest
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappingTests.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappingsTest.kt
index b1d7d144c..4de40d7bf 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappingTests.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/utils/BluePrintMappingsTest.kt
@@ -70,7 +70,9 @@ class BluePrintMappingsTest {
fun commonHeaderToJavaTest() {
val flag = Flag.newBuilder().setIsForce(true).setTtl(2).build()
- val commonHeader = CommonHeader.newBuilder().setOriginatorId("Origin").setRequestId("requestID").setSubRequestId("subRequestID").setTimestamp(dateString).setFlag(flag).build()
+ val commonHeader =
+ CommonHeader.newBuilder().setOriginatorId("Origin").setRequestId("requestID").setSubRequestId("subRequestID").setTimestamp(dateString)
+ .setFlag(flag).build()
val commonHeader2 = commonHeader.toJava()
Assert.assertEquals(commonHeader.originatorId, commonHeader2.originatorId)
@@ -101,7 +103,9 @@ class BluePrintMappingsTest {
@Test
fun actionIdentifierToJavaTest() {
- val actionIdentifiers = ActionIdentifiers.newBuilder().setActionName("Process Action").setBlueprintName("BlueprintName").setBlueprintVersion("3.0").setMode("Execution").build()
+ val actionIdentifiers =
+ ActionIdentifiers.newBuilder().setActionName("Process Action").setBlueprintName("BlueprintName").setBlueprintVersion("3.0")
+ .setMode("Execution").build()
val actionIdentifiers2 = actionIdentifiers.toJava()
Assert.assertEquals(actionIdentifiers.actionName, actionIdentifiers2.actionName)
@@ -129,4 +133,4 @@ class BluePrintMappingsTest {
Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion)
Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
index 182d5defa..9e1be36a7 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
@@ -35,19 +35,16 @@ open class BluePrintRestLibConfiguration
* Exposed Dependency Service by this Rest Lib Module
*/
fun BluePrintDependencyService.restLibPropertyService(): BluePrintRestLibPropertyService =
- instance(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
-
+ instance(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
fun BluePrintDependencyService.restClientService(selector: String): BlueprintWebClientService {
return restLibPropertyService().blueprintWebClientService(selector)
}
-
fun BluePrintDependencyService.restClientService(jsonNode: JsonNode): BlueprintWebClientService {
return restLibPropertyService().blueprintWebClientService(jsonNode)
}
-
class RestLibConstants {
companion object {
const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt
index ea32a1635..4c18f81ab 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt
@@ -35,11 +35,13 @@ open class SSLRestClientProperties : RestClientProperties() {
// FIXME("Define basic auth userName and password properties")
open class SSLBasicAuthRestClientProperties : SSLRestClientProperties() {
+
var basicAuth: BasicAuthRestClientProperties? = null
}
// FIXME("Define token properties")
open class SSLTokenAuthRestClientProperties : SSLRestClientProperties() {
+
var tokenAuth: TokenAuthRestClientProperties? = null
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
index a3da44f61..429931377 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
@@ -129,9 +129,9 @@ open class SSLRestClientPropertiesBuilder : RestClientPropertiesBuilder() {
}
open class SSLBasicAuthRestClientPropertiesBuilder : SSLRestClientPropertiesBuilder() {
- //TODO()
+ // TODO()
}
open class SSLTokenAuthRestClientPropertiesBuilder : SSLRestClientPropertiesBuilder() {
- //TODO()
-} \ No newline at end of file
+ // TODO()
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/filters/RestServerLoggingWebFilter.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/filters/RestServerLoggingWebFilter.kt
index 5aaee24de..5b6691eff 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/filters/RestServerLoggingWebFilter.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/filters/RestServerLoggingWebFilter.kt
@@ -24,15 +24,15 @@ import org.springframework.web.server.WebFilterChain
import reactor.core.publisher.Mono
import reactor.util.context.Context
-
open class RestServerLoggingWebFilter : WebFilter {
override fun filter(serverWebExchange: ServerWebExchange, webFilterChain: WebFilterChain): Mono<Void> {
val loggingService = RestLoggerService()
loggingService.entering(serverWebExchange.request)
val filterChain = webFilterChain.filter(serverWebExchange).subscriberContext(
- Context.of(MDCContext, MDCContext()))
+ Context.of(MDCContext, MDCContext())
+ )
loggingService.exiting(serverWebExchange.request, serverWebExchange.response)
return filterChain
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
index 9ce3beab6..540b3d9ad 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
@@ -21,37 +21,42 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import java.nio.charset.Charset
-import java.util.*
+import java.util.Base64
-class BasicAuthRestClientService(private val restClientProperties:
- BasicAuthRestClientProperties) :
+class BasicAuthRestClientService(
+ private val restClientProperties:
+ BasicAuthRestClientProperties
+) :
BlueprintWebClientService {
override fun defaultHeaders(): Map<String, String> {
- val encodedCredentials = setBasicAuth(restClientProperties.username,
- restClientProperties.password)
+ val encodedCredentials = setBasicAuth(
+ restClientProperties.username,
+ restClientProperties.password
+ )
return mapOf(
HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials")
+ HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials"
+ )
}
override fun host(uri: String): String {
return restClientProperties.url + uri
}
-
override fun convertToBasicHeaders(headers: Map<String, String>):
- Array<BasicHeader> {
+ Array<BasicHeader> {
val customHeaders: MutableMap<String, String> = headers.toMutableMap()
- //inject additionalHeaders
+ // inject additionalHeaders
customHeaders.putAll(verifyAdditionalHeaders(restClientProperties))
if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) {
val encodedCredentials = setBasicAuth(
restClientProperties.username,
- restClientProperties.password)
+ restClientProperties.password
+ )
customHeaders[HttpHeaders.AUTHORIZATION] =
"Basic $encodedCredentials"
}
@@ -61,7 +66,7 @@ class BasicAuthRestClientService(private val restClientProperties:
private fun setBasicAuth(username: String, password: String): String {
val credentialsString = "$username:$password"
return Base64.getEncoder().encodeToString(
- credentialsString.toByteArray(Charset.defaultCharset()))
+ credentialsString.toByteArray(Charset.defaultCharset())
+ )
}
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
index 84ba7d414..8f528a2ef 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
@@ -20,7 +20,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.*
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.PolicyManagerRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLTokenAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.TokenAuthRestClientProperties
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@@ -43,7 +50,7 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
open fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
val service = preInterceptor?.getInstance(jsonNode)
- ?: blueprintWebClientService(restClientProperties(jsonNode))
+ ?: blueprintWebClientService(restClientProperties(jsonNode))
return postInterceptor?.getInstance(jsonNode, service) ?: service
}
@@ -58,7 +65,8 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
fun restClientProperties(prefix: String): RestClientProperties {
val type = bluePrintPropertiesService.propertyBeanType(
- "$prefix.type", String::class.java)
+ "$prefix.type", String::class.java
+ )
return when (type) {
RestLibConstants.TYPE_BASIC_AUTH -> {
basicAuthRestClientProperties(prefix)
@@ -80,8 +88,10 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
policyManagerRestClientProperties(prefix)
}
else -> {
- throw BluePrintProcessorException("Rest adaptor($type) is" +
- " not supported")
+ throw BluePrintProcessorException(
+ "Rest adaptor($type) is" +
+ " not supported"
+ )
}
}
}
@@ -111,7 +121,8 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
}
else -> {
throw BluePrintProcessorException(
- "Rest adaptor($type) is not supported")
+ "Rest adaptor($type) is not supported"
+ )
}
}
}
@@ -138,24 +149,28 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
private fun tokenRestClientProperties(prefix: String):
TokenAuthRestClientProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, TokenAuthRestClientProperties::class.java)
+ prefix, TokenAuthRestClientProperties::class.java
+ )
}
private fun basicAuthRestClientProperties(prefix: String):
BasicAuthRestClientProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, BasicAuthRestClientProperties::class.java)
+ prefix, BasicAuthRestClientProperties::class.java
+ )
}
private fun sslBasicAuthRestClientProperties(prefix: String):
SSLRestClientProperties {
val sslProps: SSLBasicAuthRestClientProperties =
- bluePrintPropertiesService.propertyBeanType(
- prefix, SSLBasicAuthRestClientProperties::class.java)
+ bluePrintPropertiesService.propertyBeanType(
+ prefix, SSLBasicAuthRestClientProperties::class.java
+ )
val basicProps: BasicAuthRestClientProperties =
- bluePrintPropertiesService.propertyBeanType(
- prefix, BasicAuthRestClientProperties::class.java)
+ bluePrintPropertiesService.propertyBeanType(
+ prefix, BasicAuthRestClientProperties::class.java
+ )
sslProps.basicAuth = basicProps
return sslProps
}
@@ -164,11 +179,15 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
SSLRestClientProperties {
val sslProps: SSLTokenAuthRestClientProperties =
- bluePrintPropertiesService.propertyBeanType(prefix,
- SSLTokenAuthRestClientProperties::class.java)
+ bluePrintPropertiesService.propertyBeanType(
+ prefix,
+ SSLTokenAuthRestClientProperties::class.java
+ )
val basicProps: TokenAuthRestClientProperties =
- bluePrintPropertiesService.propertyBeanType(prefix,
- TokenAuthRestClientProperties::class.java)
+ bluePrintPropertiesService.propertyBeanType(
+ prefix,
+ TokenAuthRestClientProperties::class.java
+ )
sslProps.tokenAuth = basicProps
return sslProps
}
@@ -176,13 +195,15 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
private fun sslNoAuthRestClientProperties(prefix: String):
SSLRestClientProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, SSLRestClientProperties::class.java)
+ prefix, SSLRestClientProperties::class.java
+ )
}
private fun policyManagerRestClientProperties(prefix: String):
PolicyManagerRestClientProperties {
return bluePrintPropertiesService.propertyBeanType(
- prefix, PolicyManagerRestClientProperties::class.java)
+ prefix, PolicyManagerRestClientProperties::class.java
+ )
}
interface PreInterceptor {
@@ -197,5 +218,3 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
fun getInstance(selector: String, service: BlueprintWebClientService): BlueprintWebClientService
}
}
-
-
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
index 3e31bf9ec..3c8d92c26 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
@@ -23,7 +23,12 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
import org.apache.http.client.ClientProtocolException
-import org.apache.http.client.methods.*
+import org.apache.http.client.methods.HttpDelete
+import org.apache.http.client.methods.HttpGet
+import org.apache.http.client.methods.HttpPatch
+import org.apache.http.client.methods.HttpPost
+import org.apache.http.client.methods.HttpPut
+import org.apache.http.client.methods.HttpUriRequest
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClients
@@ -57,8 +62,12 @@ interface BlueprintWebClientService {
/** High performance non blocking Retry function, If execution block [block] throws BluePrintRetryException
* exception then this will perform wait and retrigger accoring to times [times] with delay [delay]
*/
- suspend fun <T> retry(times: Int = 1, initialDelay: Long = 0, delay: Long = 1000,
- block: suspend (Int) -> T): T {
+ suspend fun <T> retry(
+ times: Int = 1,
+ initialDelay: Long = 0,
+ delay: Long = 1000,
+ block: suspend (Int) -> T
+ ): T {
val exceptionBlock = { e: Exception ->
if (e !is BluePrintRetryException) {
throw e
@@ -71,8 +80,12 @@ interface BlueprintWebClientService {
return this.exchangeResource(methodType, path, request, defaultHeaders())
}
- fun exchangeResource(methodType: String, path: String, request: String,
- headers: Map<String, String>): WebClientResponse<String> {
+ fun exchangeResource(
+ methodType: String,
+ path: String,
+ request: String,
+ headers: Map<String, String>
+ ): WebClientResponse<String> {
/**
* TODO: Basic headers in the implementations of this client do not get added
* in blocking version, whereas in NB version defaultHeaders get added.
@@ -86,11 +99,12 @@ interface BlueprintWebClientService {
HttpMethod.PUT -> put(path, request, convertedHeaders, String::class.java)
HttpMethod.PATCH -> patch(path, request, convertedHeaders, String::class.java)
else -> throw BluePrintProcessorException(
- "Unsupported methodType($methodType) attempted on path($path)")
+ "Unsupported methodType($methodType) attempted on path($path)"
+ )
}
}
- //TODO: convert to multi-map
+ // TODO: convert to multi-map
fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> {
return headers.map { BasicHeader(it.key, it.value) }.toTypedArray()
}
@@ -145,8 +159,10 @@ interface BlueprintWebClientService {
@Throws(IOException::class, ClientProtocolException::class)
private fun <T> performCallAndExtractTypedWebClientResponse(
- httpUriRequest: HttpUriRequest, responseType: Class<T>):
- WebClientResponse<T> {
+ httpUriRequest: HttpUriRequest,
+ responseType: Class<T>
+ ):
+ WebClientResponse<T> {
val httpResponse = httpClient().execute(httpUriRequest)
val statusCode = httpResponse.statusLine.statusCode
httpResponse.entity.content.use {
@@ -164,7 +180,7 @@ interface BlueprintWebClientService {
}
suspend fun <T> getNB(path: String, additionalHeaders: Array<BasicHeader>?, responseType: Class<T>):
- WebClientResponse<T> = withContext(Dispatchers.IO) {
+ WebClientResponse<T> = withContext(Dispatchers.IO) {
get(path, additionalHeaders!!, responseType)
}
@@ -176,8 +192,12 @@ interface BlueprintWebClientService {
return postNB(path, request, additionalHeaders, String::class.java)
}
- suspend fun <T> postNB(path: String, request: Any, additionalHeaders: Array<BasicHeader>?,
- responseType: Class<T>): WebClientResponse<T> = withContext(Dispatchers.IO) {
+ suspend fun <T> postNB(
+ path: String,
+ request: Any,
+ additionalHeaders: Array<BasicHeader>?,
+ responseType: Class<T>
+ ): WebClientResponse<T> = withContext(Dispatchers.IO) {
post(path, request, additionalHeaders!!, responseType)
}
@@ -185,14 +205,20 @@ interface BlueprintWebClientService {
return putNB(path, request, null, String::class.java)
}
- suspend fun putNB(path: String, request: Any,
- additionalHeaders: Array<BasicHeader>?): WebClientResponse<String> {
+ suspend fun putNB(
+ path: String,
+ request: Any,
+ additionalHeaders: Array<BasicHeader>?
+ ): WebClientResponse<String> {
return putNB(path, request, additionalHeaders, String::class.java)
}
- suspend fun <T> putNB(path: String, request: Any,
- additionalHeaders: Array<BasicHeader>?,
- responseType: Class<T>): WebClientResponse<T> = withContext(Dispatchers.IO) {
+ suspend fun <T> putNB(
+ path: String,
+ request: Any,
+ additionalHeaders: Array<BasicHeader>?,
+ responseType: Class<T>
+ ): WebClientResponse<T> = withContext(Dispatchers.IO) {
put(path, request, additionalHeaders!!, responseType)
}
@@ -201,36 +227,42 @@ interface BlueprintWebClientService {
}
suspend fun <T> deleteNB(path: String, additionalHeaders: Array<BasicHeader>?):
- WebClientResponse<String> {
+ WebClientResponse<String> {
return deleteNB(path, additionalHeaders, String::class.java)
}
suspend fun <T> deleteNB(path: String, additionalHeaders: Array<BasicHeader>?, responseType: Class<T>):
- WebClientResponse<T> = withContext(Dispatchers.IO) {
+ WebClientResponse<T> = withContext(Dispatchers.IO) {
delete(path, additionalHeaders!!, responseType)
}
suspend fun <T> patchNB(path: String, request: Any, additionalHeaders: Array<BasicHeader>?, responseType: Class<T>):
- WebClientResponse<T> = withContext(Dispatchers.IO) {
+ WebClientResponse<T> = withContext(Dispatchers.IO) {
patch(path, request, additionalHeaders!!, responseType)
}
suspend fun exchangeNB(methodType: String, path: String, request: Any): WebClientResponse<String> {
- return exchangeNB(methodType, path, request, hashMapOf(),
- String::class.java)
+ return exchangeNB(
+ methodType, path, request, hashMapOf(),
+ String::class.java
+ )
}
suspend fun exchangeNB(methodType: String, path: String, request: Any, additionalHeaders: Map<String, String>?):
- WebClientResponse<String> {
+ WebClientResponse<String> {
return exchangeNB(methodType, path, request, additionalHeaders, String::class.java)
}
- suspend fun <T> exchangeNB(methodType: String, path: String, request: Any,
- additionalHeaders: Map<String, String>?,
- responseType: Class<T>): WebClientResponse<T> {
+ suspend fun <T> exchangeNB(
+ methodType: String,
+ path: String,
+ request: Any,
+ additionalHeaders: Map<String, String>?,
+ responseType: Class<T>
+ ): WebClientResponse<T> {
- //TODO: possible inconsistency
- //NOTE: this basic headers function is different from non-blocking
+ // TODO: possible inconsistency
+ // NOTE: this basic headers function is different from non-blocking
val convertedHeaders: Array<BasicHeader> = basicHeaders(additionalHeaders!!)
return when (HttpMethod.resolve(methodType)) {
HttpMethod.GET -> getNB(path, convertedHeaders, responseType)
@@ -259,7 +291,7 @@ interface BlueprintWebClientService {
}
private fun basicHeaders(headers: Map<String, String>?):
- Array<BasicHeader> {
+ Array<BasicHeader> {
val basicHeaders = mutableListOf<BasicHeader>()
defaultHeaders().forEach { (name, value) ->
basicHeaders.add(BasicHeader(name, value))
@@ -278,18 +310,18 @@ interface BlueprintWebClientService {
.build()
}
- //TODO maybe there could be cases where we care about return headers?
+ // TODO maybe there could be cases where we care about return headers?
data class WebClientResponse<T>(val status: Int, val body: T)
fun verifyAdditionalHeaders(restClientProperties: RestClientProperties): Map<String, String> {
val customHeaders: MutableMap<String, String> = mutableMapOf()
- //Extract additionalHeaders from the requestProperties and
- //throw an error if HttpHeaders.AUTHORIZATION key (headers are case-insensitive)
+ // Extract additionalHeaders from the requestProperties and
+ // throw an error if HttpHeaders.AUTHORIZATION key (headers are case-insensitive)
restClientProperties.additionalHeaders?.let {
if (it.keys.map { k -> k.toLowerCase().trim() }.contains(HttpHeaders.AUTHORIZATION.toLowerCase())) {
val errMsg = "Error in definition of endpoint ${restClientProperties.url}." +
- " User-supplied \"additionalHeaders\" cannot contain AUTHORIZATION header with" +
- " auth-type \"${RestLibConstants.TYPE_BASIC_AUTH}\""
+ " User-supplied \"additionalHeaders\" cannot contain AUTHORIZATION header with" +
+ " auth-type \"${RestLibConstants.TYPE_BASIC_AUTH}\""
WebClientUtils.log.error(errMsg)
throw BluePrintProcessorException(errMsg)
} else {
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt
index 969de836c..dbb98f849 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestLoggerService.kt
@@ -16,7 +16,13 @@
package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
-import kotlinx.coroutines.*
+import kotlinx.coroutines.AbstractCoroutine
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.InternalCoroutinesApi
+import kotlinx.coroutines.handleCoroutineException
+import kotlinx.coroutines.newCoroutineContext
import kotlinx.coroutines.reactor.ReactorContext
import kotlinx.coroutines.reactor.asCoroutineContext
import org.apache.http.message.BasicHeader
@@ -37,7 +43,7 @@ import java.net.InetAddress
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
-import java.util.*
+import java.util.UUID
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
@@ -89,17 +95,19 @@ class RestLoggerService {
}
}
-
/** Used in Rest controller API methods to populate MDC context to nested coroutines from reactor web filter context. */
@UseExperimental(InternalCoroutinesApi::class)
-fun <T> monoMdc(context: CoroutineContext = EmptyCoroutineContext,
- block: suspend CoroutineScope.() -> T?): Mono<T> = Mono.create { sink ->
+fun <T> monoMdc(
+ context: CoroutineContext = EmptyCoroutineContext,
+ block: suspend CoroutineScope.() -> T?
+): Mono<T> = Mono.create { sink ->
val reactorContext = (context[ReactorContext]?.context?.putAll(sink.currentContext())
- ?: sink.currentContext()).asCoroutineContext()
+ ?: sink.currentContext()).asCoroutineContext()
/** Populate MDC context only if present in Reactor Context */
- val newContext = if (!reactorContext.context.isEmpty
- && reactorContext.context.hasKey(MDCContext)) {
+ val newContext = if (!reactorContext.context.isEmpty &&
+ reactorContext.context.hasKey(MDCContext)
+ ) {
val mdcContext = reactorContext.context.get<MDCContext>(MDCContext)
GlobalScope.newCoroutineContext(context + reactorContext + mdcContext)
} else GlobalScope.newCoroutineContext(context + reactorContext)
@@ -111,9 +119,10 @@ fun <T> monoMdc(context: CoroutineContext = EmptyCoroutineContext,
@InternalCoroutinesApi
class MonoMDCCoroutine<in T>(
- parentContext: CoroutineContext,
- private val sink: MonoSink<T>
+ parentContext: CoroutineContext,
+ private val sink: MonoSink<T>
) : AbstractCoroutine<T>(parentContext, true), Disposable {
+
private var disposed = false
override fun onCompleted(value: T) {
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt
index 0ef1757e2..86e3ced06 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
+import org.apache.http.conn.ssl.NoopHostnameVerifier
import org.apache.http.conn.ssl.SSLConnectionSocketFactory
import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClients
@@ -32,7 +33,6 @@ import java.io.File
import java.io.FileInputStream
import java.security.KeyStore
import java.security.cert.X509Certificate
-import org.apache.http.conn.ssl.NoopHostnameVerifier
class SSLRestClientService(private val restClientProperties: SSLRestClientProperties) :
BlueprintWebClientService {
@@ -44,8 +44,8 @@ class SSLRestClientService(private val restClientProperties: SSLRestClientProper
}
private fun getAuthService(): BlueprintWebClientService? {
- //type,url and additional headers don't get carried over to TokenAuthRestClientProperties from SSLTokenAuthRestClientProperties
- //set them in auth obj to be consistent. TODO: refactor
+ // type,url and additional headers don't get carried over to TokenAuthRestClientProperties from SSLTokenAuthRestClientProperties
+ // set them in auth obj to be consistent. TODO: refactor
return when (restClientProperties) {
is SSLBasicAuthRestClientProperties -> {
val basicAuthProps = restClientProperties.basicAuth!!
@@ -62,7 +62,7 @@ class SSLRestClientService(private val restClientProperties: SSLRestClientProper
TokenAuthRestClientService(token)
}
else -> {
- //Returns null for No auth
+ // Returns null for No auth
null
}
}
@@ -74,7 +74,8 @@ class SSLRestClientService(private val restClientProperties: SSLRestClientProper
}
return mapOf(
HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE)
+ HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE
+ )
}
override fun host(uri: String): String {
@@ -104,7 +105,7 @@ class SSLRestClientService(private val restClientProperties: SSLRestClientProper
}
sslContext.loadTrustMaterial(File(sslTrust), sslTrustPwd.toCharArray(), acceptingTrustStrategy)
- var csf : SSLConnectionSocketFactory
+ var csf: SSLConnectionSocketFactory
if (sslTrustIgnoreHostname) {
csf = SSLConnectionSocketFactory(sslContext.build(), NoopHostnameVerifier())
} else {
@@ -123,14 +124,16 @@ class SSLRestClientService(private val restClientProperties: SSLRestClientProper
override fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> {
val mergedDefaultAndSuppliedHeaders = defaultHeaders().plus(headers)
- //During the initialization, getAuthService() sets the auth variable.
- //If it's not null, then we have an authentication mechanism.
- //If null - indicates no-auth used
+ // During the initialization, getAuthService() sets the auth variable.
+ // If it's not null, then we have an authentication mechanism.
+ // If null - indicates no-auth used
if (auth != null) {
return auth!!.convertToBasicHeaders(mergedDefaultAndSuppliedHeaders)
}
- //inject additionalHeaders
- return super.convertToBasicHeaders(mergedDefaultAndSuppliedHeaders
- .plus(verifyAdditionalHeaders(restClientProperties)))
+ // inject additionalHeaders
+ return super.convertToBasicHeaders(
+ mergedDefaultAndSuppliedHeaders
+ .plus(verifyAdditionalHeaders(restClientProperties))
+ )
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
index 73b534143..57702f8ac 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
@@ -21,21 +21,24 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.TokenAuthRestClientProperties
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
-class TokenAuthRestClientService(private val restClientProperties:
- TokenAuthRestClientProperties) :
+class TokenAuthRestClientService(
+ private val restClientProperties:
+ TokenAuthRestClientProperties
+) :
BlueprintWebClientService {
override fun defaultHeaders(): Map<String, String> {
return mapOf(
HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to restClientProperties.token!!)
+ HttpHeaders.AUTHORIZATION to restClientProperties.token!!
+ )
}
override fun convertToBasicHeaders(headers: Map<String, String>):
- Array<BasicHeader> {
+ Array<BasicHeader> {
val customHeaders: MutableMap<String, String> = headers.toMutableMap()
- //inject additionalHeaders
+ // inject additionalHeaders
customHeaders.putAll(verifyAdditionalHeaders(restClientProperties))
if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) {
customHeaders[HttpHeaders.AUTHORIZATION] = restClientProperties.token!!
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/utils/WebClientUtils.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/utils/WebClientUtils.kt
index 42006569f..ff4d54730 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/utils/WebClientUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/utils/WebClientUtils.kt
@@ -32,4 +32,4 @@ class WebClientUtils {
fun logResponse(): HttpResponseInterceptor =
HttpResponseInterceptor { response, _ -> log.info("Response status(${response.statusLine.statusCode} - ${response.statusLine.reasonPhrase})") }
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
index 1e4518a8c..53047d4a8 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
@@ -41,50 +41,59 @@ import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class,
- BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
- "blueprintsprocessor.restclient.sample.userId=sampleuser",
- "blueprintsprocessor.restclient.sslbasic.type=ssl-basic-auth",
- "blueprintsprocessor.restclient.sslbasic.url=https://localhost:8443",
- "blueprintsprocessor.restclient.sslbasic.username=admin",
- "blueprintsprocessor.restclient.sslbasic.password=cds",
- "blueprintsprocessor.restclient.sslbasic.keyStoreInstance=PKCS12",
- "blueprintsprocessor.restclient.sslbasic.sslTrust=src/test/resources/keystore.p12",
- "blueprintsprocessor.restclient.sslbasic.sslTrustPassword=changeit",
- "blueprintsprocessor.restclient.ssltoken.type=ssl-token-auth",
- "blueprintsprocessor.restclient.ssltoken.url=https://localhost:8443",
- "blueprintsprocessor.restclient.ssltoken.token=72178473kjshdkjgvbsdkjv903274908",
- "blueprintsprocessor.restclient.ssltoken.keyStoreInstance=PKCS12",
- "blueprintsprocessor.restclient.ssltoken.sslTrust=src/test/resources/keystore.p12",
- "blueprintsprocessor.restclient.ssltoken.sslTrustPassword=changeit",
- "blueprintsprocessor.restclient.ssl.type=ssl-no-auth",
- "blueprintsprocessor.restclient.ssl.url=https://localhost:8443",
- "blueprintsprocessor.restclient.ssl.keyStoreInstance=PKCS12",
- "blueprintsprocessor.restclient.ssl.sslTrust=src/test/resources/keystore.p12",
- "blueprintsprocessor.restclient.ssl.sslTrustPassword=changeit",
- "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12",
- "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit"
-])
+@ContextConfiguration(
+ classes = [BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class,
+ BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
+ "blueprintsprocessor.restclient.sample.userId=sampleuser",
+ "blueprintsprocessor.restclient.sslbasic.type=ssl-basic-auth",
+ "blueprintsprocessor.restclient.sslbasic.url=https://localhost:8443",
+ "blueprintsprocessor.restclient.sslbasic.username=admin",
+ "blueprintsprocessor.restclient.sslbasic.password=cds",
+ "blueprintsprocessor.restclient.sslbasic.keyStoreInstance=PKCS12",
+ "blueprintsprocessor.restclient.sslbasic.sslTrust=src/test/resources/keystore.p12",
+ "blueprintsprocessor.restclient.sslbasic.sslTrustPassword=changeit",
+ "blueprintsprocessor.restclient.ssltoken.type=ssl-token-auth",
+ "blueprintsprocessor.restclient.ssltoken.url=https://localhost:8443",
+ "blueprintsprocessor.restclient.ssltoken.token=72178473kjshdkjgvbsdkjv903274908",
+ "blueprintsprocessor.restclient.ssltoken.keyStoreInstance=PKCS12",
+ "blueprintsprocessor.restclient.ssltoken.sslTrust=src/test/resources/keystore.p12",
+ "blueprintsprocessor.restclient.ssltoken.sslTrustPassword=changeit",
+ "blueprintsprocessor.restclient.ssl.type=ssl-no-auth",
+ "blueprintsprocessor.restclient.ssl.url=https://localhost:8443",
+ "blueprintsprocessor.restclient.ssl.keyStoreInstance=PKCS12",
+ "blueprintsprocessor.restclient.ssl.sslTrust=src/test/resources/keystore.p12",
+ "blueprintsprocessor.restclient.ssl.sslTrustPassword=changeit",
+ "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12",
+ "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit"
+ ]
+)
class BluePrintRestLibPropertyServiceTest {
+
@Autowired
lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
@Test
fun testRestClientProperties() {
val properties = bluePrintRestLibPropertyService.restClientProperties(
- "blueprintsprocessor.restclient.sample")
+ "blueprintsprocessor.restclient.sample"
+ )
assertNotNull(properties, "failed to create property bean")
- assertNotNull(properties.url, "failed to get url property in" +
- " property bean")
+ assertNotNull(
+ properties.url, "failed to get url property in" +
+ " property bean"
+ )
}
@Test
fun testSSLBasicProperties() {
val properties = bluePrintRestLibPropertyService.restClientProperties(
- "blueprintsprocessor.restclient.sslbasic")
+ "blueprintsprocessor.restclient.sslbasic"
+ )
assertNotNull(properties, "failed to create property bean")
val p: SSLBasicAuthRestClientProperties =
properties as SSLBasicAuthRestClientProperties
@@ -99,7 +108,8 @@ class BluePrintRestLibPropertyServiceTest {
@Test
fun testSSLTokenProperties() {
val properties = bluePrintRestLibPropertyService.restClientProperties(
- "blueprintsprocessor.restclient.ssltoken")
+ "blueprintsprocessor.restclient.ssltoken"
+ )
assertNotNull(properties, "failed to create property bean")
val p: SSLTokenAuthRestClientProperties =
@@ -114,7 +124,8 @@ class BluePrintRestLibPropertyServiceTest {
@Test
fun testSSLNoAuthProperties() {
val properties = bluePrintRestLibPropertyService.restClientProperties(
- "blueprintsprocessor.restclient.ssl")
+ "blueprintsprocessor.restclient.ssl"
+ )
assertNotNull(properties, "failed to create property bean")
val p: SSLRestClientProperties =
@@ -127,12 +138,12 @@ class BluePrintRestLibPropertyServiceTest {
assertEquals(p.sslKeyPassword, "changeit")
}
-
@Test
fun testSSLBasicPropertiesAsJson() {
val actualObj: JsonNode = defaultMapper.readTree(sslBasicAuthEndpointWithHeadersField())
val properties = bluePrintRestLibPropertyService.restClientProperties(
- actualObj)
+ actualObj
+ )
assertNotNull(properties, "failed to create property bean")
val p: SSLBasicAuthRestClientProperties = properties as SSLBasicAuthRestClientProperties
@@ -166,7 +177,8 @@ class BluePrintRestLibPropertyServiceTest {
fun testSSLNoAuthPropertiesAsJson() {
val actualObj: JsonNode = defaultMapper.readTree(sslNoAuthEndpointWithHeadersField())
val properties = bluePrintRestLibPropertyService.restClientProperties(
- actualObj)
+ actualObj
+ )
assertNotNull(properties, "failed to create property bean")
val p: SSLRestClientProperties =
@@ -185,8 +197,10 @@ class BluePrintRestLibPropertyServiceTest {
fun testBlueprintWebClientService() {
val blueprintWebClientService = bluePrintRestLibPropertyService
.blueprintWebClientService("sample")
- assertNotNull(blueprintWebClientService,
- "failed to create blueprintWebClientService")
+ assertNotNull(
+ blueprintWebClientService,
+ "failed to create blueprintWebClientService"
+ )
}
@Test
@@ -197,7 +211,7 @@ class BluePrintRestLibPropertyServiceTest {
assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService")
}
- //pass the result of $typeEndpointWithHeadersField() output with and without headers to compare.
+ // pass the result of $typeEndpointWithHeadersField() output with and without headers to compare.
private fun validateHeadersDidNotChangeWithEmptyAdditionalHeaders(noHeaders: String, withHeaders: String) {
val parsedObj: JsonNode = defaultMapper.readTree(noHeaders)
val bpWebClientService =
@@ -208,7 +222,7 @@ class BluePrintRestLibPropertyServiceTest {
val bpWebClientServiceWithHeaders =
bluePrintRestLibPropertyService.blueprintWebClientService(parsedObjWithHeaders)
val extractedHeadersWithAdditionalHeaders = bpWebClientServiceWithHeaders.convertToBasicHeaders(mapOf())
- //Array<BasicHeader<>> -> Map<String,String>
+ // Array<BasicHeader<>> -> Map<String,String>
val headersMap = extractedHeaders.map { it.name to it.value }.toMap()
val additionalHeadersMap = extractedHeadersWithAdditionalHeaders.map { it.name to it.value }.toMap()
assertEquals(headersMap, additionalHeadersMap)
@@ -256,18 +270,20 @@ class BluePrintRestLibPropertyServiceTest {
val bpWebClientService =
bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj)
val extractedHeaders = bpWebClientService.convertToBasicHeaders(mapOf())
- assertEquals(MediaType.APPLICATION_XML.toString(),
- extractedHeaders.filter { it.name == HttpHeaders.CONTENT_TYPE }[0].value!!)
+ assertEquals(
+ MediaType.APPLICATION_XML.toString(),
+ extractedHeaders.filter { it.name == HttpHeaders.CONTENT_TYPE }[0].value!!
+ )
}
@Test
fun `BasicAuth WebClientService additionalHeaders can overwrite default Content-Type`() {
- //default content type is application/json
+ // default content type is application/json
val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(contentTypeAdditionalHeader)
additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson)
}
- //called from within "assertFailsWith(exceptionClass = BluePrintProcessorException::class) {"
+ // called from within "assertFailsWith(exceptionClass = BluePrintProcessorException::class) {"
private fun attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson: String) {
val parsedObj: JsonNode = defaultMapper.readTree(endPointWithHeadersJson)
val bpWebClientService =
@@ -281,7 +297,7 @@ class BluePrintRestLibPropertyServiceTest {
val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(additionalHeadersWithAuth)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
}
- //spec says headers are case insensitive...
+ // spec says headers are case insensitive...
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
@@ -309,7 +325,7 @@ class BluePrintRestLibPropertyServiceTest {
@Test
fun `TokenAuth WebClientService additionalHeaders can overwrite default Content-Type`() {
- //default content type is application/json
+ // default content type is application/json
val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(contentTypeAdditionalHeader)
additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson)
}
@@ -320,14 +336,14 @@ class BluePrintRestLibPropertyServiceTest {
val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(additionalHeadersWithAuth)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
}
- //spec says headers are case insensitive...
+ // spec says headers are case insensitive...
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
}
}
- //TESTS FOR SSL BASIC AUTH headers
+ // TESTS FOR SSL BASIC AUTH headers
@Test
fun `SSLBasicAuth WebClientService with empty additionalHeaders does not modify headers`() {
val endPointJson = sslBasicAuthEndpointWithHeadersField()
@@ -349,7 +365,7 @@ class BluePrintRestLibPropertyServiceTest {
@Test
fun `SSLBasicAuth WebClientService additionalHeaders can overwrite default Content-Type`() {
- //default content type is application/json
+ // default content type is application/json
val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(contentTypeAdditionalHeader)
additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson)
}
@@ -360,14 +376,14 @@ class BluePrintRestLibPropertyServiceTest {
val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(additionalHeadersWithAuth)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
}
- //spec says headers are case insensitive...
+ // spec says headers are case insensitive...
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
}
}
- //SSL-NO-AUTH headers tests
+ // SSL-NO-AUTH headers tests
@Test
fun `SSLNoAuth WebClientService with empty additionalHeaders does not modify headers`() {
val endPointJson = sslNoAuthEndpointWithHeadersField()
@@ -389,7 +405,7 @@ class BluePrintRestLibPropertyServiceTest {
@Test
fun `SSLNoAuth WebClientService additionalHeaders can overwrite default Content-Type`() {
- //default content type is application/json
+ // default content type is application/json
val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(contentTypeAdditionalHeader)
additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson)
}
@@ -400,7 +416,7 @@ class BluePrintRestLibPropertyServiceTest {
val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(additionalHeadersWithAuth)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
}
- //spec says headers are case insensitive...
+ // spec says headers are case insensitive...
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased)
attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson)
@@ -412,12 +428,15 @@ class BluePrintRestLibPropertyServiceTest {
val expectedTokenAuthDefaultHeaders = mapOf<String, String>(
"Content-Type" to "application/json",
"Accept" to "application/json",
- "Authorization" to "72178473kjshdkjgvbsdkjv903274908")
+ "Authorization" to "72178473kjshdkjgvbsdkjv903274908"
+ )
- val endPointWithHeadersJsonWithBasicAuthHeader = basicAuthEndpointWithHeadersField(""",
+ val endPointWithHeadersJsonWithBasicAuthHeader = basicAuthEndpointWithHeadersField(
+ """,
"additionalHeaders" : {
"authorization": "Basic aGF2ZTphbmljZWRheQo="
- }""".trimIndent())
+ }""".trimIndent()
+ )
private fun sslTokenAuthEndpointWithHeadersField(headers: String = ""): String =
"""{
@@ -455,7 +474,7 @@ class BluePrintRestLibPropertyServiceTest {
"sslKeyPassword" : "changeit"$headers
}""".trimIndent()
- //Don't forget to supply "," as the first char to make valid JSON
+ // Don't forget to supply "," as the first char to make valid JSON
private fun basicAuthEndpointWithHeadersField(headers: String = ""): String =
"""{
"type": "basic-auth",
@@ -496,4 +515,3 @@ class BluePrintRestLibPropertyServiceTest {
}""".trimIndent()
}
}
-
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
index 15133fa8a..f82fc6124 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
@@ -24,7 +24,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import kotlin.test.assertNotNull
class RestClientPropertiesDSLTest {
-
+
@Test
fun testBasicAuthRestClientProperties() {
val properties = BluePrintTypes.dslBasicAuthRestClientProperties {
@@ -56,4 +56,4 @@ class RestClientPropertiesDSLTest {
}
assertNotNull(properties, "failed to get dslSSLRestClientProperties")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt
index 05f32904a..fa357e1fe 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt
@@ -48,45 +48,56 @@ import org.springframework.security.web.server.SecurityWebFilterChain
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.DeleteMapping
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PatchMapping
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.PutMapping
+import org.springframework.web.bind.annotation.RequestHeader
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
-@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, SampleController::class,
- SecurityConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-[
- "server.port=8443",
- "server.ssl.enabled=true",
- "server.ssl.key-store=classpath:keystore.p12",
- "server.ssl.key-store-password=changeit",
- "server.ssl.keyStoreType=PKCS12",
- "server.ssl.keyAlias=tomcat",
- "blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8081",
- "blueprintsprocessor.restclient.sample.username=admin",
- "blueprintsprocessor.restclient.sample.password=jans",
- "blueprintsprocessor.restclient.test.type=ssl-basic-auth",
- "blueprintsprocessor.restclient.test.url=https://localhost:8443",
- "blueprintsprocessor.restclient.test.username=admin",
- "blueprintsprocessor.restclient.test.password=jans",
- "blueprintsprocessor.restclient.test.keyStoreInstance=PKCS12",
- "blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12",
- "blueprintsprocessor.restclient.test.sslTrustPassword=changeit"
-])
+@ContextConfiguration(
+ classes = [BluePrintRestLibConfiguration::class, SampleController::class,
+ SecurityConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ [
+ "server.port=8443",
+ "server.ssl.enabled=true",
+ "server.ssl.key-store=classpath:keystore.p12",
+ "server.ssl.key-store-password=changeit",
+ "server.ssl.keyStoreType=PKCS12",
+ "server.ssl.keyAlias=tomcat",
+ "blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8081",
+ "blueprintsprocessor.restclient.sample.username=admin",
+ "blueprintsprocessor.restclient.sample.password=jans",
+ "blueprintsprocessor.restclient.test.type=ssl-basic-auth",
+ "blueprintsprocessor.restclient.test.url=https://localhost:8443",
+ "blueprintsprocessor.restclient.test.username=admin",
+ "blueprintsprocessor.restclient.test.password=jans",
+ "blueprintsprocessor.restclient.test.keyStoreInstance=PKCS12",
+ "blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12",
+ "blueprintsprocessor.restclient.test.sslTrustPassword=changeit"
+ ]
+)
class RestClientServiceTest {
@Autowired
lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
@Autowired
- lateinit var httpHandler : HttpHandler
+ lateinit var httpHandler: HttpHandler
- lateinit var http : WebServer
+ lateinit var http: WebServer
fun localPort() = http.port
@@ -106,21 +117,26 @@ class RestClientServiceTest {
@Test
fun testPatch() {
val restClientService = bluePrintRestLibPropertyService
- .blueprintWebClientService("sample")
+ .blueprintWebClientService("sample")
val response = restClientService.exchangeResource(
- HttpMethod.PATCH.name, "/sample/name", "")
- assertEquals("Patch request successful", response.body,
- "failed to get patch response")
+ HttpMethod.PATCH.name, "/sample/name", ""
+ )
+ assertEquals(
+ "Patch request successful", response.body,
+ "failed to get patch response"
+ )
}
@Test
fun testBaseAuth() {
val restClientService = bluePrintRestLibPropertyService
- .blueprintWebClientService("sample")
+ .blueprintWebClientService("sample")
val headers = mutableMapOf<String, String>()
headers["X-Transaction-Id"] = "1234"
- val response = restClientService.exchangeResource(HttpMethod.GET.name,
- "/sample/name", "")
+ val response = restClientService.exchangeResource(
+ HttpMethod.GET.name,
+ "/sample/name", ""
+ )
assertNotNull(response.body, "failed to get response")
}
@@ -135,12 +151,15 @@ class RestClientServiceTest {
val mapper = ObjectMapper()
val actualObj: JsonNode = mapper.readTree(json)
val restClientService = bluePrintRestLibPropertyService
- .blueprintWebClientService(actualObj)
- lateinit var res:String
+ .blueprintWebClientService(actualObj)
+ lateinit var res: String
runBlocking {
val get = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.GET.name,
- "/sample/basic", "").body}
+ restClientService.exchangeNB(
+ HttpMethod.GET.name,
+ "/sample/basic", ""
+ ).body
+ }
get.start()
res = get.await()
}
@@ -151,7 +170,7 @@ class RestClientServiceTest {
@Test
fun testSampleAaiReq() {
val restClientService = bluePrintRestLibPropertyService
- .blueprintWebClientService("test")
+ .blueprintWebClientService("test")
val headers = mutableMapOf<String, String>()
headers["X-TransactionId"] = "9999"
headers["X-FromAppId"] = "AAI"
@@ -171,34 +190,52 @@ class RestClientServiceTest {
lateinit var res6: String
runBlocking {
val get1 = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.GET.name,
- "/sample/aai/v14/business/customers", "", headers,
- Customer::class.java).body}
+ restClientService.exchangeNB(
+ HttpMethod.GET.name,
+ "/sample/aai/v14/business/customers", "", headers,
+ Customer::class.java
+ ).body
+ }
val get2 = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.GET.name,
- "/sample/aai/v14/business/customers", "", headers,
- Customer::class.java).body}
+ restClientService.exchangeNB(
+ HttpMethod.GET.name,
+ "/sample/aai/v14/business/customers", "", headers,
+ Customer::class.java
+ ).body
+ }
val post = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.POST.name,
- "/sample/aai/v14/business/customers", post1, headers,
- String::class.java).body}
+ restClientService.exchangeNB(
+ HttpMethod.POST.name,
+ "/sample/aai/v14/business/customers", post1, headers,
+ String::class.java
+ ).body
+ }
val put = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.PUT.name,
- "/sample/aai/v14/business/customers", post1, headers,
- String::class.java).body}
+ restClientService.exchangeNB(
+ HttpMethod.PUT.name,
+ "/sample/aai/v14/business/customers", post1, headers,
+ String::class.java
+ ).body
+ }
val patch = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.PATCH.name,
- "/sample/aai/v14/business/customers", post1, headers,
- String::class.java).body}
+ restClientService.exchangeNB(
+ HttpMethod.PATCH.name,
+ "/sample/aai/v14/business/customers", post1, headers,
+ String::class.java
+ ).body
+ }
val delete = async(start = CoroutineStart.LAZY) {
- restClientService.exchangeNB(HttpMethod.DELETE.name,
- "/sample/aai/v14/business/customers", "", headers,
- String::class.java).body}
+ restClientService.exchangeNB(
+ HttpMethod.DELETE.name,
+ "/sample/aai/v14/business/customers", "", headers,
+ String::class.java
+ ).body
+ }
get1.start()
get2.start()
@@ -246,13 +283,13 @@ open class SampleController {
@GetMapping("/basic")
fun getBasic(): String = "Basic request arrived successfully"
-
@GetMapping("/aai/v14/business/customers")
fun getAaiCustomers(
- @RequestHeader(name = "X-TransactionId", required = true)
- transId: String,
- @RequestHeader(name = "X-FromAppId", required = true)
- appId: String) : String {
+ @RequestHeader(name = "X-TransactionId", required = true)
+ transId: String,
+ @RequestHeader(name = "X-FromAppId", required = true)
+ appId: String
+ ): String {
if (transId != "9999" || appId != "AAI") {
return ""
}
@@ -266,23 +303,24 @@ open class SampleController {
@PostMapping("/aai/v14/business/customers")
fun postAaiCustomers(
- @RequestHeader(name = "X-TransactionId", required = true)
- transId: String,
- @RequestHeader(name = "X-FromAppId", required = true)
- appId: String) : String {
+ @RequestHeader(name = "X-TransactionId", required = true)
+ transId: String,
+ @RequestHeader(name = "X-FromAppId", required = true)
+ appId: String
+ ): String {
if (transId != "9999" || appId != "AAI") {
return ""
}
return "The message is successfully posted"
}
-
@PutMapping("/aai/v14/business/customers")
fun putAaiCustomers(
- @RequestHeader(name = "X-TransactionId", required = true)
- transId: String,
- @RequestHeader(name = "X-FromAppId", required = true)
- appId: String) : String {
+ @RequestHeader(name = "X-TransactionId", required = true)
+ transId: String,
+ @RequestHeader(name = "X-FromAppId", required = true)
+ appId: String
+ ): String {
if (transId != "9999" || appId != "AAI") {
return ""
}
@@ -291,10 +329,11 @@ open class SampleController {
@PatchMapping("/aai/v14/business/customers")
fun patchAaiCustomers(
- @RequestHeader(name = "X-TransactionId", required = true)
- transId: String,
- @RequestHeader(name = "X-FromAppId", required = true)
- appId: String) : String {
+ @RequestHeader(name = "X-TransactionId", required = true)
+ transId: String,
+ @RequestHeader(name = "X-FromAppId", required = true)
+ appId: String
+ ): String {
if (transId != "9999" || appId != "AAI") {
return ""
}
@@ -303,10 +342,11 @@ open class SampleController {
@DeleteMapping("/aai/v14/business/customers")
fun deleteAaiCustomers(
- @RequestHeader(name = "X-TransactionId", required = true)
- transId: String,
- @RequestHeader(name = "X-FromAppId", required = true)
- appId: String) : String {
+ @RequestHeader(name = "X-TransactionId", required = true)
+ transId: String,
+ @RequestHeader(name = "X-FromAppId", required = true)
+ appId: String
+ ): String {
if (transId != "9999" || appId != "AAI") {
return ""
}
@@ -323,20 +363,20 @@ open class SecurityConfiguration {
@Bean
open fun userDetailsService(): MapReactiveUserDetailsService {
val user: UserDetails = User.withDefaultPasswordEncoder()
- .username("admin")
- .password("jans")
- .roles("USER")
- .build()
+ .username("admin")
+ .password("jans")
+ .roles("USER")
+ .build()
return MapReactiveUserDetailsService(user)
}
@Bean
open fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
return http
- .csrf().disable()
- .authorizeExchange().anyExchange().authenticated()
- .and().httpBasic()
- .and().build()
+ .csrf().disable()
+ .authorizeExchange().anyExchange().authenticated()
+ .and().httpBasic()
+ .and().build()
}
}
@@ -344,7 +384,8 @@ open class SecurityConfiguration {
* Data class required for response
*/
data class Customer(
- val id: String,
- val name: String,
- val type: String,
- val resource: String)
+ val id: String,
+ val name: String,
+ val type: String,
+ val resource: String
+)
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt
index 3c625a6d3..382c9b7d7 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt
@@ -33,16 +33,13 @@ open class BluePrintSshLibConfiguration
* Exposed Dependency Service by this SSH Lib Module
*/
fun BluePrintDependencyService.sshLibPropertyService(): BluePrintSshLibPropertyService =
- instance(SshLibConstants.SERVICE_BLUEPRINT_SSH_LIB_PROPERTY)
-
+ instance(SshLibConstants.SERVICE_BLUEPRINT_SSH_LIB_PROPERTY)
fun BluePrintDependencyService.sshClientService(selector: String): BlueprintSshClientService =
- sshLibPropertyService().blueprintSshClientService(selector)
-
+ sshLibPropertyService().blueprintSshClientService(selector)
fun BluePrintDependencyService.sshClientService(jsonNode: JsonNode): BlueprintSshClientService =
- sshLibPropertyService().blueprintSshClientService(jsonNode)
-
+ sshLibPropertyService().blueprintSshClientService(jsonNode)
class SshLibConstants {
companion object {
@@ -50,4 +47,4 @@ class SshLibConstants {
const val PROPERTY_SSH_CLIENT_PREFIX = "blueprintsprocessor.sshclient."
const val TYPE_BASIC_AUTH = "basic-auth"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt
index a70ea5588..c7d5105b4 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt
@@ -26,4 +26,4 @@ open class SshClientProperties {
open class BasicAuthSshClientProperties : SshClientProperties() {
lateinit var password: String
lateinit var username: String
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt
index adbde0f87..61baaa1ef 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt
@@ -26,11 +26,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.ssh.BasicAuthSshClientProperties
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.slf4j.LoggerFactory
import java.io.ByteArrayOutputStream
-import java.util.*
+import java.util.Collections
+import java.util.EnumSet
-
-open class BasicAuthSshClientService(private val basicAuthSshClientProperties: BasicAuthSshClientProperties)
- : BlueprintSshClientService {
+open class BasicAuthSshClientService(private val basicAuthSshClientProperties: BasicAuthSshClientProperties) :
+ BlueprintSshClientService {
private val log = LoggerFactory.getLogger(BasicAuthSshClientService::class.java)!!
@@ -43,10 +43,12 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B
sshClient.serverKeyVerifier = AcceptAllServerKeyVerifier.INSTANCE
sshClient.start()
log.debug("SSH Client Service started successfully")
- clientSession = sshClient.connect(basicAuthSshClientProperties.username, basicAuthSshClientProperties.host,
- basicAuthSshClientProperties.port)
- .verify(basicAuthSshClientProperties.connectionTimeOut)
- .session
+ clientSession = sshClient.connect(
+ basicAuthSshClientProperties.username, basicAuthSshClientProperties.host,
+ basicAuthSshClientProperties.port
+ )
+ .verify(basicAuthSshClientProperties.connectionTimeOut)
+ .session
clientSession.addPasswordIdentity(basicAuthSshClientProperties.password)
clientSession.auth().verify(basicAuthSshClientProperties.connectionTimeOut)
@@ -73,7 +75,7 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B
channel = clientSession.createExecChannel(command)
checkNotNull(channel) { "failed to create Channel for the command : $command" }
- //TODO("Convert to streaming ")
+ // TODO("Convert to streaming ")
val outputStream = ByteArrayOutputStream()
channel!!.out = outputStream
channel!!.err = outputStream
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt
index 337208c78..90a1746e8 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyService.kt
@@ -53,11 +53,13 @@ open class BluePrintSshLibPropertyService(private var bluePrintProperties: BlueP
fun sshClientProperties(jsonNode: JsonNode): SshClientProperties {
val type = jsonNode.get("type")?.textValue()
- ?: throw BluePrintProcessorException("missing type field in ssh client properties")
+ ?: throw BluePrintProcessorException("missing type field in ssh client properties")
return when (type) {
SshLibConstants.TYPE_BASIC_AUTH -> {
- JacksonUtils.readValue(jsonNode,
- BasicAuthSshClientProperties::class.java)!!
+ JacksonUtils.readValue(
+ jsonNode,
+ BasicAuthSshClientProperties::class.java
+ )!!
}
else -> {
throw BluePrintProcessorException("SSH adaptor($type) is not supported")
@@ -79,7 +81,7 @@ open class BluePrintSshLibPropertyService(private var bluePrintProperties: BlueP
private fun basicAuthSshClientProperties(prefix: String): BasicAuthSshClientProperties {
return bluePrintProperties.propertyBeanType(
- prefix, BasicAuthSshClientProperties::class.java)
+ prefix, BasicAuthSshClientProperties::class.java
+ )
}
-
}
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientService.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientService.kt
index 279e437cc..724c4277d 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientService.kt
@@ -44,4 +44,4 @@ interface BlueprintSshClientService {
suspend fun executeCommandNB(command: String, timeOut: Long): String
suspend fun closeSessionNB()
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyServiceTest.kt
index f4275b8f2..f4c39c936 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BluePrintSshLibPropertyServiceTest.kt
@@ -29,17 +29,20 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintSshLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.sshclient.sample.type=basic-auth",
- "blueprintsprocessor.sshclient.sample.host=127.0.0.1",
- "blueprintsprocessor.sshclient.sample.port=22",
- "blueprintsprocessor.sshclient.sample.password=1234",
- "blueprintsprocessor.sshclient.sample.username=dummy"
-])
+@ContextConfiguration(
+ classes = [BluePrintSshLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprintsprocessor.sshclient.sample.type=basic-auth",
+ "blueprintsprocessor.sshclient.sample.host=127.0.0.1",
+ "blueprintsprocessor.sshclient.sample.port=22",
+ "blueprintsprocessor.sshclient.sample.password=1234",
+ "blueprintsprocessor.sshclient.sample.username=dummy"
+ ]
+)
class BluePrintSshLibPropertyServiceTest {
@Autowired
@@ -48,11 +51,11 @@ class BluePrintSshLibPropertyServiceTest {
@Test
fun testRestClientProperties() {
val properties = bluePrintSshLibPropertyService
- .sshClientProperties("blueprintsprocessor.sshclient.sample") as BasicAuthSshClientProperties
+ .sshClientProperties("blueprintsprocessor.sshclient.sample") as BasicAuthSshClientProperties
assertNotNull(properties, "failed to create property bean")
assertEquals(properties.host, "127.0.0.1", "failed to match host property")
assertEquals(properties.port, 22, "failed to match port property")
assertEquals(properties.password, "1234", "failed to match host property")
assertEquals(properties.username, "dummy", "failed to match host property")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientServiceTest.kt
index 430b988a4..683816f7f 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BlueprintSshClientServiceTest.kt
@@ -38,17 +38,20 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintSshLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.sshclient.sample.type=basic-auth",
- "blueprintsprocessor.sshclient.sample.host=localhost",
- "blueprintsprocessor.sshclient.sample.port=52815",
- "blueprintsprocessor.sshclient.sample.username=root",
- "blueprintsprocessor.sshclient.sample.password=dummyps"
-])
+@ContextConfiguration(
+ classes = [BluePrintSshLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprintsprocessor.sshclient.sample.type=basic-auth",
+ "blueprintsprocessor.sshclient.sample.host=localhost",
+ "blueprintsprocessor.sshclient.sample.port=52815",
+ "blueprintsprocessor.sshclient.sample.username=root",
+ "blueprintsprocessor.sshclient.sample.password=dummyps"
+ ]
+)
class BlueprintSshClientServiceTest {
@Autowired
@@ -76,7 +79,7 @@ class BlueprintSshClientServiceTest {
sshd.keyPairProvider = createTestHostKeyProvider()
sshd.passwordAuthenticator = BogusPasswordAuthenticator(userName, password)
sshd.publickeyAuthenticator = AcceptAllPublickeyAuthenticator.INSTANCE
- //sshd.shellFactory = EchoShellFactory()
+ // sshd.shellFactory = EchoShellFactory()
sshd.commandFactory = ProcessShellCommandFactory.INSTANCE
return sshd
}
@@ -96,5 +99,3 @@ class BogusPasswordAuthenticator(userName: String, password: String) : PasswordA
return true
}
}
-
-
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 eb7929509..0b18fb01f 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
@@ -27,7 +27,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestMethod
+import org.springframework.web.bind.annotation.RequestParam
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
/**
* Exposes Resource Configuration Snapshot API to store and retrieve stored resource configurations.
@@ -37,52 +44,66 @@ import org.springframework.web.bind.annotation.*
*/
@RestController
@RequestMapping("/api/v1/configs")
-@Api(value = "/api/v1/configs",
- description = "Interaction with stored configurations.")
+@Api(
+ value = "/api/v1/configs",
+ description = "Interaction with stored configurations."
+)
open class ResourceConfigSnapshotController(private val resourceConfigSnapshotService: ResourceConfigSnapshotService) {
- @RequestMapping(path = ["/health-check"],
+ @RequestMapping(
+ path = ["/health-check"],
method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
fun ressCfgSnapshotControllerHealthCheck(): JsonNode = runBlocking {
"Success".asJsonPrimitive()
}
- @RequestMapping(path = [""],
+ @RequestMapping(
+ path = [""],
method = [RequestMethod.GET],
- produces = [MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE])
- @ApiOperation(value = "Retrieve a resource configuration snapshot.",
+ produces = [MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE]
+ )
+ @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')")
fun get(
- @ApiParam(value = "Resource Type associated of the resource configuration snapshot.", required = false)
+ @ApiParam(value = "Resource Type associated of the resource configuration snapshot.", required = false)
@RequestParam(value = "resourceType", required = true) resourceType: String,
- @ApiParam(value = "Resource Id associated of the resource configuration snapshot.", required = false)
+ @ApiParam(value = "Resource Id associated of the resource configuration snapshot.", required = false)
@RequestParam(value = "resourceId", required = true) resourceId: String,
- @ApiParam(value = "Status of the snapshot being retrieved.", defaultValue = "RUNNING", required = false)
+ @ApiParam(value = "Status of the snapshot being retrieved.", defaultValue = "RUNNING", required = false)
@RequestParam(value = "status", required = false, defaultValue = "RUNNING") status: String,
- @ApiParam(value = "Expected format of the snapshot being retrieved.", defaultValue = MediaType.TEXT_PLAIN_VALUE,
- required = false)
- @RequestParam(value = "format", required = false, defaultValue = MediaType.TEXT_PLAIN_VALUE) format: String)
+ @ApiParam(
+ value = "Expected format of the snapshot being retrieved.", defaultValue = MediaType.TEXT_PLAIN_VALUE,
+ required = false
+ )
+ @RequestParam(value = "format", required = false, defaultValue = MediaType.TEXT_PLAIN_VALUE) format: String
+ ):
- : ResponseEntity<String> = runBlocking {
+ ResponseEntity<String> = runBlocking {
var configSnapshot = ""
if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
try {
- configSnapshot = resourceConfigSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId,
- resourceType, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase()))
- } catch (ex : NoSuchElementException) {
+ configSnapshot = resourceConfigSnapshotService.findByResourceIdAndResourceTypeAndStatus(
+ resourceId,
+ resourceType, ResourceConfigSnapshot.Status.valueOf(status.toUpperCase())
+ )
+ } catch (ex: NoSuchElementException) {
throw ResourceConfigSnapshotException(
- "Could not find configuration snapshot entry for type $resourceType and Id $resourceId")
+ "Could not find configuration snapshot entry for type $resourceType and Id $resourceId"
+ )
}
} else {
throw IllegalArgumentException("Missing param. You must specify resource-id and resource-type.")
@@ -97,12 +118,16 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe
ResponseEntity.ok().contentType(expectedMediaType).body(configSnapshot)
}
- @PostMapping("/{resourceType}/{resourceId}/{status}",
- produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Store a resource configuration snapshot identified by resourceId, resourceType, status.",
+ @PostMapping(
+ "/{resourceType}/{resourceId}/{status}",
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @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.",
- response = ResourceConfigSnapshot::class, produces = MediaType.APPLICATION_JSON_VALUE)
+ response = ResourceConfigSnapshot::class, produces = MediaType.APPLICATION_JSON_VALUE
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
fun postWithResourceIdAndResourceType(
@@ -113,11 +138,14 @@ open class ResourceConfigSnapshotController(private val resourceConfigSnapshotSe
@ApiParam(value = "Status of the snapshot being retrieved.", defaultValue = "RUNNING", required = true)
@PathVariable(value = "status", required = true) status: String,
@ApiParam(value = "Config snapshot to store.", required = true)
- @RequestBody snapshot: String): ResponseEntity<ResourceConfigSnapshot> = runBlocking {
+ @RequestBody snapshot: String
+ ): ResponseEntity<ResourceConfigSnapshot> = runBlocking {
val resultStored =
- resourceConfigSnapshotService.write(snapshot, resourceId, resourceType,
- ResourceConfigSnapshot.Status.valueOf(status.toUpperCase()))
+ resourceConfigSnapshotService.write(
+ snapshot, resourceId, resourceType,
+ ResourceConfigSnapshot.Status.valueOf(status.toUpperCase())
+ )
ResponseEntity.ok().body(resultStored)
}
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 d21464ef5..d4c31e780 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
@@ -23,16 +23,16 @@ import com.fasterxml.jackson.annotation.JsonTypeName
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
import org.slf4j.LoggerFactory
+import org.springframework.dao.EmptyResultDataAccessException
+import org.springframework.dao.IncorrectResultSizeDataAccessException
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.orm.jpa.JpaObjectRetrievalFailureException
-import org.springframework.dao.EmptyResultDataAccessException
-import org.springframework.dao.IncorrectResultSizeDataAccessException
-import org.springframework.web.server.ServerWebInputException
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
+import org.springframework.web.server.ServerWebInputException
import java.io.Serializable
-import java.util.*
+import java.util.Date
/**
* Handle exceptions in ResourceConfigSnapshot API and provide relevant HTTP status codes and messages
@@ -102,9 +102,11 @@ open class ResourceConfigSnapshotExceptionHandler {
log.error(e.message)
}
val errorMessage =
- ErrorMessage(errorCode.message(e.message!!),
+ ErrorMessage(
+ errorCode.message(e.message!!),
errorCode.value,
- debugMsg)
+ debugMsg
+ )
return ResponseEntity(errorMessage, HttpStatus.resolve(errorCode.httpCode)!!)
}
}
@@ -113,6 +115,7 @@ open class ResourceConfigSnapshotExceptionHandler {
@JsonTypeName("errorMessage")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
class ErrorMessage(var message: String?, var code: Int?, var debugMessage: String?) : Serializable {
+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
var timestamp = Date()
-} \ No newline at end of file
+}
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 89f62812e..34c7a7c7c 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
@@ -35,8 +35,10 @@ import org.springframework.web.reactive.function.BodyInserters
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SecurityProperties::class])
+@ContextConfiguration(
+ classes = [BluePrintCoreConfiguration::class,
+ BluePrintCatalogService::class, SecurityProperties::class]
+)
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class ResourceConfigSnapshotControllerTest {
@@ -68,24 +70,24 @@ class ResourceConfigSnapshotControllerTest {
runBlocking {
webTestClient
- .post()
- .uri("/api/v1/configs/$resourceType/$resourceId/running")
- .body(BodyInserters.fromObject(snapshotData))
- .exchange()
- .expectStatus().is2xxSuccessful
- .expectBody()
- .jsonPath("$.createdDate")
- .value<String> { println(it) }
+ .post()
+ .uri("/api/v1/configs/$resourceType/$resourceId/running")
+ .body(BodyInserters.fromObject(snapshotData))
+ .exchange()
+ .expectStatus().is2xxSuccessful
+ .expectBody()
+ .jsonPath("$.createdDate")
+ .value<String> { println(it) }
webTestClient
- .post()
- .uri("/api/v1/configs/$resourceType/$resourceId/running")
- .body(BodyInserters.fromObject(snapshotData))
- .exchange()
- .expectStatus().is2xxSuccessful
- .expectBody()
- .jsonPath("$.createdDate")
- .value<String> { println(it)}
+ .post()
+ .uri("/api/v1/configs/$resourceType/$resourceId/running")
+ .body(BodyInserters.fromObject(snapshotData))
+ .exchange()
+ .expectStatus().is2xxSuccessful
+ .expectBody()
+ .jsonPath("$.createdDate")
+ .value<String> { println(it) }
}
}
@@ -93,7 +95,7 @@ class ResourceConfigSnapshotControllerTest {
fun `get returns requested JSON content-type`() {
runBlocking {
post(resourceType, "22", "RUNNING")
- get("json", resourceType,"22", "RUNNING")
+ get("json", resourceType, "22", "RUNNING")
}
}
@@ -122,8 +124,8 @@ class ResourceConfigSnapshotControllerTest {
val arguments = "resourceId=MISSING&resourceType=PNF&status=TOTALLY_WRONG"
webTestClient.get().uri("/api/v1/configs?$arguments")
- .exchange()
- .expectStatus().isBadRequest
+ .exchange()
+ .expectStatus().isBadRequest
}
}
@@ -140,7 +142,7 @@ class ResourceConfigSnapshotControllerTest {
}
}
- private fun post( resourceType: String, resourceId: String, status: String) {
+ private fun post(resourceType: String, resourceId: String, status: String) {
webTestClient
.post()
.uri("/api/v1/configs/$resourceType/$resourceId/$status")
@@ -150,7 +152,7 @@ class ResourceConfigSnapshotControllerTest {
.expectBody()
}
- private fun get(expectedType : String, resourceType: String, resourceId: String, status: String) {
+ private fun get(expectedType: String, resourceType: String, resourceId: String, status: String) {
var requestArguments = "resourceId=$resourceId&resourceType=$resourceType&status=$status"
if (expectedType.isNotEmpty()) {
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 5f2a6dfb6..bca77f275 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
@@ -30,31 +30,42 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
import org.onap.ccsdk.cds.controllerblueprints.core.emptyTONull
import org.onap.ccsdk.cds.controllerblueprints.core.utils.currentTimestamp
-import org.onap.ccsdk.cds.controllerblueprints.management.api.*
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintBootstrapInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintDownloadInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.DownloadAction
+import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk
+import org.onap.ccsdk.cds.controllerblueprints.management.api.RemoveAction
+import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction
import org.slf4j.LoggerFactory
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.stereotype.Service
-//TODO("Convert to coroutines handler")
+// TODO("Convert to coroutines handler")
@Service
-open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: BluePrintModelHandler)
- : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
+open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: BluePrintModelHandler) :
+ BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
@PreAuthorize("hasRole('USER')")
- override fun uploadBlueprint(request: BluePrintUploadInput, responseObserver:
- StreamObserver<BluePrintManagementOutput>) {
+ override fun uploadBlueprint(
+ request: BluePrintUploadInput,
+ responseObserver: StreamObserver<BluePrintManagementOutput>
+ ) {
runBlocking {
- //TODO("catch if request id is missing")
+ // TODO("catch if request id is missing")
log.info("request(${request.commonHeader.requestId})")
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()
+ ?: UploadAction.DRAFT.toString()
when (uploadAction) {
UploadAction.DRAFT.toString() -> {
@@ -66,24 +77,36 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
responseObserver.onNext(successStatus(request.commonHeader, blueprintModel.asJsonString()))
}
UploadAction.VALIDATE.toString() -> {
- //TODO("Not Implemented")
- responseObserver.onNext(failStatus(request.commonHeader,
+ // TODO("Not Implemented")
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
"Upload action($uploadAction) not implemented",
- BluePrintProcessorException("Not Implemented")))
+ BluePrintProcessorException("Not Implemented")
+ )
+ )
}
UploadAction.ENRICH.toString() -> {
val enrichedByteArray = bluePrintModelHandler.enrichBlueprintFileSource(byteArray)
responseObserver.onNext(outputWithFileBytes(request.commonHeader, enrichedByteArray))
}
else -> {
- responseObserver.onNext(failStatus(request.commonHeader,
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
"Upload action($uploadAction) not implemented",
- BluePrintProcessorException("Not implemented")))
+ BluePrintProcessorException("Not implemented")
+ )
+ )
}
}
} catch (e: Exception) {
- responseObserver.onNext(failStatus(request.commonHeader,
- "request(${request.commonHeader.requestId}): Failed to upload CBA", e))
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
+ "request(${request.commonHeader.requestId}): Failed to upload CBA", e
+ )
+ )
} finally {
responseObserver.onCompleted()
}
@@ -91,8 +114,10 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
}
@PreAuthorize("hasRole('USER')")
- override fun downloadBlueprint(request: BluePrintDownloadInput,
- responseObserver: StreamObserver<BluePrintManagementOutput>) {
+ override fun downloadBlueprint(
+ request: BluePrintDownloadInput,
+ responseObserver: StreamObserver<BluePrintManagementOutput>
+ ) {
runBlocking {
val blueprintName = request.actionIdentifiers.blueprintName
val blueprintVersion = request.actionIdentifiers.blueprintVersion
@@ -100,7 +125,7 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
/** Get the Search Action */
val searchAction = request.actionIdentifiers?.actionName.emptyTONull()
- ?: DownloadAction.SEARCH.toString()
+ ?: DownloadAction.SEARCH.toString()
log.info("request(${request.commonHeader.requestId}): Received download $blueprint")
try {
@@ -110,14 +135,22 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
responseObserver.onNext(outputWithFileBytes(request.commonHeader, downloadByteArray))
}
else -> {
- responseObserver.onNext(failStatus(request.commonHeader,
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
"Search action($searchAction) not implemented",
- BluePrintProcessorException("Not implemented")))
+ BluePrintProcessorException("Not implemented")
+ )
+ )
}
}
} catch (e: Exception) {
- responseObserver.onNext(failStatus(request.commonHeader,
- "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e))
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
+ "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e
+ )
+ )
} finally {
responseObserver.onCompleted()
}
@@ -125,8 +158,11 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
}
@PreAuthorize("hasRole('USER')")
- override fun removeBlueprint(request: BluePrintRemoveInput, responseObserver:
- StreamObserver<BluePrintManagementOutput>) {
+ override fun removeBlueprint(
+ request: BluePrintRemoveInput,
+ responseObserver:
+ StreamObserver<BluePrintManagementOutput>
+ ) {
runBlocking {
val blueprintName = request.actionIdentifiers.blueprintName
@@ -137,7 +173,7 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
/** Get the Remove Action */
val removeAction = request.actionIdentifiers?.actionName.emptyTONull()
- ?: RemoveAction.DEFAULT.toString()
+ ?: RemoveAction.DEFAULT.toString()
try {
when (removeAction) {
@@ -146,22 +182,32 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
responseObserver.onNext(successStatus(request.commonHeader))
}
else -> {
- responseObserver.onNext(failStatus(request.commonHeader,
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
"Remove action($removeAction) not implemented",
- BluePrintProcessorException("Not implemented")))
+ BluePrintProcessorException("Not implemented")
+ )
+ )
}
}
} catch (e: Exception) {
- responseObserver.onNext(failStatus(request.commonHeader,
- "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e))
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
+ "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e
+ )
+ )
} finally {
responseObserver.onCompleted()
}
}
}
- override fun bootstrapBlueprint(request: BluePrintBootstrapInput,
- responseObserver: StreamObserver<BluePrintManagementOutput>) {
+ override fun bootstrapBlueprint(
+ request: BluePrintBootstrapInput,
+ responseObserver: StreamObserver<BluePrintManagementOutput>
+ ) {
runBlocking {
try {
log.info("request(${request.commonHeader.requestId}): Received bootstrap request")
@@ -173,10 +219,13 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
/** Perform bootstrap of Model Types, Resource Definitions and CBA */
bluePrintModelHandler.bootstrapBlueprint(bootstrapRequest)
responseObserver.onNext(successStatus(request.commonHeader))
-
} catch (e: Exception) {
- responseObserver.onNext(failStatus(request.commonHeader,
- "request(${request.commonHeader.requestId}): Failed to bootstrap", e))
+ responseObserver.onNext(
+ failStatus(
+ request.commonHeader,
+ "request(${request.commonHeader.requestId}): Failed to bootstrap", e
+ )
+ )
} finally {
responseObserver.onCompleted()
}
@@ -184,15 +233,17 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
}
private fun outputWithFileBytes(header: CommonHeader, byteArray: ByteArray): BluePrintManagementOutput =
- BluePrintManagementOutput.newBuilder()
- .setCommonHeader(header)
- .setFileChunk(FileChunk.newBuilder().setChunk(ByteString.copyFrom(byteArray)))
- .setStatus(Status.newBuilder()
- .setTimestamp(currentTimestamp())
- .setMessage(BluePrintConstants.STATUS_SUCCESS)
- .setCode(200)
- .build())
+ BluePrintManagementOutput.newBuilder()
+ .setCommonHeader(header)
+ .setFileChunk(FileChunk.newBuilder().setChunk(ByteString.copyFrom(byteArray)))
+ .setStatus(
+ Status.newBuilder()
+ .setTimestamp(currentTimestamp())
+ .setMessage(BluePrintConstants.STATUS_SUCCESS)
+ .setCode(200)
.build()
+ )
+ .build()
private fun successStatus(header: CommonHeader, propertyContent: String? = null): BluePrintManagementOutput {
// Populate Response Payload
@@ -201,30 +252,34 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu
JsonFormat.parser().merge(propertyContent, propertiesBuilder)
}
return BluePrintManagementOutput.newBuilder()
- .setCommonHeader(header)
- .setProperties(propertiesBuilder.build())
- .setStatus(Status.newBuilder()
- .setTimestamp(currentTimestamp())
- .setMessage(BluePrintConstants.STATUS_SUCCESS)
- .setCode(200)
- .build())
- .build()
+ .setCommonHeader(header)
+ .setProperties(propertiesBuilder.build())
+ .setStatus(
+ Status.newBuilder()
+ .setTimestamp(currentTimestamp())
+ .setMessage(BluePrintConstants.STATUS_SUCCESS)
+ .setCode(200)
+ .build()
+ )
+ .build()
}
private fun failStatus(header: CommonHeader, message: String, e: Exception): BluePrintManagementOutput {
log.error(message, e)
return BluePrintManagementOutput.newBuilder()
- .setCommonHeader(header)
- .setStatus(Status.newBuilder()
- .setTimestamp(currentTimestamp())
- .setMessage(BluePrintConstants.STATUS_FAILURE)
- .setErrorMessage(message)
- .setCode(500)
- .build())
- .build()
-// return io.grpc.Status.INTERNAL
-// .withDescription(message)
-// .withCause(e)
-// .asException()
+ .setCommonHeader(header)
+ .setStatus(
+ Status.newBuilder()
+ .setTimestamp(currentTimestamp())
+ .setMessage(BluePrintConstants.STATUS_FAILURE)
+ .setErrorMessage(message)
+ .setCode(500)
+ .build()
+ )
+ .build()
+ // return io.grpc.Status.INTERNAL
+ // .withDescription(message)
+ // .withCause(e)
+ // .asException()
}
}
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 5ef50b09f..f257157c8 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
@@ -34,7 +34,16 @@ import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.http.codec.multipart.FilePart
import org.springframework.security.access.prepost.PreAuthorize
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.DeleteMapping
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestParam
+import org.springframework.web.bind.annotation.RequestPart
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono
/**
@@ -47,8 +56,10 @@ import reactor.core.publisher.Mono
@RequestMapping("/api/v1/blueprint-model")
open class BlueprintModelController(private val bluePrintModelHandler: BluePrintModelHandler) {
- @PostMapping(path = arrayOf("/bootstrap"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE),
- consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @PostMapping(
+ path = arrayOf("/bootstrap"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE),
+ consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE)
+ )
@ResponseBody
@Throws(BluePrintException::class)
@PreAuthorize("hasRole('USER')")
@@ -74,9 +85,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
@GetMapping("/paged", produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun allBlueprintModel(@RequestParam(defaultValue = "20") limit: Int,
- @RequestParam(defaultValue = "0") offset: Int,
- @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption): Page<BlueprintModelSearch> {
+ fun allBlueprintModel(
+ @RequestParam(defaultValue = "20") limit: Int,
+ @RequestParam(defaultValue = "0") offset: Int,
+ @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption
+ ): Page<BlueprintModelSearch> {
val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName)
return this.bluePrintModelHandler.allBlueprintModel(pageRequest)
}
@@ -88,18 +101,17 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
return this.bluePrintModelHandler.searchBluePrintModelsByKeyWord(keyWord)
}
-
@GetMapping("/paged/meta-data/{keyword}", produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun allBlueprintModelMetaDataPaged(@NotNull @PathVariable(value = "keyword") keyWord: String,
- @RequestParam(defaultValue = "20") limit: Int,
- @RequestParam(defaultValue = "0") offset: Int,
- @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption
+ fun allBlueprintModelMetaDataPaged(
+ @NotNull @PathVariable(value = "keyword") keyWord: String,
+ @RequestParam(defaultValue = "20") limit: Int,
+ @RequestParam(defaultValue = "0") offset: Int,
+ @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption
): Page<BlueprintModelSearch> {
val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName)
return this.bluePrintModelHandler.searchBluePrintModelsByKeyWordPaged(keyWord, pageRequest)
-
}
@DeleteMapping("/{id}")
@@ -113,9 +125,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
@ResponseBody
@Throws(BluePrintException::class)
@PreAuthorize("hasRole('USER')")
- fun getBlueprintByNameAndVersion(@PathVariable(value = "name") name: String,
- @PathVariable(value = "version") version: String)
- : Mono<BlueprintModelSearch> = monoMdc {
+ fun getBlueprintByNameAndVersion(
+ @PathVariable(value = "name") name: String,
+ @PathVariable(value = "version") version: String
+ ):
+ Mono<BlueprintModelSearch> = monoMdc {
bluePrintModelHandler.getBlueprintModelSearchByNameAndVersion(name, version)
}
@@ -123,9 +137,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
@ResponseBody
@Throws(BluePrintException::class)
@PreAuthorize("hasRole('USER')")
- fun downloadBlueprintByNameAndVersion(@PathVariable(value = "name") name: String,
- @PathVariable(value = "version") version: String)
- : Mono<ResponseEntity<Resource>> = monoMdc {
+ fun downloadBlueprintByNameAndVersion(
+ @PathVariable(value = "name") name: String,
+ @PathVariable(value = "version") version: String
+ ):
+ Mono<ResponseEntity<Resource>> = monoMdc {
bluePrintModelHandler.downloadBlueprintModelFileByNameAndVersion(name, version)
}
@@ -145,8 +161,10 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
bluePrintModelHandler.downloadBlueprintModelFile(id)
}
- @PostMapping("/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType
- .MULTIPART_FORM_DATA_VALUE])
+ @PostMapping(
+ "/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType
+ .MULTIPART_FORM_DATA_VALUE]
+ )
@ResponseBody
@Throws(BluePrintException::class)
@PreAuthorize("hasRole('USER')")
@@ -170,14 +188,18 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
}
@DeleteMapping("/name/{name}/version/{version}")
- @ApiOperation(value = "Delete a CBA",
- notes = "Delete the CBA package identified by its name and version.",
- produces = MediaType.APPLICATION_JSON_VALUE)
+ @ApiOperation(
+ value = "Delete a CBA",
+ notes = "Delete the CBA package identified by its name and version.",
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
@PreAuthorize("hasRole('USER')")
- fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true)
- @PathVariable(value = "name") name: String,
- @ApiParam(value = "Version of the CBA.", required = true)
- @PathVariable(value = "version") version: String) = monoMdc {
+ fun deleteBlueprint(
+ @ApiParam(value = "Name of the CBA.", required = true)
+ @PathVariable(value = "name") name: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
+ @PathVariable(value = "version") version: String
+ ) = monoMdc {
bluePrintModelHandler.deleteBlueprintModel(name, version)
}
}
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 346015bc4..d0cb67315 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
@@ -24,8 +24,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import java.io.Serializable
-import java.util.*
-
+import java.util.Date
class BootstrapRequest {
var loadModelType: Boolean = false
@@ -40,15 +39,16 @@ class BootstrapRequest {
* @version 1.0
*/
class AutoMapResponse {
+
var resourceAssignments: List<ResourceAssignment>? = null
var dataDictionaries: List<ResourceDictionary>? = null
}
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonTypeName("errorMessage")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
class ErrorMessage(var message: String?, var code: Int?, var debugMessage: String?) : Serializable {
+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
var timestamp = Date()
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
index bac281356..adeb3cf89 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
@@ -18,11 +18,18 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api
import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.springframework.http.MediaType
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.DeleteMapping
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(value = arrayOf("/api/v1/model-type"))
@@ -55,4 +62,4 @@ open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
fun deleteModelTypeByName(@PathVariable(value = "name") name: String) = runBlocking {
modelTypeHandler.deleteByModelName(name)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
index bae890a87..562932e23 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
@@ -22,7 +22,14 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ResourceDicti
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping
import org.springframework.http.MediaType
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.DeleteMapping
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(value = ["/api/v1/dictionary"])
@@ -57,7 +64,6 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R
@ResponseBody
fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List<ResourceDictionary> = runBlocking {
resourceDictionaryHandler.searchResourceDictionaryByTags(tags)
-
}
@GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE])
@@ -65,5 +71,4 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R
fun getResourceSourceMapping(): ResourceSourceMapping = runBlocking {
resourceDictionaryHandler.getResourceSourceMapping()
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt
index 97c7ab6a6..4779ad340 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt
@@ -18,7 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-
import javax.persistence.AttributeConverter
import javax.persistence.Converter
@@ -35,4 +34,4 @@ class JpaJsonNodeConverter : AttributeConverter<JsonNode, String> {
override fun convertToEntityAttribute(dbData: String): JsonNode {
return JacksonUtils.jsonNode(dbData)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt
index 75cfede50..f0692cdd9 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt
@@ -18,7 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
-
import javax.persistence.AttributeConverter
import javax.persistence.Converter
@@ -27,6 +26,7 @@ import javax.persistence.Converter
*/
@Converter
class JpaResourceDefinitionConverter : AttributeConverter<ResourceDefinition, String> {
+
override fun convertToDatabaseColumn(resourceDefinition: ResourceDefinition): String {
return JacksonUtils.getJson(resourceDefinition)
}
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 a964e0416..6e277e5c8 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
@@ -22,8 +22,16 @@ import io.swagger.annotations.ApiModelProperty
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Convert
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
/**
* Provide ModelType Entity
@@ -94,4 +102,4 @@ class ModelType : Serializable {
companion object {
private const val serialVersionUID = 1L
}
-} \ No newline at end of file
+}
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 ac5ea2070..209e2bbe8 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
@@ -22,8 +22,16 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Convert
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
/**
* Provide ResourceDictionary Entity
@@ -89,6 +97,4 @@ class ResourceDictionary : Serializable {
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 552339be9..f954df7ac 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
@@ -32,22 +32,22 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
@Service
-open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
- : BluePrintArtifactDefinitionEnhancer {
+open class BluePrintArtifactDefinitionEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService
+) :
+ BluePrintArtifactDefinitionEnhancer {
companion object {
const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
}
-
private val log = logger(BluePrintArtifactDefinitionEnhancerImpl::class)
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
-
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) {
log.info("enhancing ArtifactDefinition($name)")
@@ -55,7 +55,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val artifactTypeName = artifactDefinition.type
- ?: throw BluePrintException("artifact type is missing for ArtifactDefinition($name)")
+ ?: throw BluePrintException("artifact type is missing for ArtifactDefinition($name)")
// Populate Artifact Type
BluePrintEnhancerUtils.populateArtifactType(bluePrintContext, bluePrintRepoService, artifactTypeName)
@@ -80,7 +80,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ
if (!alreadyEnhanced) {
val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(artifactFilePath, ResourceAssignment::class.java)
as? MutableList<ResourceAssignment>
- ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)")
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)")
// Call Resource Assignment Enhancer
resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
@@ -88,5 +88,4 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ
bluePrintRuntimeService.put(alreadyEnhancedKey, true.asJsonPrimitive())
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
index 0b64ed503..030fbe8ae 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
@@ -26,9 +26,11 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnha
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
- : BluePrintAttributeDefinitionEnhancer {
+class BluePrintAttributeDefinitionEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
+) :
+ BluePrintAttributeDefinitionEnhancer {
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
@@ -39,10 +41,9 @@ class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService:
val propertyType = attributeDefinition.type
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
-
} else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
val entrySchema = attributeDefinition.entrySchema
- ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
+ ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type)
@@ -51,5 +52,4 @@ class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService:
BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType)
}
}
-
-} \ No newline at end of file
+}
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 b4d149e16..e99f49489 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
@@ -26,11 +26,13 @@ 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
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
@Service
-open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService {
+open class BluePrintEnhancerServiceImpl(
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService
+) : BluePrintEnhancerService {
private val log = logger(BluePrintEnhancerServiceImpl::class)
@@ -48,16 +50,20 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
log.info("Enhancing blueprint($basePath)")
val blueprintRuntimeService = BluePrintMetadataUtils
- .getBaseEnhancementBluePrintRuntime(UUID.randomUUID().toString(), basePath)
+ .getBaseEnhancementBluePrintRuntime(UUID.randomUUID().toString(), basePath)
try {
- bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template",
- blueprintRuntimeService.bluePrintContext().serviceTemplate)
+ bluePrintTypeEnhancerService.enhanceServiceTemplate(
+ blueprintRuntimeService, "service_template",
+ blueprintRuntimeService.bluePrintContext().serviceTemplate
+ )
log.info("##### Enhancing blueprint Resource Definitions")
- val resourceDefinitions = resourceDefinitionEnhancerService.enhance(bluePrintTypeEnhancerService,
- blueprintRuntimeService)
+ val resourceDefinitions = resourceDefinitionEnhancerService.enhance(
+ bluePrintTypeEnhancerService,
+ blueprintRuntimeService
+ )
// Write the Enhanced Blueprint Definitions
BluePrintFileUtils.writeEnhancedBluePrint(blueprintRuntimeService.bluePrintContext())
@@ -68,12 +74,9 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
if (blueprintRuntimeService.getBluePrintError().errors.isNotEmpty()) {
throw BluePrintException(blueprintRuntimeService.getBluePrintError().errors.toString())
}
-
} catch (e: Exception) {
throw e
}
return blueprintRuntimeService.bluePrintContext()
}
-
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
index 723d7bb27..6ca0b2d14 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
@@ -31,22 +31,22 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
- : BluePrintNodeTemplateEnhancer {
+open class BluePrintNodeTemplateEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
+) :
+ BluePrintNodeTemplateEnhancer {
- private val log= logger(BluePrintNodeTemplateEnhancerImpl::class)
+ private val log = logger(BluePrintNodeTemplateEnhancerImpl::class)
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
-
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
log.info("***** Enhancing NodeTemplate($name)")
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
-
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
val nodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName)
@@ -54,7 +54,7 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
// Enrich NodeType
bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
- //Enrich Node Template Artifacts
+ // Enrich Node Template Artifacts
enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
}
@@ -65,5 +65,4 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition)
}
}
-
-} \ No newline at end of file
+}
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 efb695b22..d28084e40 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
@@ -34,20 +34,20 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintNodeTypeEnhancer {
+open class BluePrintNodeTypeEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
+) : BluePrintNodeTypeEnhancer {
- private val log= logger(BluePrintNodeTypeEnhancerImpl::class)
+ private val log = logger(BluePrintNodeTypeEnhancerImpl::class)
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
-
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
-
val derivedFrom = nodeType.derivedFrom
if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
@@ -62,15 +62,14 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
// NodeType Property Definitions
enrichNodeTypeProperties(name, nodeType)
- //NodeType Requirement
+ // NodeType Requirement
enrichNodeTypeRequirements(name, nodeType)
- //NodeType Capability
+ // NodeType Capability
enrichNodeTypeCapabilityProperties(name, nodeType)
- //NodeType Interface
+ // NodeType Interface
enrichNodeTypeInterfaces(name, nodeType)
-
}
open fun enrichNodeTypeAttributes(nodeTypeName: String, nodeType: NodeType) {
@@ -91,15 +90,19 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
// Populate Requirement Node
requirementDefinition.node?.let { requirementNodeTypeName ->
// Get Requirement NodeType from Repo and Update Service Template
- val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext,
- bluePrintRepoService, requirementNodeTypeName)
+ val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(
+ bluePrintContext,
+ bluePrintRepoService, requirementNodeTypeName
+ )
// Enhance Node Type
enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
// Enhance Relationship Type
val relationShipTypeName = requirementDefinition.relationship
- ?: throw BluePrintException("couldn't get relationship name for the NodeType($nodeTypeName) " +
- "Requirement($requirementName)")
+ ?: throw BluePrintException(
+ "couldn't get relationship name for the NodeType($nodeTypeName) " +
+ "Requirement($requirementName)"
+ )
enrichRelationShipType(relationShipTypeName)
}
}
@@ -118,7 +121,6 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
// Populate Node type Interface Operation
log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName)
populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj)
-
}
}
@@ -136,8 +138,11 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
}
- open fun enrichNodeTypeInterfaceOperationOutputs(nodeTypeName: String, operationName: String,
- operation: OperationDefinition) {
+ open fun enrichNodeTypeInterfaceOperationOutputs(
+ nodeTypeName: String,
+ operationName: String,
+ operation: OperationDefinition
+ ) {
operation.outputs?.let { inputs ->
bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
@@ -149,5 +154,4 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
open fun enrichRelationShipType(relationshipName: String) {
BluePrintEnhancerUtils.populateRelationshipType(bluePrintContext, bluePrintRepoService, relationshipName)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
index 83fd403e8..212dc440d 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
@@ -27,17 +27,18 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-class BluePrintPolicyTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
- : BluePrintPolicyTypeEnhancer {
+class BluePrintPolicyTypeEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
+) :
+ BluePrintPolicyTypeEnhancer {
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
-
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: PolicyType) {
- this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintRuntimeService = bluePrintRuntimeService
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
index b87cf9c6b..eb7443443 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
@@ -32,9 +32,11 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
- : BluePrintPropertyDefinitionEnhancer {
+open class BluePrintPropertyDefinitionEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
+) :
+ BluePrintPropertyDefinitionEnhancer {
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
@@ -44,12 +46,13 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val propertyType = propertyDefinition.type
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)
- || BluePrintTypes.validComplexTypes().contains(propertyType)) {
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType) ||
+ BluePrintTypes.validComplexTypes().contains(propertyType)
+ ) {
// Do Nothing,
} else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
val entrySchema = propertyDefinition.entrySchema
- ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
+ ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type)
@@ -58,5 +61,4 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ
BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType)
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
index 65e5ff9e1..9f4a4592a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
@@ -28,10 +28,10 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
- : BluePrintServiceTemplateEnhancer {
- private val log = logger(BluePrintServiceTemplateEnhancerImpl::class)
+open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) :
+ BluePrintServiceTemplateEnhancer {
+ private val log = logger(BluePrintServiceTemplateEnhancerImpl::class)
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
@@ -57,7 +57,6 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhance
bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
bluePrintContext.serviceTemplate.relationshipTypes = mutableMapOf()
log.info("reinitialized all type definitions")
-
}
open fun enhanceTopologyTemplate() {
@@ -65,4 +64,4 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhance
bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "topology_template", topologyTemplate)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
index c22370c33..c0100fbea 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
@@ -27,8 +27,11 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintTopologyTemplateEnhancer {
+open class BluePrintTopologyTemplateEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
+) :
+ BluePrintTopologyTemplateEnhancer {
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
@@ -57,5 +60,4 @@ open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoServic
bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintRuntimeService, workflowName, workflow)
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt
index db361a248..5b7c6b2d0 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt
@@ -16,7 +16,16 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.*
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTopologyTemplateEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
@@ -62,4 +71,4 @@ open class BluePrintTypeEnhancerServiceImpl : BluePrintTypeEnhancerService {
override fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer> {
return context.getBeansOfType(BluePrintAttributeDefinitionEnhancer::class.java).map { it.value }
}
-} \ No newline at end of file
+}
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 394289ced..88127e3ca 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
@@ -17,13 +17,17 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
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.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -34,11 +38,14 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
- : BluePrintWorkflowEnhancer {
- private val log= logger(BluePrintWorkflowEnhancerImpl::class)
+open class BluePrintWorkflowEnhancerImpl(
+ private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService
+) :
+ BluePrintWorkflowEnhancer {
+
+ private val log = logger(BluePrintWorkflowEnhancerImpl::class)
companion object {
const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
@@ -70,8 +77,6 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
// Enrich Only for Resource Assignment and Dynamic Input Properties if any
enhanceStepTargets(name, workflow)
-
-
}
open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
@@ -102,11 +107,12 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
enhanceStepTargets(name, workflow, firstNodeTemplateName, true)
}
else -> {
- throw BluePrintProcessorException("couldn't execute workflow($name) step mapped " +
- "to node template($firstNodeTemplateName) derived from($derivedFrom)")
+ throw BluePrintProcessorException(
+ "couldn't execute workflow($name) step mapped " +
+ "to node template($firstNodeTemplateName) derived from($derivedFrom)"
+ )
}
}
-
}
private fun enhanceStepTargets(name: String, workflow: Workflow, nodeTemplateName: String, isDG: Boolean) {
@@ -132,10 +138,10 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
log.info("identified workflow($name) targets($componentNodeTemplateName)")
val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName)
- .artifacts?.filter {
+ .artifacts?.filter {
it.value.type == ARTIFACT_TYPE_MAPPING_SOURCE
}?.map {
- log.info("resource assignment artifacts(${it.key}) for NodeType(${componentNodeTemplateName})")
+ log.info("resource assignment artifacts(${it.key}) for NodeType($componentNodeTemplateName)")
it.value.file
}
resourceAssignmentArtifacts
@@ -162,13 +168,13 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
val filePath = "${bluePrintContext.rootPath}/$fileName"
- log.info("enriching artifacts file(${filePath}")
+ log.info("enriching artifacts file($filePath")
val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
as? MutableList<ResourceAssignment>
- ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
val alreadyEnhancedKey = "enhanced-$fileName"
val alreadyEnhanced = bluePrintRuntimeService.check(alreadyEnhancedKey)
@@ -215,7 +221,6 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
// Overwrite WorkFlow DataType
bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dynamicDataType)
-
} else {
log.info("dynamic dataType($dataTypeName) already present for workflow($workflowName).")
}
@@ -224,4 +229,4 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
dynamicDataType.properties?.put(propertyName, propertyDefinition)
}
}
-} \ No newline at end of file
+}
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 55eb42f89..94e183405 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
@@ -16,6 +16,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
@@ -25,7 +26,6 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -38,9 +38,11 @@ import org.springframework.stereotype.Service
interface ResourceAssignmentEnhancerService {
@Throws(BluePrintException::class)
- fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
- resourceAssignments: List<ResourceAssignment>)
+ fun enhanceBluePrint(
+ bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceAssignments: List<ResourceAssignment>
+ )
}
/**
@@ -50,17 +52,20 @@ interface ResourceAssignmentEnhancerService {
*/
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
- : ResourceAssignmentEnhancerService {
- private val log= logger(ResourceAssignmentEnhancerServiceImpl::class)
+open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) :
+ ResourceAssignmentEnhancerService {
+
+ private val log = logger(ResourceAssignmentEnhancerServiceImpl::class)
/**
* Get the defined source instance from the ResourceAssignment,
* then get the NodeType of the Sources assigned
*/
- override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
- resourceAssignments: List<ResourceAssignment>) {
+ override fun enhanceBluePrint(
+ bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceAssignments: List<ResourceAssignment>
+ ) {
val uniqueSourceNodeTypeNames = hashSetOf<String>()
@@ -77,14 +82,16 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
// TODO("Candidate for Optimisation")
if (checkResourceDefinitionNeeded(resourceAssignment)) {
- bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintRuntimeService, resourceAssignment.name,
- resourceAssignment.property!!);
+ bluePrintTypeEnhancerService.enhancePropertyDefinition(
+ bluePrintRuntimeService, resourceAssignment.name,
+ resourceAssignment.property!!
+ )
// Get the Resource Definition from Repo
val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
val sourceNodeTemplate = resourceDefinition.sources[dictionarySource]
- ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)")
+ ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)")
// Enrich as NodeTemplate
bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate)
@@ -95,16 +102,15 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName)
bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
}
-
}
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 {
return resourceDefinitionRepoService.getResourceDefinition(name)
}
-} \ No newline at end of file
+}
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 c018664e4..042c76805 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
@@ -20,6 +20,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService
+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.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.cds.controllerblueprints.core.logger
@@ -28,20 +30,20 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
import org.springframework.stereotype.Service
interface ResourceDefinitionEnhancerService {
@Throws(BluePrintException::class)
- fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition>
+ fun enhance(
+ bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>
+ ): List<ResourceDefinition>
}
@Service
class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) :
- ResourceDefinitionEnhancerService {
+ ResourceDefinitionEnhancerService {
private val log = logger(ResourceDefinitionEnhancerService::class)
@@ -54,8 +56,10 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
// 2. Get all the Unique Resource assignments from all mapping files
// 3. Collect the Resource Definition for Resource Assignment names from database.
// 4. Create the Resource Definition under blueprint base path.
- override fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
- bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition> {
+ override fun enhance(
+ bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>
+ ): List<ResourceDefinition> {
var resourceDefinitions: List<ResourceDefinition> = mutableListOf()
@@ -82,7 +86,6 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
}?.mapNotNull { artifactDefinitionMap ->
artifactDefinitionMap.value.file
}
-
}?.flatten()?.distinct()
}
@@ -104,33 +107,34 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
val distinctResourceAssignments = resourceAssignments.distinctBy { it.name }
generateResourceDictionary(blueprintBasePath, distinctResourceAssignments)
- //log.info("distinct Resource assignment ($distinctResourceAssignments)")
+ // log.info("distinct Resource assignment ($distinctResourceAssignments)")
}
-
// Read the Resource Definitions from the Database and write to type file.
- private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>)
- : List<ResourceDefinition> {
+ private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>):
+ List<ResourceDefinition> {
val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted()
log.info("distinct resource keys ($resourceKeys)")
- //TODO("Optimise DB single Query to multiple Query")
+ // TODO("Optimise DB single Query to multiple Query")
return resourceKeys.map { resourceKey ->
getResourceDefinition(resourceKey)
}
}
- private fun enrichResourceDefinitionSources(bluePrintContext: BluePrintContext,
- resourceDefinitions: List<ResourceDefinition>) {
+ private fun enrichResourceDefinitionSources(
+ bluePrintContext: BluePrintContext,
+ resourceDefinitions: List<ResourceDefinition>
+ ) {
val sources = resourceDefinitions
- .map { it.sources }
- .map {
- it.values
- .map { nodeTemplate ->
- nodeTemplate.type
- }
- }
- .flatten().distinct()
+ .map { it.sources }
+ .map {
+ it.values
+ .map { nodeTemplate ->
+ nodeTemplate.type
+ }
+ }
+ .flatten().distinct()
log.info("Enriching Resource Definition sources Node Template: $sources")
sources.forEach {
BluePrintEnhancerUtils.populateNodeType(bluePrintContext, resourceDefinitionRepoService, it)
@@ -141,4 +145,4 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
private fun getResourceDefinition(name: String): ResourceDefinition {
return resourceDefinitionRepoService.getResourceDefinition(name)
}
-} \ No newline at end of file
+}
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 5f7eacee8..392fa0bb4 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
@@ -27,11 +27,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintMod
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.BootstrapRequest
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.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir
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.utils.BluePrintFileUtils
import org.springframework.core.io.ByteArrayResource
@@ -46,8 +50,7 @@ import org.springframework.http.codec.multipart.FilePart
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.io.IOException
-import java.util.*
-
+import java.util.UUID
/**
* BlueprintModelHandler Purpose: Handler service to handle the request from BlurPrintModelRest
@@ -57,21 +60,24 @@ import java.util.*
*/
@Service
-open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BluePrintDatabaseLoadService,
- private val blueprintsProcessorCatalogService: BluePrintCatalogService,
- private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val blueprintModelSearchRepository: BlueprintModelSearchRepository,
- private val blueprintModelRepository: BlueprintModelRepository,
- private val blueprintModelContentRepository: BlueprintModelContentRepository,
- private val bluePrintEnhancerService: BluePrintEnhancerService) {
+open class BluePrintModelHandler(
+ private val bluePrintDatabaseLoadService: BluePrintDatabaseLoadService,
+ private val blueprintsProcessorCatalogService: BluePrintCatalogService,
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val blueprintModelSearchRepository: BlueprintModelSearchRepository,
+ private val blueprintModelRepository: BlueprintModelRepository,
+ private val blueprintModelContentRepository: BlueprintModelContentRepository,
+ private val bluePrintEnhancerService: BluePrintEnhancerService
+) {
private val log = logger(BluePrintModelHandler::class)
-
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})")
+ log.info(
+ "Bootstrap request with type load(${bootstrapRequest.loadModelType}), " +
+ "resource dictionary load(${bootstrapRequest.loadResourceDictionary}) and " +
+ "cba load(${bootstrapRequest.loadCBA})"
+ )
if (bootstrapRequest.loadModelType) {
bluePrintDatabaseLoadService.initModelTypes()
}
@@ -113,12 +119,13 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
try {
return upload(filePart, false)
} catch (e: IOException) {
- throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
- "Error in Save CBA: ${e.message}", e)
+ throw BluePrintException(
+ ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Save CBA: ${e.message}", e
+ )
}
}
-
/**
* This is a searchBlueprintModels method
*
@@ -140,9 +147,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
@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)
+ )
}
/**
@@ -154,15 +162,19 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
* @throws BluePrintException BluePrintException
</Resource> */
@Throws(BluePrintException::class)
- open fun downloadBlueprintModelFileByNameAndVersion(name: String,
- version: String): ResponseEntity<Resource> {
+ open fun downloadBlueprintModelFileByNameAndVersion(
+ name: String,
+ version: String
+ ): ResponseEntity<Resource> {
try {
val archiveByteArray = download(name, version)
val fileName = "${name}_$version.zip"
return prepareResourceEntity(fileName, archiveByteArray)
} catch (e: BluePrintException) {
- throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format("Error while " + "downloading the CBA file: %s", e.message), e)
+ throw BluePrintException(
+ ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while " + "downloading the CBA file: %s", e.message), e
+ )
}
}
@@ -183,8 +195,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
val fileName = "${blueprintModel.artifactName}_${blueprintModel.artifactVersion}.zip"
val file = blueprintModel.blueprintModelContent?.content
- ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format("Error while downloading the CBA file: couldn't get model content"))
+ ?: throw BluePrintException(
+ ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while downloading the CBA file: couldn't get model content")
+ )
return prepareResourceEntity(fileName, file)
}
@@ -193,9 +207,9 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
</Resource> */
private fun prepareResourceEntity(fileName: String, file: ByteArray): ResponseEntity<Resource> {
return ResponseEntity.ok()
- .contentType(MediaType.parseMediaType("text/plain"))
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"")
- .body(ByteArrayResource(file))
+ .contentType(MediaType.parseMediaType("text/plain"))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"")
+ .body(ByteArrayResource(file))
}
/**
@@ -229,7 +243,7 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
@Throws(BluePrintException::class)
open fun getBlueprintModelByNameAndVersion(name: String, version: String): BlueprintModel {
val blueprintModel = blueprintModelRepository
- .findByArtifactNameAndArtifactVersion(name, version)
+ .findByArtifactNameAndArtifactVersion(name, version)
if (blueprintModel != null) {
return blueprintModel
} else {
@@ -248,8 +262,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
@Throws(BluePrintException::class)
open fun getBlueprintModelSearch(id: String): BlueprintModelSearch {
return blueprintModelSearchRepository.findById(id)
- ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id))
+ ?: throw BluePrintException(
+ ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id)
+ )
}
/**
@@ -262,10 +278,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
</BlueprintModelSearch> */
open fun searchBluePrintModelsByKeyWord(keyWord: String): List<BlueprintModelSearch> {
return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
- keyWord, keyWord, keyWord, keyWord, keyWord)
+ keyWord, keyWord, keyWord, keyWord, keyWord
+ )
}
-
/**
* This is a searchBluePrintModelsByKeyWordPagebale method to retrieve specific BlueprintModel in Database
* where keyword equals updatedBy or tags or artifcat name or artifcat version or artifact type and pageable
@@ -275,7 +291,14 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
* @return List<BlueprintModelSearch> list of the controller blueprint
</BlueprintModelSearch> */
open fun searchBluePrintModelsByKeyWordPaged(keyWord: String, pageRequest: PageRequest): Page<BlueprintModelSearch> {
- return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(keyWord, keyWord, keyWord, keyWord, keyWord, pageRequest)
+ return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
+ keyWord,
+ keyWord,
+ keyWord,
+ keyWord,
+ keyWord,
+ pageRequest
+ )
}
/**
@@ -319,8 +342,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
val enhancedByteArray = enrichBlueprintFileSource(filePart)
return BluePrintEnhancerUtils.prepareResourceEntity("enhanced-cba.zip", enhancedByteArray)
} catch (e: IOException) {
- throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
- "Error in Enriching CBA: ${e.message}", e)
+ throw BluePrintException(
+ ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Enriching CBA: ${e.message}", e
+ )
}
}
@@ -336,8 +361,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
try {
return upload(filePart, true)
} catch (e: Exception) {
- throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
- "Error in Publishing CBA: ${e.message}", e)
+ throw BluePrintException(
+ ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Publishing CBA: ${e.message}", e
+ )
}
}
@@ -357,16 +384,19 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(saveId, compressedFile, validate)
return blueprintModelSearchRepository.findById(blueprintId)
- ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId))
-
+ ?: throw BluePrintException(
+ ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId)
+ )
} catch (e: IOException) {
- throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
- "Error in Upload CBA: ${e.message}", e)
+ throw BluePrintException(
+ ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Upload CBA: ${e.message}", e
+ )
} finally {
// Clean blueprint script cache
val cacheKey = BluePrintFileUtils
- .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId))
+ .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId))
BluePrintCompileCache.cleanClassLoader(cacheKey)
deleteNBDir(blueprintArchive)
deleteNBDir(blueprintWorking)
@@ -379,11 +409,15 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
try {
val blueprintModel = getBlueprintModelByNameAndVersion(name, version)
return blueprintModel.blueprintModelContent?.content
- ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format("Error while downloading the CBA file: couldn't get model content"))
+ ?: throw BluePrintException(
+ ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while downloading the CBA file: couldn't get model content")
+ )
} catch (e: BluePrintException) {
- throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format("Error while " + "downloading the CBA file: %s", e.message), e)
+ throw BluePrintException(
+ ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while " + "downloading the CBA file: %s", e.message), e
+ )
}
}
@@ -396,17 +430,18 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP
try {
when (fileSource) {
is FilePart -> BluePrintEnhancerUtils
- .copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir)
+ .copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir)
is ByteArray -> BluePrintEnhancerUtils
- .copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir)
- } // Enhance the Blue Prints
+ .copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir)
+ } // Enhance the Blue Prints
bluePrintEnhancerService.enhance(blueprintWorkingDir)
return BluePrintEnhancerUtils.compressEnhanceDirAndReturnByteArray(blueprintWorkingDir, blueprintArchive)
-
} catch (e: IOException) {
- throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
- "Error in Enriching CBA: ${e.message}", e)
+ throw BluePrintException(
+ ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Enriching CBA: ${e.message}", e
+ )
} 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 5c7ba275d..a364f3678 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
@@ -17,10 +17,10 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ModelTypeRepository
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.ModelTypeValidator
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@@ -46,7 +46,6 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
}
}
-
/**
* This is a searchModelTypes service
*
@@ -66,7 +65,7 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
* @throws BluePrintException BluePrintException
*/
@Throws(BluePrintException::class)
- suspend open fun saveModel(modelType: ModelType): ModelType {
+ open suspend fun saveModel(modelType: ModelType): ModelType {
lateinit var dbModel: ModelType
ModelTypeValidator.validateModelType(modelType)
val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName)
@@ -86,16 +85,14 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
return dbModel
}
-
/**
* This is a deleteByModelName service
*
* @param modelName modelName
*/
- suspend open fun deleteByModelName(modelName: String) {
+ open suspend fun deleteByModelName(modelName: String) {
check(modelName.isNotBlank()) { "Model Name Information is missing." }
modelTypeRepository.deleteByModelName(modelName)
-
}
/**
@@ -119,4 +116,4 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." }
return modelTypeRepository.findByDerivedFrom(derivedFrom)
}
-} \ No newline at end of file
+}
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 8ba4c7b38..af40f56ed 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
@@ -31,7 +31,6 @@ import org.springframework.stereotype.Service
@Service
class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) {
-
/**
* This is a getDataDictionaryByName service
*
@@ -85,8 +84,8 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
val resourceDefinition = resourceDictionary.definition
Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content")
// Validate the Resource Definitions
- //TODO( Save Validator)
- //validate(resourceDefinition)
+ // TODO( Save Validator)
+ // validate(resourceDefinition)
resourceDictionary.tags = resourceDefinition.tags!!
resourceDefinition.updatedBy = resourceDictionary.updatedBy
@@ -137,11 +136,11 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
}
private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean {
- checkNotEmpty(resourceDictionary.name){ "DataDictionary Definition name is missing."}
+ checkNotEmpty(resourceDictionary.name) { "DataDictionary Definition name is missing." }
checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." }
- checkNotEmpty(resourceDictionary.description){ "DataDictionary Definition Information is missing."}
- checkNotEmpty(resourceDictionary.tags){ "DataDictionary Definition tags is missing."}
- checkNotEmpty(resourceDictionary.updatedBy){ "DataDictionary Definition updatedBy is missing."}
+ checkNotEmpty(resourceDictionary.description) { "DataDictionary Definition Information is missing." }
+ checkNotEmpty(resourceDictionary.tags) { "DataDictionary Definition tags is missing." }
+ checkNotEmpty(resourceDictionary.updatedBy) { "DataDictionary Definition updatedBy is missing." }
return true
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt
index 36df06909..8d209449c 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt
@@ -25,7 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogS
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.io.File
-import java.util.*
+import java.util.UUID
@Service
open class BluePrintCatalogLoadService(private val controllerBlueprintsCatalogService: BluePrintCatalogService) {
@@ -66,5 +66,4 @@ open class BluePrintCatalogLoadService(private val controllerBlueprintsCatalogSe
errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}")
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt
index 31bd2c953..02d6ad3c1 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt
@@ -23,10 +23,12 @@ import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@Service
-open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val modelTypeLoadService: ModelTypeLoadService,
- private val resourceDictionaryLoadService: ResourceDictionaryLoadService,
- private val bluePrintCatalogLoadService: BluePrintCatalogLoadService) {
+open class BluePrintDatabaseLoadService(
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val modelTypeLoadService: ModelTypeLoadService,
+ private val resourceDictionaryLoadService: ResourceDictionaryLoadService,
+ private val bluePrintCatalogLoadService: BluePrintCatalogLoadService
+) {
private val log = LoggerFactory.getLogger(BluePrintDatabaseLoadService::class.java)
@@ -62,4 +64,4 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
bluePrintCatalogLoadService.loadPathsBluePrintModelCatalog(paths)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt
index 9f43740aa..e96daf9f0 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt
@@ -26,7 +26,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.EntityType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import org.onap.ccsdk.cds.controllerblueprints.core.readNBText
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -108,7 +112,7 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
val dataKey = FilenameUtils.getBaseName(file.name)
val definitionContent = file.readNBText()
val definition = JacksonUtils.readValue(definitionContent, classType) as EntityType
- //checkNotNull(definition) { "failed to get data type from file : ${file.name}" }
+ // checkNotNull(definition) { "failed to get data type from file : ${file.name}" }
val modelType = ModelType()
val definitionType: String?
@@ -143,4 +147,4 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
errorBuilder.appendln("Couldn't load ${classType.name}(${file.name}: ${e.message}")
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt
index 95073e99d..0350bc731 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt
@@ -66,7 +66,6 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler:
if (!errorBuilder.isEmpty) {
log.error(errorBuilder.toString())
}
-
}
private suspend fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) {
@@ -91,9 +90,8 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler:
resourceDictionary.updatedBy = resourceDefinition.updatedBy
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!!
}
@@ -107,5 +105,4 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler:
errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message}")
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepository.kt
index 1d69cd7cc..80aa6b49a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepository.kt
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.core.scheduler.Schedulers
+
// TODO("Convert into coroutines")
/**
* ModelTypeReactRepository.
@@ -40,37 +41,36 @@ open class ModelTypeReactRepository(private val modelTypeRepository: ModelTypeRe
fun findByModelNameIn(modelNames: List<String>): Flux<ModelType> {
return Flux.fromIterable(modelTypeRepository.findByModelNameIn(modelNames))
- .subscribeOn(Schedulers.elastic())
+ .subscribeOn(Schedulers.elastic())
}
fun findByDerivedFrom(derivedFrom: String): Flux<ModelType> {
return Flux.fromIterable(modelTypeRepository.findByDerivedFrom(derivedFrom))
- .subscribeOn(Schedulers.elastic())
+ .subscribeOn(Schedulers.elastic())
}
fun findByDerivedFromIn(derivedFroms: List<String>): Flux<ModelType> {
return Flux.fromIterable(modelTypeRepository.findByDerivedFromIn(derivedFroms))
- .subscribeOn(Schedulers.elastic())
+ .subscribeOn(Schedulers.elastic())
}
fun findByDefinitionType(definitionType: String): Flux<ModelType> {
return Flux.fromIterable(modelTypeRepository.findByDefinitionType(definitionType))
- .subscribeOn(Schedulers.elastic())
+ .subscribeOn(Schedulers.elastic())
}
fun findByDefinitionTypeIn(definitionTypes: List<String>): Flux<ModelType> {
return Flux.fromIterable(modelTypeRepository.findByDefinitionTypeIn(definitionTypes))
- .subscribeOn(Schedulers.elastic())
+ .subscribeOn(Schedulers.elastic())
}
fun findByTagsContainingIgnoreCase(tags: String): Flux<ModelType> {
return Flux.fromIterable(modelTypeRepository.findByTagsContainingIgnoreCase(tags))
- .subscribeOn(Schedulers.elastic())
+ .subscribeOn(Schedulers.elastic())
}
fun deleteByModelName(modelName: String): Mono<Void> {
modelTypeRepository.deleteByModelName(modelName)
return Mono.empty()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt
index 3e36947a4..8beea7161 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt
@@ -23,6 +23,7 @@ import javax.transaction.Transactional
@Repository
interface ModelTypeRepository : JpaRepository<ModelType, String> {
+
/**
* This is a findByModelName method
*
@@ -30,6 +31,7 @@ interface ModelTypeRepository : JpaRepository<ModelType, String> {
* @return Optional<ModelType>
*/
fun findByModelName(modelName: String): ModelType?
+
/**
* This is a findByModelNameIn method
*
@@ -37,19 +39,21 @@ interface ModelTypeRepository : JpaRepository<ModelType, String> {
* @return List<ModelType>
*/
fun findByModelNameIn(modelNames: List<String>): List<ModelType>
+
/**
* This is a findByDerivedFrom method
*
* @param derivedFrom Derived From
* @return List<ModelType>
- */
+ */
fun findByDerivedFrom(derivedFrom: String): List<ModelType>
+
/**
* This is a findByDerivedFromIn method
*
* @param derivedFroms Derived Froms
* @return List<ModelType>
- */
+ */
fun findByDerivedFromIn(derivedFroms: List<String>): List<ModelType>
/**
@@ -59,12 +63,13 @@ interface ModelTypeRepository : JpaRepository<ModelType, String> {
* @return List<ModelType>
*/
fun findByDefinitionType(definitionType: String): List<ModelType>
+
/**
* This is a findByDefinitionTypeIn method
*
* @param definitionTypes Definition Types
* @return List<ModelType>
- */
+ */
fun findByDefinitionTypeIn(definitionTypes: List<String>): List<ModelType>
/**
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 68db371c6..da7893861 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
@@ -20,7 +20,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictio
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
-
/**
* ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository
*
@@ -30,7 +29,6 @@ import org.springframework.stereotype.Repository
@Repository
interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, String> {
-
/**
* This is a findByName method
*
@@ -61,6 +59,4 @@ interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, Strin
* @param name name
*/
fun deleteByName(name: String)
-
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt
index f8e6163a5..420a9fcd7 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt
@@ -23,7 +23,11 @@ import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ModelTypeRepository
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ResourceDictionaryRepository
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
@@ -36,37 +40,39 @@ interface ResourceDefinitionRepoService : BluePrintRepoService {
}
@Service
-open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRepository,
- private val resourceDictionaryRepository: ResourceDictionaryRepository) : ResourceDefinitionRepoService {
+open class BluePrintRepoFileService(
+ private val modelTypeRepository: ModelTypeRepository,
+ private val resourceDictionaryRepository: ResourceDictionaryRepository
+) : ResourceDefinitionRepoService {
@Throws(BluePrintException::class)
override fun getNodeType(nodeTypeName: String): NodeType {
return getModelType(nodeTypeName, NodeType::class.java)
- ?: throw BluePrintException("couldn't get NodeType($nodeTypeName)")
+ ?: throw BluePrintException("couldn't get NodeType($nodeTypeName)")
}
@Throws(BluePrintException::class)
override fun getDataType(dataTypeName: String): DataType {
return getModelType(dataTypeName, DataType::class.java)
- ?: throw BluePrintException("couldn't get DataType($dataTypeName)")
+ ?: throw BluePrintException("couldn't get DataType($dataTypeName)")
}
@Throws(BluePrintException::class)
override fun getArtifactType(artifactTypeName: String): ArtifactType {
return getModelType(artifactTypeName, ArtifactType::class.java)
- ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName)")
+ ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName)")
}
@Throws(BluePrintException::class)
override fun getRelationshipType(relationshipTypeName: String): RelationshipType {
return getModelType(relationshipTypeName, RelationshipType::class.java)
- ?: throw BluePrintException("couldn't get RelationshipType($relationshipTypeName)")
+ ?: throw BluePrintException("couldn't get RelationshipType($relationshipTypeName)")
}
@Throws(BluePrintException::class)
override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition {
return getModelType(capabilityDefinitionName, CapabilityDefinition::class.java)
- ?: throw BluePrintException("couldn't get CapabilityDefinition($capabilityDefinitionName)")
+ ?: throw BluePrintException("couldn't get CapabilityDefinition($capabilityDefinitionName)")
}
@Throws(BluePrintException::class)
@@ -81,12 +87,16 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe
@Throws(BluePrintException::class)
private fun <T> getModelType(modelName: String, valueClass: Class<T>): T? {
- Preconditions.checkArgument(StringUtils.isNotBlank(modelName),
- "Failed to get model from repo, model name is missing")
+ Preconditions.checkArgument(
+ StringUtils.isNotBlank(modelName),
+ "Failed to get model from repo, model name is missing"
+ )
val modelDefinition = getModelDefinition(modelName)
- Preconditions.checkNotNull(modelDefinition,
- String.format("Failed to get model content for model name (%s)", modelName))
+ Preconditions.checkNotNull(
+ modelDefinition,
+ String.format("Failed to get model content for model name (%s)", modelName)
+ )
return JacksonUtils.readValue(modelDefinition, valueClass)
}
@@ -102,4 +112,4 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe
}
return modelDefinition
}
-} \ No newline at end of file
+}
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 c79d1b526..4d5ca36cf 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
@@ -19,12 +19,18 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils
import kotlinx.coroutines.reactive.awaitSingle
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
+import org.onap.ccsdk.cds.controllerblueprints.core.deCompress
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+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.reCreateNBDirs
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
import org.springframework.core.io.ByteArrayResource
@@ -36,47 +42,57 @@ import org.springframework.http.codec.multipart.FilePart
import java.io.File
import java.nio.file.Paths
-
class BluePrintEnhancerUtils {
companion object {
val log = logger(BluePrintEnhancerUtils)
- fun populateDataTypes(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
- dataTypeName: String): DataType {
+ fun populateDataTypes(
+ bluePrintContext: BluePrintContext,
+ bluePrintRepoService: BluePrintRepoService,
+ dataTypeName: String
+ ): DataType {
val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
- ?: bluePrintRepoService.getDataType(dataTypeName)
- ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.")
+ ?: bluePrintRepoService.getDataType(dataTypeName)
+ ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.")
bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType)
return dataType
}
- fun populateRelationshipType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
- relationshipName: String): RelationshipType {
+ fun populateRelationshipType(
+ bluePrintContext: BluePrintContext,
+ bluePrintRepoService: BluePrintRepoService,
+ relationshipName: String
+ ): RelationshipType {
val relationshipType = bluePrintContext.serviceTemplate.relationshipTypes?.get(relationshipName)
- ?: bluePrintRepoService.getRelationshipType(relationshipName)
- ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.")
+ ?: bluePrintRepoService.getRelationshipType(relationshipName)
+ ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.")
bluePrintContext.serviceTemplate.relationshipTypes?.put(relationshipName, relationshipType)
return relationshipType
}
-
- fun populateNodeType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
- nodeTypeName: String): NodeType {
+ fun populateNodeType(
+ bluePrintContext: BluePrintContext,
+ bluePrintRepoService: BluePrintRepoService,
+ nodeTypeName: String
+ ): NodeType {
val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
- ?: bluePrintRepoService.getNodeType(nodeTypeName)
- ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.")
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)
+ ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.")
bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
}
- fun populateArtifactType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
- artifactTypeName: String): ArtifactType {
+ fun populateArtifactType(
+ bluePrintContext: BluePrintContext,
+ bluePrintRepoService: BluePrintRepoService,
+ artifactTypeName: String
+ ): ArtifactType {
val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: bluePrintRepoService.getArtifactType(artifactTypeName)
- ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.")
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName)
+ ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.")
bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
return artifactType
}
@@ -90,17 +106,16 @@ class BluePrintEnhancerUtils {
return targetFile
}
-
suspend fun filePartAsFile(filePart: FilePart, targetFile: File): File {
// Delete the Directory
targetFile.parentFile.reCreateNBDirs()
return filePart.transferTo(targetFile)
- .thenReturn(targetFile)
- .awaitSingle()
+ .thenReturn(targetFile)
+ .awaitSingle()
}
private suspend fun byteArrayAsArchiveFile(byteArray: ByteArray, archiveDir: String, enhanceDir: String): File {
- //Recreate the Base Directories
+ // Recreate the Base Directories
normalizedFile(archiveDir).reCreateNBDirs()
normalizedFile(enhanceDir).reCreateNBDirs()
val archiveFile = normalizedFile(archiveDir, "cba.zip")
@@ -109,7 +124,7 @@ class BluePrintEnhancerUtils {
}
private suspend fun filePartAsArchiveFile(filePart: FilePart, archiveDir: String, enhanceDir: String): File {
- //Recreate the Base Directories
+ // Recreate the Base Directories
normalizedFile(archiveDir).reCreateNBDirs()
normalizedFile(enhanceDir).reCreateNBDirs()
val archiveFile = normalizedFile(archiveDir, "cba.zip")
@@ -132,17 +147,23 @@ class BluePrintEnhancerUtils {
}
/** compress [enhanceDir] to [archiveDir] and return ByteArray */
- suspend fun compressEnhanceDirAndReturnByteArray(enhanceDir: String, archiveDir: String,
- outputFileName: String = "enhanced-cba.zip"): ByteArray {
+ suspend fun compressEnhanceDirAndReturnByteArray(
+ enhanceDir: String,
+ archiveDir: String,
+ outputFileName: String = "enhanced-cba.zip"
+ ): ByteArray {
val compressedFile = normalizedFile(archiveDir, outputFileName)
BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile)
return compressedFile.readBytes()
}
/** compress [enhanceDir] to [archiveDir] and return ResponseEntity */
- suspend fun compressEnhanceDirAndReturnFilePart(enhanceDir: String, archiveDir: String,
- outputFileName: String = "enhanced-cba.zip")
- : ResponseEntity<Resource> {
+ suspend fun compressEnhanceDirAndReturnFilePart(
+ enhanceDir: String,
+ archiveDir: String,
+ outputFileName: String = "enhanced-cba.zip"
+ ):
+ ResponseEntity<Resource> {
val compressedFile = normalizedFile(archiveDir, outputFileName)
BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile)
return prepareResourceEntity(compressedFile)
@@ -152,12 +173,13 @@ class BluePrintEnhancerUtils {
suspend fun prepareResourceEntity(file: File): ResponseEntity<Resource> {
return prepareResourceEntity(file.name, file.readBytes())
}
+
/** convert [byteArray] to ResourceEntity with [fileName]*/
fun prepareResourceEntity(fileName: String, byteArray: ByteArray): ResponseEntity<Resource> {
return ResponseEntity.ok()
- .contentType(MediaType.parseMediaType("text/plain"))
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"")
- .body(ByteArrayResource(byteArray))
+ .contentType(MediaType.parseMediaType("text/plain"))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"")
+ .body(ByteArrayResource(byteArray))
}
suspend fun cleanEnhancer(archiveLocation: String, enhancementLocation: String) {
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt
index 6f5636516..92573892a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt
@@ -3,4 +3,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils
enum class BlueprintSortByOption(val columnName: String) {
DATE("createdDate"),
NAME("artifactName")
-} \ No newline at end of file
+}
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 8ec0b9bab..6b9ea28f0 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
@@ -21,7 +21,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
class ModelTypeValidator {
@@ -38,23 +42,23 @@ class ModelTypeValidator {
when (definitionType) {
BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE -> {
JacksonUtils.readValue(definitionContent, DataType::class.java)
- ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent")
+ ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent")
}
BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE -> {
JacksonUtils.readValue(definitionContent, NodeType::class.java)
- ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent")
+ ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent")
}
BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE -> {
JacksonUtils.readValue(definitionContent, ArtifactType::class.java)
- ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent")
+ ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent")
}
BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE -> {
JacksonUtils.readValue(definitionContent, CapabilityDefinition::class.java)
- ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent")
+ ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent")
}
BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE -> {
JacksonUtils.readValue(definitionContent, RelationshipType::class.java)
- ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent")
+ ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent")
}
}
return true
@@ -79,5 +83,4 @@ class ModelTypeValidator {
return true
}
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt
index 61f515017..0938431d6 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt
@@ -32,20 +32,34 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
-import org.onap.ccsdk.cds.controllerblueprints.management.api.*
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintBootstrapInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintDownloadInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.DownloadAction
+import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk
+import org.onap.ccsdk.cds.controllerblueprints.management.api.RemoveAction
+import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.*
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@EnableAutoConfiguration
@DirtiesContext
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
- "org.onap.ccsdk.cds.controllerblueprints"])
+@ComponentScan(
+ basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
+ "org.onap.ccsdk.cds.controllerblueprints"]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintManagementGRPCHandlerTest {
@@ -74,8 +88,10 @@ class BluePrintManagementGRPCHandlerTest {
val req = createBootstrapInputRequest(id)
val bootstrapOutput = blockingStub.bootstrapBlueprint(req)
assertEquals(200, bootstrapOutput.status.code)
- assertTrue(bootstrapOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
- "failed to get success status")
+ assertTrue(
+ bootstrapOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+ "failed to get success status"
+ )
assertEquals(id, bootstrapOutput.commonHeader.requestId)
}
@@ -87,8 +103,10 @@ class BluePrintManagementGRPCHandlerTest {
val output = blockingStub.uploadBlueprint(req)
assertEquals(200, output.status.code)
- assertTrue(output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
- "failed to get success status")
+ assertTrue(
+ output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+ "failed to get success status"
+ )
assertEquals(id, output.commonHeader.requestId)
val downloadId = "123_download"
@@ -96,8 +114,10 @@ class BluePrintManagementGRPCHandlerTest {
val downloadOutput = blockingStub.downloadBlueprint(downloadReq)
assertEquals(200, downloadOutput.status.code)
- assertTrue(downloadOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
- "failed to get success status")
+ assertTrue(
+ downloadOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+ "failed to get success status"
+ )
assertNotNull(downloadOutput.fileChunk?.chunk, "failed to get cba file chunks")
assertEquals(downloadId, downloadOutput.commonHeader.requestId)
}
@@ -110,8 +130,10 @@ class BluePrintManagementGRPCHandlerTest {
var output = blockingStub.uploadBlueprint(req)
assertEquals(200, output.status.code)
- assertTrue(output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
- "failed to get success status")
+ assertTrue(
+ output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+ "failed to get success status"
+ )
assertEquals(id, output.commonHeader.requestId)
val removeReq = createRemoveInputRequest(id)
@@ -142,18 +164,18 @@ class BluePrintManagementGRPCHandlerTest {
private fun createBootstrapInputRequest(id: String): BluePrintBootstrapInput {
val commonHeader = CommonHeader
- .newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(id)
- .setSubRequestId("1234-56").build()
+ .newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(id)
+ .setSubRequestId("1234-56").build()
return BluePrintBootstrapInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setLoadModelType(false)
- .setLoadResourceDictionary(false)
- .setLoadCBA(false)
- .build()
+ .setCommonHeader(commonHeader)
+ .setLoadModelType(false)
+ .setLoadResourceDictionary(false)
+ .setLoadCBA(false)
+ .build()
}
private fun createUploadInputRequest(id: String, action: String): BluePrintUploadInput {
@@ -161,59 +183,63 @@ class BluePrintManagementGRPCHandlerTest {
assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
val commonHeader = CommonHeader
- .newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(id)
- .setSubRequestId("1234-56").build()
+ .newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(id)
+ .setSubRequestId("1234-56").build()
val actionIdentifier = ActionIdentifiers.newBuilder()
- .setActionName(action)
- .setBlueprintName("sample")
- .setBlueprintVersion("1.0.0")
- .build()
+ .setActionName(action)
+ .setBlueprintName("sample")
+ .setBlueprintVersion("1.0.0")
+ .build()
val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes()))
- .build()
+ .build()
return BluePrintUploadInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(actionIdentifier)
- .setFileChunk(fileChunk)
- .build()
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(actionIdentifier)
+ .setFileChunk(fileChunk)
+ .build()
}
private fun createDownloadInputRequest(id: String, action: String): BluePrintDownloadInput {
val commonHeader = CommonHeader
- .newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(id)
- .setSubRequestId("1234-56").build()
+ .newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(id)
+ .setSubRequestId("1234-56").build()
return BluePrintDownloadInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(ActionIdentifiers.newBuilder()
- .setBlueprintName("baseconfiguration")
- .setBlueprintVersion("1.0.0")
- .setActionName(action).build())
- .build()
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(
+ ActionIdentifiers.newBuilder()
+ .setBlueprintName("baseconfiguration")
+ .setBlueprintVersion("1.0.0")
+ .setActionName(action).build()
+ )
+ .build()
}
private fun createRemoveInputRequest(id: String): BluePrintRemoveInput {
val commonHeader = CommonHeader
- .newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(id)
- .setSubRequestId("1234-56").build()
+ .newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(id)
+ .setSubRequestId("1234-56").build()
return BluePrintRemoveInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(ActionIdentifiers.newBuilder()
- .setBlueprintName("sample")
- .setBlueprintVersion("1.0.0")
- .setActionName(RemoveAction.DEFAULT.toString()).build())
- .build()
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(
+ ActionIdentifiers.newBuilder()
+ .setBlueprintName("sample")
+ .setBlueprintVersion("1.0.0")
+ .setActionName(RemoveAction.DEFAULT.toString()).build()
+ )
+ .build()
}
}
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 149acb03c..50eafd12c 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
@@ -30,8 +30,13 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.compress
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
+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.reCreateDirs
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.core.io.ByteArrayResource
@@ -60,8 +65,10 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class BlueprintModelControllerTest {
@@ -82,7 +89,6 @@ class BlueprintModelControllerTest {
private var testZipFile: File? = null
-
@Before
fun setUp() {
assertNotNull(webTestClient, " Failed to create WebTestClient")
@@ -121,14 +127,14 @@ class BlueprintModelControllerTest {
}.build()
val saveBP = webTestClient
- .post()
- .uri("/api/v1/blueprint-model")
- .body(BodyInserters.fromMultipartData(body))
- .exchange()
- .expectStatus().isOk
- .returnResult<BlueprintModelSearch>()
- .responseBody
- .awaitSingle()
+ .post()
+ .uri("/api/v1/blueprint-model")
+ .body(BodyInserters.fromMultipartData(body))
+ .exchange()
+ .expectStatus().isOk
+ .returnResult<BlueprintModelSearch>()
+ .responseBody
+ .awaitSingle()
assertNotNull(saveBP, "failed to get response")
assertEquals("baseconfiguration", saveBP.artifactName, "mismatch artifact name")
@@ -141,18 +147,21 @@ class BlueprintModelControllerTest {
@Test
@Throws(JSONException::class)
fun test02_getBluePrintByNameAndVersion() {
- webTestClient(HttpMethod.GET, null,
- "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
- HttpStatus.OK, false)
+ webTestClient(
+ HttpMethod.GET, null,
+ "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
+ HttpStatus.OK, false
+ )
}
-
@Test
@Throws(JSONException::class)
fun test03_getBlueprintModel() {
- webTestClient(HttpMethod.GET, null,
- "/api/v1/blueprint-model/${bp!!.id}",
- HttpStatus.OK, false)
+ webTestClient(
+ HttpMethod.GET, null,
+ "/api/v1/blueprint-model/${bp!!.id}",
+ HttpStatus.OK, false
+ )
}
@Test
@@ -164,9 +173,11 @@ class BlueprintModelControllerTest {
@Test
@Throws(JSONException::class)
fun test05_downloadBluePrint() {
- webTestClient(HttpMethod.GET, null,
- "/api/v1/blueprint-model/download/${bp!!.id}",
- HttpStatus.OK, false)
+ webTestClient(
+ HttpMethod.GET, null,
+ "/api/v1/blueprint-model/download/${bp!!.id}",
+ HttpStatus.OK, false
+ )
}
@Test
@@ -185,14 +196,14 @@ class BlueprintModelControllerTest {
}.build()
val publishBP = webTestClient
- .post()
- .uri("/api/v1/blueprint-model/publish")
- .body(BodyInserters.fromMultipartData(body))
- .exchange()
- .expectStatus().isOk
- .returnResult<BlueprintModelSearch>()
- .responseBody
- .awaitSingle()
+ .post()
+ .uri("/api/v1/blueprint-model/publish")
+ .body(BodyInserters.fromMultipartData(body))
+ .exchange()
+ .expectStatus().isOk
+ .returnResult<BlueprintModelSearch>()
+ .responseBody
+ .awaitSingle()
assertNotNull(publishBP, "failed to get response")
assertEquals("baseconfiguration", publishBP.artifactName, "mismatch artifact name")
@@ -205,49 +216,60 @@ class BlueprintModelControllerTest {
@Test
@Throws(JSONException::class)
fun test08_searchBlueprintModels() {
- webTestClient(HttpMethod.GET, null,
- "/api/v1/blueprint-model/search/${bp!!.artifactName}",
- HttpStatus.OK, false)
+ webTestClient(
+ HttpMethod.GET, null,
+ "/api/v1/blueprint-model/search/${bp!!.artifactName}",
+ HttpStatus.OK, false
+ )
}
@Test
@Throws(JSONException::class)
fun test09_downloadBlueprintByNameAndVersion() {
- webTestClient(HttpMethod.GET, null,
- "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
- HttpStatus.OK, false)
+ webTestClient(
+ HttpMethod.GET, null,
+ "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
+ HttpStatus.OK, false
+ )
}
@Test
fun test10_deleteBluePrint() {
-// webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}")
-// .header("Authorization", "Basic " + Base64Utils
-// .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
-// .exchange()
-// .expectStatus().is2xxSuccessful
+ // webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}")
+ // .header("Authorization", "Basic " + Base64Utils
+ // .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
+ // .exchange()
+ // .expectStatus().is2xxSuccessful
webTestClient.delete().uri("/api/v1/blueprint-model/name/${bp!!.artifactName}/version/${bp!!.artifactVersion}")
- .header("Authorization", "Basic " + Base64Utils
- .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
- .exchange()
- .expectStatus().is2xxSuccessful
+ .header(
+ "Authorization", "Basic " + Base64Utils
+ .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))
+ )
+ .exchange()
+ .expectStatus().is2xxSuccessful
}
@Throws(JSONException::class)
- private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String,
- expectedResponceStatus: HttpStatus, setParam: Boolean) {
+ private fun webTestClient(
+ requestMethod: HttpMethod,
+ body: BodyInserters.MultipartInserter?,
+ uri: String,
+ expectedResponceStatus: HttpStatus,
+ setParam: Boolean
+ ) {
log.info("Requesting($uri): Method(${requestMethod.name})")
webTestClient.method(requestMethod).uri(uri)
- .header("Authorization", "Basic " + Base64Utils
- .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
- .body(body)
- .exchange()
- .expectStatus().isEqualTo(expectedResponceStatus)
- .expectBody()
- .returnResult().responseBody!!
-
+ .header(
+ "Authorization", "Basic " + Base64Utils
+ .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))
+ )
+ .body(body)
+ .exchange()
+ .expectStatus().isEqualTo(expectedResponceStatus)
+ .expectBody()
+ .returnResult().responseBody!!
}
-
-} \ No newline at end of file
+}
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 03e016b8e..4953d9cee 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
@@ -21,7 +21,9 @@ import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
@Configuration
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints",
- "org.onap.ccsdk.cds.blueprintsprocessor"])
+@ComponentScan(
+ basePackages = ["org.onap.ccsdk.cds.controllerblueprints",
+ "org.onap.ccsdk.cds.blueprintsprocessor"]
+)
@EnableAutoConfiguration
open class DesignerApiTestConfiguration
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 8871676d2..fd51df482 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
@@ -24,9 +24,9 @@ import org.junit.runners.MethodSorters
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.annotation.Commit
@@ -35,8 +35,10 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ModelTypeControllerTest {
@@ -62,8 +64,8 @@ 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())
@@ -71,15 +73,16 @@ class ModelTypeControllerTest {
Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName)
val dbModelType = modelTypeController!!.getModelTypeByName(modelType.modelName)
- Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
- dbModelType)
+ Assert.assertNotNull(
+ "Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
+ dbModelType
+ )
// Model Update
modelType.updatedBy = "bs2796@xxx.com"
modelType = modelTypeController!!.saveModelType(modelType)
Assert.assertNotNull("Failed to get Saved ModelType", modelType)
Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy)
-
}
@Test
@@ -92,7 +95,6 @@ class ModelTypeControllerTest {
val dbModelTypes = modelTypeController!!.searchModelTypes(tags)
Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes)
Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.isNotEmpty())
-
}
@Test
@@ -113,7 +115,8 @@ class ModelTypeControllerTest {
@Throws(Exception::class)
fun test04DeleteModelType() {
log.info(
- "************************ test03DeleteModelType ***********************")
+ "************************ test03DeleteModelType ***********************"
+ )
val dbResourceMapping = modelTypeController!!.getModelTypeByName(modelName)
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping)
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName)
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt
index b13b1ac08..cfb16c786 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt
@@ -32,8 +32,10 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ResourceDictionaryControllerTest {
@@ -45,5 +47,4 @@ class ResourceDictionaryControllerTest {
fun testResourceDictionaryControllerPresence() {
assertNotNull(resourceDictionaryController, "failed to initialise ResourceDictionaryController")
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt
index a5a0511f5..c8c2f0b9b 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt
@@ -37,8 +37,10 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintEnhancerServiceImplTest {
@@ -54,7 +56,6 @@ class BluePrintEnhancerServiceImplTest {
@Autowired
lateinit var bluePrintValidatorService: BluePrintValidatorService
-
@Test
@Throws(Exception::class)
fun testEnhancementAndValidation() {
@@ -93,7 +94,6 @@ class BluePrintEnhancerServiceImplTest {
fun testRemoteScriptsEnhancementAndValidation() {
val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
testComponentInvokeEnhancementAndValidation(basePath, "remote_scripts-enhance")
-
}
fun testCapabilityCliEnhancementAndValidation() {
@@ -115,12 +115,10 @@ class BluePrintEnhancerServiceImplTest {
Assert.assertTrue("blueprint($basePath) validation failed ", valid)
// Enable this to get the enhanced zip file
-// val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip")
-// normalizedFile(targetPath).compress(compressFile)
+ // val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip")
+ // normalizedFile(targetPath).compress(compressFile)
deleteDir(targetPath)
}
}
-
-
-} \ No newline at end of file
+}
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 7ea845dee..fe5cd4d3e 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
@@ -26,9 +26,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.annotation.Commit
@@ -36,13 +36,15 @@ import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
-
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ModelTypeServiceTest {
+
@Autowired
private val modelTypeHandler: ModelTypeHandler? = null
@@ -65,8 +67,8 @@ 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())
@@ -74,8 +76,10 @@ class ModelTypeServiceTest {
Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName)
val dbModelType = modelTypeHandler.getModelTypeByName(modelType.modelName)
- Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
- dbModelType)
+ Assert.assertNotNull(
+ "Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
+ dbModelType
+ )
// Model Update
modelType.updatedBy = "bs2796@xxx.com"
@@ -83,7 +87,6 @@ class ModelTypeServiceTest {
Assert.assertNotNull("Failed to get Saved ModelType", modelType)
Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy)
}
-
}
@Test
@@ -98,7 +101,6 @@ class ModelTypeServiceTest {
Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes)
Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size > 0)
}
-
}
@Test
@@ -118,7 +120,6 @@ class ModelTypeServiceTest {
Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms)
Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size > 0)
}
-
}
@Test
@@ -126,7 +127,8 @@ class ModelTypeServiceTest {
fun test04DeleteModelType() {
runBlocking {
log.info(
- "************************ test03DeleteModelType ***********************")
+ "************************ test03DeleteModelType ***********************"
+ )
val dbResourceMapping = modelTypeHandler!!.getModelTypeByName(modelName)
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping)
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName)
@@ -134,5 +136,4 @@ class ModelTypeServiceTest {
modelTypeHandler.deleteByModelName(dbResourceMapping.modelName)
}
}
-
-} \ No newline at end of file
+}
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 3165a6e2f..27949901c 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
@@ -30,11 +30,11 @@ 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.
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
override fun headers(): HttpHeaders {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
override fun filename(): String {
@@ -46,8 +46,8 @@ class MockFilePart(private val fileName: String) : FilePart {
}
override fun transferTo(path: Path): Mono<Void> {
- log.info("Copying file($fileName to ${path}")
+ log.info("Copying file($fileName to $path")
FileCopyUtils.copy(File(fileName), path.toFile())
return Mono.empty()
}
-} \ No newline at end of file
+}
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 3dfed1ccb..4b771c0a6 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
@@ -25,17 +25,17 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.annotation.Commit
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import java.nio.charset.Charset
-import java.util.*
+import java.util.Arrays
/**
* ModelTypeReactRepositoryTest.
@@ -44,8 +44,10 @@ import java.util.*
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ModelTypeReactRepositoryTest {
@@ -59,7 +61,7 @@ class ModelTypeReactRepositoryTest {
@Commit
fun test01Save() {
val content = normalizedFile("./src/test/resources/model_type/data_type/datatype-property.json")
- .readText(Charset.defaultCharset())
+ .readText(Charset.defaultCharset())
val modelType = ModelType()
modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT
@@ -67,8 +69,8 @@ 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()
@@ -80,7 +82,8 @@ class ModelTypeReactRepositoryTest {
val dbFindByModelName = modelTypeReactRepository!!.findByModelName(modelName).block()
Assert.assertNotNull("Failed to findByModelName ", dbFindByModelName)
- val dbFindByDefinitionType = modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block()
+ val dbFindByDefinitionType =
+ modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block()
Assert.assertNotNull("Failed to findByDefinitionType ", dbFindByDefinitionType)
Assert.assertTrue("Failed to findByDefinitionType count", dbFindByDefinitionType!!.size > 0)
@@ -92,11 +95,13 @@ class ModelTypeReactRepositoryTest {
Assert.assertNotNull("Failed to findByModelNameIn ", dbFindByModelNameIn)
Assert.assertTrue("Failed to findByModelNameIn by count", dbFindByModelNameIn!!.size > 0)
- val dbFindByDefinitionTypeIn = modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block()
+ val dbFindByDefinitionTypeIn =
+ modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block()
Assert.assertNotNull("Failed to findByDefinitionTypeIn", dbFindByDefinitionTypeIn)
Assert.assertTrue("Failed to findByDefinitionTypeIn by count", dbFindByDefinitionTypeIn!!.size > 0)
- val dbFindByDerivedFromIn = modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block()
+ val dbFindByDerivedFromIn =
+ modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block()
Assert.assertNotNull("Failed to find findByDerivedFromIn", dbFindByDerivedFromIn)
Assert.assertTrue("Failed to find findByDerivedFromIn by count", dbFindByDerivedFromIn!!.size > 0)
}
@@ -106,5 +111,4 @@ class ModelTypeReactRepositoryTest {
fun test03Delete() {
modelTypeReactRepository!!.deleteByModelName(modelName).block()
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt
index 6351f6aa0..0534afa2a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt
@@ -36,8 +36,10 @@ import org.springframework.test.context.junit4.SpringRunner
import org.springframework.transaction.annotation.Transactional
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class])
+@ContextConfiguration(
+ classes = [DesignerApiTestConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ResourceDictionaryReactRepositoryTest {
@@ -51,8 +53,10 @@ class ResourceDictionaryReactRepositoryTest {
@Commit
fun test01Save() {
val 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
+ )
Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition)
resourceDefinition!!.name = sourceName
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt
index 10bf887f6..c644aeedd 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt
@@ -21,8 +21,12 @@ import org.junit.After
import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.mock.MockFilePart
-import org.onap.ccsdk.cds.controllerblueprints.core.*
-import java.util.*
+import org.onap.ccsdk.cds.controllerblueprints.core.compress
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.onap.ccsdk.cds.controllerblueprints.core.reCreateDirs
+import java.util.UUID
import kotlin.test.assertTrue
class BluePrintEnhancerUtilsTest {
@@ -30,7 +34,7 @@ class BluePrintEnhancerUtilsTest {
private val blueprintDir = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
private val blueprintArchivePath: String = "./target/blueprints/archive"
private val blueprintEnrichmentPath: String = "./target/blueprints/enrichment"
- private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip")
+ private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip")
@Before
fun setUp() {
@@ -62,4 +66,3 @@ class BluePrintEnhancerUtilsTest {
}
}
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml b/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml
index 2bd6782a7..3b3fec4d1 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml
@@ -27,7 +27,7 @@
<artifactId>health-api-common</artifactId>
<packaging>jar</packaging>
- <name>Blueprints Processor Health API common </name>
+ <name>Blueprints Processor Health API common</name>
<description>checking system check health endpoints</description>
<dependencies>
@@ -36,7 +36,6 @@
<artifactId>rest-lib</artifactId>
</dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt
index 0c6099a1a..ead1f3b78 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt
@@ -45,5 +45,4 @@ open class BasicAuthRestClientServiceConfiguration(private val securityConfigura
open fun getBasicAuthRestClientService(): BasicAuthRestClientService {
return BasicAuthRestClientService(getBasicAuthRestClientProperties())
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt
index c63952d80..080a26e6f 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt
@@ -54,7 +54,6 @@ open class HealthCheckProperties {
open fun getCDSListenerServiceInformation(): List<ServiceEndpoint> {
val serviceName = ServiceName.BLUEPRINT
return getListOfServiceEndPoints(cdsListenerServiceMapping, serviceName)
-
}
private fun getListOfServiceEndPoints(serviceMapping: List<String>?, serviceName: ServiceName): MutableList<ServiceEndpoint> {
@@ -67,7 +66,7 @@ open class HealthCheckProperties {
return serviceEndpoints
}
- private fun fillListOfService(serviceName: ServiceName , element: String, listOfCDSListenerServiceEndpoint: MutableList<ServiceEndpoint>) {
+ private fun fillListOfService(serviceName: ServiceName, element: String, listOfCDSListenerServiceEndpoint: MutableList<ServiceEndpoint>) {
val serviceEndpointInfo = element.split(",/")
val serviceEndpoint = getServiceEndpoint(serviceEndpointInfo)
if (serviceName.equals(ServiceName.CDSLISTENER))
@@ -77,16 +76,15 @@ open class HealthCheckProperties {
listOfCDSListenerServiceEndpoint.add(serviceEndpoint)
}
-
private fun getServiceEndpoint(serviceEndpointInfo: List<String>): ServiceEndpoint {
- return ServiceEndpoint(removeSpecialCharacter(serviceEndpointInfo.get(0))
- , removeSpecialCharacter(serviceEndpointInfo.get(1))
+ return ServiceEndpoint(
+ removeSpecialCharacter(serviceEndpointInfo.get(0)), removeSpecialCharacter(serviceEndpointInfo.get(1))
)
}
- private fun removeSpecialCharacter(value:String):String{
- return value.replaceFirst(",[","")
- .replace("[","")
- .replace("]","")
+ private fun removeSpecialCharacter(value: String): String {
+ return value.replaceFirst(",[", "")
+ .replace("[", "")
+ .replace("]", "")
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt
index 94021207a..8b319fc43 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt
@@ -16,17 +16,15 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration
-
import org.apache.commons.net.util.Base64
import org.springframework.stereotype.Component
-import org.springframework.stereotype.Service
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
-
@Component
class SecurityEncryptionConfiguration {
+
private val key = "aesEncryptionKey"
private val initVector = "encryptionIntVec"
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt
index f66e8774c..f6ce829c1 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt
@@ -21,5 +21,3 @@ import org.springframework.boot.actuate.health.Status
data class ApplicationHealth(val status: Status?, val details: Map<String, Any>?) {
constructor() : this(null, HashMap())
}
-
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
index 61d8120d4..285dc0878 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
@@ -16,8 +16,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
-data class HealthApiResponse(val status: HealthCheckStatus, val checks: List<ServicesCheckResponse>
+data class HealthApiResponse(
+ val status: HealthCheckStatus,
+ val checks: List<ServicesCheckResponse>
)
-
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt
index d9f1c79d4..ceb92d1b4 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
data class Metrics(val names: ArrayList<Any>?) {
constructor() : this(ArrayList())
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt
index b3796c91a..f58a31e8c 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt
@@ -16,6 +16,4 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-data class MetricsResponse(val maps: HashMap<String, String>) {
-
-}
+data class MetricsResponse(val maps: HashMap<String, String>)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
index ce95a5c0c..badd772c4 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
@@ -15,5 +15,4 @@
*/
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
data class ServiceEndpoint(val serviceName: String, var serviceLink: String)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt
index 1a78a5d10..3e984b3b6 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt
@@ -17,5 +17,5 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
enum class ServiceName(s: String) {
- BLUEPRINT("Blue Print service"),CDSLISTENER("CDS Listener service")
+ BLUEPRINT("Blue Print service"), CDSLISTENER("CDS Listener service")
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt
index 391d7f38a..908007523 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt
@@ -16,7 +16,4 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
data class ServicesCheckResponse(val name: String, val status: HealthCheckStatus)
-
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt
index 03e864a9d..1e7e670b5 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt
@@ -18,5 +18,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
-data class WebClientEnpointResponse (val response:BlueprintWebClientService.WebClientResponse<String>?) {
-}
+data class WebClientEnpointResponse(val response: BlueprintWebClientService.WebClientResponse<String>?)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt
index 72fa6c849..9f526251e 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
-
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ApplicationHealth
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
@@ -35,8 +34,10 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class EndPointExecution(private val basicAuthRestClientService: BasicAuthRestClientService
- , private val restClientProperties: BasicAuthRestClientProperties) {
+open class EndPointExecution(
+ private val basicAuthRestClientService: BasicAuthRestClientService,
+ private val restClientProperties: BasicAuthRestClientProperties
+) {
private var logger = LoggerFactory.getLogger(EndPointExecution::class.java)
@@ -46,25 +47,21 @@ open class EndPointExecution(private val basicAuthRestClientService: BasicAuthRe
val result = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
if (result.status == 200)
return WebClientEnpointResponse(result)
-
} catch (e: Exception) {
logger.error("service name ${serviceEndpoint.serviceName} is down ${e.message}")
}
- return WebClientEnpointResponse(BlueprintWebClientService.WebClientResponse(500,""))
+ return WebClientEnpointResponse(BlueprintWebClientService.WebClientResponse(500, ""))
}
private fun addClientPropertiesConfiguration(serviceEndpoint: ServiceEndpoint) {
restClientProperties.url = serviceEndpoint.serviceLink
}
-
open fun getHealthFromWebClientEnpointResponse(webClientEnpointResponse: WebClientEnpointResponse): ApplicationHealth? {
return mappingMetricsToDTO(webClientEnpointResponse?.response?.body.toString())
-
}
private fun mappingMetricsToDTO(body: String): ApplicationHealth {
return ObjectMapper().readValue(body, ApplicationHealth::class.java)
}
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt
index f793754e3..6d49ebe65 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt
@@ -16,7 +16,11 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.*
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServicesCheckResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointResponse
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
import org.slf4j.LoggerFactory
@@ -27,7 +31,7 @@ import org.slf4j.LoggerFactory
* @author Shaaban Ebrahim
* @version 1.0
*/
-abstract class AbstractHealthCheck (private val endPointExecution: EndPointExecution) {
+abstract class AbstractHealthCheck(private val endPointExecution: EndPointExecution) {
private var logger = LoggerFactory.getLogger(BluePrintProcessorHealthCheck::class.java)
@@ -45,10 +49,8 @@ abstract class AbstractHealthCheck (private val endPointExecution: EndPointExec
}
healthApiResponse = HealthApiResponse(systemStatus, listOfResponse)
return healthApiResponse
-
}
-
private fun retrieveServiceStatus(serviceEndpoint: ServiceEndpoint): HealthCheckStatus {
var serviceStatus: HealthCheckStatus = HealthCheckStatus.UP
try {
@@ -59,16 +61,13 @@ abstract class AbstractHealthCheck (private val endPointExecution: EndPointExec
} catch (e: Exception) {
logger.error("service name ${serviceEndpoint.serviceName} is down ${e.message}")
serviceStatus = HealthCheckStatus.DOWN
-
}
return serviceStatus
}
-
open fun retrieveEndpointExecutionStatus(): HealthApiResponse {
return retrieveSystemStatus(setupServiceEndpoint())
}
abstract fun setupServiceEndpoint(): List<ServiceEndpoint>
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt
index d661b32b5..dddad52e2 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt
@@ -28,9 +28,11 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class BluePrintProcessorHealthCheck(private val endPointExecution: EndPointExecution
- , private val healthCheckProperties: HealthCheckProperties)
- : AbstractHealthCheck(endPointExecution) {
+open class BluePrintProcessorHealthCheck(
+ private val endPointExecution: EndPointExecution,
+ private val healthCheckProperties: HealthCheckProperties
+) :
+ AbstractHealthCheck(endPointExecution) {
override fun setupServiceEndpoint(): List<ServiceEndpoint> {
return healthCheckProperties.getBluePrintServiceInformation()
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt
index 0a7c5e092..aa0d4d5f2 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt
@@ -17,14 +17,8 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServicesCheckResponse
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
-import org.slf4j.LoggerFactory
-import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
/**
@@ -34,13 +28,13 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class SDCListenerHealthCheck (private val endPointExecution: EndPointExecution
- ,private val healthCheckProperties: HealthCheckProperties)
- : AbstractHealthCheck(endPointExecution) {
+open class SDCListenerHealthCheck(
+ private val endPointExecution: EndPointExecution,
+ private val healthCheckProperties: HealthCheckProperties
+) :
+ AbstractHealthCheck(endPointExecution) {
override fun setupServiceEndpoint(): List<ServiceEndpoint> {
return healthCheckProperties.getCDSListenerServiceInformation()
}
-
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt
index c4a8d1235..e3ba72428 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt
@@ -16,25 +16,18 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
+import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
-import org.mockito.ArgumentMatchers.any
-import org.mockito.ArgumentMatchers.eq
-import org.mockito.Mockito.anyString
-import org.mockito.Mockito.mock
-
-import java.util.Arrays
-import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.mockito.ArgumentMatchers
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.Mockito
+import org.mockito.Mockito.anyString
import org.mockito.junit.MockitoJUnitRunner
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
@@ -42,8 +35,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.BluePrint
import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse
-import org.springframework.http.HttpMethod
+import java.util.Arrays
@RunWith(MockitoJUnitRunner::class)
class HealthCheckServiceTest {
@@ -62,106 +54,113 @@ class HealthCheckServiceTest {
private var bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck? = null
-
@Before
fun setup() {
endPointExecution = Mockito.spy(endPointExecution!!)
- Mockito.`when`(healthCheckProperties!!.getBluePrintServiceInformation()).thenReturn(Arrays.asList(
+ Mockito.`when`(healthCheckProperties!!.getBluePrintServiceInformation()).thenReturn(
+ Arrays.asList(
ServiceEndpoint("Execution service ", "http://cds-blueprints-processor-http:8080/api/v1/execution-service/health-check"),
- ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"), ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check")
- ))
+ ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"),
+ ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check")
+ )
+ )
bluePrintProcessorHealthCheck = BluePrintProcessorHealthCheck(endPointExecution!!, healthCheckProperties)
}
- @Test
+ @Test
fun testSystemIsCompletelyDown() {
- Mockito.`when`(basicAuthRestClientService!!.exchangeResource(
- anyString(),
- anyString(),
- anyString())).thenThrow(RuntimeException())
+ Mockito.`when`(
+ basicAuthRestClientService!!.exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()
+ )
+ ).thenThrow(RuntimeException())
val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
assertNotNull(healthApiResponse)
Assert.assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
healthApiResponse.checks.forEach { serviceEndpoint ->
assertNotNull(serviceEndpoint)
assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
-
}
-
}
@Test
fun testSystemIsUPAndRunning() {
- Mockito.`when`(basicAuthRestClientService!!
- .exchangeResource(
- anyString(),
- anyString(),
- anyString())).thenReturn(BlueprintWebClientService.WebClientResponse(200, "Success"))
+ Mockito.`when`(
+ basicAuthRestClientService!!
+ .exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()
+ )
+ ).thenReturn(BlueprintWebClientService.WebClientResponse(200, "Success"))
val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
assertNotNull(healthApiResponse)
assertEquals(HealthCheckStatus.UP, healthApiResponse.status)
healthApiResponse.checks.forEach { serviceEndpoint ->
assertNotNull(serviceEndpoint)
assertEquals(HealthCheckStatus.UP, serviceEndpoint.status)
-
}
-
}
@Test
fun testServiceIsNotFound() {
- Mockito.`when`(basicAuthRestClientService!!.exchangeResource(
- anyString(),
- anyString(),
- anyString())).thenReturn(BlueprintWebClientService.WebClientResponse(404, "failure"))
+ Mockito.`when`(
+ basicAuthRestClientService!!.exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()
+ )
+ ).thenReturn(BlueprintWebClientService.WebClientResponse(404, "failure"))
val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
assertNotNull(healthApiResponse)
assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
healthApiResponse.checks.forEach { serviceEndpoint ->
assertNotNull(serviceEndpoint)
assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
-
}
-
}
-
@Test
fun testServiceInternalServerError() {
- Mockito.`when`(basicAuthRestClientService!!.exchangeResource(
- anyString(),
- anyString(),
- anyString()))
- .thenReturn(BlueprintWebClientService.WebClientResponse(500, "failure"))
+ Mockito.`when`(
+ basicAuthRestClientService!!.exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()
+ )
+ )
+ .thenReturn(BlueprintWebClientService.WebClientResponse(500, "failure"))
val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
assertNotNull(healthApiResponse)
assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
healthApiResponse.checks.forEach { serviceEndpoint ->
assertNotNull(serviceEndpoint)
assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
-
}
-
}
@Test
fun testServiceIsRedirected() {
- Mockito.`when`(basicAuthRestClientService!!.
- exchangeResource(
- anyString(),
- anyString(),
- anyString()))
- .thenReturn(BlueprintWebClientService.WebClientResponse(300, "failure"))
+ Mockito.`when`(
+ basicAuthRestClientService!!
+ .exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()
+ )
+ )
+ .thenReturn(BlueprintWebClientService.WebClientResponse(300, "failure"))
val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
assertNotNull(healthApiResponse)
assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
healthApiResponse.checks.forEach { serviceEndpoint ->
assertNotNull(serviceEndpoint)
assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
-
}
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt
index e1f7abdb7..54becbadf 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt
@@ -20,7 +20,6 @@ import org.junit.Assert
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.SecurityEncryptionConfiguration
-
class SecurityConfigurationTest {
@Test
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
index 54c85a0fc..531a275fa 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
@@ -35,18 +35,20 @@ import org.springframework.web.bind.annotation.RestController
*/
@RestController
@RequestMapping("/api/v1/combinedHealth")
-@Api(value = "/api/v1/combinedHealth",
- description = "gather all HealthCheckResponses for HealthChecks known to the runtime")
+@Api(
+ value = "/api/v1/combinedHealth",
+ description = "gather all HealthCheckResponses for HealthChecks known to the runtime"
+)
open class CombinedHealth(private val combinedHealthService: CombinedHealthService) {
- @RequestMapping(path = [""],
- method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(
+ path = [""],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
fun getSystemHealthCheckResponse(): ResponseEntity<List<ApplicationHealth?>> {
return ResponseEntity.ok().body(combinedHealthService.getCombinedHealthCheck())
-
}
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
index 785def524..d2f02028c 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
@@ -35,18 +35,20 @@ import org.springframework.web.bind.annotation.RestController
*/
@RestController
@RequestMapping("/api/v1/combinedMetrics")
-@Api(value = "/api/v1/combinedMetrics",
- description = "gather all Metrics info from BluePrint and CDSListener")
+@Api(
+ value = "/api/v1/combinedMetrics",
+ description = "gather all Metrics info from BluePrint and CDSListener"
+)
open class CombinedMetrics(private val combinedMetricsService: CombinedMetricsService) {
- @RequestMapping(path = [""],
- method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(
+ path = [""],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = " Metrics Check", hidden = true)
fun getMetricsHealthCheckResponse(): ResponseEntity<MetricsInfo?> {
return ResponseEntity.ok().body(combinedMetricsService.metricsInfo)
-
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
index 786048ce4..f4c3e93bf 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
@@ -22,7 +22,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointR
import org.springframework.boot.actuate.health.Status
import org.springframework.stereotype.Service
-
/**
*Service for combined health (BluePrintProcessor and CDSListener)
*
@@ -30,13 +29,15 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class CombinedHealthService(private val endPointExecution: EndPointExecution
- , private val healthCheckProperties: HealthCheckProperties) {
+open class CombinedHealthService(
+ private val endPointExecution: EndPointExecution,
+ private val healthCheckProperties: HealthCheckProperties
+) {
private fun setupServiceEndpoint(): List<ServiceEndpoint> {
return listOf(
- ServiceEndpoint("BluePrintProcessor Health Check ", healthCheckProperties.getBluePrintBaseURL() + "actuator/health")
- , ServiceEndpoint("CDSListener Health Check", healthCheckProperties.getCDSListenerBaseURL() + "actuator/health")
+ ServiceEndpoint("BluePrintProcessor Health Check ", healthCheckProperties.getBluePrintBaseURL() + "actuator/health"),
+ ServiceEndpoint("CDSListener Health Check", healthCheckProperties.getCDSListenerBaseURL() + "actuator/health")
)
}
@@ -45,14 +46,18 @@ open class CombinedHealthService(private val endPointExecution: EndPointExecutio
for (serviceEndpoint in setupServiceEndpoint().parallelStream()) {
val result: WebClientEnpointResponse? = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
if (result?.response != null &&
- result.response!!.status?.equals(200)!!) {
+ result.response!!.status?.equals(200)!!
+ ) {
listOfResponse.add(endPointExecution?.getHealthFromWebClientEnpointResponse(result))
} else {
- listOfResponse.add(ApplicationHealth(Status.DOWN,
- hashMapOf(serviceEndpoint.serviceLink to serviceEndpoint.serviceLink)))
+ listOfResponse.add(
+ ApplicationHealth(
+ Status.DOWN,
+ hashMapOf(serviceEndpoint.serviceLink to serviceEndpoint.serviceLink)
+ )
+ )
}
}
return listOfResponse
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
index a23c9925b..0a2e7ae24 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
@@ -16,7 +16,12 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.*
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ActuatorCheckResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.Metrics
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.MetricsInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.MetricsResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.utils.ObjectMappingUtils
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.springframework.stereotype.Service
@@ -28,14 +33,16 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class CombinedMetricsService(private val endPointExecution: EndPointExecution
- , private val healthCheckProperties: HealthCheckProperties
- , private val objectMappingUtils: ObjectMappingUtils<Metrics>) {
+open class CombinedMetricsService(
+ private val endPointExecution: EndPointExecution,
+ private val healthCheckProperties: HealthCheckProperties,
+ private val objectMappingUtils: ObjectMappingUtils<Metrics>
+) {
private fun setupServiceEndpoint(): List<ServiceEndpoint> {
return listOf(
- ServiceEndpoint("BluePrintProcessor metrics", healthCheckProperties.getBluePrintBaseURL() + "/actuator/metrics")
- , ServiceEndpoint("CDS Listener metrics", healthCheckProperties.getCDSListenerBaseURL() + "/actuator/metrics")
+ ServiceEndpoint("BluePrintProcessor metrics", healthCheckProperties.getBluePrintBaseURL() + "/actuator/metrics"),
+ ServiceEndpoint("CDS Listener metrics", healthCheckProperties.getCDSListenerBaseURL() + "/actuator/metrics")
)
}
@@ -46,7 +53,8 @@ open class CombinedMetricsService(private val endPointExecution: EndPointExecuti
val webClientResponse = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
var actuatorsHealthResponse: ActuatorCheckResponse? = null
actuatorsHealthResponse = if (webClientResponse?.response != null &&
- webClientResponse.response!!.status?.equals(200)!!) {
+ webClientResponse.response!!.status?.equals(200)!!
+ ) {
var body = gettingCustomizedBody(serviceEndpoint, webClientResponse.response!!)
ActuatorCheckResponse(serviceEndpoint.serviceName, body)
} else {
@@ -57,7 +65,10 @@ open class CombinedMetricsService(private val endPointExecution: EndPointExecuti
return MetricsInfo(containerHealthChecks)
}
- private fun gettingCustomizedBody(serviceEndpoint: ServiceEndpoint?, webClientResponse: BlueprintWebClientService.WebClientResponse<String>): Any {
+ private fun gettingCustomizedBody(
+ serviceEndpoint: ServiceEndpoint?,
+ webClientResponse: BlueprintWebClientService.WebClientResponse<String>
+ ): Any {
var body: Any
val metrics: Metrics = objectMappingUtils.getObjectFromBody(webClientResponse.body, Metrics::class.java)
val mapOfMetricsInfo = HashMap<String, String>()
@@ -69,4 +80,3 @@ open class CombinedMetricsService(private val endPointExecution: EndPointExecuti
return body
}
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
index b1d629da7..5a1999ec1 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
-
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
@@ -40,8 +39,10 @@ import org.springframework.test.web.reactive.server.WebTestClient
*/
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [BluePrintRuntimeService::class, BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SecurityProperties::class, ComponentScriptExecutor::class])
+@ContextConfiguration(
+ classes = [BluePrintRuntimeService::class, BluePrintCoreConfiguration::class,
+ BluePrintCatalogService::class, SecurityProperties::class, ComponentScriptExecutor::class]
+)
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class HealthCheckApplicationTests {
@@ -52,17 +53,14 @@ class HealthCheckApplicationTests {
@Test
fun testHealthApiUp() {
webTestClient.get().uri("/api/v1/combinedHealth")
- .exchange()
- .expectStatus().is2xxSuccessful
-
+ .exchange()
+ .expectStatus().is2xxSuccessful
}
@Test
fun testMetricsApiUp() {
webTestClient.get().uri("/api/v1/combinedMetrics")
- .exchange()
- .expectStatus().is2xxSuccessful
+ .exchange()
+ .expectStatus().is2xxSuccessful
}
-
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index 6dc39a7ff..81fe3af4e 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -53,7 +53,6 @@
<artifactId>resource-resolution</artifactId>
</dependency>
-
<!-- Test Dependencies -->
<dependency>
<groupId>io.mockk</groupId>
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 3a708a973..b49ca68ed 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
@@ -27,31 +27,43 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestMethod
+import org.springframework.web.bind.annotation.RequestParam
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/api/v1/resources")
-@Api(value = "/api/v1/resources",
- description = "Interaction with resolved resources.")
+@Api(
+ value = "/api/v1/resources",
+ description = "Interaction with resolved resources."
+)
open class ResourceController(private var resourceResolutionDBService: ResourceResolutionDBService) {
- @RequestMapping(path = ["/health-check"],
+ @RequestMapping(
+ path = ["/health-check"],
method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
fun resourceControllerHealthCheck(): JsonNode = runBlocking {
JacksonUtils.getJsonNode("Success")
}
- @RequestMapping(path = [""],
- method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Get all resolved resources using the resolution key. ",
+ @RequestMapping(
+ path = [""],
+ method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @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.",
response = ResourceResolution::class,
responseContainer = "List",
- produces = MediaType.APPLICATION_JSON_VALUE)
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
fun getAllFromResolutionKeyOrFromResourceTypeAndId(
@@ -66,8 +78,9 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
@ApiParam(value = "Resource Type associated with the resolution.", required = false)
@RequestParam(value = "resourceType", required = false, defaultValue = "") resourceType: String,
@ApiParam(value = "Resource Id associated with the resolution.", required = false)
- @RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String)
- : ResponseEntity<List<ResourceResolution>> = runBlocking {
+ @RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String
+ ):
+ ResponseEntity<List<ResourceResolution>> = runBlocking {
if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) {
throw ResolutionException("Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.")
@@ -76,36 +89,46 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
.body(resourceResolutionDBService.readWithResolutionKey(bpName, bpVersion, artifactName, resolutionKey))
} else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
ResponseEntity.ok()
- .body(resourceResolutionDBService.readWithResourceIdAndResourceType(bpName,
- bpVersion,
- resourceId,
- resourceType))
+ .body(
+ resourceResolutionDBService.readWithResourceIdAndResourceType(
+ bpName,
+ bpVersion,
+ resourceId,
+ resourceType
+ )
+ )
} else {
throw ResolutionException("Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.")
}
}
- @RequestMapping(path = ["/resource"],
+ @RequestMapping(
+ path = ["/resource"],
method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Fetch a resource value using resolution key.",
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @ApiOperation(
+ value = "Fetch a resource value using resolution key.",
notes = "Retrieve a stored resource value using the blueprint metadata, artifact name, resolution-key along with the name of the resource value to retrieve.",
- produces = MediaType.APPLICATION_JSON_VALUE)
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun getOneFromResolutionKey(@ApiParam(value = "Name of the CBA.", required = true)
- @RequestParam(value = "bpName", required = true) bpName: String,
- @ApiParam(value = "Version of the CBA.", required = true)
- @RequestParam(value = "bpVersion", required = true) bpVersion: String,
- @ApiParam(value = "Artifact name for which to retrieve a resolved resource.", required = true)
- @RequestParam(value = "artifactName", required = true) artifactName: String,
- @ApiParam(value = "Resolution Key associated with the resolution.", required = true)
- @RequestParam(value = "resolutionKey", required = true) resolutionKey: String,
- @ApiParam(value = "Name of the resource to retrieve.", required = true)
- @RequestParam(value = "name", required = true) name: String)
- : ResponseEntity<ResourceResolution> = runBlocking {
+ fun getOneFromResolutionKey(
+ @ApiParam(value = "Name of the CBA.", required = true)
+ @RequestParam(value = "bpName", required = true) bpName: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
+ @RequestParam(value = "bpVersion", required = true) bpVersion: String,
+ @ApiParam(value = "Artifact name for which to retrieve a resolved resource.", required = true)
+ @RequestParam(value = "artifactName", required = true) artifactName: String,
+ @ApiParam(value = "Resolution Key associated with the resolution.", required = true)
+ @RequestParam(value = "resolutionKey", required = true) resolutionKey: String,
+ @ApiParam(value = "Name of the resource to retrieve.", required = true)
+ @RequestParam(value = "name", required = true) name: String
+ ):
+ ResponseEntity<ResourceResolution> = runBlocking {
ResponseEntity.ok()
.body(resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name))
}
-} \ No newline at end of file
+}
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 42ff8016c..5d5623d4f 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
@@ -23,16 +23,16 @@ import com.fasterxml.jackson.annotation.JsonTypeName
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
import org.slf4j.LoggerFactory
+import org.springframework.dao.EmptyResultDataAccessException
+import org.springframework.dao.IncorrectResultSizeDataAccessException
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.orm.jpa.JpaObjectRetrievalFailureException
-import org.springframework.dao.EmptyResultDataAccessException
-import org.springframework.dao.IncorrectResultSizeDataAccessException
-import org.springframework.web.server.ServerWebInputException
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
+import org.springframework.web.server.ServerWebInputException
import java.io.Serializable
-import java.util.*
+import java.util.Date
/**
* Handle exceptions in Resolution API and provide relevant HTTP status codes and messages
@@ -86,9 +86,11 @@ open class ResourceExceptionHandler {
fun returnError(e: Exception, errorCode: ErrorCode): ResponseEntity<ErrorMessage> {
log.error(e.message, e)
val errorMessage =
- ErrorMessage(errorCode.message(e.message!!),
+ ErrorMessage(
+ errorCode.message(e.message!!),
errorCode.value,
- debugMsg)
+ debugMsg
+ )
return ResponseEntity(errorMessage, HttpStatus.resolve(errorCode.httpCode)!!)
}
@@ -103,6 +105,7 @@ open class ResourceExceptionHandler {
@JsonTypeName("errorMessage")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
class ErrorMessage(var message: String?, var code: Int?, var debugMessage: String?) : Serializable {
+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
var timestamp = Date()
-} \ No newline at end of file
+}
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 93253a554..5913bde1d 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
@@ -27,7 +27,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestMethod
+import org.springframework.web.bind.annotation.RequestParam
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
/**
* Exposes Template Resolution API to store and retrieve rendered template results.
@@ -37,26 +44,34 @@ import org.springframework.web.bind.annotation.*
*/
@RestController
@RequestMapping("/api/v1/template")
-@Api(value = "/api/v1/template",
- description = "Interaction with resolved template.")
+@Api(
+ value = "/api/v1/template",
+ description = "Interaction with resolved template."
+)
open class TemplateController(private val templateResolutionService: TemplateResolutionService) {
- @RequestMapping(path = ["/health-check"],
+ @RequestMapping(
+ path = ["/health-check"],
method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
fun templateControllerHealthCheck(): JsonNode = runBlocking {
JacksonUtils.getJsonNode("Success")
}
- @RequestMapping(path = [""],
+ @RequestMapping(
+ path = [""],
method = [RequestMethod.GET],
- produces = [MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE])
- @ApiOperation(value = "Retrieve a resolved template.",
+ produces = [MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE]
+ )
+ @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")
+ " to expect in return"
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
fun get(
@@ -72,11 +87,14 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@RequestParam(value = "resourceType", required = false, defaultValue = "") resourceType: String,
@ApiParam(value = "Resource Id associated with the resolution.", required = false)
@RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String,
- @ApiParam(value = "Expected format of the template being retrieved.",
+ @ApiParam(
+ value = "Expected format of the template being retrieved.",
defaultValue = MediaType.TEXT_PLAIN_VALUE,
- required = true)
- @RequestParam(value = "format", required = false, defaultValue = MediaType.TEXT_PLAIN_VALUE) format: String)
- : ResponseEntity<String> = runBlocking {
+ required = true
+ )
+ @RequestParam(value = "format", required = false, defaultValue = MediaType.TEXT_PLAIN_VALUE) format: String
+ ):
+ ResponseEntity<String> = runBlocking {
var result = ""
@@ -87,7 +105,8 @@ open class TemplateController(private val templateResolutionService: TemplateRes
bpName,
bpVersion,
artifactName,
- resolutionKey)
+ resolutionKey
+ )
} else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
result =
templateResolutionService.findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(
@@ -95,12 +114,12 @@ open class TemplateController(private val templateResolutionService: TemplateRes
bpVersion,
artifactName,
resourceId,
- resourceType)
+ resourceType
+ )
} else {
throw ResolutionException("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"
@@ -110,13 +129,14 @@ open class TemplateController(private val templateResolutionService: TemplateRes
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",
+ @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.",
response = TemplateResolution::class,
- produces = MediaType.APPLICATION_JSON_VALUE)
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
fun postWithResolutionKey(
@@ -129,7 +149,8 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@ApiParam(value = "Resolution Key associated with the resolution.", required = true)
@PathVariable(value = "resolutionKey") resolutionKey: String,
@ApiParam(value = "Template to store.", required = true)
- @RequestBody result: String): ResponseEntity<TemplateResolution> = runBlocking {
+ @RequestBody result: String
+ ): ResponseEntity<TemplateResolution> = runBlocking {
val resultStored =
templateResolutionService.write(bpName, bpVersion, artifactName, result, resolutionKey = resolutionKey)
@@ -137,13 +158,17 @@ open class TemplateController(private val templateResolutionService: TemplateRes
ResponseEntity.ok().body(resultStored)
}
- @PostMapping("/{bpName}/{bpVersion}/{artifactName}/{resourceType}/{resourceId}",
- produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Store a resolved template w/ resourceId and resourceType",
+ @PostMapping(
+ "/{bpName}/{bpVersion}/{artifactName}/{resourceType}/{resourceId}",
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @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.",
response = TemplateResolution::class,
- produces = MediaType.APPLICATION_JSON_VALUE)
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
fun postWithResourceIdAndResourceType(
@@ -158,7 +183,8 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@ApiParam(value = "Resource Id associated with the resolution.", required = false)
@PathVariable(value = "resourceId", required = true) resourceId: String,
@ApiParam(value = "Template to store.", required = true)
- @RequestBody result: String): ResponseEntity<TemplateResolution> = runBlocking {
+ @RequestBody result: String
+ ): ResponseEntity<TemplateResolution> = runBlocking {
val resultStored =
templateResolutionService.write(bpName, bpVersion, artifactName, result, resourceId = resourceId, resourceType = resourceType)
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 85ac7bddd..60b24131f 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
@@ -22,6 +22,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolution
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionDBService
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -35,8 +36,6 @@ import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import org.springframework.test.web.reactive.server.WebTestClient
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-
@RunWith(SpringRunner::class)
@WebFluxTest
@@ -88,8 +87,10 @@ class ResourceControllerTest {
.consumeWith {
val json = String(it.responseBody!!)
val typeFactory = JacksonUtils.objectMapper.typeFactory
- val list: List<ResourceResolution> = JacksonUtils.objectMapper.readValue(json,
- typeFactory.constructCollectionType(List::class.java, ResourceResolution::class.java))
+ val list: List<ResourceResolution> = JacksonUtils.objectMapper.readValue(
+ json,
+ typeFactory.constructCollectionType(List::class.java, ResourceResolution::class.java)
+ )
Assert.assertEquals(2, list.size)
assertEqual(ra1, list[0])
assertEqual(ra1, list[0])
@@ -119,8 +120,10 @@ class ResourceControllerTest {
.consumeWith {
val json = String(it.responseBody!!)
val typeFactory = JacksonUtils.objectMapper.typeFactory
- val list: List<ResourceResolution> = JacksonUtils.objectMapper.readValue(json,
- typeFactory.constructCollectionType(List::class.java, ResourceResolution::class.java))
+ val list: List<ResourceResolution> = JacksonUtils.objectMapper.readValue(
+ json,
+ typeFactory.constructCollectionType(List::class.java, ResourceResolution::class.java)
+ )
Assert.assertEquals(2, list.size)
assertEqual(ra1, list[0])
assertEqual(ra1, list[0])
@@ -128,7 +131,6 @@ class ResourceControllerTest {
}
}
-
@Test
fun getAllFromMissingParamTest() {
runBlocking {
@@ -140,8 +142,10 @@ class ResourceControllerTest {
.expectBody()
.consumeWith {
val r = JacksonUtils.objectMapper.readValue(it.responseBody, ErrorMessage::class.java)
- Assert.assertEquals("Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.",
- r.message)
+ Assert.assertEquals(
+ "Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.",
+ r.message
+ )
}
}
}
@@ -157,8 +161,10 @@ class ResourceControllerTest {
.expectBody()
.consumeWith {
val r = JacksonUtils.objectMapper.readValue(it.responseBody, ErrorMessage::class.java)
- Assert.assertEquals("Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.",
- r.message)
+ Assert.assertEquals(
+ "Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.",
+ r.message
+ )
}
}
}
@@ -195,15 +201,21 @@ class ResourceControllerTest {
}
}
- private suspend fun store(resourceAssignment: ResourceAssignment, resKey: String = "", resId: String = "",
- resType: String = "") {
- resourceResolutionDBService.write(blueprintName,
+ private suspend fun store(
+ resourceAssignment: ResourceAssignment,
+ resKey: String = "",
+ resId: String = "",
+ resType: String = ""
+ ) {
+ resourceResolutionDBService.write(
+ blueprintName,
blueprintVersion,
resKey,
resId,
resType,
templatePrefix,
- resourceAssignment)
+ resourceAssignment
+ )
}
private fun createRA(prefix: String): ResourceAssignment {
@@ -221,8 +233,10 @@ class ResourceControllerTest {
}
private fun assertEqual(resourceAssignment: ResourceAssignment, resourceResolution: ResourceResolution) {
- Assert.assertEquals(JacksonUtils.getValue(resourceAssignment.property?.value!!).toString(),
- resourceResolution.value)
+ Assert.assertEquals(
+ JacksonUtils.getValue(resourceAssignment.property?.value!!).toString(),
+ resourceResolution.value
+ )
Assert.assertEquals(resourceAssignment.status, resourceResolution.status)
Assert.assertEquals(resourceAssignment.dictionarySource, resourceResolution.dictionarySource)
Assert.assertEquals(resourceAssignment.dictionaryName, resourceResolution.dictionaryName)
@@ -230,6 +244,5 @@ class ResourceControllerTest {
Assert.assertEquals(resourceAssignment.name, resourceResolution.name)
Assert.assertEquals(blueprintVersion, resourceResolution.blueprintVersion)
Assert.assertEquals(blueprintName, resourceResolution.blueprintName)
-
}
-} \ No newline at end of file
+}
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 c3a718e11..baf0aa7c1 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 = [BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SecurityProperties::class])
+@ContextConfiguration(
+ classes = [BluePrintCoreConfiguration::class,
+ BluePrintCatalogService::class, SecurityProperties::class]
+)
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class TemplateControllerTest {
@@ -129,8 +131,10 @@ class TemplateControllerTest {
webTestClient
.get()
- .uri("/api/v1/template?bpName=$blueprintName&bpVersion=$blueprintVersion" +
- "&artifactName=$templatePrefix&resolutionKey=notFound")
+ .uri(
+ "/api/v1/template?bpName=$blueprintName&bpVersion=$blueprintVersion" +
+ "&artifactName=$templatePrefix&resolutionKey=notFound"
+ )
.exchange()
.expectStatus().isNotFound
}
@@ -172,4 +176,4 @@ class TemplateControllerTest {
.expectBody().equals(payloadDummyTemplateData)
}
}
-} \ No newline at end of file
+}
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 b25acd148..305437923 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
@@ -31,16 +31,20 @@ import java.util.concurrent.Phaser
import javax.annotation.PreDestroy
@Service
-open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
- private val executionServiceHandler: ExecutionServiceHandler)
- : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
+open class BluePrintProcessingGRPCHandler(
+ private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+ private val executionServiceHandler: ExecutionServiceHandler
+) :
+ BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
+
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
private val ph = Phaser(1)
@PreAuthorize("hasRole('USER')")
override fun process(
- responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
+ responseObserver: StreamObserver<ExecutionServiceOutput>
+ ): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
@@ -51,17 +55,18 @@ open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration
}
} catch (e: Exception) {
onError(e)
- }
- finally {
+ } finally {
ph.arriveAndDeregister()
}
}
override fun onError(error: Throwable) {
log.debug("Fail to process message", error)
- responseObserver.onError(io.grpc.Status.INTERNAL
+ responseObserver.onError(
+ io.grpc.Status.INTERNAL
.withDescription(error.message)
- .asException())
+ .asException()
+ )
}
override fun onCompleted() {
@@ -77,4 +82,4 @@ open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration
ph.arriveAndAwaitAdvance()
log.info("Done waiting in $name")
}
-} \ No newline at end of file
+}
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 a9dda7e0c..6293f48f4 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
@@ -32,12 +32,15 @@ import org.springframework.stereotype.Service
import java.util.concurrent.Phaser
import javax.annotation.PreDestroy
-@ConditionalOnProperty(name = ["blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable"],
- havingValue = "true")
+@ConditionalOnProperty(
+ name = ["blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable"],
+ havingValue = "true"
+)
@Service
open class BluePrintProcessingKafkaConsumer(
- private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService,
- private val executionServiceHandler: ExecutionServiceHandler) {
+ private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService,
+ private val executionServiceHandler: ExecutionServiceHandler
+) {
val log = logger(BluePrintProcessingKafkaConsumer::class)
@@ -53,13 +56,15 @@ open class BluePrintProcessingKafkaConsumer(
@EventListener(ApplicationReadyEvent::class)
fun setupMessageListener() = runBlocking {
try {
- log.info("Setting up message consumer($CONSUMER_SELECTOR) and " +
- "message producer($PRODUCER_SELECTOR)...")
+ log.info(
+ "Setting up message consumer($CONSUMER_SELECTOR) and " +
+ "message producer($PRODUCER_SELECTOR)..."
+ )
/** Get the Message Consumer Service **/
blueprintMessageConsumerService = try {
bluePrintMessageLibPropertyService
- .blueprintMessageConsumerService(CONSUMER_SELECTOR)
+ .blueprintMessageConsumerService(CONSUMER_SELECTOR)
} catch (e: Exception) {
throw BluePrintProcessorException("failed to create consumer service ${e.message}")
}
@@ -67,7 +72,7 @@ open class BluePrintProcessingKafkaConsumer(
/** Get the Message Producer Service **/
val blueprintMessageProducerService = try {
bluePrintMessageLibPropertyService
- .blueprintMessageProducerService(PRODUCER_SELECTOR)
+ .blueprintMessageProducerService(PRODUCER_SELECTOR)
} catch (e: Exception) {
throw BluePrintProcessorException("failed to create producer service ${e.message}")
}
@@ -83,34 +88,36 @@ open class BluePrintProcessingKafkaConsumer(
log.trace("Consumed Message : $message")
val executionServiceInput = message.jsonAsType<ExecutionServiceInput>()
val executionServiceOutput = executionServiceHandler.doProcess(executionServiceInput)
- //TODO("In future, Message publisher configuration vary with respect to request")
+ // TODO("In future, Message publisher configuration vary with respect to request")
/** Send the response message */
blueprintMessageProducerService.sendMessage(executionServiceOutput)
} catch (e: Exception) {
log.error("failed in processing the consumed message : $message", e)
- }
- finally {
+ } finally {
ph.arriveAndDeregister()
}
}
}
}
} catch (e: Exception) {
- log.error("failed to start message consumer($CONSUMER_SELECTOR) and " +
- "message producer($PRODUCER_SELECTOR) ", e)
+ log.error(
+ "failed to start message consumer($CONSUMER_SELECTOR) and " +
+ "message producer($PRODUCER_SELECTOR) ", e
+ )
}
}
@PreDestroy
fun shutdownMessageListener() = runBlocking {
try {
- log.info("Shutting down message consumer($CONSUMER_SELECTOR) and " +
- "message producer($PRODUCER_SELECTOR)...")
+ log.info(
+ "Shutting down message consumer($CONSUMER_SELECTOR) and " +
+ "message producer($PRODUCER_SELECTOR)..."
+ )
blueprintMessageConsumerService.shutDown()
ph.arriveAndAwaitAdvance()
} catch (e: Exception) {
log.error("failed to shutdown message listener($CONSUMER_SELECTOR)", e)
}
}
-
-} \ No newline at end of file
+}
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 130e23ecc..02d3f2026 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
@@ -32,16 +32,23 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestMethod
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono
import java.util.concurrent.Phaser
import javax.annotation.PreDestroy
@RestController
@RequestMapping("/api/v1/execution-service")
-@Api(value = "/api/v1/execution-service",
- description = "Interaction with CBA.")
+@Api(
+ value = "/api/v1/execution-service",
+ description = "Interaction with CBA."
+)
open class ExecutionServiceController {
+
val log = logger(ExecutionServiceController::class)
private val ph = Phaser(1)
@@ -49,9 +56,11 @@ open class ExecutionServiceController {
@Autowired
lateinit var executionServiceHandler: ExecutionServiceHandler
- @RequestMapping(path = ["/health-check"],
- method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(
+ path = ["/health-check"],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
fun executionServiceControllerHealthCheck() = monoMdc(Dispatchers.IO) {
@@ -59,15 +68,19 @@ open class ExecutionServiceController {
}
@RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Execute a CBA workflow (action)",
- notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.",
- produces = MediaType.APPLICATION_JSON_VALUE,
- response = ExecutionServiceOutput::class)
+ @ApiOperation(
+ value = "Execute a CBA workflow (action)",
+ notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.",
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ response = ExecutionServiceOutput::class
+ )
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun process(@ApiParam(value = "ExecutionServiceInput payload.", required = true)
- @RequestBody executionServiceInput: ExecutionServiceInput)
- : Mono<ResponseEntity<ExecutionServiceOutput>> = monoMdc(Dispatchers.IO) {
+ fun process(
+ @ApiParam(value = "ExecutionServiceInput payload.", required = true)
+ @RequestBody executionServiceInput: ExecutionServiceInput
+ ):
+ Mono<ResponseEntity<ExecutionServiceOutput>> = monoMdc(Dispatchers.IO) {
if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
@@ -87,4 +100,3 @@ open class ExecutionServiceController {
log.info("Done waiting in $name")
}
}
-
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 356f0f7ee..9524e375e 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
@@ -21,7 +21,11 @@ import io.grpc.stub.StreamObserver
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.toProto
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractServiceFunction
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
@@ -36,15 +40,19 @@ import org.springframework.stereotype.Service
import java.util.stream.Collectors
@Service
-class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val blueprintsProcessorCatalogService: BluePrintCatalogService,
- private val bluePrintWorkflowExecutionService
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>) {
+class ExecutionServiceHandler(
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val blueprintsProcessorCatalogService: BluePrintCatalogService,
+ private val bluePrintWorkflowExecutionService:
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>
+) {
private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
- suspend fun process(executionServiceInput: ExecutionServiceInput,
- responseObserver: StreamObserver<org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput>) {
+ suspend fun process(
+ executionServiceInput: ExecutionServiceInput,
+ responseObserver: StreamObserver<org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput>
+ ) {
when {
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> {
GlobalScope.launch(Dispatchers.Default) {
@@ -59,9 +67,13 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL
responseObserver.onNext(executionServiceOutput.toProto())
responseObserver.onCompleted()
}
- else -> responseObserver.onNext(response(executionServiceInput,
+ else -> responseObserver.onNext(
+ response(
+ executionServiceInput,
"Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
- true).toProto());
+ true
+ ).toProto()
+ )
}
}
@@ -81,8 +93,10 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL
val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString())
- val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService,
- executionServiceInput, hashMapOf())
+ val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow(
+ blueprintRuntimeService,
+ executionServiceInput, hashMapOf()
+ )
val errors = blueprintRuntimeService.getBluePrintError().errors
if (errors.isNotEmpty()) {
@@ -118,8 +132,11 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL
status.message = BluePrintConstants.STATUS_FAILURE
}
- private fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "",
- failure: Boolean = false): ExecutionServiceOutput {
+ private fun response(
+ executionServiceInput: ExecutionServiceInput,
+ errorMessage: String = "",
+ failure: Boolean = false
+ ): ExecutionServiceOutput {
val executionServiceOutput = ExecutionServiceOutput()
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
@@ -138,5 +155,4 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL
return executionServiceOutput
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
index 16fe36cfe..66cdbef3e 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
@@ -22,7 +22,7 @@ import org.springframework.util.StringUtils
import java.io.File
import java.io.IOException
import java.nio.file.Path
-import java.util.*
+import java.util.UUID
const val INTERNAL_SERVER_ERROR_HTTP_STATUS_CODE = 500
@@ -55,8 +55,8 @@ fun determineHttpStatusCode(statusCode: Int): HttpStatus {
try {
return HttpStatus.valueOf(statusCode)
} catch (exception: Exception) {
- //if statusCode cannot be converted to a proper HttpStatus, the resource still needs to assign a HTTP status
+ // if statusCode cannot be converted to a proper HttpStatus, the resource still needs to assign a HTTP status
// code to the response. In this case, a 500 Internal Server Error will be returned as default.
return HttpStatus.valueOf(INTERNAL_SERVER_ERROR_HTTP_STATUS_CODE)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt
index ab0d4256c..ff615536b 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt
@@ -22,6 +22,8 @@ import org.onap.ccsdk.cds.controllerblueprints.validation.extension.ResourceDefi
import org.springframework.stereotype.Service
@Service("bluePrintRuntimeValidatorService")
-open class BluePrintRuntimeValidatorService(bluePrintTypeValidatorService: BluePrintTypeValidatorService,
- resourceDefinitionValidator: ResourceDefinitionValidator)
- : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService, resourceDefinitionValidator)
+open class BluePrintRuntimeValidatorService(
+ bluePrintTypeValidatorService: BluePrintTypeValidatorService,
+ resourceDefinitionValidator: ResourceDefinitionValidator
+) :
+ BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService, resourceDefinitionValidator)
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 8bedc9628..e990c90d8 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
@@ -18,7 +18,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
-
import com.google.protobuf.util.JsonFormat
import io.grpc.stub.StreamObserver
import io.grpc.testing.GrpcServerRule
@@ -44,10 +43,13 @@ import kotlin.test.BeforeTest
@RunWith(SpringRunner::class)
@DirtiesContext
@EnableAutoConfiguration
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
- "org.onap.ccsdk.cds.controllerblueprints"])
+@ComponentScan(
+ basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
+ "org.onap.ccsdk.cds.controllerblueprints"]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintProcessingGRPCHandlerTest {
+
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)
@get:Rule
@@ -68,7 +70,10 @@ class BluePrintProcessingGRPCHandlerTest {
override fun onNext(executionServiceOuput: ExecutionServiceOutput) {
log.debug("onNext {}", executionServiceOuput)
if ("1234".equals(executionServiceOuput.commonHeader.requestId)) {
- Assert.assertEquals("Failed to process request, \'actionIdentifiers.mode\' not specified. Valid value are: \'sync\' or \'async\'.", executionServiceOuput.status.errorMessage)
+ Assert.assertEquals(
+ "Failed to process request, \'actionIdentifiers.mode\' not specified. Valid value are: \'sync\' or \'async\'.",
+ executionServiceOuput.status.errorMessage
+ )
}
}
@@ -86,39 +91,38 @@ class BluePrintProcessingGRPCHandlerTest {
@Test
fun testSelfServiceGRPCHandler() {
val commonHeader = CommonHeader.newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId("1234")
- .setSubRequestId("1234-56").build()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("1234")
+ .setSubRequestId("1234-56").build()
val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
JsonFormat.parser().merge(jsonContent, payloadBuilder)
val input = ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setPayload(payloadBuilder.build())
- .build()
+ .setCommonHeader(commonHeader)
+ .setPayload(payloadBuilder.build())
+ .build()
requestObs.onNext(input)
val commonHeader2 = CommonHeader.newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId("2345")
- .setSubRequestId("1234-56").build()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("2345")
+ .setSubRequestId("1234-56").build()
val actionIdentifier = ActionIdentifiers.newBuilder().setMode("sync").build()
val input2 = ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader2)
- .setActionIdentifiers(actionIdentifier)
- .setPayload(payloadBuilder.build())
- .build()
+ .setCommonHeader(commonHeader2)
+ .setActionIdentifiers(actionIdentifier)
+ .setPayload(payloadBuilder.build())
+ .build()
requestObs.onNext(input2)
requestObs.onCompleted()
}
-
-} \ No newline at end of file
+}
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 8971ebde2..b26781ad2 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
@@ -36,7 +36,7 @@ class BluePrintProcessingIntegrationTest {
private val log = logger(BluePrintProcessingIntegrationTest::class)
/** This is Integration test sample, Do not enable this test case in server build, this is for local desktop testing*/
- //@Test
+ // @Test
fun integrationTestGrpcManagement() {
runBlocking {
val tokenAuthGrpcClientProperties = TokenAuthGrpcClientProperties().apply {
@@ -65,26 +65,26 @@ class BluePrintProcessingIntegrationTest {
})
val commonHeader = CommonHeader.newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId("1234-$it")
- .setSubRequestId("1234-56").build()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("1234-$it")
+ .setSubRequestId("1234-56").build()
val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
JsonFormat.parser().merge(jsonContent, payloadBuilder)
val actionIdentifier = ActionIdentifiers.newBuilder()
- .setActionName("SampleScript")
- .setBlueprintName("sample-cba")
- .setBlueprintVersion("1.0.0")
- .build()
+ .setActionName("SampleScript")
+ .setBlueprintName("sample-cba")
+ .setBlueprintVersion("1.0.0")
+ .build()
val input = ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(actionIdentifier)
- .setPayload(payloadBuilder.build())
- .build()
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(actionIdentifier)
+ .setPayload(payloadBuilder.build())
+ .build()
requestObs.onNext(input)
requestObs.onCompleted()
@@ -93,4 +93,4 @@ class BluePrintProcessingIntegrationTest {
channel.shutdownNow()
}
}
-} \ No newline at end of file
+}
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 01199c131..f71d1b444 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
@@ -34,8 +34,10 @@ import kotlin.test.Test
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class])
+@ContextConfiguration(
+ classes = [BluePrintMessageLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintProcessingKafkaConsumerTest {
@@ -45,15 +47,19 @@ class BluePrintProcessingKafkaConsumerTest {
@Test
fun testExecutionInputMessageConsumer() {
runBlocking {
- assertNotNull(bluePrintMessageLibPropertyService,
- "failed to initialise bluePrintMessageLibPropertyService")
+ assertNotNull(
+ bluePrintMessageLibPropertyService,
+ "failed to initialise bluePrintMessageLibPropertyService"
+ )
val executionServiceHandle = mockk<ExecutionServiceHandler>()
coEvery { executionServiceHandle.doProcess(any()) } returns mockk()
- val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer(bluePrintMessageLibPropertyService,
- executionServiceHandle)
+ val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer(
+ bluePrintMessageLibPropertyService,
+ executionServiceHandle
+ )
launch {
bluePrintProcessingKafkaConsumer.setupMessageListener()
@@ -62,5 +68,4 @@ class BluePrintProcessingKafkaConsumerTest {
bluePrintProcessingKafkaConsumer.shutdownMessageListener()
}
}
-
-} \ No newline at end of file
+}
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 e1a498a6f..a6ebe9c3e 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
@@ -36,17 +36,21 @@ import org.springframework.test.context.junit4.SpringRunner
import org.springframework.test.web.reactive.server.WebTestClient
import org.springframework.web.reactive.function.BodyInserters
import java.io.File
-import java.util.*
+import java.util.UUID
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SecurityProperties::class])
-@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
- "org.onap.ccsdk.cds.controllerblueprints"])
+@ContextConfiguration(
+ classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class,
+ BluePrintCatalogService::class, SecurityProperties::class]
+)
+@ComponentScan(
+ basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor",
+ "org.onap.ccsdk.cds.controllerblueprints"]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class ExecutionServiceControllerTest {
@@ -71,15 +75,17 @@ class ExecutionServiceControllerTest {
blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
val executionServiceInput = JacksonUtils
- .readValueFromClassPathFile("execution-input/default-input.json",
- ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile(
+ "execution-input/default-input.json",
+ ExecutionServiceInput::class.java
+ )!!
webTestClient
- .post()
- .uri("/api/v1/execution-service/process")
- .body(BodyInserters.fromObject(executionServiceInput))
- .exchange()
- .expectStatus().isOk
+ .post()
+ .uri("/api/v1/execution-service/process")
+ .body(BodyInserters.fromObject(executionServiceInput))
+ .exchange()
+ .expectStatus().isOk
}
}
@@ -89,15 +95,17 @@ class ExecutionServiceControllerTest {
blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
val executionServiceInput = JacksonUtils
- .readValueFromClassPathFile("execution-input/faulty-input.json",
- ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile(
+ "execution-input/faulty-input.json",
+ ExecutionServiceInput::class.java
+ )!!
webTestClient
- .post()
- .uri("/api/v1/execution-service/process")
- .body(BodyInserters.fromObject(executionServiceInput))
- .exchange()
- .expectStatus().is5xxServerError
+ .post()
+ .uri("/api/v1/execution-service/process")
+ .body(BodyInserters.fromObject(executionServiceInput))
+ .exchange()
+ .expectStatus().is5xxServerError
}
}
@@ -106,4 +114,4 @@ class ExecutionServiceControllerTest {
assertTrue(testCbaFile.exists(), "couldn't get file ${testCbaFile.absolutePath}")
return testCbaFile
}
-} \ No newline at end of file
+}
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 293da0da6..5a44403e1 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
@@ -73,12 +73,12 @@ class ExecutionServiceHandlerTest {
@Service("mock-service-action")
class MockServiceAction : AbstractServiceFunction() {
+
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val responsePayload = """{"answer" : "correct"}""".jsonAsJsonType()
setResponsePayloadForAction(responsePayload)
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
-
}
-} \ No newline at end of file
+}
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 27130a7bc..9f5cc6097 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
@@ -41,8 +41,10 @@ class MockComponentFunction : AbstractComponentFunction() {
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
log.info("Processing component : $operationInputs")
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- "assignment-params", "params".asJsonPrimitive())
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ "assignment-params", "params".asJsonPrimitive()
+ )
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
@@ -51,13 +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"])
+ @Bean(
+ name = [
+ "rr-processor-source-input",
+ "rr-processor-source-default",
+ "rr-processor-source-db",
+ "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/utils/Utils.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/UtilsTest.kt
index 07d8ca4e1..db2791101 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/Utils.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/utils/UtilsTest.kt
@@ -23,5 +23,4 @@ class UtilsTest {
val nonExistentHttpStatusCode = determineHttpStatusCode(999999)
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, nonExistentHttpStatusCode)
}
-
-} \ No newline at end of file
+}
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 08da9dc28..820c4be42 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
@@ -26,8 +26,10 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintRuntimeValidatorService::class,
- BluePrintValidationConfiguration::class, MockResourceSource::class])
+@ContextConfiguration(
+ classes = [BluePrintRuntimeValidatorService::class,
+ BluePrintValidationConfiguration::class, MockResourceSource::class]
+)
class BluePrintRuntimeValidatorServiceTest {
@Autowired
@@ -39,6 +41,5 @@ class BluePrintRuntimeValidatorServiceTest {
assertNotNull(bluePrintRuntimeValidatorService, " failed to initilize bluePrintRuntimeValidatorService")
bluePrintRuntimeValidatorService.validateBluePrints(blueprintBasePath)
-
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index bee919249..1abac7f3d 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution
-
import com.fasterxml.jackson.databind.JsonNode
import kotlinx.coroutines.withTimeout
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
@@ -25,8 +24,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutp
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.getAsString
+import org.onap.ccsdk.cds.controllerblueprints.core.getOptionalAsInt
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
import org.slf4j.LoggerFactory
@@ -36,6 +42,7 @@ import org.slf4j.LoggerFactory
* @author Brinda Santh
*/
abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
+
@Transient
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
@@ -85,7 +92,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }
val operationResolvedProperties = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
+ .resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
this.operationInputs.putAll(operationResolvedProperties)
@@ -103,7 +110,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
try {
// Resolve the Output Expression
val stepOutputs = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
+ .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
val stepOutputData = StepData().apply {
name = stepName
@@ -135,7 +142,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
fun getOperationInput(key: String): JsonNode {
return operationInputs[key]
- ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
+ ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
}
fun getOptionalOperationInput(key: String): JsonNode? {
@@ -188,5 +195,4 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
val file = normalizedFile(bluePrintRuntimeService.bluePrintContext().rootPath, artifactDefinition.file)
return file.readNBLines()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt
index f17085ef1..041588616 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt
@@ -45,7 +45,7 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() {
@Deprecated("Dependencies will be resolved dynamically")
open fun <T> functionDependencyInstanceAsType(name: String): T {
return functionDependencyInstances[name] as? T
- ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
}
fun checkDynamicProperties(key: String): Boolean {
@@ -125,4 +125,4 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() {
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
throw BluePrintException("Not Implemented, child class will implement this")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt
index 67ab9c4de..e573afd7a 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt
@@ -109,4 +109,4 @@ abstract class AbstractServiceFunction : BlueprintFunctionNode<ExecutionServiceI
}
return executionServiceInput.payload.jsonPathParse(".$requestExpression")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
index 062d370bc..4c7d5d0ec 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
@@ -28,21 +28,29 @@ import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
@Service
-class ComponentFunctionScriptingService(private val applicationContext: ApplicationContext,
- private val blueprintJythonService: BlueprintJythonService) {
+class ComponentFunctionScriptingService(
+ private val applicationContext: ApplicationContext,
+ private val blueprintJythonService: BlueprintJythonService
+) {
private val log = LoggerFactory.getLogger(ComponentFunctionScriptingService::class.java)
- suspend fun <T : AbstractScriptComponentFunction> scriptInstance(componentFunction: AbstractComponentFunction,
- scriptType: String,
- scriptClassReference: String,
- instanceDependencies: List<String>): T {
+ suspend fun <T : AbstractScriptComponentFunction> scriptInstance(
+ componentFunction: AbstractComponentFunction,
+ scriptType: String,
+ scriptClassReference: String,
+ instanceDependencies: List<String>
+ ): T {
- log.info("creating component function of script type($scriptType), reference name($scriptClassReference) and " +
- "instanceDependencies($instanceDependencies)")
+ log.info(
+ "creating component function of script type($scriptType), reference name($scriptClassReference) and " +
+ "instanceDependencies($instanceDependencies)"
+ )
- val scriptComponent: T = scriptInstance(componentFunction.bluePrintRuntimeService.bluePrintContext(),
- scriptType, scriptClassReference)
+ val scriptComponent: T = scriptInstance(
+ componentFunction.bluePrintRuntimeService.bluePrintContext(),
+ scriptType, scriptClassReference
+ )
checkNotNull(scriptComponent) { "failed to initialize script component" }
@@ -60,14 +68,16 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
// Populate Instance Properties
instanceDependencies.forEach { instanceDependency ->
scriptComponent.functionDependencyInstances[instanceDependency] = applicationContext
- .getBean(instanceDependency)
+ .getBean(instanceDependency)
}
return scriptComponent
}
-
- suspend fun <T : BlueprintFunctionNode<*, *>> scriptInstance(bluePrintContext: BluePrintContext, scriptType: String,
- scriptClassReference: String): T {
+ suspend fun <T : BlueprintFunctionNode<*, *>> scriptInstance(
+ bluePrintContext: BluePrintContext,
+ scriptType: String,
+ scriptClassReference: String
+ ): T {
var scriptComponent: T? = null
when (scriptType) {
@@ -77,8 +87,10 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
}
BluePrintConstants.SCRIPT_KOTLIN -> {
val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl()
- scriptComponent = bluePrintScriptsService.scriptInstance<T>(bluePrintContext.rootPath,
- bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false)
+ scriptComponent = bluePrintScriptsService.scriptInstance<T>(
+ bluePrintContext.rootPath,
+ bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false
+ )
}
BluePrintConstants.SCRIPT_JYTHON -> {
scriptComponent = blueprintJythonService.jythonComponentInstance(bluePrintContext, scriptClassReference) as T
@@ -89,5 +101,4 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
}
return scriptComponent
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
index c66c3e913..09eee6717 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
@@ -28,8 +28,8 @@ import org.springframework.stereotype.Component
*/
@Component("component-script-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentScriptExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService)
- : AbstractComponentFunction() {
+open class ComponentScriptExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService) :
+ AbstractComponentFunction() {
companion object {
const val INPUT_SCRIPT_TYPE = "script-type"
@@ -53,8 +53,10 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService
val scriptDependencies: MutableList<String> = arrayListOf()
populateScriptDependencies(scriptDependencies)
- scriptComponentFunction = componentFunctionScriptingService.scriptInstance(this, scriptType,
- scriptClassReference, scriptDependencies)
+ scriptComponentFunction = componentFunctionScriptingService.scriptInstance(
+ this, scriptType,
+ scriptClassReference, scriptDependencies
+ )
// Handles both script processing and error handling
scriptComponentFunction.executeScript(executionServiceInput)
@@ -62,11 +64,10 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError()
- .addError("Failed in ComponentCliExecutor : ${runtimeException.message}")
-
+ .addError("Failed in ComponentCliExecutor : ${runtimeException.message}")
}
open fun populateScriptDependencies(scriptDependencies: MutableList<String>) {
/** Place holder for Child to add extra dependencies */
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
index 89338b781..d4ca0f487 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
@@ -31,52 +31,72 @@ import kotlin.reflect.KClass
/** Component Extensions **/
fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
- return nodeType(id = "component-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- description = "Generic Script Component Executor") {
+ return nodeType(
+ id = "component-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ description = "Generic Script Component Executor"
+ ) {
attribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false)
attribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING, true)
operation("ComponentScriptExecutor", "ComponentScriptExecutor Operation") {
inputs {
- property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Script Type") {
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Script Type"
+ ) {
defaultValue(BluePrintConstants.SCRIPT_INTERNAL)
constrain {
- validValues(listOf(BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
+ validValues(
+ listOf(
+ BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive(),
- BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive()))
+ BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive()
+ )
+ )
}
}
- property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Kotlin Script class name or jython script name.")
- property(ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Dynamic Json Content or DSL Json reference.")
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Kotlin Script class name or jython script name."
+ )
+ property(
+ ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Dynamic Json Content or DSL Json reference."
+ )
}
outputs {
- property(ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON,
- false, "Output Response")
- property(ComponentScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
- true, "Status of the Component Execution ( success or failure )")
+ property(
+ ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Output Response"
+ )
+ property(
+ ComponentScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Status of the Component Execution ( success or failure )"
+ )
}
}
}
}
/** Component Builder */
-fun BluePrintTypes.nodeTemplateComponentScriptExecutor(id: String,
- description: String,
- block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit)
- : NodeTemplate {
+fun BluePrintTypes.nodeTemplateComponentScriptExecutor(
+ id: String,
+ description: String,
+ block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit
+):
+ NodeTemplate {
return ComponentScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(id, "component-script-executor",
- "ComponentScriptExecutor",
- description) {
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
+ id, "component-script-executor",
+ "ComponentScriptExecutor",
+ description
+ ) {
class InputsBuilder : PropertiesAssignmentBuilder() {
@@ -117,4 +137,4 @@ class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String
property(ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, responseData)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt
index 806c33039..3ff54076d 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt
@@ -23,7 +23,6 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
open class ExecutionServiceConfiguration
-
object ExecutionServiceConstant {
const val SERVICE_GRPC_REMOTE_SCRIPT_EXECUTION = "grpc-remote-script-execution-service"
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
index d6146e111..3b83261e5 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
@@ -21,10 +21,19 @@ import com.google.protobuf.Struct
import com.google.protobuf.Timestamp
import com.google.protobuf.util.JsonFormat
import io.grpc.ManagedChannel
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteIdentifier
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StatusType
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService
-import org.onap.ccsdk.cds.controllerblueprints.command.api.*
+import org.onap.ccsdk.cds.controllerblueprints.command.api.CommandExecutorServiceGrpc
+import org.onap.ccsdk.cds.controllerblueprints.command.api.ExecutionInput
+import org.onap.ccsdk.cds.controllerblueprints.command.api.ExecutionOutput
+import org.onap.ccsdk.cds.controllerblueprints.command.api.Identifiers
+import org.onap.ccsdk.cds.controllerblueprints.command.api.Packages
+import org.onap.ccsdk.cds.controllerblueprints.command.api.PrepareEnvInput
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
@@ -41,11 +50,13 @@ interface RemoteScriptExecutionService {
}
@Service(ExecutionServiceConstant.SERVICE_GRPC_REMOTE_SCRIPT_EXECUTION)
-@ConditionalOnProperty(prefix = "blueprintprocessor.remoteScriptCommand", name = arrayOf("enabled"),
- havingValue = "true", matchIfMissing = false)
+@ConditionalOnProperty(
+ prefix = "blueprintprocessor.remoteScriptCommand", name = arrayOf("enabled"),
+ havingValue = "true", matchIfMissing = false
+)
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService)
- : RemoteScriptExecutionService {
+class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) :
+ RemoteScriptExecutionService {
private val log = LoggerFactory.getLogger(GrpcRemoteScriptExecutionService::class.java)!!
@@ -70,8 +81,8 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
}
}
- override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput)
- : RemoteScriptExecutionOutput {
+ override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput):
+ RemoteScriptExecutionOutput {
val grpResponse = commandExecutorServiceGrpc.prepareEnv(prepareEnvInput.asGrpcData())
checkNotNull(grpResponse.status) {
@@ -84,8 +95,8 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
return remoteScriptExecutionOutput
}
- override suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput)
- : RemoteScriptExecutionOutput {
+ override suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput):
+ RemoteScriptExecutionOutput {
val grpResponse = commandExecutorServiceGrpc.executeCommand(remoteExecutionInput.asGrpcData())
@@ -103,7 +114,6 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
channel?.shutdownNow()
}
-
fun PrepareRemoteEnvInput.asGrpcData(): PrepareEnvInput {
val correlationId = this.correlationId ?: this.requestId
@@ -116,33 +126,33 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
}
return PrepareEnvInput.newBuilder()
- .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
- .setRequestId(this.requestId)
- .setCorrelationId(correlationId)
- .setTimeOut(this.timeOut.toInt())
- .addAllPackages(packageList)
- .setProperties(this.properties.asGrpcData())
- .build()
+ .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
+ .setRequestId(this.requestId)
+ .setCorrelationId(correlationId)
+ .setTimeOut(this.timeOut.toInt())
+ .addAllPackages(packageList)
+ .setProperties(this.properties.asGrpcData())
+ .build()
}
fun RemoteScriptExecutionInput.asGrpcData(): ExecutionInput {
val correlationId = this.correlationId ?: this.requestId
return ExecutionInput.newBuilder()
- .setRequestId(this.requestId)
- .setCorrelationId(correlationId)
- .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
- .setCommand(this.command)
- .setTimeOut(this.timeOut.toInt())
- .setProperties(this.properties.asGrpcData())
- .setTimestamp(Timestamp.getDefaultInstance())
- .build()
+ .setRequestId(this.requestId)
+ .setCorrelationId(correlationId)
+ .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
+ .setCommand(this.command)
+ .setTimeOut(this.timeOut.toInt())
+ .setProperties(this.properties.asGrpcData())
+ .setTimestamp(Timestamp.getDefaultInstance())
+ .build()
}
fun RemoteIdentifier.asGrpcData(): Identifiers? {
return Identifiers.newBuilder()
- .setBlueprintName(this.blueprintName)
- .setBlueprintVersion(this.blueprintVersion)
- .build()
+ .setBlueprintName(this.blueprintName)
+ .setBlueprintVersion(this.blueprintVersion)
+ .build()
}
fun Map<String, JsonNode>.asGrpcData(): Struct {
@@ -153,11 +163,10 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
fun ExecutionOutput.asJavaData(): RemoteScriptExecutionOutput {
return RemoteScriptExecutionOutput(
- requestId = this.requestId,
- response = this.responseList,
- status = StatusType.valueOf(this.status.name),
- payload = payload.jsonAsJsonType()
+ requestId = this.requestId,
+ response = this.responseList,
+ status = StatusType.valueOf(this.status.name),
+ payload = payload.jsonAsJsonType()
)
}
-
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt
index adb1d67d2..239ff00c5 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt
@@ -20,10 +20,14 @@ import com.fasterxml.jackson.databind.JsonNode
import com.github.marcoferrer.krotoplus.coroutines.client.ClientBidiCallChannel
import com.github.marcoferrer.krotoplus.coroutines.client.clientCallBidiStreaming
import io.grpc.ManagedChannel
-import kotlinx.coroutines.*
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withTimeout
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService
@@ -50,10 +54,12 @@ interface StreamingRemoteExecutionService<ReqT, ResT> {
}
@Service
-@ConditionalOnProperty(prefix = "blueprintsprocessor.streamingRemoteExecution", name = ["enabled"],
- havingValue = "true", matchIfMissing = false)
-class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService)
- : StreamingRemoteExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+@ConditionalOnProperty(
+ prefix = "blueprintsprocessor.streamingRemoteExecution", name = ["enabled"],
+ havingValue = "true", matchIfMissing = false
+)
+class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) :
+ StreamingRemoteExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = logger(StreamingRemoteExecutionServiceImpl::class)
@@ -62,7 +68,6 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
private val commChannels: MutableMap<String,
ClientBidiCallChannel<ExecutionServiceInput, ExecutionServiceOutput>> = hashMapOf()
-
/**
* Open new channel to send and receive for grpc properties [selector] for [txId],
* Create the only one GRPC channel per host port and reuse for further communication.
@@ -84,7 +89,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
}
val commChannel = commChannels[txId]
- ?: throw BluePrintException("failed to create response subscription for transactionId($txId) channel")
+ ?: throw BluePrintException("failed to create response subscription for transactionId($txId) channel")
log.info("created subscription for transactionId($txId)")
@@ -97,7 +102,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
*/
override suspend fun send(txId: String, input: ExecutionServiceInput) {
val sendChannel = commChannels[txId]?.requestChannel
- ?: throw BluePrintException("failed to get transactionId($txId) send channel")
+ ?: throw BluePrintException("failed to get transactionId($txId) send channel")
coroutineScope {
launch {
sendChannel.send(input)
@@ -114,15 +119,15 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
* so the correlation is sub request id to receive the response.
*/
@ExperimentalCoroutinesApi
- override suspend fun sendNonInteractive(selector: Any, txId: String, input: ExecutionServiceInput, timeOutMill: Long)
- : ExecutionServiceOutput {
+ override suspend fun sendNonInteractive(selector: Any, txId: String, input: ExecutionServiceInput, timeOutMill: Long):
+ ExecutionServiceOutput {
var output: ExecutionServiceOutput? = null
val flow = openSubscription(selector, txId)
/** Send the request */
val sendChannel = commChannels[txId]?.requestChannel
- ?: throw BluePrintException("failed to get transactionId($txId) send channel")
+ ?: throw BluePrintException("failed to get transactionId($txId) send channel")
sendChannel.send(input)
/** Receive the response with timeout */
@@ -145,7 +150,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
if (!it.requestChannel.isClosedForSend)
it.requestChannel.close()
/** If receive channel has to close immediately, once the subscription has cancelled, then enable this */
- //it.responseChannel.cancel(CancellationException("subscription cancelled"))
+ // it.responseChannel.cancel(CancellationException("subscription cancelled"))
commChannels.remove(txId)
log.info("closed subscription for transactionId($txId)")
}
@@ -182,7 +187,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
suspend fun createGrpcChannel(grpcProperties: GrpcClientProperties): ManagedChannel {
val grpcClientService: BluePrintGrpcClientService = bluePrintGrpcLibPropertyService
- .blueprintGrpcClientService(grpcProperties)
+ .blueprintGrpcClientService(grpcProperties)
return grpcClientService.channel()
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
index 814054804..dd4c0ec99 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
@@ -32,13 +32,19 @@ import org.springframework.stereotype.Service
import java.io.File
@Service
-class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
- private val applicationContext: ApplicationContext) {
+class BlueprintJythonService(
+ val pythonExecutorProperty: PythonExecutorProperty,
+ private val applicationContext: ApplicationContext
+) {
val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::class.java)
- inline fun <reified T> jythonInstance(blueprintContext: BluePrintContext, pythonClassName: String, content: String,
- dependencyInstanceNames: MutableMap<String, Any>?): T {
+ inline fun <reified T> jythonInstance(
+ blueprintContext: BluePrintContext,
+ pythonClassName: String,
+ content: String,
+ dependencyInstanceNames: MutableMap<String, Any>?
+ ): T {
val blueprintBasePath: String = blueprintContext.rootPath
val pythonPath: MutableList<String> = arrayListOf()
@@ -59,8 +65,8 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
BlueprintFunctionNode<*, *> {
val pythonFileName = bluePrintContext.rootPath
- .plus(File.separator)
- .plus(scriptClassReference)
+ .plus(File.separator)
+ .plus(scriptClassReference)
val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
log.info("Getting Jython Script Class($pythonClassName)")
@@ -70,8 +76,10 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val jythonInstances: MutableMap<String, Any> = hashMapOf()
jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
- return jythonInstance<BlueprintFunctionNode<*, *>>(bluePrintContext, pythonClassName,
- content, jythonInstances)
+ return jythonInstance<BlueprintFunctionNode<*, *>>(
+ bluePrintContext, pythonClassName,
+ content, jythonInstances
+ )
}
fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction {
@@ -82,25 +90,27 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val operationInputs: MutableMap<String, JsonNode> = abstractComponentFunction.operationInputs
val operationAssignment: OperationAssignment = bluePrintContext
- .nodeTemplateInterfaceOperation(abstractComponentFunction.nodeTemplateName,
- abstractComponentFunction.interfaceName, abstractComponentFunction.operationName)
+ .nodeTemplateInterfaceOperation(
+ abstractComponentFunction.nodeTemplateName,
+ abstractComponentFunction.interfaceName, abstractComponentFunction.operationName
+ )
val blueprintBasePath: String = bluePrintContext.rootPath
val artifactName: String = operationAssignment.implementation?.primary
- ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+ ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
val pythonFileName = artifactDefinition.file
- ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+ ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
log.info("Getting Jython Script Class($pythonClassName)")
val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
- checkNotEmpty(content){ "artifact ($artifactName) content is empty"}
+ checkNotEmpty(content) { "artifact ($artifactName) content is empty" }
val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
pythonPath.add(blueprintBasePath)
@@ -110,17 +120,17 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
- ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+ ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
instanceDependenciesNode.forEach { instanceName ->
jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
}
- val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(bluePrintContext, pythonClassName,
- content!!, jythonInstances)
+ val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(
+ bluePrintContext, pythonClassName,
+ content!!, jythonInstances
+ )
return scriptComponentFunction
-
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
index 78b7556f3..b348a9bef 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
@@ -19,7 +19,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.python.core.PyObject
import org.python.util.PythonInterpreter
-open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
+open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython) {
private val blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
init {
@@ -42,9 +42,9 @@ open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
try {
return blueprintPythonInterpreterProxy.getPythonInstance(properties)
} catch (e: Exception) {
- throw BluePrintProcessorException("Failed to execute Jython component ${e.toString()}", e)
+ throw BluePrintProcessorException("Failed to execute Jython component $e", e)
}
}
- //TODO Check potential errors in python scripts
+ // TODO Check potential errors in python scripts
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
index 6e514de49..6f311bcd2 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
@@ -33,12 +33,13 @@ open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrin
try {
this.exec(bluePrintPython.content)
} catch (e: PySyntaxError) {
- throw BluePrintProcessorException("Error executing Jython code! Python error: '${e.toString()}'", e)
+ throw BluePrintProcessorException("Error executing Jython code! Python error: '$e'", e)
}
}
val initCommand = bluePrintPython.pythonClassName.plus(" = ").plus(
- bluePrintPython.pythonClassName).plus("()")
+ bluePrintPython.pythonClassName
+ ).plus("()")
this.exec(initCommand)
return this.get(bluePrintPython.pythonClassName)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
index 658b0c291..0a220948d 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
@@ -32,6 +32,7 @@ open class PythonExecutorConfiguration
@Configuration
open class PythonExecutorProperty {
+
@Value("\${blueprints.processor.functions.python.executor.executionPath}")
lateinit var executionPath: String
@Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
@@ -44,8 +45,12 @@ class PythonExecutorConstants {
}
}
-open class BluePrintPython(executablePath: String, blueprintPythonPlatform: MutableList<String>,
- val argv: MutableList<String>){
+open class BluePrintPython(
+ executablePath: String,
+ blueprintPythonPlatform: MutableList<String>,
+ val argv: MutableList<String>
+) {
+
lateinit var moduleName: String
lateinit var pythonClassName: String
lateinit var content: String
@@ -65,4 +70,4 @@ open class BluePrintPython(executablePath: String, blueprintPythonPlatform: Muta
props.setProperty("python.verbose", "error")
props.setProperty("python.executable", executablePath)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt
index 6bffffdb5..a0eaeca5f 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt
@@ -31,15 +31,16 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOu
private val log = logger(MockBluePrintProcessingServer::class)
-
class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
override fun process(responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
- log.info("Received requestId(${executionServiceInput.commonHeader.requestId}) " +
- "subRequestId(${executionServiceInput.commonHeader.subRequestId})")
+ log.info(
+ "Received requestId(${executionServiceInput.commonHeader.requestId}) " +
+ "subRequestId(${executionServiceInput.commonHeader.subRequestId})"
+ )
runBlocking {
launch(MDCContext()) {
responseObserver.onNext(buildNotification(executionServiceInput))
@@ -52,9 +53,11 @@ class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintPr
override fun onError(error: Throwable) {
log.debug("Fail to process message", error)
- responseObserver.onError(io.grpc.Status.INTERNAL
+ responseObserver.onError(
+ io.grpc.Status.INTERNAL
.withDescription(error.message)
- .asException())
+ .asException()
+ )
}
override fun onCompleted() {
@@ -63,29 +66,27 @@ class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintPr
}
}
-
private fun buildNotification(input: ExecutionServiceInput): ExecutionServiceOutput {
val status = Status.newBuilder()
- .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION)
- .build()
+ .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION)
+ .build()
return ExecutionServiceOutput.newBuilder()
- .setCommonHeader(input.commonHeader)
- .setActionIdentifiers(input.actionIdentifiers)
- .setStatus(status)
- .build()
+ .setCommonHeader(input.commonHeader)
+ .setActionIdentifiers(input.actionIdentifiers)
+ .setStatus(status)
+ .build()
}
private fun buildResponse(input: ExecutionServiceInput): ExecutionServiceOutput {
val status = Status.newBuilder().setCode(200)
- .setEventType(EventType.EVENT_COMPONENT_EXECUTED)
- .build()
+ .setEventType(EventType.EVENT_COMPONENT_EXECUTED)
+ .build()
return ExecutionServiceOutput.newBuilder()
- .setCommonHeader(input.commonHeader)
- .setActionIdentifiers(input.actionIdentifiers)
- .setStatus(status)
- .build()
-
+ .setCommonHeader(input.commonHeader)
+ .setActionIdentifiers(input.actionIdentifiers)
+ .setStatus(status)
+ .build()
}
}
@@ -93,15 +94,14 @@ class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintPr
fun main() {
try {
val server = ServerBuilder
- .forPort(50052)
- .intercept(GrpcServerLoggingInterceptor())
- .addService(MockBluePrintProcessingServer())
- .build()
+ .forPort(50052)
+ .intercept(GrpcServerLoggingInterceptor())
+ .addService(MockBluePrintProcessingServer())
+ .build()
server.start()
log.info("GRPC Serve started(${server.isShutdown}) on port(${server.port})...")
server.awaitTermination()
} catch (e: Exception) {
e.printStackTrace()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt
index 9a5be0151..dede885c1 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt
@@ -23,8 +23,13 @@ import io.grpc.testing.GrpcCleanupRule
import io.mockk.coEvery
import io.mockk.mockk
import io.mockk.spyk
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.runBlocking
import org.junit.Rule
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC
@@ -37,11 +42,10 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput
-import java.util.*
+import java.util.UUID
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
-
class StreamingRemoteExecutionServiceTest {
val log = logger(StreamingRemoteExecutionServiceTest::class)
@@ -82,16 +86,21 @@ class StreamingRemoteExecutionServiceTest {
val request = getRequest(requestId)
val invocationId = request.commonHeader.subRequestId
val deferred = async {
- val response = spyStreamingRemoteExecutionService.sendNonInteractive(tokenAuthGrpcClientProperties,
- invocationId, request, 1000L)
+ val response = spyStreamingRemoteExecutionService.sendNonInteractive(
+ tokenAuthGrpcClientProperties,
+ invocationId, request, 1000L
+ )
assertNotNull(response, "failed to get non interactive response")
- assertEquals(response.commonHeader.requestId, requestId,
- "failed to match non interactive response id")
- assertEquals(response.status.eventType, EventType.EVENT_COMPONENT_EXECUTED,
- "failed to match non interactive response type")
+ assertEquals(
+ response.commonHeader.requestId, requestId,
+ "failed to match non interactive response id"
+ )
+ assertEquals(
+ response.status.eventType, EventType.EVENT_COMPONENT_EXECUTED,
+ "failed to match non interactive response type"
+ )
}
nonInteractiveDeferred.add(deferred)
-
}
nonInteractiveDeferred.awaitAll()
@@ -102,7 +111,7 @@ class StreamingRemoteExecutionServiceTest {
val request = getRequest(requestId)
val invocationId = request.commonHeader.requestId
val responseFlow = spyStreamingRemoteExecutionService
- .openSubscription(tokenAuthGrpcClientProperties, invocationId)
+ .openSubscription(tokenAuthGrpcClientProperties, invocationId)
val deferred = async {
responseFlow.collect {
@@ -119,33 +128,30 @@ class StreamingRemoteExecutionServiceTest {
responseFlowsDeferred.awaitAll()
streamingRemoteExecutionService.closeChannel(tokenAuthGrpcClientProperties)
}
-
}
private fun getRequest(requestId: String): ExecutionServiceInput {
val commonHeader = CommonHeader.newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(requestId)
- .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build()
-
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(requestId)
+ .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build()
val actionIdentifier = ActionIdentifiers.newBuilder()
- .setActionName("SampleScript")
- .setBlueprintName("sample-cba")
- .setBlueprintVersion("1.0.0")
- .setMode(ACTION_MODE_SYNC)
- .build()
+ .setActionName("SampleScript")
+ .setBlueprintName("sample-cba")
+ .setBlueprintVersion("1.0.0")
+ .setMode(ACTION_MODE_SYNC)
+ .build()
val jsonContent = """{ "key1" : "value1" }"""
val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
JsonFormat.parser().merge(jsonContent, payloadBuilder)
return ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(actionIdentifier)
- .setPayload(payloadBuilder.build())
- .build()
-
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(actionIdentifier)
+ .setPayload(payloadBuilder.build())
+ .build()
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
index 2fc9a993b..d6720427e 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts;
+package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
@@ -54,9 +54,11 @@ import kotlin.test.assertNotNull
* Unit test cases for abstract component function.
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ComponentFunctionScriptingService::class,
- BluePrintScriptsServiceImpl::class, PythonExecutorProperty::class,
- BlueprintJythonService::class])
+@ContextConfiguration(
+ classes = [ComponentFunctionScriptingService::class,
+ BluePrintScriptsServiceImpl::class, PythonExecutorProperty::class,
+ BlueprintJythonService::class]
+)
class AbstractComponentFunctionTest {
lateinit var blueprintContext: BluePrintContext
@@ -97,7 +99,8 @@ class AbstractComponentFunctionTest {
val sampleComponent = SampleComponent()
sampleComponent.workflowName = "sample-action"
sampleComponent.executionServiceInput = JacksonUtils.readValueFromClassPathFile(
- "payload/requests/sample-execution-request.json", ExecutionServiceInput::class.java)!!
+ "payload/requests/sample-execution-request.json", ExecutionServiceInput::class.java
+ )!!
val payload = sampleComponent.requestPayload()
assertNotNull(payload, "failed to get payload")
val data = sampleComponent.requestPayloadActionProperty("data")?.first()
@@ -153,14 +156,13 @@ class AbstractComponentFunctionTest {
val operationInputs = hashMapOf<String, JsonNode>()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] =
- "activate-restconf".asJsonPrimitive()
+ "activate-restconf".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] =
- "interfaceName".asJsonPrimitive()
+ "interfaceName".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] =
- "operationName".asJsonPrimitive()
+ "operationName".asJsonPrimitive()
operationInputs["dynamic-properties"] = rootNode
-
val stepInputData = StepData().apply {
name = "activate-restconf"
properties = operationInputs
@@ -178,13 +180,15 @@ class AbstractComponentFunctionTest {
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs(
- "activate-restconf", "interfaceName", "operationName")
+ "activate-restconf", "interfaceName", "operationName"
+ )
} returns operationInputs
val operationOutputs = hashMapOf<String, JsonNode>()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs(
- "activate-restconf", "interfaceName", "operationName")
+ "activate-restconf", "interfaceName", "operationName"
+ )
} returns operationOutputs
every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
@@ -196,6 +200,4 @@ class AbstractComponentFunctionTest {
val componentScriptExecutor = BluePrintTypes.nodeTypeComponentScriptExecutor()
assertNotNull(componentScriptExecutor.interfaces, "failed to get interface operations")
}
-
}
-
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
index fd18baf52..a34794a85 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
@@ -33,9 +33,11 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
+@TestPropertySource(
+ properties =
+ ["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"]
+)
class BlueprintJythonServiceTest {
lateinit var blueprintContext: BluePrintContext
@@ -47,26 +49,27 @@ class BlueprintJythonServiceTest {
blueprintContext = mockk<BluePrintContext>()
every { blueprintContext.rootPath } returns normalizedPathName("target")
}
-
+
@Test
fun testGetAbstractPythonPlugin() {
- val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
- val dependencies: MutableMap<String, Any> = hashMapOf()
+ val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
+ val dependencies: MutableMap<String, Any> = hashMapOf()
- val abstractPythonPlugin = blueprintJythonService
- .jythonInstance<AbstractComponentFunction>(blueprintContext, "SamplePythonComponentNode",
- content, dependencies)
+ val abstractPythonPlugin = blueprintJythonService
+ .jythonInstance<AbstractComponentFunction>(
+ blueprintContext, "SamplePythonComponentNode",
+ content, dependencies
+ )
- assertNotNull(abstractPythonPlugin, "failed to get python component")
+ assertNotNull(abstractPythonPlugin, "failed to get python component")
}
@Test
fun testGetAbstractJythonComponent() {
- val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
-
- val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
+ val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
- assertNotNull(abstractJythonComponent, "failed to get Jython component")
+ val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
+ assertNotNull(abstractJythonComponent, "failed to get Jython component")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
index 3c3efa252..9a93abe0c 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
@@ -16,21 +16,22 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import org.junit.Test
-
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.assertNotNull
import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BluePrintPython::class, PythonExecutorProperty::class, String::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
+@TestPropertySource(
+ properties =
+ ["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"]
+)
class BlueprintPythonHostTest {
lateinit var blueprintPythonHost: BlueprintPythonHost
@@ -59,4 +60,4 @@ class BlueprintPythonHostTest {
assertNotNull(pythonObject, "failed to get python object")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
index 000d8c09b..31b1a59c8 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
@@ -18,21 +18,18 @@
* ============LICENSE_END=========================================================
*/
-
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-
import org.slf4j.LoggerFactory
open class SampleComponent : AbstractComponentFunction() {
val log = LoggerFactory.getLogger(SampleComponent::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
}
@@ -40,20 +37,21 @@ open class SampleComponent : AbstractComponentFunction() {
}
}
-open class SampleRestconfComponent (private var componentFunctionScriptingService: ComponentFunctionScriptingService)
- : AbstractComponentFunction() {
+open class SampleRestconfComponent(private var componentFunctionScriptingService: ComponentFunctionScriptingService) :
+ AbstractComponentFunction() {
val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
var scriptComponent: AbstractScriptComponentFunction
scriptComponent = componentFunctionScriptingService
- .scriptInstance<AbstractScriptComponentFunction>(this,
- "internal",
- "org.onap.ccsdk.cds.blueprintsprocessor.services" +
- ".execution.scripts.SampleTest",
- mutableListOf())
+ .scriptInstance<AbstractScriptComponentFunction>(
+ this,
+ "internal",
+ "org.onap.ccsdk.cds.blueprintsprocessor.services" +
+ ".execution.scripts.SampleTest",
+ mutableListOf()
+ )
scriptComponent.executeScript(executionServiceInput)
}
@@ -65,11 +63,9 @@ open class SampleScriptComponent : AbstractScriptComponentFunction() {
val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
-
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
index 6a95e29e7..b10f08dd4 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
@@ -29,7 +29,6 @@ open class SampleTest : AbstractScriptComponentFunction() {
val log = LoggerFactory.getLogger(SampleTest::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val isPresent = checkDynamicProperties("type")
assertTrue(isPresent)
@@ -39,4 +38,4 @@ open class SampleTest : AbstractScriptComponentFunction() {
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
index cde919ce8..492b0ba44 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -29,23 +29,25 @@ import org.springframework.stereotype.Service
@Service("bluePrintWorkflowExecutionService")
open class BluePrintWorkflowExecutionServiceImpl(
- private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
- private val dgWorkflowExecutionService: DGWorkflowExecutionService,
- private val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService
+ private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
+ private val dgWorkflowExecutionService: DGWorkflowExecutionService,
+ private val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService
) : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(BluePrintWorkflowExecutionServiceImpl::class.java)!!
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val workflowName = executionServiceInput.actionIdentifiers.actionName
// Assign Workflow inputs
- //check if request structure exists
+ // check if request structure exists
if (!executionServiceInput.payload.has("$workflowName-request")) {
throw BluePrintProcessorException("Input request missing the expected '$workflowName-request' block!")
}
@@ -59,7 +61,7 @@ open class BluePrintWorkflowExecutionServiceImpl(
/** If workflow has multiple steps, then it is imperative workflow */
val executionServiceOutput: ExecutionServiceOutput = if (steps.size > 1) {
imperativeWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
} else {
// Get the DG Node Template
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
@@ -71,15 +73,17 @@ open class BluePrintWorkflowExecutionServiceImpl(
when {
derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> {
componentWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
}
derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> {
dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
}
else -> {
- throw BluePrintProcessorException("couldn't execute workflow($workflowName) step mapped " +
- "to node template($nodeTemplateName) derived from($derivedFrom)")
+ throw BluePrintProcessorException(
+ "couldn't execute workflow($workflowName) step mapped " +
+ "to node template($nodeTemplateName) derived from($derivedFrom)"
+ )
}
}
}
@@ -93,5 +97,4 @@ open class BluePrintWorkflowExecutionServiceImpl(
executionServiceOutput.payload.set("$workflowName-response", workflowOutputs.asObjectNode())
return executionServiceOutput
}
-
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
index a2db8aab7..044e8cf53 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
@@ -48,5 +48,4 @@ class BlueprintSvcLogicContext : SvcLogicContext() {
fun getResponse(): Any {
return this.response!!
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
index df250ae98..9cc325d94 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
@@ -18,14 +18,25 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.sli.core.sli.*
-import org.onap.ccsdk.sli.core.sli.provider.base.*
+import org.onap.ccsdk.sli.core.sli.ExitNodeException
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext
+import org.onap.ccsdk.sli.core.sli.SvcLogicException
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore
+import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.BreakNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.ExitNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.Properties
import javax.annotation.PostConstruct
interface BlueprintSvcLogicService : SvcLogicServiceBase {
@@ -54,7 +65,6 @@ interface BlueprintSvcLogicService : SvcLogicServiceBase {
}
}
-
@Service
class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
@@ -88,9 +98,12 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
}
}
- override suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>,
- input: Any): Any {
- //Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
+ override suspend fun execute(
+ graph: SvcLogicGraph,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ input: Any
+ ): Any {
+ // Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
val blueprintSvcLogicContext = BlueprintSvcLogicContext()
blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
blueprintSvcLogicContext.setRequest(input)
@@ -140,4 +153,4 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
MDC.remove("currentGraph")
return svcLogicContext
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
index 3c474de37..70910e15c 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
-
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
@@ -24,12 +23,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.springframework.stereotype.Service
@Service("componentWorkflowExecutionService")
-open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) :
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -38,8 +39,9 @@ open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionSe
// Get the DG Node Template
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
- return nodeTemplateExecutionService.executeNodeTemplate(bluePrintRuntimeService,
- nodeTemplateName, executionServiceInput)
+ return nodeTemplateExecutionService.executeNodeTemplate(
+ bluePrintRuntimeService,
+ nodeTemplateName, executionServiceInput
+ )
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
index 4485800ff..b1847df43 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
@@ -26,16 +26,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
-
@Service("dgWorkflowExecutionService")
-open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService)
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService) :
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(DGWorkflowExecutionService::class.java)
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -47,8 +48,10 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
log.info("Executing workflow($workflowName) directed graph NodeTemplate($nodeTemplateName)")
// Get the DG file info
- val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName,
- WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
+ val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(
+ nodeTemplateName,
+ WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH
+ )
// Populate the DG Path
val dgFilePath = normalizedPathName(bluePrintContext.rootPath, artifactDefinition.file)
@@ -59,10 +62,10 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
// Execute the DG
- return blueprintSvcLogicService.execute(graph,
+ return blueprintSvcLogicService.execute(
+ graph,
bluePrintRuntimeService,
- executionServiceInput) as ExecutionServiceOutput
-
+ executionServiceInput
+ ) as ExecutionServiceOutput
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
index d296ec6e6..ebd9d553d 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
@@ -21,23 +21,35 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asGraph
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel
import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.*
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.AbstractBluePrintWorkFlowService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintWorkFlowService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.NodeExecuteMessage
+import org.onap.ccsdk.cds.controllerblueprints.core.service.NodeSkipMessage
+import org.onap.ccsdk.cds.controllerblueprints.core.service.WorkflowExecuteMessage
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@Service("imperativeWorkflowExecutionService")
class ImperativeWorkflowExecutionService(
- private val imperativeBluePrintWorkflowService: BluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>)
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+ private val imperativeBluePrintWorkflowService: BluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>
+) :
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -45,23 +57,29 @@ class ImperativeWorkflowExecutionService(
val graph = bluePrintContext.workflowByName(workflowName).asGraph()
- return imperativeBluePrintWorkflowService.executeWorkflow(graph, bluePrintRuntimeService,
- executionServiceInput)
+ return imperativeBluePrintWorkflowService.executeWorkflow(
+ graph, bluePrintRuntimeService,
+ executionServiceInput
+ )
}
}
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
- : AbstractBluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>() {
+open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) :
+ AbstractBluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>() {
+
val log = logger(ImperativeBluePrintWorkflowService::class)
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var executionServiceInput: ExecutionServiceInput
lateinit var workflowName: String
- override suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>,
- input: ExecutionServiceInput): ExecutionServiceOutput {
+ override suspend fun executeWorkflow(
+ graph: Graph,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ input: ExecutionServiceInput
+ ): ExecutionServiceOutput {
this.graph = graph
this.bluePrintRuntimeService = bluePrintRuntimeService
this.executionServiceInput = input
@@ -103,8 +121,8 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
}
}
- override suspend fun prepareNodeExecutionMessage(node: Graph.Node)
- : NodeExecuteMessage<ExecutionServiceInput, ExecutionServiceOutput> {
+ override suspend fun prepareNodeExecutionMessage(node: Graph.Node):
+ NodeExecuteMessage<ExecutionServiceInput, ExecutionServiceOutput> {
val nodeOutput = ExecutionServiceOutput().apply {
commonHeader = executionServiceInput.commonHeader
actionIdentifiers = executionServiceInput.actionIdentifiers
@@ -112,8 +130,8 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
return NodeExecuteMessage(node, executionServiceInput, nodeOutput)
}
- override suspend fun prepareNodeSkipMessage(node: Graph.Node)
- : NodeSkipMessage<ExecutionServiceInput, ExecutionServiceOutput> {
+ override suspend fun prepareNodeSkipMessage(node: Graph.Node):
+ NodeSkipMessage<ExecutionServiceInput, ExecutionServiceOutput> {
val nodeOutput = ExecutionServiceOutput().apply {
commonHeader = executionServiceInput.commonHeader
actionIdentifiers = executionServiceInput.actionIdentifiers
@@ -121,15 +139,18 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
return NodeSkipMessage(node, executionServiceInput, nodeOutput)
}
- override suspend fun executeNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun executeNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
log.info("Executing workflow($workflowName[${this.workflowId}])'s step($${node.id})")
val step = bluePrintRuntimeService.bluePrintContext().workflowStepByName(this.workflowName, node.id)
checkNotEmpty(step.target) { "couldn't get step target for workflow(${this.workflowName})'s step(${node.id})" }
val nodeTemplateName = step.target!!
/** execute node template */
val executionServiceOutput = nodeTemplateExecutionService
- .executeNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeInput)
+ .executeNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeInput)
return when (executionServiceOutput.status.message) {
BluePrintConstants.STATUS_FAILURE -> EdgeLabel.FAILURE
@@ -137,18 +158,27 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
}
}
- override suspend fun skipNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun skipNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
return EdgeLabel.SUCCESS
}
- override suspend fun cancelNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun cancelNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
TODO("not implemented")
}
- override suspend fun restartNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun restartNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
TODO("not implemented")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
index b64177aab..615a31c77 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
@@ -33,8 +33,11 @@ open class NodeTemplateExecutionService {
private val log = LoggerFactory.getLogger(NodeTemplateExecutionService::class.java)!!
- suspend fun executeNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ suspend fun executeNodeTemplate(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ executionServiceInput: ExecutionServiceInput
+ ): ExecutionServiceOutput {
// Get the Blueprint Context
val blueprintContext = bluePrintRuntimeService.bluePrintContext()
@@ -47,12 +50,14 @@ open class NodeTemplateExecutionService {
val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
val nodeTemplateImplementation = blueprintContext
- .nodeTemplateOperationImplementation(nodeTemplateName, interfaceName, operationName)
+ .nodeTemplateOperationImplementation(nodeTemplateName, interfaceName, operationName)
val timeout: Int = nodeTemplateImplementation?.timeout ?: 180
- log.info("executing node template($nodeTemplateName) component($componentName) " +
- "interface($interfaceName) operation($operationName) with timeout($timeout) sec.")
+ log.info(
+ "executing node template($nodeTemplateName) component($componentName) " +
+ "interface($interfaceName) operation($operationName) with timeout($timeout) sec."
+ )
// Get the Component Instance
val plugin = BluePrintDependencyService.instance<AbstractComponentFunction>(componentName)
@@ -82,5 +87,4 @@ open class NodeTemplateExecutionService {
// Get the Request from the Context and Set to the Function Input and Invoke the function
return plugin.applyNB(clonedExecutionServiceInput)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
index 67f13f760..c1bcc649f 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
@@ -23,9 +23,8 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
open class WorkflowServiceConfiguration
-
class WorkflowServiceConstants {
companion object {
const val ARTIFACT_TYPE_DIRECTED_GRAPH = "artifact-directed-graph"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
index b6e767503..8c4e2d215 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -31,14 +31,14 @@ import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@Service
-open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
- : ExecuteNodeExecutor() {
+open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService: NodeTemplateExecutionService) :
+ ExecuteNodeExecutor() {
private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
@Throws(SvcLogicException::class)
- override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext)
- : SvcLogicNode = runBlocking {
+ override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext):
+ SvcLogicNode = runBlocking {
var outValue: String
@@ -48,15 +48,16 @@ open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService
val executionInput = ctx.getRequest() as ExecutionServiceInput
- try { // Get the Request from the Context and Set to the Function Input and Invoke the function
- val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(ctx.getBluePrintService(),
- nodeTemplateName, executionInput)
+ try { // Get the Request from the Context and Set to the Function Input and Invoke the function
+ val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(
+ ctx.getBluePrintService(),
+ nodeTemplateName, executionInput
+ )
ctx.setResponse(executionOutput)
outValue = executionOutput.status.message
ctx.status = executionOutput.status.message
-
} catch (e: Exception) {
log.error("Could not execute plugin($nodeTemplateName) : ", e)
outValue = "failure"
@@ -65,5 +66,4 @@ open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService
getNextNode(node, outValue)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
index 8f9579230..86934f29a 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
@@ -32,4 +32,4 @@ object SvcGraphUtils {
val svcLogicParser = SvcLogicParser()
return svcLogicParser.parse(fileName).first
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
index 436de1b56..330056221 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
@@ -40,7 +40,6 @@ import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
class BluePrintWorkflowExecutionServiceImplTest {
@@ -62,36 +61,48 @@ class BluePrintWorkflowExecutionServiceImplTest {
@Test
fun testBluePrintWorkflowExecutionService() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java
+ )!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
}
@Test
fun testImperativeBluePrintWorkflowExecutionService() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/imperative-test-input.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "execution-input/imperative-test-input.json",
+ ExecutionServiceInput::class.java
+ )!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
}
@@ -99,16 +110,20 @@ class BluePrintWorkflowExecutionServiceImplTest {
fun `Blueprint fails on missing workflowName-parameters with a useful message`() {
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- //service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input-missing-resource_assignment_request.json",
- ExecutionServiceInput::class.java)!!
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
+ // service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message
+ val executionServiceInput =
+ JacksonUtils.readValueFromClassPathFile(
+ "execution-input/resource-assignment-input-missing-resource_assignment_request.json",
+ ExecutionServiceInput::class.java
+ )!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
}
}
}
-
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
index 12fd9c7c4..3d44894ee 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -54,47 +54,51 @@ class BlueprintServiceLogicTest {
@Test
fun testExecuteGraphWithSingleComponent() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput = JacksonReactorUtils
- .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("resource-assignment-request")
bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
val executionServiceOutput = dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
-
-
}
@Test
fun testExecuteGraphWithMultipleComponents() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput = JacksonReactorUtils
- .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("assign-activate-request")
bluePrintRuntimeService.assignWorkflowInputs("assign-activate", input)
-
val executionServiceOutput = dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
-
}
@Test
@@ -118,5 +122,4 @@ class BlueprintServiceLogicTest {
assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
index 3ac5cd864..86d3be26b 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
@@ -44,7 +44,6 @@ class DGWorkflowExecutionServiceTest {
@Autowired
lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
-
@Before
fun init() {
BluePrintDependencyService.inject(applicationContext)
@@ -54,25 +53,28 @@ class DGWorkflowExecutionServiceTest {
fun testExecuteDirectedGraph() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput = JacksonReactorUtils
- .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("resource-assignment-request")
bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
- val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService,
- executionServiceInput, mutableMapOf())
+ val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow(
+ bluePrintRuntimeService,
+ executionServiceInput, mutableMapOf()
+ )
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
-
}
-
-
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
index b7fcae1d1..415f11d58 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
@@ -56,18 +56,36 @@ class ImperativeWorkflowExecutionServiceTest {
}
fun mockServiceTemplate(): ServiceTemplate {
- return serviceTemplate("imperative-test", "1.0.0",
- "brindasanth@onap.com", "tosca") {
+ return serviceTemplate(
+ "imperative-test", "1.0.0",
+ "brindasanth@onap.com", "tosca"
+ ) {
topologyTemplate {
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("resolve-config",
- "cba.wt.imperative.test.ResolveConfig"))
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config",
- "cba.wt.imperative.test.ActivateConfig"))
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config-rollback",
- "cba.wt.imperative.test.ActivateConfigRollback"))
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-licence",
- "cba.wt.imperative.test.ActivateLicence"))
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "resolve-config",
+ "cba.wt.imperative.test.ResolveConfig"
+ )
+ )
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "activate-config",
+ "cba.wt.imperative.test.ActivateConfig"
+ )
+ )
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "activate-config-rollback",
+ "cba.wt.imperative.test.ActivateConfigRollback"
+ )
+ )
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "activate-licence",
+ "cba.wt.imperative.test.ActivateLicence"
+ )
+ )
workflow("imperative-test-wf", "Test Imperative flow") {
step("resolve-config", "resolve-config", "") {
@@ -95,17 +113,19 @@ class ImperativeWorkflowExecutionServiceTest {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("12345", bluePrintContext)
val executionServiceInput = JacksonUtils
- .readValueFromClassPathFile("execution-input/imperative-test-input.json",
- ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile(
+ "execution-input/imperative-test-input.json",
+ ExecutionServiceInput::class.java
+ )!!
val bluePrintWorkFlowService = ImperativeBluePrintWorkflowService(NodeTemplateExecutionService())
val imperativeWorkflowExecutionService = ImperativeWorkflowExecutionService(bluePrintWorkFlowService)
val output = imperativeWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(output, "failed to get imperative workflow output")
assertNotNull(output.status, "failed to get imperative workflow output status")
assertEquals(output.status.message, BluePrintConstants.STATUS_SUCCESS)
assertEquals(output.status.eventType, EventType.EVENT_COMPONENT_EXECUTED.name)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
index 24d96629e..1f51a6aae 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
@@ -38,6 +38,7 @@ import kotlin.test.assertNotNull
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
class NodeTemplateExecutionServiceTest {
+
@Before
fun init() {
mockkObject(BluePrintDependencyService)
@@ -52,11 +53,15 @@ class NodeTemplateExecutionServiceTest {
@Test
fun testExecuteNodeTemplate() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java
+ )!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("resource-assignment-request")
@@ -65,11 +70,13 @@ class NodeTemplateExecutionServiceTest {
val nodeTemplate = "resource-assignment"
val nodeTemplateExecutionService = NodeTemplateExecutionService()
val executionServiceOutput = nodeTemplateExecutionService
- .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput)
+ .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput)
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
index 44751b5b5..9c3727288 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
@@ -29,8 +29,10 @@ import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
-fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor(id,
- "mock($id) component function") {
+fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor(
+ id,
+ "mock($id) component function"
+) {
definedOperation("") {
inputs {
type("kotlin")
@@ -55,8 +57,10 @@ class MockComponentFunction : AbstractComponentFunction() {
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
log.info("Processing component : $operationInputs")
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- "assignment-params", "params".asJsonPrimitive())
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ "assignment-params", "params".asJsonPrimitive()
+ )
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
@@ -92,4 +96,4 @@ class PrototypeComponentFunction : AbstractComponentFunction() {
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
log.info("Recovering component..")
}
-} \ No newline at end of file
+}