Skip to content

Commit

Permalink
Fixed fromStringIgnoreUnknownProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-babak committed Dec 7, 2023
1 parent b90892d commit 2ab43e6
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class AdminSettingsCloudProcessor extends BaseEdgeProcessor {

public ListenableFuture<Void> processAdminSettingsMsgFromCloud(TenantId tenantId, AdminSettingsUpdateMsg adminSettingsUpdateMsg) {
AdminSettings adminSettingsMsg = JacksonUtil.fromStringIgnoreUnknownProperties(adminSettingsUpdateMsg.getEntity(), AdminSettings.class);
AdminSettings adminSettingsMsg = JacksonUtil.fromString(adminSettingsUpdateMsg.getEntity(), AdminSettings.class, true);
if (adminSettingsMsg == null) {
throw new RuntimeException("[{" + tenantId + "}] adminSettingsUpdateMsg {" + adminSettingsUpdateMsg + " } cannot be converted to admin settings");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public UplinkMsg convertAlarmEventToUplink(CloudEvent cloudEvent, EdgeVersion ed

@Override
protected EntityId getAlarmOriginatorFromMsg(TenantId tenantId, AlarmUpdateMsg alarmUpdateMsg) {
Alarm alarm = JacksonUtil.fromStringIgnoreUnknownProperties(alarmUpdateMsg.getEntity(), Alarm.class);
Alarm alarm = JacksonUtil.fromString(alarmUpdateMsg.getEntity(), Alarm.class, true);
return alarm != null ? alarm.getOriginator() : null;
}

@Override
protected Alarm constructAlarmFromUpdateMsg(TenantId tenantId, AlarmId alarmId, EntityId originatorId, AlarmUpdateMsg alarmUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(alarmUpdateMsg.getEntity(), Alarm.class);
return JacksonUtil.fromString(alarmUpdateMsg.getEntity(), Alarm.class, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public UplinkMsg convertAssetEventToUplink(CloudEvent cloudEvent, EdgeVersion ed

@Override
protected Asset constructAssetFromUpdateMsg(TenantId tenantId, AssetId assetId, AssetUpdateMsg assetUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(assetUpdateMsg.getEntity(), Asset.class);
return JacksonUtil.fromString(assetUpdateMsg.getEntity(), Asset.class, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ListenableFuture<Void> processAssetProfileMsgFromCloud(TenantId tenantId,
case ENTITY_UPDATED_RPC_MESSAGE:
assetCreationLock.lock();
try {
AssetProfile assetProfileMsg = JacksonUtil.fromStringIgnoreUnknownProperties(assetProfileUpdateMsg.getEntity(), AssetProfile.class);
AssetProfile assetProfileMsg = JacksonUtil.fromString(assetProfileUpdateMsg.getEntity(), AssetProfile.class, true);
if (assetProfileMsg == null) {
throw new RuntimeException("[{" + tenantId + "}] assetProfileUpdateMsg {" + assetProfileUpdateMsg + "} cannot be converted to asset profile");
}
Expand Down Expand Up @@ -180,7 +180,7 @@ public UplinkMsg convertAssetProfileEventToUplink(CloudEvent cloudEvent, EdgeVer

@Override
protected AssetProfile constructAssetProfileFromUpdateMsg(TenantId tenantId, AssetProfileId assetProfileId, AssetProfileUpdateMsg assetProfileUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(assetProfileUpdateMsg.getEntity(), AssetProfile.class);
return JacksonUtil.fromString(assetProfileUpdateMsg.getEntity(), AssetProfile.class, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ListenableFuture<Void> processCustomerMsgFromCloud(TenantId tenantId, Cus
case ENTITY_UPDATED_RPC_MESSAGE:
customerCreationLock.lock();
try {
Customer customer = JacksonUtil.fromStringIgnoreUnknownProperties(customerUpdateMsg.getEntity(), Customer.class);
Customer customer = JacksonUtil.fromString(customerUpdateMsg.getEntity(), Customer.class, true);
if (customer == null) {
throw new RuntimeException("[{" + tenantId + "}] customerUpdateMsg {" + customerUpdateMsg + "} cannot be converted to customer");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public UplinkMsg convertDashboardEventToUplink(CloudEvent cloudEvent, EdgeVersio

@Override
protected Dashboard constructDashboardFromUpdateMsg(TenantId tenantId, DashboardId dashboardId, DashboardUpdateMsg dashboardUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(dashboardUpdateMsg.getEntity(), Dashboard.class);
return JacksonUtil.fromString(dashboardUpdateMsg.getEntity(), Dashboard.class, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public UplinkMsg convertDeviceEventToUplink(TenantId tenantId, CloudEvent cloudE

@Override
protected Device constructDeviceFromUpdateMsg(TenantId tenantId, DeviceId deviceId, DeviceUpdateMsg deviceUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(deviceUpdateMsg.getEntity(), Device.class);
return JacksonUtil.fromString(deviceUpdateMsg.getEntity(), Device.class, true);
}

@Override
Expand All @@ -283,6 +283,6 @@ protected void setCustomerId(TenantId tenantId, CustomerId customerId, Device de

@Override
protected DeviceCredentials constructDeviceCredentialsFromUpdateMsg(TenantId tenantId, DeviceCredentialsUpdateMsg deviceCredentialsUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(deviceCredentialsUpdateMsg.getEntity(), DeviceCredentials.class);
return JacksonUtil.fromString(deviceCredentialsUpdateMsg.getEntity(), DeviceCredentials.class, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ListenableFuture<Void> processDeviceProfileMsgFromCloud(TenantId tenantId
case ENTITY_UPDATED_RPC_MESSAGE:
deviceCreationLock.lock();
try {
DeviceProfile deviceProfileMsg = JacksonUtil.fromStringIgnoreUnknownProperties(deviceProfileUpdateMsg.getEntity(), DeviceProfile.class);
DeviceProfile deviceProfileMsg = JacksonUtil.fromString(deviceProfileUpdateMsg.getEntity(), DeviceProfile.class, true);
if (deviceProfileMsg == null) {
throw new RuntimeException("[{" + tenantId + "}] deviceProfileUpdateMsg {" + deviceProfileUpdateMsg + "} cannot be converted to device profile");
}
Expand Down Expand Up @@ -195,7 +195,7 @@ public UplinkMsg convertDeviceProfileEventToUplink(CloudEvent cloudEvent, EdgeVe

@Override
protected DeviceProfile constructDeviceProfileFromUpdateMsg(TenantId tenantId, DeviceProfileId deviceProfileId, DeviceProfileUpdateMsg deviceProfileUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(deviceProfileUpdateMsg.getEntity(), DeviceProfile.class);
return JacksonUtil.fromString(deviceProfileUpdateMsg.getEntity(), DeviceProfile.class, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public UplinkMsg convertEntityViewEventToUplink(CloudEvent cloudEvent, EdgeVersi

@Override
protected EntityView constructEntityViewFromUpdateMsg(TenantId tenantId, EntityViewId entityViewId, EntityViewUpdateMsg entityViewUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(entityViewUpdateMsg.getEntity(), EntityView.class);
return JacksonUtil.fromString(entityViewUpdateMsg.getEntity(), EntityView.class, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ListenableFuture<Void> processOtaPackageMsgFromCloud(TenantId tenantId, O
case ENTITY_UPDATED_RPC_MESSAGE:
otaPackageCreationLock.lock();
try {
OtaPackage otaPackage = JacksonUtil.fromStringIgnoreUnknownProperties(otaPackageUpdateMsg.getEntity(), OtaPackage.class);
OtaPackage otaPackage = JacksonUtil.fromString(otaPackageUpdateMsg.getEntity(), OtaPackage.class, true);
if (otaPackage == null) {
throw new RuntimeException("[{" + tenantId + "}] otaPackageUpdateMsg {" + otaPackageUpdateMsg + "} cannot be converted to ota package");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ListenableFuture<Void> processQueueMsgFromCloud(TenantId tenantId, QueueU
case ENTITY_UPDATED_RPC_MESSAGE:
queueCreationLock.lock();
try {
Queue queue = JacksonUtil.fromStringIgnoreUnknownProperties(queueUpdateMsg.getEntity(), Queue.class);
Queue queue = JacksonUtil.fromString(queueUpdateMsg.getEntity(), Queue.class, true);
if (queue == null) {
throw new RuntimeException("[{" + tenantId + "}] queueUpdateMsg {" + queueUpdateMsg + "} cannot be converted to queue");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public UplinkMsg convertRelationEventToUplink(CloudEvent cloudEvent, EdgeVersion

@Override
protected EntityRelation constructEntityRelationFromUpdateMsg(RelationUpdateMsg relationUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(relationUpdateMsg.getEntity(), EntityRelation.class);
return JacksonUtil.fromString(relationUpdateMsg.getEntity(), EntityRelation.class, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ListenableFuture<Void> processResourceMsgFromCloud(TenantId tenantId, Res
switch (resourceUpdateMsg.getMsgType()) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
TbResource tbResource = JacksonUtil.fromStringIgnoreUnknownProperties(resourceUpdateMsg.getEntity(), TbResource.class);
TbResource tbResource = JacksonUtil.fromString(resourceUpdateMsg.getEntity(), TbResource.class, true);
if (tbResource == null) {
throw new RuntimeException("[{" + tenantId + "}] resourceUpdateMsg {" + resourceUpdateMsg + "} cannot be converted to tb resource");
}
Expand Down Expand Up @@ -132,6 +132,6 @@ public UplinkMsg convertResourceEventToUplink(CloudEvent cloudEvent, EdgeVersion

@Override
protected TbResource constructResourceFromUpdateMsg(TenantId tenantId, TbResourceId tbResourceId, ResourceUpdateMsg resourceUpdateMsg) {
return JacksonUtil.fromStringIgnoreUnknownProperties(resourceUpdateMsg.getEntity(), TbResource.class);
return JacksonUtil.fromString(resourceUpdateMsg.getEntity(), TbResource.class, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ListenableFuture<Void> processRuleChainMsgFromCloud(TenantId tenantId, Ru
switch (ruleChainUpdateMsg.getMsgType()) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
RuleChain ruleChainMsg = JacksonUtil.fromStringIgnoreUnknownProperties(ruleChainUpdateMsg.getEntity(), RuleChain.class);
RuleChain ruleChainMsg = JacksonUtil.fromString(ruleChainUpdateMsg.getEntity(), RuleChain.class, true);
if (ruleChainMsg == null) {
throw new RuntimeException("[{" + tenantId + "}] ruleChainUpdateMsg {" + ruleChainUpdateMsg + "} cannot be converted to rule chain");
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public ListenableFuture<Void> processRuleChainMetadataMsgFromCloud(TenantId tena
switch (ruleChainMetadataUpdateMsg.getMsgType()) {
case ENTITY_CREATED_RPC_MESSAGE:
case ENTITY_UPDATED_RPC_MESSAGE:
RuleChainMetaData ruleChainMetadata = JacksonUtil.fromStringIgnoreUnknownProperties(ruleChainMetadataUpdateMsg.getEntity(), RuleChainMetaData.class);
RuleChainMetaData ruleChainMetadata = JacksonUtil.fromString(ruleChainMetadataUpdateMsg.getEntity(), RuleChainMetaData.class, true);
if (ruleChainMetadata == null) {
throw new RuntimeException("[{" + tenantId + "}] ruleChainMetadataUpdateMsg {" + ruleChainMetadataUpdateMsg + "} cannot be converted to rule chain metadata");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void createTenantIfNotExists(TenantId tenantId, Long queueStartTs) throws
}

public ListenableFuture<Void> processTenantMsgFromCloud(TenantUpdateMsg tenantUpdateMsg) {
Tenant tenant = JacksonUtil.fromStringIgnoreUnknownProperties(tenantUpdateMsg.getEntity(), Tenant.class);
Tenant tenant = JacksonUtil.fromString(tenantUpdateMsg.getEntity(), Tenant.class, true);
if (tenant == null) {
throw new RuntimeException("[{" + TenantId.SYS_TENANT_ID + "}] tenantUpdateMsg {" + tenantUpdateMsg + "} cannot be converted to tenant");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class TenantProfileCloudProcessor extends BaseEdgeProcessor {

public ListenableFuture<Void> processTenantProfileMsgFromCloud(TenantId tenantId, TenantProfileUpdateMsg tenantProfileUpdateMsg) {
TenantProfile tenantProfileMsg = JacksonUtil.fromStringIgnoreUnknownProperties(tenantProfileUpdateMsg.getEntity(), TenantProfile.class);
TenantProfile tenantProfileMsg = JacksonUtil.fromString(tenantProfileUpdateMsg.getEntity(), TenantProfile.class, true);
if (tenantProfileMsg == null) {
throw new RuntimeException("[{" + tenantId + "}] tenantProfileUpdateMsg {" + tenantProfileUpdateMsg + "} cannot be converted to tenant profile");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ListenableFuture<Void> processUserMsgFromCloud(TenantId tenantId,
case ENTITY_UPDATED_RPC_MESSAGE:
userCreationLock.lock();
try {
User user = JacksonUtil.fromStringIgnoreUnknownProperties(userUpdateMsg.getEntity(), User.class);
User user = JacksonUtil.fromString(userUpdateMsg.getEntity(), User.class, true);
if (user == null) {
throw new RuntimeException("[{" + tenantId + "}] userUpdateMsg {" + userUpdateMsg + "} cannot be converted to user");
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public ListenableFuture<Void> processUserMsgFromCloud(TenantId tenantId,
public ListenableFuture<Void> processUserCredentialsMsgFromCloud(TenantId tenantId, UserCredentialsUpdateMsg userCredentialsUpdateMsg) {
try {
cloudSynchronizationManager.getSync().set(true);
UserCredentials userCredentialsMsg = JacksonUtil.fromStringIgnoreUnknownProperties(userCredentialsUpdateMsg.getEntity(), UserCredentials.class);
UserCredentials userCredentialsMsg = JacksonUtil.fromString(userCredentialsUpdateMsg.getEntity(), UserCredentials.class, true);
if (userCredentialsMsg == null) {
throw new RuntimeException("[{" + tenantId + "}] userCredentialsUpdateMsg {" + userCredentialsUpdateMsg + "} cannot be converted to user credentials");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ListenableFuture<Void> processWidgetsBundleMsgFromCloud(TenantId tenantId
case ENTITY_UPDATED_RPC_MESSAGE:
widgetCreationLock.lock();
try {
WidgetsBundle widgetsBundle = JacksonUtil.fromStringIgnoreUnknownProperties(widgetsBundleUpdateMsg.getEntity(), WidgetsBundle.class);
WidgetsBundle widgetsBundle = JacksonUtil.fromString(widgetsBundleUpdateMsg.getEntity(), WidgetsBundle.class, true);
if (widgetsBundle == null) {
throw new RuntimeException("[{" + tenantId + "}] widgetsBundleUpdateMsg {" + widgetsBundleUpdateMsg + "} cannot be converted to widget bundle");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ListenableFuture<Void> processWidgetTypeMsgFromCloud(TenantId tenantId, W
case ENTITY_UPDATED_RPC_MESSAGE:
widgetCreationLock.lock();
try {
WidgetTypeDetails widgetTypeDetails = JacksonUtil.fromStringIgnoreUnknownProperties(widgetTypeUpdateMsg.getEntity(), WidgetTypeDetails.class);
WidgetTypeDetails widgetTypeDetails = JacksonUtil.fromString(widgetTypeUpdateMsg.getEntity(), WidgetTypeDetails.class, true);
if (widgetTypeDetails == null) {
throw new RuntimeException("[{" + tenantId + "}] widgetTypeUpdateMsg {" + widgetTypeUpdateMsg + "} cannot be converted to widget type");
}
Expand Down
2 changes: 1 addition & 1 deletion common/proto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.thingsboard</groupId>
<version>3.6.2-SNAPSHOT</version>
<version>3.6.2EDGE-SNAPSHOT</version>
<artifactId>common</artifactId>
</parent>
<groupId>org.thingsboard.common</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private TbResource saveResourceOnEdge(String title, String resourceKey, RestClie
tbResource.setResourceKey(resourceKey);
tbResource.setResourceType(ResourceType.JKS);
tbResource.setFileName(resourceKey);
tbResource.setData("Data");
tbResource.setData("Data".getBytes());
return restClient.saveResource(tbResource);
}
}

0 comments on commit 2ab43e6

Please sign in to comment.