Commit 7801c3d7aa27046129190f4537118e71dce41ba5

Authored by Viacheslav Klimov
1 parent f7aa8cc7

Fix up fields length validation for rule nodes and alarm rules

... ... @@ -19,6 +19,7 @@ import io.swagger.annotations.ApiModel;
19 19 import io.swagger.annotations.ApiModelProperty;
20 20 import lombok.Data;
21 21 import org.thingsboard.server.common.data.alarm.AlarmSeverity;
  22 +import org.thingsboard.server.common.data.validation.Length;
22 23 import org.thingsboard.server.common.data.validation.NoXss;
23 24
24 25 import javax.validation.Valid;
... ... @@ -32,6 +33,7 @@ public class DeviceProfileAlarm implements Serializable {
32 33
33 34 @ApiModelProperty(position = 1, value = "String value representing the alarm rule id", example = "highTemperatureAlarmID")
34 35 private String id;
  36 + @Length(fieldName = "alarm type")
35 37 @NoXss
36 38 @ApiModelProperty(position = 2, value = "String value representing type of the alarm", example = "High Temperature Alarm")
37 39 private String alarmType;
... ...
... ... @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiModelProperty;
21 21 import lombok.Data;
22 22 import org.thingsboard.server.common.data.id.RuleChainId;
23 23
  24 +import javax.validation.Valid;
24 25 import java.util.ArrayList;
25 26 import java.util.List;
26 27
... ... @@ -37,6 +38,7 @@ public class RuleChainMetaData {
37 38 @ApiModelProperty(position = 2, required = true, value = "Index of the first rule node in the 'nodes' list")
38 39 private Integer firstNodeIndex;
39 40
  41 + @Valid
40 42 @ApiModelProperty(position = 3, required = true, value = "List of rule node JSON objects")
41 43 private List<RuleNode> nodes;
42 44
... ...
... ... @@ -52,6 +52,7 @@ import org.thingsboard.server.common.data.rule.RuleNode;
52 52 import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
53 53 import org.thingsboard.server.dao.entity.AbstractEntityService;
54 54 import org.thingsboard.server.dao.exception.DataValidationException;
  55 +import org.thingsboard.server.dao.service.ConstraintValidator;
55 56 import org.thingsboard.server.dao.service.DataValidator;
56 57 import org.thingsboard.server.dao.service.PaginatedRemover;
57 58 import org.thingsboard.server.dao.service.Validator;
... ... @@ -135,6 +136,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
135 136 if (ruleChain == null) {
136 137 return false;
137 138 }
  139 + ConstraintValidator.validateFields(ruleChainMetaData);
138 140
139 141 if (CollectionUtils.isNotEmpty(ruleChainMetaData.getConnections())) {
140 142 validateCircles(ruleChainMetaData.getConnections());
... ...