Browse Source

Fixed the usage of emptyId in delete methods with getOrEmptyId to find out if Id is really empty.

Signed-off-by: Oleksandra Matviienko <al.zzzeebra@gmail.com>
pull/14967/head
Oleksandra Matviienko 8 months ago
parent
commit
c3b88c74ee
  1. 6
      application/src/main/java/org/thingsboard/server/service/entitiy/alarm/DefaultTbAlarmService.java
  2. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/asset/DefaultTbAssetService.java
  3. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/asset/profile/DefaultTbAssetProfileService.java
  4. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/cf/DefaultTbCalculatedFieldService.java
  5. 4
      application/src/main/java/org/thingsboard/server/service/entitiy/customer/DefaultTbCustomerService.java
  6. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/dashboard/DefaultTbDashboardService.java
  7. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/device/DefaultTbDeviceService.java
  8. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/device/profile/DefaultTbDeviceProfileService.java
  9. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/edge/DefaultTbEdgeService.java
  10. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/entityview/DefaultTbEntityViewService.java
  11. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/ota/DefaultTbOtaPackageService.java
  12. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/user/DefaultUserService.java
  13. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/widgets/bundle/DefaultWidgetsBundleService.java
  14. 2
      application/src/main/java/org/thingsboard/server/service/entitiy/widgets/type/DefaultWidgetTypeService.java
  15. 2
      application/src/main/java/org/thingsboard/server/service/resource/DefaultTbResourceService.java
  16. 2
      application/src/main/java/org/thingsboard/server/service/rule/DefaultTbRuleChainService.java

6
application/src/main/java/org/thingsboard/server/service/entitiy/alarm/DefaultTbAlarmService.java

@ -197,18 +197,18 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
public boolean delete(Alarm alarm, User user) { public boolean delete(Alarm alarm, User user) {
var tenantId = alarm.getTenantId(); var tenantId = alarm.getTenantId();
var alarmId = alarm.getId(); var alarmId = alarm.getId();
var alarmOriginator = alarm.getOriginator(); var alarmOriginatorId = alarm.getOriginator();
boolean deleted; boolean deleted;
try { try {
deleted = alarmSubscriptionService.deleteAlarm(tenantId, alarmId); deleted = alarmSubscriptionService.deleteAlarm(tenantId, alarmId);
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(alarmOriginator.getEntityType()), ActionType.ALARM_DELETE, user, e, alarmId); logEntityActionService.logEntityAction(tenantId, alarmOriginatorId, ActionType.ALARM_DELETE, user, e, alarmId);
throw e; throw e;
} }
if (deleted) { if (deleted) {
logEntityActionService.logEntityAction(tenantId, alarmOriginator, alarm, alarm.getCustomerId(), ActionType.ALARM_DELETE, user, alarmId); logEntityActionService.logEntityAction(tenantId, alarmOriginatorId, alarm, alarm.getCustomerId(), ActionType.ALARM_DELETE, user, alarmId);
} }
return deleted; return deleted;

2
application/src/main/java/org/thingsboard/server/service/entitiy/asset/DefaultTbAssetService.java

@ -70,7 +70,7 @@ public class DefaultTbAssetService extends AbstractTbEntityService implements Tb
assetService.deleteAsset(tenantId, assetId); assetService.deleteAsset(tenantId, assetId);
logEntityActionService.logEntityAction(tenantId, assetId, asset, asset.getCustomerId(), actionType, user, assetId.toString()); logEntityActionService.logEntityAction(tenantId, assetId, asset, asset.getCustomerId(), actionType, user, assetId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.ASSET), actionType, user, e, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(assetId, EntityType.ASSET), actionType, user, e,
assetId.toString()); assetId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/asset/profile/DefaultTbAssetProfileService.java

@ -64,7 +64,7 @@ public class DefaultTbAssetProfileService extends AbstractTbEntityService implem
logEntityActionService.logEntityAction(tenantId, assetProfileId, assetProfile, null, logEntityActionService.logEntityAction(tenantId, assetProfileId, assetProfile, null,
actionType, user, assetProfileId.toString()); actionType, user, assetProfileId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.ASSET_PROFILE), actionType, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(assetProfileId, EntityType.ASSET_PROFILE), actionType,
user, e, assetProfileId.toString()); user, e, assetProfileId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/cf/DefaultTbCalculatedFieldService.java

@ -84,7 +84,7 @@ public class DefaultTbCalculatedFieldService extends AbstractTbEntityService imp
calculatedFieldService.deleteCalculatedField(tenantId, calculatedFieldId); calculatedFieldService.deleteCalculatedField(tenantId, calculatedFieldId);
logEntityActionService.logEntityAction(tenantId, calculatedFieldId, calculatedField, actionType, user, calculatedFieldId.toString()); logEntityActionService.logEntityAction(tenantId, calculatedFieldId, calculatedField, actionType, user, calculatedFieldId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.CALCULATED_FIELD), actionType, user, e, calculatedFieldId.toString()); logEntityActionService.logEntityAction(tenantId, getOrEmptyId(calculatedFieldId, EntityType.CALCULATED_FIELD), actionType, user, e, calculatedFieldId.toString());
throw e; throw e;
} }
} }

