|
|
|
@ -35,7 +35,7 @@ import org.thingsboard.server.common.data.tenant.profile.TenantProfileConfigurat |
|
|
|
import org.thingsboard.server.dao.entity.AbstractEntityService; |
|
|
|
import org.thingsboard.server.dao.exception.DataValidationException; |
|
|
|
import org.thingsboard.server.dao.service.DataValidator; |
|
|
|
import org.thingsboard.server.dao.tenant.TenantDao; |
|
|
|
import org.thingsboard.server.dao.tenant.TenantService; |
|
|
|
import org.thingsboard.server.dao.tenant.TenantProfileDao; |
|
|
|
import org.thingsboard.server.dao.timeseries.TimeseriesService; |
|
|
|
|
|
|
|
@ -52,11 +52,11 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A |
|
|
|
|
|
|
|
private final ApiUsageStateDao apiUsageStateDao; |
|
|
|
private final TenantProfileDao tenantProfileDao; |
|
|
|
private final TenantDao tenantDao; |
|
|
|
private final TenantService tenantService; |
|
|
|
private final TimeseriesService tsService; |
|
|
|
|
|
|
|
public ApiUsageStateServiceImpl(TenantDao tenantDao, ApiUsageStateDao apiUsageStateDao, TenantProfileDao tenantProfileDao, TimeseriesService tsService) { |
|
|
|
this.tenantDao = tenantDao; |
|
|
|
public ApiUsageStateServiceImpl(TenantService tenantService, ApiUsageStateDao apiUsageStateDao, TenantProfileDao tenantProfileDao, TimeseriesService tsService) { |
|
|
|
this.tenantService = tenantService; |
|
|
|
this.apiUsageStateDao = apiUsageStateDao; |
|
|
|
this.tenantProfileDao = tenantProfileDao; |
|
|
|
this.tsService = tsService; |
|
|
|
@ -114,7 +114,7 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A |
|
|
|
|
|
|
|
if (entityId.getEntityType() == EntityType.TENANT && !entityId.equals(TenantId.SYS_TENANT_ID)) { |
|
|
|
tenantId = (TenantId) entityId; |
|
|
|
Tenant tenant = tenantDao.findById(tenantId, tenantId.getId()); |
|
|
|
Tenant tenant = tenantService.findTenantById(tenantId); |
|
|
|
TenantProfile tenantProfile = tenantProfileDao.findById(tenantId, tenant.getTenantProfileId().getId()); |
|
|
|
TenantProfileConfiguration configuration = tenantProfile.getProfileData().getConfiguration(); |
|
|
|
|
|
|
|
@ -164,7 +164,8 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A |
|
|
|
if (apiUsageState.getTenantId() == null) { |
|
|
|
throw new DataValidationException("ApiUsageState should be assigned to tenant!"); |
|
|
|
} else { |
|
|
|
Tenant tenant = tenantDao.findById(requestTenantId, apiUsageState.getTenantId().getId()); |
|
|
|
Tenant tenant = tenantService.findTenantById(apiUsageState.getTenantId()); |
|
|
|
// TODO: 12.01.22 Instead of finding and checking for null need to create and use tenantService.exists()
|
|
|
|
if (tenant == null && !requestTenantId.equals(TenantId.SYS_TENANT_ID)) { |
|
|
|
throw new DataValidationException("ApiUsageState is referencing to non-existent tenant!"); |
|
|
|
} |
|
|
|
|