From adcd4f2bc695840e9ecbc05003bc52c675f22fec Mon Sep 17 00:00:00 2001 From: KAPIL SINGAL Date: Fri, 22 Jan 2021 11:49:51 -0500 Subject: Renaming Files having BluePrint to have Blueprint Replacing BluePrint with Blueprint throughout Issue-ID: CCSDK-3098 Signed-off-by: KAPIL SINGAL Change-Id: Ibee8bad07ae7d9287073db2d4f2f2cd730fa8b96 --- .../db/BluePrintDBLibConfiguration.kt | 81 ---------------------- .../blueprintsprocessor/db/BluePrintDBLibData.kt | 52 -------------- .../db/BluePrintDBLibGenericService.kt | 44 ------------ .../db/BlueprintDBLibConfiguration.kt | 81 ++++++++++++++++++++++ .../blueprintsprocessor/db/BlueprintDBLibData.kt | 52 ++++++++++++++ .../db/BlueprintDBLibGenericService.kt | 44 ++++++++++++ .../db/DatabasePropertiesDSL.kt | 30 ++++---- .../db/primary/BluePrintDBLibPropertyService.kt | 79 --------------------- .../db/primary/BlueprintDBLibPropertyService.kt | 79 +++++++++++++++++++++ .../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 ++-- 17 files changed, 343 insertions(+), 343 deletions(-) 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/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/primary/BluePrintDBLibPropertyService.kt create 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 deleted file mode 100644 index d4b3f807b..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt +++ /dev/null @@ -1,81 +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" - - // 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" - } -} 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 7023106eb..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt +++ /dev/null @@ -1,52 +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 -} 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 aeb87fd66..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/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..f11832beb --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibConfiguration.kt @@ -0,0 +1,81 @@ +/* + * 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" + + // 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" + } +} 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..7023106eb --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintDBLibData.kt @@ -0,0 +1,52 @@ +/* + * 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 +} 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..6c382377d --- /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/DatabasePropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt index 34dd0a417..fd51da152 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 deleted file mode 100644 index 79f5c09bc..000000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt +++ /dev/null @@ -1,79 +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.PROCESSOR_DB -import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties -import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties -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) - else -> { - throw BluePrintProcessorException( - "DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_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) - 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) - 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) -} 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..b272a9708 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BlueprintDBLibPropertyService.kt @@ -0,0 +1,79 @@ +/* + * 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.PROCESSOR_DB +import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties +import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties +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) + else -> { + throw BlueprintProcessorException( + "DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_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) + 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) + 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) +} 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 82895257a..6132190c2 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 0761b72d2..ea13dfb83 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 9d1826395..fe6da176b 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 6637c62ec..10a526365 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,9 +179,9 @@ class BlueprintProcessorCatalogServiceImpl( } private suspend fun cleanClassLoader(cacheKey: String) { - val clusterService = BluePrintDependencyService.optionalClusterService() + val clusterService = BlueprintDependencyService.optionalClusterService() if (null == clusterService) - BluePrintCompileCache.cleanClassLoader(cacheKey) + BlueprintCompileCache.cleanClassLoader(cacheKey) else { log.info("Sending ClusterMessage: Clean Classloader Cache") clusterService.sendMessage(BlueprintClusterTopic.BLUEPRINT_CLEAN_COMPILER_CACHE, 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 b7b1f78cf..4084e156c 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 dd84e5b02..d182651af 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 d8192acfa..38a8ef427 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 248181f16..6135f5bbd 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