commit
772c565619
@ -43,6 +43,7 @@ import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.Abstrac
|
||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential;
|
||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapServerCredential;
|
||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapServerCredential;
|
||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.queue.Queue;
|
||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||
@ -188,13 +189,11 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
||||
}
|
||||
|
||||
if (deviceProfile.getDefaultRuleChainId() != null) {
|
||||
RuleChain ruleChain = ruleChainService.findRuleChainById(tenantId, deviceProfile.getDefaultRuleChainId());
|
||||
if (ruleChain == null) {
|
||||
throw new DataValidationException("Can't assign non-existent rule chain!");
|
||||
}
|
||||
if (!ruleChain.getTenantId().equals(deviceProfile.getTenantId())) {
|
||||
throw new DataValidationException("Can't assign rule chain from different tenant!");
|
||||
validateRuleChain(tenantId, deviceProfile.getTenantId(), deviceProfile.getDefaultRuleChainId());
|
||||
}
|
||||
|
||||
if (deviceProfile.getDefaultEdgeRuleChainId() != null) {
|
||||
validateRuleChain(tenantId, deviceProfile.getTenantId(), deviceProfile.getDefaultEdgeRuleChainId());
|
||||
}
|
||||
|
||||
if (deviceProfile.getDefaultDashboardId() != null) {
|
||||
@ -210,6 +209,16 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
||||
validateOtaPackage(tenantId, deviceProfile, deviceProfile.getId());
|
||||
}
|
||||
|
||||
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(deviceProfileTenantId)) {
|
||||
throw new DataValidationException("Can't assign rule chain from different tenant!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DeviceProfile validateUpdate(TenantId tenantId, DeviceProfile deviceProfile) {
|
||||
DeviceProfile old = deviceProfileDao.findById(deviceProfile.getTenantId(), deviceProfile.getId().getId());
|
||||
@ -423,4 +432,5 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
||||
private String getCertificateString(X509Certificate cert) throws CertificateEncodingException {
|
||||
return EncryptionUtil.certTrimNewLines(Base64.getEncoder().encodeToString(cert.getEncoded()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user