Browse Source
Merge pull request #10649 from AndriiLandiak/fix/entity-listener
Improvement for EntityStateSourcingListener
pull/10662/head
Viacheslav Klimov
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
6 additions and
0 deletions
-
application/src/main/java/org/thingsboard/server/service/entitiy/EntityStateSourcingListener.java
|
|
|
@ -73,6 +73,9 @@ public class EntityStateSourcingListener { |
|
|
|
public void handleEvent(SaveEntityEvent<?> event) { |
|
|
|
TenantId tenantId = event.getTenantId(); |
|
|
|
EntityId entityId = event.getEntityId(); |
|
|
|
if (entityId == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
EntityType entityType = entityId.getEntityType(); |
|
|
|
log.debug("[{}][{}][{}] Handling entity save event: {}", tenantId, entityType, entityId, event); |
|
|
|
boolean isCreated = event.getCreated() != null && event.getCreated(); |
|
|
|
@ -122,6 +125,9 @@ public class EntityStateSourcingListener { |
|
|
|
public void handleEvent(DeleteEntityEvent<?> event) { |
|
|
|
TenantId tenantId = event.getTenantId(); |
|
|
|
EntityId entityId = event.getEntityId(); |
|
|
|
if (entityId == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
EntityType entityType = entityId.getEntityType(); |
|
|
|
if (!tenantId.isSysTenantId() && entityType != EntityType.TENANT && !tenantService.tenantExists(tenantId)) { |
|
|
|
log.debug("[{}] Ignoring DeleteEntityEvent because tenant does not exist: {}", tenantId, event); |
|
|
|
|