|
|
@ -19,6 +19,7 @@ import com.google.common.util.concurrent.ListenableFuture; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.thingsboard.server.common.data.Tenant; |
|
|
import org.thingsboard.server.common.data.Tenant; |
|
|
import org.thingsboard.server.common.data.TenantInfo; |
|
|
import org.thingsboard.server.common.data.TenantInfo; |
|
|
@ -55,6 +56,9 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe |
|
|
private static final String DEFAULT_TENANT_REGION = "Global"; |
|
|
private static final String DEFAULT_TENANT_REGION = "Global"; |
|
|
public static final String INCORRECT_TENANT_ID = "Incorrect tenantId "; |
|
|
public static final String INCORRECT_TENANT_ID = "Incorrect tenantId "; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${zk.enabled}") |
|
|
|
|
|
private Boolean zkEnabled; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private TenantDao tenantDao; |
|
|
private TenantDao tenantDao; |
|
|
|
|
|
|
|
|
@ -190,6 +194,7 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe |
|
|
if (!StringUtils.isEmpty(tenant.getEmail())) { |
|
|
if (!StringUtils.isEmpty(tenant.getEmail())) { |
|
|
validateEmail(tenant.getEmail()); |
|
|
validateEmail(tenant.getEmail()); |
|
|
} |
|
|
} |
|
|
|
|
|
validateTenantProfile(tenantId, tenant); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -198,6 +203,14 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe |
|
|
if (old == null) { |
|
|
if (old == null) { |
|
|
throw new DataValidationException("Can't update non existing tenant!"); |
|
|
throw new DataValidationException("Can't update non existing tenant!"); |
|
|
} |
|
|
} |
|
|
|
|
|
validateTenantProfile(tenantId, tenant); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void validateTenantProfile(TenantId tenantId, Tenant tenant) { |
|
|
|
|
|
TenantProfile tenantProfileById = tenantProfileService.findTenantProfileById(tenantId, tenant.getTenantProfileId()); |
|
|
|
|
|
if (!zkEnabled && (tenantProfileById.isIsolatedTbCore() || tenantProfileById.isIsolatedTbRuleEngine())) { |
|
|
|
|
|
throw new DataValidationException("Can't use isolated tenant profiles in monolith setup!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|