|
|
|
@ -71,9 +71,9 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
|
public <E extends HasName, I extends EntityId> void notifyDeleteEntity(TenantId tenantId, I entityId, E entity, |
|
|
|
CustomerId customerId, ActionType actionType, |
|
|
|
List<EdgeId> relatedEdgeIds, |
|
|
|
SecurityUser user, boolean isBody, Object... additionalInfo) { |
|
|
|
SecurityUser user, Object... additionalInfo) { |
|
|
|
logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo); |
|
|
|
sendDeleteNotificationMsg(tenantId, entityId, entity, relatedEdgeIds, isBody); |
|
|
|
sendDeleteNotificationMsg(tenantId, entityId, entity, relatedEdgeIds); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -194,10 +194,16 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
|
sendEntityNotificationMsg(alarm.getTenantId(), alarm.getId(), edgeTypeByActionType (actionType)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void notifyDeleteAlarm(Alarm alarm, SecurityUser user, List<EdgeId> relatedEdgeIds) { |
|
|
|
logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarm, alarm.getCustomerId(), ActionType.ALARM_DELETE, user, null); |
|
|
|
sendAlarmDeleteNotificationMsg(alarm, relatedEdgeIds); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void notifyDeleteCustomer(Customer customer, SecurityUser user, List<EdgeId> edgeIds) { |
|
|
|
logEntityAction(customer.getTenantId(), customer.getId(), customer, customer.getId(), ActionType.DELETED, user, null); |
|
|
|
sendDeleteNotificationMsg(customer.getTenantId(), customer.getId(), customer, edgeIds, false); |
|
|
|
sendDeleteNotificationMsg(customer.getTenantId(), customer.getId(), customer, edgeIds); |
|
|
|
tbClusterService.broadcastEntityStateChangeEvent(customer.getTenantId(), customer.getId(), ComponentLifecycleEvent.DELETED); |
|
|
|
} |
|
|
|
|
|
|
|
@ -227,15 +233,22 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected <E extends HasName, I extends EntityId> void sendDeleteNotificationMsg(TenantId tenantId, I entityId, E entity, List<EdgeId> edgeIds, boolean isBody) { |
|
|
|
protected <E extends HasName, I extends EntityId> void sendDeleteNotificationMsg(TenantId tenantId, I entityId, E entity, List<EdgeId> edgeIds) { |
|
|
|
try { |
|
|
|
String body = isBody ? json.writeValueAsString(entity) : null; |
|
|
|
sendDeleteNotificationMsg(tenantId, entityId, edgeIds, body); |
|
|
|
sendDeleteNotificationMsg(tenantId, entityId, edgeIds, null); |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("Failed to push delete " + entity.getClass().getName() + " msg to core: {}", entity, e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected void sendAlarmDeleteNotificationMsg(Alarm alarm, List<EdgeId> relatedEdgeIds) { |
|
|
|
try { |
|
|
|
sendDeleteNotificationMsg(alarm.getTenantId(), alarm.getId(), relatedEdgeIds, json.writeValueAsString(alarm)); |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("Failed to push delete alarm msg to core: {}", alarm, e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void sendDeleteNotificationMsg(TenantId tenantId, EntityId entityId, List<EdgeId> edgeIds, String body) { |
|
|
|
if (edgeIds != null && !edgeIds.isEmpty()) { |
|
|
|
for (EdgeId edgeId : edgeIds) { |
|
|
|
|