4
application/src/main/java/org/thingsboard/server/service/entitiy/customer/DefaultTbCustomerService.java

@ -58,10 +58,10 @@ public class DefaultTbCustomerService extends AbstractTbEntityService implements
CustomerId customerId = customer.getId(); CustomerId customerId = customer.getId();
try { try {
customerService.deleteCustomer(tenantId, customerId); customerService.deleteCustomer(tenantId, customerId);
logEntityActionService.logEntityAction(tenantId, customer.getId(), customer, customerId, actionType, logEntityActionService.logEntityAction(tenantId, customerId, customer, customerId, actionType,
user, customerId.toString()); user, customerId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.CUSTOMER), actionType, user, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(customerId, EntityType.CUSTOMER), actionType, user,
e, customerId.toString()); e, customerId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/dashboard/DefaultTbDashboardService.java

@ -77,7 +77,7 @@ public class DefaultTbDashboardService extends AbstractTbEntityService implement
dashboardService.deleteDashboard(tenantId, dashboardId); dashboardService.deleteDashboard(tenantId, dashboardId);
logEntityActionService.logEntityAction(tenantId, dashboardId, dashboard, null, actionType, user, dashboardId.toString()); logEntityActionService.logEntityAction(tenantId, dashboardId, dashboard, null, actionType, user, dashboardId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.DASHBOARD), actionType, user, e, dashboardId.toString()); logEntityActionService.logEntityAction(tenantId, getOrEmptyId(dashboardId, EntityType.DASHBOARD), actionType, user, e, dashboardId.toString());
throw e; throw e;
} }
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/device/DefaultTbDeviceService.java

@ -109,7 +109,7 @@ public class DefaultTbDeviceService extends AbstractTbEntityService implements T
logEntityActionService.logEntityAction(tenantId, deviceId, device, device.getCustomerId(), actionType, logEntityActionService.logEntityAction(tenantId, deviceId, device, device.getCustomerId(), actionType,
user, deviceId.toString()); user, deviceId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.DEVICE), actionType, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(deviceId, EntityType.DEVICE), actionType,
user, e, deviceId.toString()); user, e, deviceId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/device/profile/DefaultTbDeviceProfileService.java

@ -66,7 +66,7 @@ public class DefaultTbDeviceProfileService extends AbstractTbEntityService imple
logEntityActionService.logEntityAction(tenantId, deviceProfileId, deviceProfile, null, logEntityActionService.logEntityAction(tenantId, deviceProfileId, deviceProfile, null,
actionType, user, deviceProfileId.toString()); actionType, user, deviceProfileId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.DEVICE_PROFILE), actionType, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(deviceProfileId, EntityType.DEVICE_PROFILE), actionType,
user, e, deviceProfileId.toString()); user, e, deviceProfileId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/edge/DefaultTbEdgeService.java

@ -76,7 +76,7 @@ public class DefaultTbEdgeService extends AbstractTbEntityService implements TbE
edgeService.deleteEdge(tenantId, edgeId); edgeService.deleteEdge(tenantId, edgeId);
logEntityActionService.logEntityAction(tenantId, edgeId, edge, edge.getCustomerId(), actionType, user, edgeId.toString()); logEntityActionService.logEntityAction(tenantId, edgeId, edge, edge.getCustomerId(), actionType, user, edgeId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.EDGE), actionType, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(edgeId, EntityType.EDGE), actionType,
user, e, edgeId.toString()); user, e, edgeId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/entityview/DefaultTbEntityViewService.java

@ -144,7 +144,7 @@ public class DefaultTbEntityViewService extends AbstractTbEntityService implemen
localCache.computeIfAbsent(tenantId, (k) -> new ConcurrentReferenceHashMap<>()).clear(); localCache.computeIfAbsent(tenantId, (k) -> new ConcurrentReferenceHashMap<>()).clear();
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.ENTITY_VIEW), logEntityActionService.logEntityAction(tenantId, getOrEmptyId(entityViewId, EntityType.ENTITY_VIEW),
ActionType.DELETED, user, e, entityViewId.toString()); ActionType.DELETED, user, e, entityViewId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/ota/DefaultTbOtaPackageService.java

