RED-5293: 500 for invalid tenant
This commit is contained in:
parent
eaa0a640d5
commit
a9f4c5f31f
@ -1,6 +1,7 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.multitenancy;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -13,6 +14,7 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class TenantRequest {
|
||||
|
||||
@NotNull
|
||||
private String tenantId;
|
||||
@NotBlank
|
||||
private String displayName;
|
||||
|
||||
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.postgresql.util.PSQLException;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@ -15,6 +16,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.ConflictException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.multitenancy.entity.TenantEntity;
|
||||
@ -61,6 +63,8 @@ public class TenantManagementService {
|
||||
try (Connection connection = DriverManager.getConnection(tenantRequest.getJdbcUrl(), tenantRequest.getUser(), tenantRequest.getPassword())) {
|
||||
DataSource tenantDataSource = new SingleConnectionDataSource(connection, false);
|
||||
runLiquibase(tenantDataSource);
|
||||
} catch (PSQLException e) {
|
||||
throw new BadRequestException("Could not connect to datbase", e);
|
||||
}
|
||||
|
||||
TenantEntity tenantEntity = TenantEntity.builder()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user