RED-6593 - Fix azure test connection + move create schema logic
This commit is contained in:
parent
858be8c050
commit
81ad77fa59
@ -77,7 +77,7 @@ dependencies {
|
||||
implementation("org.apache.commons:commons-lang3:3.12.0")
|
||||
implementation("commons-validator:commons-validator:1.7")
|
||||
implementation("org.springframework.boot:spring-boot-configuration-processor")
|
||||
implementation("com.iqser.red.commons:storage-commons:2.3.0")
|
||||
implementation("com.iqser.red.commons:storage-commons:2.4.0")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.cloud:spring-cloud-starter-openfeign")
|
||||
testImplementation("org.projectlombok:lombok")
|
||||
|
||||
@ -93,9 +93,6 @@ public class TenantManagementService implements TenantProvider {
|
||||
log.info("Creating tenant: {}", tenantRequest.getTenantId());
|
||||
var jdbcUrl = JDBCUtils.buildJdbcUrlWithSchema(tenantRequest.getDatabaseConnection());
|
||||
validateJdbcUrl(jdbcUrl);
|
||||
createSchema(tenantRequest);
|
||||
|
||||
log.info("Created schema for tenant: {}", tenantRequest.getTenantId());
|
||||
|
||||
TenantEntity tenantEntity = TenantEntity.builder()
|
||||
.tenantId(tenantRequest.getTenantId())
|
||||
@ -122,7 +119,8 @@ public class TenantManagementService implements TenantProvider {
|
||||
.build();
|
||||
|
||||
if (tenantRequest.getAzureStorageConnection() != null) {
|
||||
testAzureConnection(tenantRequest.getAzureStorageConnection().getConnectionString());
|
||||
testAzureConnection(tenantRequest.getAzureStorageConnection().getConnectionString(),
|
||||
tenantRequest.getAzureStorageConnection().getContainerName());
|
||||
|
||||
tenantEntity.setAzureStorageConnection(AzureStorageConnectionEntity.builder()
|
||||
.connectionString(encryptionService.encrypt(tenantRequest.getAzureStorageConnection().getConnectionString()))
|
||||
@ -143,6 +141,10 @@ public class TenantManagementService implements TenantProvider {
|
||||
.build());
|
||||
}
|
||||
|
||||
createSchema(tenantRequest);
|
||||
|
||||
log.info("Created schema for tenant: {}", tenantRequest.getTenantId());
|
||||
|
||||
propagateTenantToKeyCloak(tenantRequest);
|
||||
|
||||
log.info("Updated roles for tenant: {}", tenantRequest.getTenantId());
|
||||
@ -395,7 +397,8 @@ public class TenantManagementService implements TenantProvider {
|
||||
|
||||
var azureStorageConnection = tenantRequest.getAzureStorageConnection();
|
||||
if (azureStorageConnection != null) {
|
||||
testAzureConnection(tenantRequest.getAzureStorageConnection().getConnectionString());
|
||||
testAzureConnection(azureStorageConnection.getConnectionString(),
|
||||
azureStorageConnection.getContainerName());
|
||||
tenantEntity
|
||||
.setAzureStorageConnection(AzureStorageConnectionEntity.builder()
|
||||
.connectionString(encryptionService.encrypt(azureStorageConnection.getConnectionString()))
|
||||
@ -485,9 +488,9 @@ public class TenantManagementService implements TenantProvider {
|
||||
return tenantResponse;
|
||||
}
|
||||
|
||||
private void testAzureConnection(String connectionString) {
|
||||
private void testAzureConnection(String connectionString, String containerName) {
|
||||
|
||||
var connection = storageConfiguration.getAzureBlobStorageService().testConnection(connectionString);
|
||||
var connection = storageConfiguration.getAzureBlobStorageService().testConnection(connectionString, containerName);
|
||||
|
||||
if (!connection) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Could not connect to Azure storage");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user