|
|
|
@ -19,10 +19,12 @@ import com.google.protobuf.ByteString; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.thingsboard.server.common.data.TenantProfile; |
|
|
|
import org.thingsboard.server.gen.edge.v1.EdgeVersion; |
|
|
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg; |
|
|
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
|
|
|
import org.thingsboard.server.queue.util.DataDecodingEncodingService; |
|
|
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
|
|
|
import org.thingsboard.server.service.edge.rpc.utils.EdgeVersionUtils; |
|
|
|
|
|
|
|
@Component |
|
|
|
@TbCoreComponent |
|
|
|
@ -31,7 +33,9 @@ public class TenantProfileMsgConstructor { |
|
|
|
@Autowired |
|
|
|
private DataDecodingEncodingService dataDecodingEncodingService; |
|
|
|
|
|
|
|
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile) { |
|
|
|
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile, EdgeVersion edgeVersion) { |
|
|
|
ByteString profileData = EdgeVersionUtils.isEdgeVersionOlderThan(edgeVersion, EdgeVersion.V_3_6_1) ? |
|
|
|
ByteString.empty() : ByteString.copyFrom(dataDecodingEncodingService.encode(tenantProfile.getProfileData())); |
|
|
|
TenantProfileUpdateMsg.Builder builder = TenantProfileUpdateMsg.newBuilder() |
|
|
|
.setMsgType(msgType) |
|
|
|
.setIdMSB(tenantProfile.getId().getId().getMostSignificantBits()) |
|
|
|
@ -39,7 +43,7 @@ public class TenantProfileMsgConstructor { |
|
|
|
.setName(tenantProfile.getName()) |
|
|
|
.setDefault(tenantProfile.isDefault()) |
|
|
|
.setIsolatedRuleChain(tenantProfile.isIsolatedTbRuleEngine()) |
|
|
|
.setProfileDataBytes(ByteString.copyFrom(dataDecodingEncodingService.encode(tenantProfile.getProfileData()))); |
|
|
|
.setProfileDataBytes(profileData); |
|
|
|
if (tenantProfile.getDescription() != null) { |
|
|
|
builder.setDescription(tenantProfile.getDescription()); |
|
|
|
} |
|
|
|
|