Minor refactoring
This commit is contained in:
parent
2d845c7840
commit
fe5215c7cc
@ -103,7 +103,6 @@ public class AdminController extends BaseController {
|
|||||||
} else if (adminSettings.getKey().equals("sms")) {
|
} else if (adminSettings.getKey().equals("sms")) {
|
||||||
smsService.updateSmsConfiguration();
|
smsService.updateSmsConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
return adminSettings;
|
return adminSettings;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
|
|||||||
@ -37,7 +37,6 @@ import org.thingsboard.server.common.data.relation.EntityRelation;
|
|||||||
import org.thingsboard.server.common.data.relation.EntityRelationInfo;
|
import org.thingsboard.server.common.data.relation.EntityRelationInfo;
|
||||||
import org.thingsboard.server.common.data.relation.EntityRelationsQuery;
|
import org.thingsboard.server.common.data.relation.EntityRelationsQuery;
|
||||||
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
||||||
import org.thingsboard.server.dao.service.ConstraintValidator;
|
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.security.permission.Operation;
|
import org.thingsboard.server.service.security.permission.Operation;
|
||||||
|
|
||||||
@ -85,7 +84,6 @@ public class EntityRelationController extends BaseController {
|
|||||||
if (relation.getTypeGroup() == null) {
|
if (relation.getTypeGroup() == null) {
|
||||||
relation.setTypeGroup(RelationTypeGroup.COMMON);
|
relation.setTypeGroup(RelationTypeGroup.COMMON);
|
||||||
}
|
}
|
||||||
ConstraintValidator.validateFields(relation);
|
|
||||||
relationService.saveRelation(getTenantId(), relation);
|
relationService.saveRelation(getTenantId(), relation);
|
||||||
|
|
||||||
logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
|
logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
|
||||||
|
|||||||
@ -95,6 +95,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleThingsboardException(ThingsboardException thingsboardException, HttpServletResponse response) throws IOException {
|
private void handleThingsboardException(ThingsboardException thingsboardException, HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
ThingsboardErrorCode errorCode = thingsboardException.getErrorCode();
|
ThingsboardErrorCode errorCode = thingsboardException.getErrorCode();
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
|||||||
import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
|
import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
|
||||||
import org.thingsboard.server.dao.entity.EntityService;
|
import org.thingsboard.server.dao.entity.EntityService;
|
||||||
import org.thingsboard.server.dao.exception.DataValidationException;
|
import org.thingsboard.server.dao.exception.DataValidationException;
|
||||||
|
import org.thingsboard.server.dao.service.ConstraintValidator;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -559,6 +560,7 @@ public class BaseRelationService implements RelationService {
|
|||||||
if (relation == null) {
|
if (relation == null) {
|
||||||
throw new DataValidationException("Relation type should be specified!");
|
throw new DataValidationException("Relation type should be specified!");
|
||||||
}
|
}
|
||||||
|
ConstraintValidator.validateFields(relation);
|
||||||
validate(relation.getFrom(), relation.getTo(), relation.getType(), relation.getTypeGroup());
|
validate(relation.getFrom(), relation.getTo(), relation.getType(), relation.getTypeGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user