From daab14bd058de198c80b71d63e108fd788b7f5ee Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Mon, 26 Jul 2021 12:00:59 -0400 Subject: Revert "Renaming Files having BluePrint to have Blueprint" The renaming in CCSDK-3098 caused breaking changes to the grpc api and compile issues for kotlin scripts. Issue-ID: CCSDK-3385 Change-Id: I0d745cb858371678eabcb2284671c1fd76a1ab6d Signed-off-by: Jozsef Csongvai --- .../db/BluePrintDBLibConfiguration.kt | 83 +++++++++++++++++++++ .../blueprintsprocessor/db/BluePrintDBLibData.kt | 60 +++++++++++++++ .../db/BluePrintDBLibGenericService.kt | 44 +++++++++++ .../db/BlueprintDBLibConfiguration.kt | 83 --------------------- .../blueprintsprocessor/db/BlueprintDBLibData.kt | 60 --------------- .../db/BlueprintDBLibGenericService.kt | 44 ----------- .../db/DatabasePropertiesDSL.kt | 30 ++++---- .../db/primary/BluePrintDBLibPropertyService.kt | 87 ++++++++++++++++++++++ .../db/primary/BlueprintDBLibPropertyService.kt | 87 ---------------------- .../db/primary/MSSqlDatabaseConfiguration.kt | 4 +- .../db/primary/MariaDatabaseConfiguration.kt | 4 +- .../db/primary/MySqlDatabaseConfiguration.kt | 4 +- .../primary/service/BlueprintCatalogServiceImpl.kt | 38 +++++----- .../BlueprintProcessorCatalogServiceImpl.kt | 54 +++++++------- .../db/BlueprintProcessorCatalogServiceImplTest.kt | 20 ++--- .../db/DatabasePropertiesDSLTest.kt | 10 +-- .../db/TestDatabaseConfiguration.kt | 2 +- .../MockBlueprintProcessorCatalogServiceImpl.kt | 12 +-- 18 files changed, 363 insertions(+), 363 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt create mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt create mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibConfiguration.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibData.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibGenericService.kt create mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BlueprintDBLibPropertyService.kt (limited to 'ms/blueprintsprocessor/modules/commons/db-lib') 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 new file mode 100644 index 000000000..6cff85e68 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt @@ -0,0 +1,83 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.db + +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate +import javax.sql.DataSource + +@Configuration +@Import( + BluePrintPropertyConfiguration::class, + BluePrintPropertiesService::class, + BluePrintCoreConfiguration::class +) +@EnableConfigurationProperties +open class BluePrintDBLibConfiguration(private var bluePrintPropertiesService: BluePrintPropertiesService) { + + @Bean("primary-database-properties") + open fun getPrimaryProperties(): PrimaryDataSourceProperties { + return bluePrintPropertiesService.propertyBeanType( + DBLibConstants.PREFIX_DB, + PrimaryDataSourceProperties::class.java + ) + } + + @Bean("primaryNamedParameterJdbcTemplate") + open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate { + return NamedParameterJdbcTemplate(primaryDataSource) + } +} + +/** + * Exposed Dependency Service by this SSH Lib Module + */ +fun BluePrintDependencyService.dbLibPropertyService(): BluePrintDBLibPropertyService = + instance(BluePrintDBLibPropertyService::class) + +fun BluePrintDependencyService.primaryDBLibGenericService(): BluePrintDBLibGenericService = + instance(PrimaryDBLibGenericService::class) + +class DBLibConstants { + companion object { + + const val PREFIX_DB: String = "blueprintsprocessor.db" + + // list of database + const val MARIA_DB: String = "maria-db" + const val PROCESSOR_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" + const val MSSQL_DB: String = "mssql" + + // 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" + const val DRIVER_POSTGRES_DB = "org.postgresql.Driver" + const val DRIVER_MSSQL_DB = "com.microsoft.sqlserver.jdbc.SQLServerDriver" + } +} 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 new file mode 100644 index 000000000..2da83823c --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt @@ -0,0 +1,60 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.db + +open class DBDataSourceProperties { + + var type: String = DBLibConstants.MARIA_DB + lateinit var url: String + lateinit var username: String + lateinit var password: String + open lateinit var driverClassName: String +} + +open class PrimaryDataSourceProperties : DBDataSourceProperties() { + + lateinit var hibernateHbm2ddlAuto: String + lateinit var hibernateDDLAuto: String + lateinit var hibernateNamingStrategy: String + lateinit var hibernateDialect: String +} + +open class MariaDataSourceProperties : DBDataSourceProperties() { + + lateinit var hibernateHbm2ddlAuto: String + lateinit var hibernateDDLAuto: String + lateinit var hibernateNamingStrategy: String + lateinit var hibernateDialect: String + override var driverClassName = DBLibConstants.DRIVER_MARIA_DB +} + +open class MySqlDataSourceProperties : DBDataSourceProperties() { + + lateinit var hibernateHbm2ddlAuto: String + lateinit var hibernateDDLAuto: String + lateinit var hibernateNamingStrategy: String + lateinit var hibernateDialect: String + override var driverClassName = DBLibConstants.DRIVER_MYSQL_DB +} + +open class MSSqlDataSourceProperties : DBDataSourceProperties() { + lateinit var hibernateHbm2ddlAuto: String + lateinit var hibernateDDLAuto: String + lateinit var hibernateNamingStrategy: String + lateinit var hibernateDialect: String + override var driverClassName = DBLibConstants.DRIVER_MSSQL_DB +} 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 new file mode 100644 index 000000000..aeb87fd66 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibGenericService.kt @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.db + +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate + +interface BluePrintDBLibGenericService { + + fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate + + fun query(sql: String, params: Map): List> + + fun update(sql: String, params: Map): Int +} + +abstract class AbstractDBLibGenericService(private val namedParameterJdbcTemplate: NamedParameterJdbcTemplate) : + BluePrintDBLibGenericService { + + override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { + return namedParameterJdbcTemplate + } + + override fun query(sql: String, params: Map): List> { + return namedParameterJdbcTemplate.queryForList(sql, params) + } + + override fun update(sql: String, params: Map): Int { + return namedParameterJdbcTemplate.update(sql, params) + } +} 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 deleted file mode 100644 index ff1072c94..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibConfiguration.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.db - -import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintCoreConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertiesService -import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BlueprintDBLibPropertyService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.springframework.boot.context.properties.EnableConfigurationProperties -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.Import -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate -import javax.sql.DataSource - -@Configuration -@Import( - BlueprintPropertyConfiguration::class, - BlueprintPropertiesService::class, - BlueprintCoreConfiguration::class -) -@EnableConfigurationProperties -open class BlueprintDBLibConfiguration(private var bluePrintPropertiesService: BlueprintPropertiesService) { - - @Bean("primary-database-properties") - open fun getPrimaryProperties(): PrimaryDataSourceProperties { - return bluePrintPropertiesService.propertyBeanType( - DBLibConstants.PREFIX_DB, - PrimaryDataSourceProperties::class.java - ) - } - - @Bean("primaryNamedParameterJdbcTemplate") - open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate { - return NamedParameterJdbcTemplate(primaryDataSource) - } -} - -/** - * Exposed Dependency Service by this SSH Lib Module - */ -fun BlueprintDependencyService.dbLibPropertyService(): BlueprintDBLibPropertyService = - instance(BlueprintDBLibPropertyService::class) - -fun BlueprintDependencyService.primaryDBLibGenericService(): BlueprintDBLibGenericService = - instance(PrimaryDBLibGenericService::class) - -class DBLibConstants { - companion object { - - const val PREFIX_DB: String = "blueprintsprocessor.db" - - // list of database - const val MARIA_DB: String = "maria-db" - const val PROCESSOR_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" - const val MSSQL_DB: String = "mssql" - - // 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" - const val DRIVER_POSTGRES_DB = "org.postgresql.Driver" - const val DRIVER_MSSQL_DB = "com.microsoft.sqlserver.jdbc.SQLServerDriver" - } -} 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 deleted file mode 100644 index 2da83823c..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibData.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.db - -open class DBDataSourceProperties { - - var type: String = DBLibConstants.MARIA_DB - lateinit var url: String - lateinit var username: String - lateinit var password: String - open lateinit var driverClassName: String -} - -open class PrimaryDataSourceProperties : DBDataSourceProperties() { - - lateinit var hibernateHbm2ddlAuto: String - lateinit var hibernateDDLAuto: String - lateinit var hibernateNamingStrategy: String - lateinit var hibernateDialect: String -} - -open class MariaDataSourceProperties : DBDataSourceProperties() { - - lateinit var hibernateHbm2ddlAuto: String - lateinit var hibernateDDLAuto: String - lateinit var hibernateNamingStrategy: String - lateinit var hibernateDialect: String - override var driverClassName = DBLibConstants.DRIVER_MARIA_DB -} - -open class MySqlDataSourceProperties : DBDataSourceProperties() { - - lateinit var hibernateHbm2ddlAuto: String - lateinit var hibernateDDLAuto: String - lateinit var hibernateNamingStrategy: String - lateinit var hibernateDialect: String - override var driverClassName = DBLibConstants.DRIVER_MYSQL_DB -} - -open class MSSqlDataSourceProperties : DBDataSourceProperties() { - lateinit var hibernateHbm2ddlAuto: String - lateinit var hibernateDDLAuto: String - lateinit var hibernateNamingStrategy: String - lateinit var hibernateDialect: String - override var driverClassName = DBLibConstants.DRIVER_MSSQL_DB -} 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 deleted file mode 100644 index 6c382377d..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibGenericService.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.db - -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate - -interface BlueprintDBLibGenericService { - - fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate - - fun query(sql: String, params: Map): List> - - fun update(sql: String, params: Map): Int -} - -abstract class AbstractDBLibGenericService(private val namedParameterJdbcTemplate: NamedParameterJdbcTemplate) : - BlueprintDBLibGenericService { - - override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { - return namedParameterJdbcTemplate - } - - override fun query(sql: String, params: Map): List> { - return namedParameterJdbcTemplate.queryForList(sql, params) - } - - override fun update(sql: String, params: Map): Int { - return namedParameterJdbcTemplate.update(sql, params) - } -} diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt index fd51da152..34dd0a417 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType @@ -30,25 +30,25 @@ import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipType /** Relationships Types DSL for Database Producer */ fun ServiceTemplateBuilder.relationshipTypeConnectsToDb() { - val relationshipType = BlueprintTypes.relationshipTypeConnectsToDb() + val relationshipType = BluePrintTypes.relationshipTypeConnectsToDb() if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf() this.relationshipTypes!![relationshipType.id!!] = relationshipType } -fun BlueprintTypes.relationshipTypeConnectsToDb(): RelationshipType { +fun BluePrintTypes.relationshipTypeConnectsToDb(): RelationshipType { return relationshipType( - id = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB, - version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, + id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB, + version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, description = "Relationship connects to through Database." ) { property( - BlueprintConstants.PROPERTY_CONNECTION_CONFIG, - BlueprintConstants.DATA_TYPE_MAP, + BluePrintConstants.PROPERTY_CONNECTION_CONFIG, + BluePrintConstants.DATA_TYPE_MAP, true, "Connection Config details." ) - validTargetTypes(arrayListOf(BlueprintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT)) + validTargetTypes(arrayListOf(BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT)) } } @@ -66,25 +66,25 @@ fun TopologyTemplateBuilder.relationshipTemplateDb( class DbRelationshipTemplateBuilder(name: String, description: String) : RelationshipTemplateBuilder( name, - BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB, description + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB, description ) { fun mariaDb(block: DbMariaDataSourcePropertiesAssignmentBuilder.() -> Unit) { - property(BlueprintConstants.PROPERTY_CONNECTION_CONFIG, BlueprintTypes.mariaDbProperties(block)) + property(BluePrintConstants.PROPERTY_CONNECTION_CONFIG, BluePrintTypes.mariaDbProperties(block)) } fun mySqlDb(block: DbMySqlDataSourcePropertiesAssignmentBuilder.() -> Unit) { - property(BlueprintConstants.PROPERTY_CONNECTION_CONFIG, BlueprintTypes.mySqlDbProperties(block)) + property(BluePrintConstants.PROPERTY_CONNECTION_CONFIG, BluePrintTypes.mySqlDbProperties(block)) } } -fun BlueprintTypes.mariaDbProperties(block: DbMariaDataSourcePropertiesAssignmentBuilder.() -> Unit): JsonNode { +fun BluePrintTypes.mariaDbProperties(block: DbMariaDataSourcePropertiesAssignmentBuilder.() -> Unit): JsonNode { val assignments = DbMariaDataSourcePropertiesAssignmentBuilder().apply(block).build() assignments[DBDataSourceProperties::type.name] = DBLibConstants.MARIA_DB.asJsonPrimitive() return assignments.asJsonNode() } -fun BlueprintTypes.mySqlDbProperties(block: DbMySqlDataSourcePropertiesAssignmentBuilder.() -> Unit): JsonNode { +fun BluePrintTypes.mySqlDbProperties(block: DbMySqlDataSourcePropertiesAssignmentBuilder.() -> Unit): JsonNode { val assignments = DbMySqlDataSourcePropertiesAssignmentBuilder().apply(block).build() assignments[DBDataSourceProperties::type.name] = DBLibConstants.MYSQL_DB.asJsonPrimitive() return assignments.asJsonNode() 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 new file mode 100644 index 000000000..436f2fcab --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt @@ -0,0 +1,87 @@ +/* + * Copyright © 2019 Bell Canada Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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.BluePrintDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.DBDataSourceProperties +import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MARIA_DB +import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MYSQL_DB +import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MSSQL_DB +import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.PROCESSOR_DB +import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties +import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties +import org.onap.ccsdk.cds.blueprintsprocessor.db.MSSqlDataSourceProperties +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.springframework.stereotype.Service + +@Service +class BluePrintDBLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) { + + fun JdbcTemplate(jsonNode: JsonNode): BluePrintDBLibGenericService = + blueprintDBDataSourceService(dBDataSourceProperties(jsonNode)) + + fun JdbcTemplate(selector: String): BluePrintDBLibGenericService = + blueprintDBDataSourceService(dBDataSourceProperties("blueprintsprocessor.db.$selector")) + + private fun dBDataSourceProperties(jsonNode: JsonNode): DBDataSourceProperties = + when (val type = jsonNode.get("type").textValue()) { + MYSQL_DB -> JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java) + MARIA_DB -> JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java) + MSSQL_DB -> JacksonUtils.readValue(jsonNode, MSSqlDataSourceProperties::class.java) + else -> { + throw BluePrintProcessorException( + "DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $MSSQL_DB" + ) + } + }!! + + private fun dBDataSourceProperties(prefix: String): DBDataSourceProperties = + bluePrintPropertiesService.propertyBeanType("$prefix.type", String::class.java).let { + return when (it) { + MARIA_DB, PROCESSOR_DB -> mariaDBConnectionProperties(prefix) + MYSQL_DB -> mySqlDBConnectionProperties(prefix) + MSSQL_DB -> mssqlDBConnectionProperties(prefix) + else -> { + throw BluePrintProcessorException( + "DB type ($it) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $PROCESSOR_DB" + ) + } + } + } + + private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BluePrintDBLibGenericService = + when (dBConnetionProperties) { + is MariaDataSourceProperties -> MariaDatabaseConfiguration(dBConnetionProperties) + is MySqlDataSourceProperties -> MySqlDatabaseConfiguration(dBConnetionProperties) + is MSSqlDataSourceProperties -> MSSqlDatabaseConfiguration(dBConnetionProperties) + else -> throw BluePrintProcessorException( + "Failed to create db configuration for ${dBConnetionProperties.url}" + ) + } + + private fun mySqlDBConnectionProperties(prefix: String): MySqlDataSourceProperties = + bluePrintPropertiesService.propertyBeanType(prefix, MySqlDataSourceProperties::class.java) + + private fun mariaDBConnectionProperties(prefix: String): MariaDataSourceProperties = + bluePrintPropertiesService.propertyBeanType(prefix, MariaDataSourceProperties::class.java) + + private fun mssqlDBConnectionProperties(prefix: String): MSSqlDataSourceProperties = + bluePrintPropertiesService.propertyBeanType(prefix, MSSqlDataSourceProperties::class.java) +} 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 deleted file mode 100644 index 3dbd76c13..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BlueprintDBLibPropertyService.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright © 2019 Bell Canada Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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.BlueprintDBLibGenericService -import org.onap.ccsdk.cds.blueprintsprocessor.db.DBDataSourceProperties -import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MARIA_DB -import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MYSQL_DB -import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MSSQL_DB -import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.PROCESSOR_DB -import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties -import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties -import org.onap.ccsdk.cds.blueprintsprocessor.db.MSSqlDataSourceProperties -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.springframework.stereotype.Service - -@Service -class BlueprintDBLibPropertyService(private var bluePrintPropertiesService: BlueprintPropertiesService) { - - fun JdbcTemplate(jsonNode: JsonNode): BlueprintDBLibGenericService = - blueprintDBDataSourceService(dBDataSourceProperties(jsonNode)) - - fun JdbcTemplate(selector: String): BlueprintDBLibGenericService = - blueprintDBDataSourceService(dBDataSourceProperties("blueprintsprocessor.db.$selector")) - - private fun dBDataSourceProperties(jsonNode: JsonNode): DBDataSourceProperties = - when (val type = jsonNode.get("type").textValue()) { - MYSQL_DB -> JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java) - MARIA_DB -> JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java) - MSSQL_DB -> JacksonUtils.readValue(jsonNode, MSSqlDataSourceProperties::class.java) - else -> { - throw BlueprintProcessorException( - "DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $MSSQL_DB" - ) - } - }!! - - private fun dBDataSourceProperties(prefix: String): DBDataSourceProperties = - bluePrintPropertiesService.propertyBeanType("$prefix.type", String::class.java).let { - return when (it) { - MARIA_DB, PROCESSOR_DB -> mariaDBConnectionProperties(prefix) - MYSQL_DB -> mySqlDBConnectionProperties(prefix) - MSSQL_DB -> mssqlDBConnectionProperties(prefix) - else -> { - throw BlueprintProcessorException( - "DB type ($it) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $PROCESSOR_DB" - ) - } - } - } - - private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BlueprintDBLibGenericService = - when (dBConnetionProperties) { - is MariaDataSourceProperties -> MariaDatabaseConfiguration(dBConnetionProperties) - is MySqlDataSourceProperties -> MySqlDatabaseConfiguration(dBConnetionProperties) - is MSSqlDataSourceProperties -> MSSqlDatabaseConfiguration(dBConnetionProperties) - else -> throw BlueprintProcessorException( - "Failed to create db configuration for ${dBConnetionProperties.url}" - ) - } - - private fun mySqlDBConnectionProperties(prefix: String): MySqlDataSourceProperties = - bluePrintPropertiesService.propertyBeanType(prefix, MySqlDataSourceProperties::class.java) - - private fun mariaDBConnectionProperties(prefix: String): MariaDataSourceProperties = - bluePrintPropertiesService.propertyBeanType(prefix, MariaDataSourceProperties::class.java) - - private fun mssqlDBConnectionProperties(prefix: String): MSSqlDataSourceProperties = - bluePrintPropertiesService.propertyBeanType(prefix, MSSqlDataSourceProperties::class.java) -} diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MSSqlDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MSSqlDatabaseConfiguration.kt index d0ff5b6f3..01f5318ac 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MSSqlDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MSSqlDatabaseConfiguration.kt @@ -16,14 +16,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary -import org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.db.MSSqlDataSourceProperties import org.slf4j.LoggerFactory import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate import org.springframework.jdbc.datasource.DriverManagerDataSource import javax.sql.DataSource -class MSSqlDatabaseConfiguration(private val msSqlDataSourceProperties: MSSqlDataSourceProperties) : BlueprintDBLibGenericService { +class MSSqlDatabaseConfiguration(private val msSqlDataSourceProperties: MSSqlDataSourceProperties) : BluePrintDBLibGenericService { override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { return msSqlNamedParameterJdbcTemplate(msSqlDataSource()) } 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 6132190c2..82895257a 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 @@ -16,14 +16,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary -import org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties import org.slf4j.LoggerFactory import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate import org.springframework.jdbc.datasource.DriverManagerDataSource import javax.sql.DataSource -class MariaDatabaseConfiguration(private val mariaDataSourceProperties: MariaDataSourceProperties) : BlueprintDBLibGenericService { +class MariaDatabaseConfiguration(private val mariaDataSourceProperties: MariaDataSourceProperties) : BluePrintDBLibGenericService { val log = LoggerFactory.getLogger(MariaDatabaseConfiguration::class.java)!! 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 ea13dfb83..0761b72d2 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 @@ -16,14 +16,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary -import org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintDBLibGenericService +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties import org.slf4j.LoggerFactory import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate import org.springframework.jdbc.datasource.DriverManagerDataSource import javax.sql.DataSource -class MySqlDatabaseConfiguration(private val mySqlDataSourceProperties: MySqlDataSourceProperties) : BlueprintDBLibGenericService { +class MySqlDatabaseConfiguration(private val mySqlDataSourceProperties: MySqlDataSourceProperties) : BluePrintDBLibGenericService { override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { return mySqlNamedParameterJdbcTemplate(mySqlDataSource()) 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 fe6da176b..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,16 +18,16 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service -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.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.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.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.slf4j.LoggerFactory import java.io.File import java.nio.file.Path @@ -35,9 +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)!! @@ -51,8 +51,8 @@ abstract class BlueprintCatalogServiceImpl( workingDir = blueprintFile.absolutePath archiveFile = normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, processingId, "cba.zip") - if (!BlueprintArchiveUtils.compress(blueprintFile, archiveFile)) { - throw BlueprintException("Fail to compress blueprint") + if (!BluePrintArchiveUtils.compress(blueprintFile, archiveFile)) { + throw BluePrintException("Fail to compress blueprint") } } else { // Compressed File @@ -63,16 +63,16 @@ abstract class BlueprintCatalogServiceImpl( blueprintFile.deCompress(workingDir) } - var valid = BlueprintConstants.FLAG_N + var valid = BluePrintConstants.FLAG_N if (validate) { - blueprintValidator.validateBlueprints(workingDir!!) - valid = BlueprintConstants.FLAG_Y + blueprintValidator.validateBluePrints(workingDir!!) + valid = BluePrintConstants.FLAG_Y } - val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime(processingId, workingDir!!) + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(processingId, workingDir!!) val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! - metadata[BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = processingId - metadata[BlueprintConstants.PROPERTY_BLUEPRINT_VALID] = valid + metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = processingId + metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID] = valid save(metadata, archiveFile) @@ -83,7 +83,7 @@ abstract class BlueprintCatalogServiceImpl( name, version, extract ) - ?: throw BlueprintException("Could not find blueprint $name:$version from database") + ?: throw BluePrintException("Could not find blueprint $name:$version from database") override suspend fun deleteFromDatabase(name: String, version: String) = delete(name, version) 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 5b9853855..9c007da31 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 @@ -23,21 +23,21 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.cluster.optionalClusterServic 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.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +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.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.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.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.slf4j.LoggerFactory import org.springframework.dao.DataIntegrityViolationException import org.springframework.stereotype.Service @@ -51,8 +51,8 @@ import java.util.UUID */ @Service("blueprintsProcessorCatalogService") class BlueprintProcessorCatalogServiceImpl( - bluePrintRuntimeValidatorService: BlueprintValidatorService, - private val bluePrintLoadConfiguration: BlueprintLoadConfiguration, + bluePrintRuntimeValidatorService: BluePrintValidatorService, + private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val blueprintModelRepository: BlueprintModelRepository ) : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintRuntimeValidatorService) { @@ -61,7 +61,7 @@ class BlueprintProcessorCatalogServiceImpl( override suspend fun delete(name: String, version: String) { // Clean blueprint script cache - val cacheKey = BlueprintFileUtils + val cacheKey = BluePrintFileUtils .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, name, version)) cleanClassLoader(cacheKey) log.info("removed cba file name($name), version($version) from cache") @@ -100,11 +100,11 @@ class BlueprintProcessorCatalogServiceImpl( } check(deployFile.exists() && deployFile.list().isNotEmpty()) { - throw BlueprintProcessorException("file check failed") + throw BluePrintProcessorException("file check failed") } } catch (e: Exception) { deleteNBDir(deployFile.absolutePath) - throw BlueprintProcessorException( + throw BluePrintProcessorException( "failed to get get cba file name($name), version($version) from db" + " : ${e.message}" ) @@ -121,11 +121,11 @@ class BlueprintProcessorCatalogServiceImpl( } override suspend fun save(metadata: MutableMap, archiveFile: File) { - val artifactName = metadata[BlueprintConstants.METADATA_TEMPLATE_NAME] - val artifactVersion = metadata[BlueprintConstants.METADATA_TEMPLATE_VERSION] + val artifactName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] + val artifactVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] check(archiveFile.isFile && !archiveFile.isDirectory) { - throw BlueprintException("Not a valid Archive file(${archiveFile.absolutePath})") + throw BluePrintException("Not a valid Archive file(${archiveFile.absolutePath})") } blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let { @@ -134,7 +134,7 @@ class BlueprintProcessorCatalogServiceImpl( val deployFile = normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, artifactName, artifactVersion) - val cacheKey = BlueprintFileUtils.compileCacheKey(deployFile) + val cacheKey = BluePrintFileUtils.compileCacheKey(deployFile) cleanClassLoader(cacheKey) deleteNBDir(deployFile).let { @@ -144,20 +144,20 @@ class BlueprintProcessorCatalogServiceImpl( } val blueprintModel = BlueprintModel() - blueprintModel.id = metadata[BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] + 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 + blueprintModel.published = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID] + ?: BluePrintConstants.FLAG_N blueprintModel.artifactName = artifactName blueprintModel.artifactVersion = artifactVersion - blueprintModel.updatedBy = metadata[BlueprintConstants.METADATA_TEMPLATE_AUTHOR]!! - blueprintModel.tags = metadata[BlueprintConstants.METADATA_TEMPLATE_TAGS]!! + blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]!! + blueprintModel.tags = metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS]!! val description = - if (null != metadata[BlueprintConstants.METADATA_TEMPLATE_DESCRIPTION]) metadata[BlueprintConstants.METADATA_TEMPLATE_DESCRIPTION] else "" + if (null != metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION]) metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION] else "" blueprintModel.artifactDescription = description val blueprintModelContent = BlueprintModelContent() - blueprintModelContent.id = metadata[BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] + blueprintModelContent.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] blueprintModelContent.contentType = "CBA_ZIP" blueprintModelContent.name = "$artifactName:$artifactVersion" blueprintModelContent.description = "$artifactName:$artifactVersion CBA Zip Content" @@ -169,7 +169,7 @@ class BlueprintProcessorCatalogServiceImpl( try { blueprintModelRepository.saveAndFlush(blueprintModel) } catch (ex: DataIntegrityViolationException) { - throw BlueprintException( + throw BluePrintException( ErrorCode.CONFLICT_ADDING_RESOURCE.value, "The blueprint entry " + "is already exist in database: ${ex.message}", @@ -179,10 +179,10 @@ class BlueprintProcessorCatalogServiceImpl( } private suspend fun cleanClassLoader(cacheKey: String) { - val clusterService = BlueprintDependencyService.optionalClusterService() + val clusterService = BluePrintDependencyService.optionalClusterService() if (clusterService != null && clusterService.clusterJoined()) { log.info("Sending ClusterMessage: Clean Classloader Cache") clusterService.sendMessage(BlueprintClusterTopic.BLUEPRINT_CLEAN_COMPILER_CACHE, cacheKey) - } else BlueprintCompileCache.cleanClassLoader(cacheKey) + } else BluePrintCompileCache.cleanClassLoader(cacheKey) } } 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 4084e156c..b7b1f78cf 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 @@ -20,16 +20,16 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintCoreConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.mock.MockBlueprintProcessorCatalogServiceImpl import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service.BlueprintCatalogServiceImpl import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service.BlueprintProcessorCatalogServiceImpl -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants 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.service.BlueprintRuntimeService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.ComponentScan @@ -46,7 +46,7 @@ import kotlin.test.assertTrue @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor"]) @ContextConfiguration( classes = [ - BlueprintProcessorCatalogServiceImpl::class, BlueprintCoreConfiguration::class, + BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class ] ) @@ -57,9 +57,9 @@ class BlueprintProcessorCatalogServiceImplTest { lateinit var blueprintsProcessorCatalogService: BlueprintCatalogServiceImpl @Autowired - lateinit var blueprintCoreConfiguration: BlueprintCoreConfiguration + lateinit var blueprintCoreConfiguration: BluePrintCoreConfiguration - private lateinit var bluePrintRuntimeService: BlueprintRuntimeService<*> + private lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> private val blueprintId = "1234" @@ -72,7 +72,7 @@ class BlueprintProcessorCatalogServiceImplTest { normalizedFile("./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") .compress(normalizedFile("./target/blueprints/generated-cba.zip")) - bluePrintRuntimeService = BlueprintMetadataUtils.bluePrintRuntime( + bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime( blueprintId, "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" ) @@ -103,7 +103,7 @@ class BlueprintProcessorCatalogServiceImplTest { val file = normalizedFile("./target/blueprints/generated-cba.zip") assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! - metadata[BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId + metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId blueprintsProcessorCatalogService.save(metadata, file) } @@ -115,7 +115,7 @@ class BlueprintProcessorCatalogServiceImplTest { val file = normalizedFile("./target/blueprints/generated-cba.zip") assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! - metadata[BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId + metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId blueprintsProcessorCatalogService.save(metadata, file) blueprintsProcessorCatalogService.get("baseconfiguration", "1.0.0", true) diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt index d182651af..dd84e5b02 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate import kotlin.test.assertEquals @@ -68,12 +68,12 @@ class DatabasePropertiesDSLTest { assertNotNull(relationshipTypes, "failed to get relationship types") assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match") assertNotNull( - relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO], - "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}" + relationshipTypes[BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO], + "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}" ) assertNotNull( - relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB], - "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB}" + relationshipTypes[BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB], + "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB}" ) } } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/TestDatabaseConfiguration.kt index 38a8ef427..d8192acfa 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/TestDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/TestDatabaseConfiguration.kt @@ -27,7 +27,7 @@ import org.springframework.transaction.PlatformTransactionManager import javax.sql.DataSource @Configuration -@Import(BlueprintDBLibConfiguration::class) +@Import(BluePrintDBLibConfiguration::class) @EnableJpaRepositories( basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.db.primary"], entityManagerFactoryRef = "primaryEntityManager", 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 6135f5bbd..248181f16 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 @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.mock import io.mockk.coEvery import io.mockk.mockk -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintValidatorService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -26,10 +26,10 @@ import org.springframework.context.annotation.Configuration open class MockBlueprintProcessorCatalogServiceImpl { @Bean(name = ["bluePrintRuntimeValidatorService"]) - open fun bluePrintRuntimeValidatorService(): BlueprintValidatorService { - val bluePrintValidatorService = mockk() - coEvery { bluePrintValidatorService.validateBlueprints(any()) } returns true - coEvery { bluePrintValidatorService.validateBlueprints(any>()) } returns true + open fun bluePrintRuntimeValidatorService(): BluePrintValidatorService { + val bluePrintValidatorService = mockk() + coEvery { bluePrintValidatorService.validateBluePrints(any()) } returns true + coEvery { bluePrintValidatorService.validateBluePrints(any>()) } returns true return bluePrintValidatorService } } -- cgit 1.2.3-korg