moved check to validator
This commit is contained in:
parent
593b6452e6
commit
ae02d43142
@ -289,6 +289,8 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
|
|||||||
if (state.isSizeOk()) {
|
if (state.isSizeOk()) {
|
||||||
if (!calculationResult.isEmpty()) {
|
if (!calculationResult.isEmpty()) {
|
||||||
cfService.pushMsgToRuleEngine(tenantId, entityId, calculationResult, cfIdList, callback);
|
cfService.pushMsgToRuleEngine(tenantId, entityId, calculationResult, cfIdList, callback);
|
||||||
|
} else {
|
||||||
|
callback.onSuccess();
|
||||||
}
|
}
|
||||||
if (DebugModeUtil.isDebugAllAvailable(ctx.getCalculatedField())) {
|
if (DebugModeUtil.isDebugAllAvailable(ctx.getCalculatedField())) {
|
||||||
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, JacksonUtil.writeValueAsString(calculationResult.getResult()), null);
|
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, JacksonUtil.writeValueAsString(calculationResult.getResult()), null);
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.cluster.TbClusterService;
|
import org.thingsboard.server.cluster.TbClusterService;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
|
||||||
import org.thingsboard.server.common.data.TenantProfile;
|
import org.thingsboard.server.common.data.TenantProfile;
|
||||||
import org.thingsboard.server.common.data.id.QueueId;
|
import org.thingsboard.server.common.data.id.QueueId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -57,7 +56,6 @@ public class DefaultTbQueueService extends AbstractTbEntityService implements Tb
|
|||||||
oldQueue = queueService.findQueueById(queue.getTenantId(), queue.getId());
|
oldQueue = queueService.findQueueById(queue.getTenantId(), queue.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
checkQueueName(queue.getName());
|
|
||||||
Queue savedQueue = queueService.saveQueue(queue);
|
Queue savedQueue = queueService.saveQueue(queue);
|
||||||
createTopicsIfNeeded(savedQueue, oldQueue);
|
createTopicsIfNeeded(savedQueue, oldQueue);
|
||||||
tbClusterService.onQueuesUpdate(List.of(savedQueue));
|
tbClusterService.onQueuesUpdate(List.of(savedQueue));
|
||||||
@ -183,10 +181,4 @@ public class DefaultTbQueueService extends AbstractTbEntityService implements Tb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkQueueName(String queueName) {
|
|
||||||
if (DataConstants.CF_QUEUE_NAME.equals(queueName) || DataConstants.CF_STATES_QUEUE_NAME.equals(queueName)) {
|
|
||||||
throw new IllegalArgumentException(String.format("The queue name '%s' is not allowed. This name is reserved for internal use. Please choose a different name.", queueName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.thingsboard.server.common.data.BaseData;
|
import org.thingsboard.server.common.data.BaseData;
|
||||||
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.StringUtils;
|
import org.thingsboard.server.common.data.StringUtils;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
@ -158,6 +159,9 @@ public abstract class DataValidator<D extends BaseData<?>> {
|
|||||||
|
|
||||||
protected static void validateQueueName(String name) {
|
protected static void validateQueueName(String name) {
|
||||||
validateQueueNameOrTopic(name, NAME);
|
validateQueueNameOrTopic(name, NAME);
|
||||||
|
if (DataConstants.CF_QUEUE_NAME.equals(name) || DataConstants.CF_STATES_QUEUE_NAME.equals(name)) {
|
||||||
|
throw new DataValidationException(String.format("The queue name '%s' is not allowed. This name is reserved for internal use. Please choose a different name.", name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void validateQueueTopic(String topic) {
|
protected static void validateQueueTopic(String topic) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user