TenantId.fromUUID() usage instead of new TenantId() refactored. new TenantId() is deprecated.
This commit is contained in:
		
							parent
							
								
									6a726a8c56
								
							
						
					
					
						commit
						b8c0fae602
					
				@ -38,7 +38,7 @@ import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor;
 | 
			
		||||
public class TenantEdgeProcessor extends BaseEdgeProcessor {
 | 
			
		||||
 | 
			
		||||
    public DownlinkMsg convertTenantEventToDownlink(EdgeEvent edgeEvent, EdgeVersion edgeVersion) {
 | 
			
		||||
        TenantId tenantId = new TenantId(edgeEvent.getEntityId());
 | 
			
		||||
        TenantId tenantId = TenantId.fromUUID(edgeEvent.getEntityId());
 | 
			
		||||
        DownlinkMsg downlinkMsg = null;
 | 
			
		||||
        if (EdgeEventActionType.UPDATED.equals(edgeEvent.getAction())) {
 | 
			
		||||
            Tenant tenant = tenantService.findTenantById(tenantId);
 | 
			
		||||
 | 
			
		||||
@ -503,7 +503,7 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void forwardToResourceService(TransportProtos.ResourceCacheInvalidateMsg msg, TbCallback callback) {
 | 
			
		||||
        var tenantId = new TenantId(new UUID(msg.getTenantIdMSB(), msg.getTenantIdLSB()));
 | 
			
		||||
        var tenantId = TenantId.fromUUID(new UUID(msg.getTenantIdMSB(), msg.getTenantIdLSB()));
 | 
			
		||||
        msg.getKeysList().stream().map(cacheKeyProto -> {
 | 
			
		||||
            if (cacheKeyProto.hasResourceKey()) {
 | 
			
		||||
                return ImageCacheKey.forImage(tenantId, cacheKeyProto.getResourceKey());
 | 
			
		||||
 | 
			
		||||
@ -192,7 +192,7 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService<
 | 
			
		||||
    private void updateQueues(List<QueueUpdateMsg> queueUpdateMsgs) {
 | 
			
		||||
        for (QueueUpdateMsg queueUpdateMsg : queueUpdateMsgs) {
 | 
			
		||||
            log.info("Received queue update msg: [{}]", queueUpdateMsg);
 | 
			
		||||
            TenantId tenantId = new TenantId(new UUID(queueUpdateMsg.getTenantIdMSB(), queueUpdateMsg.getTenantIdLSB()));
 | 
			
		||||
            TenantId tenantId = TenantId.fromUUID(new UUID(queueUpdateMsg.getTenantIdMSB(), queueUpdateMsg.getTenantIdLSB()));
 | 
			
		||||
            if (partitionService.isManagedByCurrentService(tenantId)) {
 | 
			
		||||
                QueueId queueId = new QueueId(new UUID(queueUpdateMsg.getQueueIdMSB(), queueUpdateMsg.getQueueIdLSB()));
 | 
			
		||||
                String queueName = queueUpdateMsg.getQueueName();
 | 
			
		||||
@ -212,7 +212,7 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService<
 | 
			
		||||
    private void deleteQueues(List<QueueDeleteMsg> queueDeleteMsgs) {
 | 
			
		||||
        for (QueueDeleteMsg queueDeleteMsg : queueDeleteMsgs) {
 | 
			
		||||
            log.info("Received queue delete msg: [{}]", queueDeleteMsg);
 | 
			
		||||
            TenantId tenantId = new TenantId(new UUID(queueDeleteMsg.getTenantIdMSB(), queueDeleteMsg.getTenantIdLSB()));
 | 
			
		||||
            TenantId tenantId = TenantId.fromUUID(new UUID(queueDeleteMsg.getTenantIdMSB(), queueDeleteMsg.getTenantIdLSB()));
 | 
			
		||||
            QueueKey queueKey = new QueueKey(ServiceType.TB_RULE_ENGINE, queueDeleteMsg.getQueueName(), tenantId);
 | 
			
		||||
            removeConsumer(queueKey).ifPresent(consumer -> consumer.delete(true));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ public class DeviceIdInfo implements Serializable, HasTenantId {
 | 
			
		||||
    private final DeviceId deviceId;
 | 
			
		||||
 | 
			
		||||
    public DeviceIdInfo(UUID tenantId, UUID customerId, UUID deviceId) {
 | 
			
		||||
        this.tenantId = new TenantId(tenantId);
 | 
			
		||||
        this.tenantId = TenantId.fromUUID(tenantId);
 | 
			
		||||
        this.customerId = customerId != null ? new CustomerId(customerId) : null;
 | 
			
		||||
        this.deviceId = new DeviceId(deviceId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -63,7 +63,7 @@ public class DeviceProfileInfo extends EntityInfo {
 | 
			
		||||
 | 
			
		||||
    public DeviceProfileInfo(UUID uuid, UUID tenantId, String name, String image, UUID defaultDashboardId, DeviceProfileType type, DeviceTransportType transportType) {
 | 
			
		||||
        super(EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE_PROFILE, uuid), name);
 | 
			
		||||
        this.tenantId = new TenantId(tenantId);
 | 
			
		||||
        this.tenantId = TenantId.fromUUID(tenantId);
 | 
			
		||||
        this.image = image;
 | 
			
		||||
        this.defaultDashboardId = defaultDashboardId != null ? new DashboardId(defaultDashboardId) : null;
 | 
			
		||||
        this.type = type;
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ public class AssetProfileInfo extends EntityInfo {
 | 
			
		||||
 | 
			
		||||
    public AssetProfileInfo(UUID uuid, UUID tenantId, String name, String image, UUID defaultDashboardId) {
 | 
			
		||||
        super(EntityIdFactory.getByTypeAndUuid(EntityType.ASSET_PROFILE, uuid), name);
 | 
			
		||||
        this.tenantId = new TenantId(tenantId);
 | 
			
		||||
        this.tenantId = TenantId.fromUUID(tenantId);
 | 
			
		||||
        this.image = image;
 | 
			
		||||
        this.defaultDashboardId = defaultDashboardId != null ? new DashboardId(defaultDashboardId) : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -118,7 +118,7 @@ public class EntityIdFactory {
 | 
			
		||||
    public static EntityId getByEdgeEventTypeAndUuid(EdgeEventType edgeEventType, UUID uuid) {
 | 
			
		||||
        switch (edgeEventType) {
 | 
			
		||||
            case TENANT:
 | 
			
		||||
                return new TenantId(uuid);
 | 
			
		||||
                return TenantId.fromUUID(uuid);
 | 
			
		||||
            case CUSTOMER:
 | 
			
		||||
                return new CustomerId(uuid);
 | 
			
		||||
            case USER:
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,9 @@ public final class TenantId extends UUIDBased implements EntityId {
 | 
			
		||||
        return tenants.computeIfAbsent(id, TenantId::new);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //default constructor is still available due to possible usage in extensions
 | 
			
		||||
    // Please, use TenantId.fromUUID instead
 | 
			
		||||
    // Default constructor is still available due to possible usage in extensions
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public TenantId(UUID id) {
 | 
			
		||||
        super(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -297,7 +297,7 @@ public class LwM2MClientSerDes {
 | 
			
		||||
        if (tenantId != null) {
 | 
			
		||||
            Field tenantIdField = lwM2mClientClass.getDeclaredField("tenantId");
 | 
			
		||||
            tenantIdField.setAccessible(true);
 | 
			
		||||
            tenantIdField.set(lwM2mClient, new TenantId(UUID.fromString(tenantId.getAsString())));
 | 
			
		||||
            tenantIdField.set(lwM2mClient, TenantId.fromUUID(UUID.fromString(tenantId.getAsString())));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        JsonElement deviceId = o.get("deviceId");
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ public class VersionControlRequestCtx {
 | 
			
		||||
    public VersionControlRequestCtx(ToVersionControlServiceMsg msg, RepositorySettings settings) {
 | 
			
		||||
        this.nodeId = msg.getNodeId();
 | 
			
		||||
        this.requestId = new UUID(msg.getRequestIdMSB(), msg.getRequestIdLSB());
 | 
			
		||||
        this.tenantId = new TenantId(new UUID(msg.getTenantIdMSB(), msg.getTenantIdLSB()));
 | 
			
		||||
        this.tenantId = TenantId.fromUUID(new UUID(msg.getTenantIdMSB(), msg.getTenantIdLSB()));
 | 
			
		||||
        this.settings = settings;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -168,7 +168,7 @@ public class OAuth2ClientEntity extends BaseSqlEntity<OAuth2Client> {
 | 
			
		||||
        OAuth2Client registration = new OAuth2Client();
 | 
			
		||||
        registration.setId(new OAuth2ClientId(id));
 | 
			
		||||
        registration.setCreatedTime(createdTime);
 | 
			
		||||
        registration.setTenantId(new TenantId(tenantId));
 | 
			
		||||
        registration.setTenantId(TenantId.fromUUID(tenantId));
 | 
			
		||||
        registration.setTitle(title);
 | 
			
		||||
        registration.setAdditionalInfo(additionalInfo);
 | 
			
		||||
        registration.setMapperConfig(
 | 
			
		||||
 | 
			
		||||
@ -97,7 +97,7 @@ public class QueueEntity extends BaseSqlEntity<Queue> {
 | 
			
		||||
    public Queue toData() {
 | 
			
		||||
        Queue queue = new Queue(new QueueId(getUuid()));
 | 
			
		||||
        queue.setCreatedTime(createdTime);
 | 
			
		||||
        queue.setTenantId(new TenantId(tenantId));
 | 
			
		||||
        queue.setTenantId(TenantId.fromUUID(tenantId));
 | 
			
		||||
        queue.setName(name);
 | 
			
		||||
        queue.setTopic(topic);
 | 
			
		||||
        queue.setPollInterval(pollInterval);
 | 
			
		||||
 | 
			
		||||
@ -61,7 +61,7 @@ public class QueueStatsEntity extends BaseSqlEntity<QueueStats> {
 | 
			
		||||
    public QueueStats toData() {
 | 
			
		||||
        QueueStats queueStats = new QueueStats(new QueueStatsId(getUuid()));
 | 
			
		||||
        queueStats.setCreatedTime(createdTime);
 | 
			
		||||
        queueStats.setTenantId(new TenantId(tenantId));
 | 
			
		||||
        queueStats.setTenantId(TenantId.fromUUID(tenantId));
 | 
			
		||||
        queueStats.setQueueName(queueName);
 | 
			
		||||
        queueStats.setServiceId(serviceId);
 | 
			
		||||
        return queueStats;
 | 
			
		||||
 | 
			
		||||
@ -235,7 +235,7 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Optional<HasId<?>> findEntity(TenantId tenantId, EntityId entityId) {
 | 
			
		||||
        return Optional.ofNullable(findTenantById(new TenantId(entityId.getId())));
 | 
			
		||||
        return Optional.ofNullable(findTenantById(TenantId.fromUUID(entityId.getId())));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
@ -61,7 +61,7 @@ public class TenantIdLoader {
 | 
			
		||||
        HasTenantId tenantEntity;
 | 
			
		||||
        switch (entityType) {
 | 
			
		||||
            case TENANT:
 | 
			
		||||
                return new TenantId(id);
 | 
			
		||||
                return TenantId.fromUUID(id);
 | 
			
		||||
            case CUSTOMER:
 | 
			
		||||
                tenantEntity = ctx.getCustomerService().findCustomerById(ctxTenantId, new CustomerId(id));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user