moved check to validator

This commit is contained in:
IrynaMatveieva 2025-03-12 12:29:00 +02:00
parent 593b6452e6
commit ae02d43142
3 changed files with 6 additions and 8 deletions

View File

@ -289,6 +289,8 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
if (state.isSizeOk()) {
if (!calculationResult.isEmpty()) {
cfService.pushMsgToRuleEngine(tenantId, entityId, calculationResult, cfIdList, callback);
} else {
callback.onSuccess();
}
if (DebugModeUtil.isDebugAllAvailable(ctx.getCalculatedField())) {
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, JacksonUtil.writeValueAsString(calculationResult.getResult()), null);

View File

@ -19,7 +19,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
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.id.QueueId;
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());
}
checkQueueName(queue.getName());
Queue savedQueue = queueService.saveQueue(queue);
createTopicsIfNeeded(savedQueue, oldQueue);
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));
}
}
}

View File

@ -21,6 +21,7 @@ import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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.StringUtils;
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) {
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) {