@ -105,7 +105,7 @@ public class DefaultTbOtaPackageService extends AbstractTbEntityService implemen
logEntityActionService.logEntityAction(tenantId, otaPackageId, otaPackageInfo, null, logEntityActionService.logEntityAction(tenantId, otaPackageId, otaPackageInfo, null,
actionType, user, otaPackageInfo.getId().toString()); actionType, user, otaPackageInfo.getId().toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.OTA_PACKAGE), logEntityActionService.logEntityAction(tenantId, getOrEmptyId(otaPackageId, EntityType.OTA_PACKAGE),
actionType, user, e, otaPackageId.toString()); actionType, user, e, otaPackageId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/user/DefaultUserService.java

@ -78,7 +78,7 @@ public class DefaultUserService extends AbstractTbEntityService implements TbUse
userService.deleteUser(tenantId, user); userService.deleteUser(tenantId, user);
logEntityActionService.logEntityAction(tenantId, userId, user, customerId, actionType, responsibleUser, customerId.toString()); logEntityActionService.logEntityAction(tenantId, userId, user, customerId, actionType, responsibleUser, customerId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.USER), logEntityActionService.logEntityAction(tenantId, getOrEmptyId(userId, EntityType.USER),
actionType, responsibleUser, e, userId.toString()); actionType, responsibleUser, e, userId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/widgets/bundle/DefaultWidgetsBundleService.java

@ -66,7 +66,7 @@ public class DefaultWidgetsBundleService extends AbstractTbEntityService impleme
widgetsBundleService.deleteWidgetsBundle(widgetsBundle.getTenantId(), widgetsBundle.getId()); widgetsBundleService.deleteWidgetsBundle(widgetsBundle.getTenantId(), widgetsBundle.getId());
logEntityActionService.logEntityAction(tenantId, widgetsBundle.getId(), widgetsBundle, null, actionType, user); logEntityActionService.logEntityAction(tenantId, widgetsBundle.getId(), widgetsBundle, null, actionType, user);
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.WIDGETS_BUNDLE), actionType, user, e, widgetsBundle.getId()); logEntityActionService.logEntityAction(tenantId, getOrEmptyId(widgetsBundle.getId(), EntityType.WIDGETS_BUNDLE), actionType, user, e, widgetsBundle.getId());
throw e; throw e;
} }
} }

2
application/src/main/java/org/thingsboard/server/service/entitiy/widgets/type/DefaultWidgetTypeService.java

@ -78,7 +78,7 @@ public class DefaultWidgetTypeService extends AbstractTbEntityService implements
widgetTypeService.deleteWidgetType(widgetTypeDetails.getTenantId(), widgetTypeDetails.getId()); widgetTypeService.deleteWidgetType(widgetTypeDetails.getTenantId(), widgetTypeDetails.getId());
logEntityActionService.logEntityAction(tenantId, widgetTypeDetails.getId(), widgetTypeDetails, null, actionType, user); logEntityActionService.logEntityAction(tenantId, widgetTypeDetails.getId(), widgetTypeDetails, null, actionType, user);
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.WIDGET_TYPE), actionType, user, e, widgetTypeDetails.getId()); logEntityActionService.logEntityAction(tenantId, getOrEmptyId(widgetTypeDetails.getId(), EntityType.WIDGET_TYPE), actionType, user, e, widgetTypeDetails.getId());
throw e; throw e;
} }
} }

2
application/src/main/java/org/thingsboard/server/service/resource/DefaultTbResourceService.java

@ -104,7 +104,7 @@ public class DefaultTbResourceService extends AbstractTbEntityService implements
} }
return result; return result;
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.TB_RESOURCE), logEntityActionService.logEntityAction(tenantId, getOrEmptyId(resourceId, EntityType.TB_RESOURCE),
actionType, user, e, resourceId.toString()); actionType, user, e, resourceId.toString());
throw e; throw e;
} }

2
application/src/main/java/org/thingsboard/server/service/rule/DefaultTbRuleChainService.java

@ -193,7 +193,7 @@ public class DefaultTbRuleChainService extends AbstractTbEntityService implement
ruleChainService.deleteRuleChainById(tenantId, ruleChainId); ruleChainService.deleteRuleChainById(tenantId, ruleChainId);
logEntityActionService.logEntityAction(tenantId, ruleChainId, ruleChain, null, ActionType.DELETED, user, ruleChainId.toString()); logEntityActionService.logEntityAction(tenantId, ruleChainId, ruleChain, null, ActionType.DELETED, user, ruleChainId.toString());
} catch (Exception e) { } catch (Exception e) {
logEntityActionService.logEntityAction(tenantId, emptyId(EntityType.RULE_CHAIN), ActionType.DELETED, logEntityActionService.logEntityAction(tenantId, getOrEmptyId(ruleChainId, EntityType.RULE_CHAIN), ActionType.DELETED,
user, e, ruleChainId.toString()); user, e, ruleChainId.toString());
throw e; throw e;
} }

Loading…
Cancel
Save