TenantId for SYS_TENANT_ID refactored (new instances replaced with constant)
This commit is contained in:
		
							parent
							
								
									d3987d1c67
								
							
						
					
					
						commit
						6f19efd539
					
				@ -222,7 +222,7 @@ public class AppActor extends ContextAwareActor {
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public TbActorId createActorId() {
 | 
			
		||||
            return new TbEntityActorId(new TenantId(EntityId.NULL_UUID));
 | 
			
		||||
            return new TbEntityActorId(TenantId.SYS_TENANT_ID);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
 | 
			
		||||
@ -99,7 +99,7 @@ public class DatabaseHelper {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                for (CustomerId customerId : customerIds) {
 | 
			
		||||
                    dashboardService.assignDashboardToCustomer(new TenantId(EntityId.NULL_UUID), dashboardId, customerId);
 | 
			
		||||
                    dashboardService.assignDashboardToCustomer(TenantId.SYS_TENANT_ID, dashboardId, customerId);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -169,7 +169,7 @@ public class InstallScripts {
 | 
			
		||||
        ruleChain = ruleChainService.saveRuleChain(ruleChain);
 | 
			
		||||
 | 
			
		||||
        ruleChainMetaData.setRuleChainId(ruleChain.getId());
 | 
			
		||||
        ruleChainService.saveRuleChainMetaData(new TenantId(EntityId.NULL_UUID), ruleChainMetaData);
 | 
			
		||||
        ruleChainService.saveRuleChainMetaData(TenantId.SYS_TENANT_ID, ruleChainMetaData);
 | 
			
		||||
 | 
			
		||||
        return ruleChain;
 | 
			
		||||
    }
 | 
			
		||||
@ -217,7 +217,7 @@ public class InstallScripts {
 | 
			
		||||
                            dashboard.setTenantId(tenantId);
 | 
			
		||||
                            Dashboard savedDashboard = dashboardService.saveDashboard(dashboard);
 | 
			
		||||
                            if (customerId != null && !customerId.isNullUid()) {
 | 
			
		||||
                                dashboardService.assignDashboardToCustomer(new TenantId(EntityId.NULL_UUID), savedDashboard.getId(), customerId);
 | 
			
		||||
                                dashboardService.assignDashboardToCustomer(TenantId.SYS_TENANT_ID, savedDashboard.getId(), customerId);
 | 
			
		||||
                            }
 | 
			
		||||
                        } catch (Exception e) {
 | 
			
		||||
                            log.error("Unable to load dashboard from json: [{}]", path.toString());
 | 
			
		||||
 | 
			
		||||
@ -95,7 +95,7 @@ public class DefaultMailService implements MailService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void updateMailConfiguration() {
 | 
			
		||||
        AdminSettings settings = adminSettingsService.findAdminSettingsByKey(new TenantId(EntityId.NULL_UUID), "mail");
 | 
			
		||||
        AdminSettings settings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail");
 | 
			
		||||
        if (settings != null) {
 | 
			
		||||
            JsonNode jsonConfig = settings.getJsonValue();
 | 
			
		||||
            mailSender = createMailSender(jsonConfig);
 | 
			
		||||
 | 
			
		||||
@ -75,7 +75,7 @@ public class RefreshTokenAuthenticationProvider implements AuthenticationProvide
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private SecurityUser authenticateByUserId(UserId userId) {
 | 
			
		||||
        TenantId systemId = new TenantId(EntityId.NULL_UUID);
 | 
			
		||||
        TenantId systemId = TenantId.SYS_TENANT_ID;
 | 
			
		||||
        User user = userService.findUserById(systemId, userId);
 | 
			
		||||
        if (user == null) {
 | 
			
		||||
            throw new UsernameNotFoundException("User not found by refresh token");
 | 
			
		||||
@ -99,7 +99,7 @@ public class RefreshTokenAuthenticationProvider implements AuthenticationProvide
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private SecurityUser authenticateByPublicId(String publicId) {
 | 
			
		||||
        TenantId systemId = new TenantId(EntityId.NULL_UUID);
 | 
			
		||||
        TenantId systemId = TenantId.SYS_TENANT_ID;
 | 
			
		||||
        CustomerId customerId;
 | 
			
		||||
        try {
 | 
			
		||||
            customerId = new CustomerId(UUID.fromString(publicId));
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,7 @@ public class DefaultSmsService implements SmsService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void updateSmsConfiguration() {
 | 
			
		||||
        AdminSettings settings = adminSettingsService.findAdminSettingsByKey(new TenantId(EntityId.NULL_UUID), "sms");
 | 
			
		||||
        AdminSettings settings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "sms");
 | 
			
		||||
        if (settings != null) {
 | 
			
		||||
            try {
 | 
			
		||||
                JsonNode jsonConfig = settings.getJsonValue();
 | 
			
		||||
 | 
			
		||||
@ -279,7 +279,7 @@ public class HashPartitionService implements PartitionService {
 | 
			
		||||
            tpi.tenantId(tenantId);
 | 
			
		||||
            myPartitionsSearchKey = new ServiceQueueKey(serviceQueue, tenantId);
 | 
			
		||||
        } else {
 | 
			
		||||
            myPartitionsSearchKey = new ServiceQueueKey(serviceQueue, new TenantId(TenantId.NULL_UUID));
 | 
			
		||||
            myPartitionsSearchKey = new ServiceQueueKey(serviceQueue, TenantId.SYS_TENANT_ID);
 | 
			
		||||
        }
 | 
			
		||||
        List<Integer> partitions = myPartitions.get(myPartitionsSearchKey);
 | 
			
		||||
        if (partitions != null) {
 | 
			
		||||
 | 
			
		||||
@ -51,7 +51,7 @@ public class BaseComponentDescriptorService implements ComponentDescriptorServic
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ComponentDescriptor saveComponent(TenantId tenantId, ComponentDescriptor component) {
 | 
			
		||||
        componentValidator.validate(component, data -> new TenantId(EntityId.NULL_UUID));
 | 
			
		||||
        componentValidator.validate(component, data -> TenantId.SYS_TENANT_ID);
 | 
			
		||||
        Optional<ComponentDescriptor> result = componentDescriptorDao.saveIfNotExist(tenantId, component);
 | 
			
		||||
        return result.orElseGet(() -> componentDescriptorDao.findByClazz(tenantId, component.getClazz()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -73,7 +73,7 @@ public class DeviceCredentialsServiceImpl extends AbstractEntityService implemen
 | 
			
		||||
    public DeviceCredentials findDeviceCredentialsByCredentialsId(String credentialsId) {
 | 
			
		||||
        log.trace("Executing findDeviceCredentialsByCredentialsId [{}]", credentialsId);
 | 
			
		||||
        validateString(credentialsId, "Incorrect credentialsId " + credentialsId);
 | 
			
		||||
        return deviceCredentialsDao.findByCredentialsId(new TenantId(EntityId.NULL_UUID), credentialsId);
 | 
			
		||||
        return deviceCredentialsDao.findByCredentialsId(TenantId.SYS_TENANT_ID, credentialsId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
@ -168,20 +168,20 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
 | 
			
		||||
    public PageData<Tenant> findTenants(PageLink pageLink) {
 | 
			
		||||
        log.trace("Executing findTenants pageLink [{}]", pageLink);
 | 
			
		||||
        Validator.validatePageLink(pageLink);
 | 
			
		||||
        return tenantDao.findTenantsByRegion(new TenantId(EntityId.NULL_UUID), DEFAULT_TENANT_REGION, pageLink);
 | 
			
		||||
        return tenantDao.findTenantsByRegion(TenantId.SYS_TENANT_ID, DEFAULT_TENANT_REGION, pageLink);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public PageData<TenantInfo> findTenantInfos(PageLink pageLink) {
 | 
			
		||||
        log.trace("Executing findTenantInfos pageLink [{}]", pageLink);
 | 
			
		||||
        Validator.validatePageLink(pageLink);
 | 
			
		||||
        return tenantDao.findTenantInfosByRegion(new TenantId(EntityId.NULL_UUID), DEFAULT_TENANT_REGION, pageLink);
 | 
			
		||||
        return tenantDao.findTenantInfosByRegion(TenantId.SYS_TENANT_ID, DEFAULT_TENANT_REGION, pageLink);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void deleteTenants() {
 | 
			
		||||
        log.trace("Executing deleteTenants");
 | 
			
		||||
        tenantsRemover.removeEntities(new TenantId(EntityId.NULL_UUID), DEFAULT_TENANT_REGION);
 | 
			
		||||
        tenantsRemover.removeEntities(TenantId.SYS_TENANT_ID, DEFAULT_TENANT_REGION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private DataValidator<Tenant> tenantValidator =
 | 
			
		||||
 | 
			
		||||
@ -86,7 +86,7 @@ public abstract class AbstractServiceTest {
 | 
			
		||||
 | 
			
		||||
    protected ObjectMapper mapper = new ObjectMapper();
 | 
			
		||||
 | 
			
		||||
    public static final TenantId SYSTEM_TENANT_ID = new TenantId(EntityId.NULL_UUID);
 | 
			
		||||
    public static final TenantId SYSTEM_TENANT_ID = TenantId.SYS_TENANT_ID;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    protected UserService userService;
 | 
			
		||||
 | 
			
		||||
@ -158,7 +158,7 @@ public class JpaWidgetsBundleDaoTest extends AbstractJpaDaoTest {
 | 
			
		||||
            WidgetsBundle widgetsBundle = new WidgetsBundle();
 | 
			
		||||
            widgetsBundle.setAlias(prefix + i);
 | 
			
		||||
            widgetsBundle.setTitle(prefix + i);
 | 
			
		||||
            widgetsBundle.setTenantId(new TenantId(NULL_UUID));
 | 
			
		||||
            widgetsBundle.setTenantId(TenantId.SYS_TENANT_ID);
 | 
			
		||||
            widgetsBundle.setId(new WidgetsBundleId(Uuids.timeBased()));
 | 
			
		||||
            widgetsBundleDao.save(AbstractServiceTest.SYSTEM_TENANT_ID, widgetsBundle);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user