Commit fe5215c7ccb6df14ae34fe81a07c4f61c164b8ce

Authored by Viacheslav Klimov
1 parent 2d845c78

Minor refactoring

@@ -103,7 +103,6 @@ public class AdminController extends BaseController { @@ -103,7 +103,6 @@ public class AdminController extends BaseController {
103 } else if (adminSettings.getKey().equals("sms")) { 103 } else if (adminSettings.getKey().equals("sms")) {
104 smsService.updateSmsConfiguration(); 104 smsService.updateSmsConfiguration();
105 } 105 }
106 -  
107 return adminSettings; 106 return adminSettings;
108 } catch (Exception e) { 107 } catch (Exception e) {
109 throw handleException(e); 108 throw handleException(e);
@@ -37,7 +37,6 @@ import org.thingsboard.server.common.data.relation.EntityRelation; @@ -37,7 +37,6 @@ import org.thingsboard.server.common.data.relation.EntityRelation;
37 import org.thingsboard.server.common.data.relation.EntityRelationInfo; 37 import org.thingsboard.server.common.data.relation.EntityRelationInfo;
38 import org.thingsboard.server.common.data.relation.EntityRelationsQuery; 38 import org.thingsboard.server.common.data.relation.EntityRelationsQuery;
39 import org.thingsboard.server.common.data.relation.RelationTypeGroup; 39 import org.thingsboard.server.common.data.relation.RelationTypeGroup;
40 -import org.thingsboard.server.dao.service.ConstraintValidator;  
41 import org.thingsboard.server.queue.util.TbCoreComponent; 40 import org.thingsboard.server.queue.util.TbCoreComponent;
42 import org.thingsboard.server.service.security.permission.Operation; 41 import org.thingsboard.server.service.security.permission.Operation;
43 42
@@ -85,7 +84,6 @@ public class EntityRelationController extends BaseController { @@ -85,7 +84,6 @@ public class EntityRelationController extends BaseController {
85 if (relation.getTypeGroup() == null) { 84 if (relation.getTypeGroup() == null) {
86 relation.setTypeGroup(RelationTypeGroup.COMMON); 85 relation.setTypeGroup(RelationTypeGroup.COMMON);
87 } 86 }
88 - ConstraintValidator.validateFields(relation);  
89 relationService.saveRelation(getTenantId(), relation); 87 relationService.saveRelation(getTenantId(), relation);
90 88
91 logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(), 89 logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
@@ -95,6 +95,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand @@ -95,6 +95,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand
95 } 95 }
96 } 96 }
97 97
  98 +
98 private void handleThingsboardException(ThingsboardException thingsboardException, HttpServletResponse response) throws IOException { 99 private void handleThingsboardException(ThingsboardException thingsboardException, HttpServletResponse response) throws IOException {
99 100
100 ThingsboardErrorCode errorCode = thingsboardException.getErrorCode(); 101 ThingsboardErrorCode errorCode = thingsboardException.getErrorCode();
@@ -41,6 +41,7 @@ import org.thingsboard.server.common.data.relation.RelationTypeGroup; @@ -41,6 +41,7 @@ import org.thingsboard.server.common.data.relation.RelationTypeGroup;
41 import org.thingsboard.server.common.data.relation.RelationsSearchParameters; 41 import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
42 import org.thingsboard.server.dao.entity.EntityService; 42 import org.thingsboard.server.dao.entity.EntityService;
43 import org.thingsboard.server.dao.exception.DataValidationException; 43 import org.thingsboard.server.dao.exception.DataValidationException;
  44 +import org.thingsboard.server.dao.service.ConstraintValidator;
44 45
45 import javax.annotation.Nullable; 46 import javax.annotation.Nullable;
46 import java.util.ArrayList; 47 import java.util.ArrayList;
@@ -559,6 +560,7 @@ public class BaseRelationService implements RelationService { @@ -559,6 +560,7 @@ public class BaseRelationService implements RelationService {
559 if (relation == null) { 560 if (relation == null) {
560 throw new DataValidationException("Relation type should be specified!"); 561 throw new DataValidationException("Relation type should be specified!");
561 } 562 }
  563 + ConstraintValidator.validateFields(relation);
562 validate(relation.getFrom(), relation.getTo(), relation.getType(), relation.getTypeGroup()); 564 validate(relation.getFrom(), relation.getTo(), relation.getType(), relation.getTypeGroup());
563 } 565 }
564 566