Add validation for DefaultEdgeRuleChain in DeviceProfile
- reverted changes
This commit is contained in:
		
							parent
							
								
									ae4bdb52da
								
							
						
					
					
						commit
						ed1639663f
					
				@ -189,11 +189,11 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (deviceProfile.getDefaultRuleChainId() != null) {
 | 
			
		||||
            validateRuleChain(tenantId, deviceProfile.getDefaultRuleChainId());
 | 
			
		||||
            validateRuleChain(tenantId, deviceProfile.getTenantId(), deviceProfile.getDefaultRuleChainId());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (deviceProfile.getDefaultEdgeRuleChainId() != null) {
 | 
			
		||||
            validateRuleChain(tenantId, deviceProfile.getDefaultEdgeRuleChainId());
 | 
			
		||||
            validateRuleChain(tenantId, deviceProfile.getTenantId(), deviceProfile.getDefaultEdgeRuleChainId());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (deviceProfile.getDefaultDashboardId() != null) {
 | 
			
		||||
@ -209,12 +209,12 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
 | 
			
		||||
        validateOtaPackage(tenantId, deviceProfile, deviceProfile.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void validateRuleChain(TenantId tenantId, RuleChainId ruleChainId) {
 | 
			
		||||
    private void validateRuleChain(TenantId tenantId, TenantId deviceProfileTenantId, RuleChainId ruleChainId) {
 | 
			
		||||
        RuleChain ruleChain = ruleChainService.findRuleChainById(tenantId, ruleChainId);
 | 
			
		||||
        if (ruleChain == null) {
 | 
			
		||||
            throw new DataValidationException("Can't assign non-existent rule chain!");
 | 
			
		||||
        }
 | 
			
		||||
        if (!ruleChain.getTenantId().equals(tenantId)) {
 | 
			
		||||
        if (!ruleChain.getTenantId().equals(deviceProfileTenantId)) {
 | 
			
		||||
            throw new DataValidationException("Can't assign rule chain from different tenant!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user