Package com.totvs.tjf.tenant.schema
Class TenantSchemaUtilsService
java.lang.Object
com.totvs.tjf.tenant.schema.TenantSchemaUtilsService
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
public class TenantSchemaUtilsService
extends Object
implements org.springframework.beans.factory.InitializingBean
Custom implementation to manipulate the schema creation/validation.
-
Constructor Summary
ConstructorsConstructorDescriptionTenantSchemaUtilsService
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, com.totvs.tjf.tenant.context.schema.SchemaUtils schemaUtils, com.totvs.tjf.tenant.context.schema.SchemaProperties schemaProperties, com.totvs.tjf.migration.context.FlywayMigrationService migrationService, com.totvs.tjf.repository.context.aggregate.MultiDataSourceProperties multiTenantProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
createSchema
(String schema) Creates the schema if it has not been created.Get the all schemas in the cache listprotected boolean
isAvailable
(String schema) Validate if the given tenant identifier exists in the database.protected boolean
onlyAcceptedSchemas
(String schema) Verify if the given schema is should be ignored.void
validateSchemaDynamically
(String schema) Validates the schema if it's created and up-to-date when connection was requested.
-
Constructor Details
-
TenantSchemaUtilsService
public TenantSchemaUtilsService(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, com.totvs.tjf.tenant.context.schema.SchemaUtils schemaUtils, com.totvs.tjf.tenant.context.schema.SchemaProperties schemaProperties, @Nullable com.totvs.tjf.migration.context.FlywayMigrationService migrationService, com.totvs.tjf.repository.context.aggregate.MultiDataSourceProperties multiTenantProperties)
-
-
Method Details
-
createSchema
Creates the schema if it has not been created.- Parameters:
schema
- schema name- See Also:
-
FlywayMigrationService.migrate(String)
-
validateSchemaDynamically
Validates the schema if it's created and up-to-date when connection was requested.- Parameters:
schema
- schema name- See Also:
-
FlywayMigrationService.validateDynamically(String)
-
isAvailable
Validate if the given tenant identifier exists in the database.Note: The validation occurs over the normalized tenant identifier.
- Parameters:
schema
- identifier to check the availability.- Returns:
true
if the tenant have an equivalent schema in the database, otherwise,false
.- See Also:
-
SchemaUtils.normalizeSchema(String)
-
getSchemas
Get the all schemas in the cache list- Returns:
- schemas set of schemas
-
onlyAcceptedSchemas
Verify if the given schema is should be ignored.- Parameters:
schema
- to verified.- Returns:
true
if schema is not present in ignored list, otherwise,false
.
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-