Commit 3b909f6e47a2189f2c9b7d12ec3568ec0b90882a
Merge remote-tracking branch 'origin/develop/2.6-edge' into develop/3.3-edge
Showing
9 changed files
with
84 additions
and
44 deletions
@@ -132,13 +132,16 @@ public class AssetController extends BaseController { | @@ -132,13 +132,16 @@ public class AssetController extends BaseController { | ||
132 | try { | 132 | try { |
133 | AssetId assetId = new AssetId(toUUID(strAssetId)); | 133 | AssetId assetId = new AssetId(toUUID(strAssetId)); |
134 | Asset asset = checkAssetId(assetId, Operation.DELETE); | 134 | Asset asset = checkAssetId(assetId, Operation.DELETE); |
135 | + | ||
136 | + List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), assetId); | ||
137 | + | ||
135 | assetService.deleteAsset(getTenantId(), assetId); | 138 | assetService.deleteAsset(getTenantId(), assetId); |
136 | 139 | ||
137 | logEntityAction(assetId, asset, | 140 | logEntityAction(assetId, asset, |
138 | asset.getCustomerId(), | 141 | asset.getCustomerId(), |
139 | ActionType.DELETED, null, strAssetId); | 142 | ActionType.DELETED, null, strAssetId); |
140 | 143 | ||
141 | - sendNotificationMsgToEdgeService(getTenantId(), assetId, EntityType.ASSET, EdgeEventActionType.DELETED); | 144 | + sendDeleteNotificationMsgToEdgeService(getTenantId(), assetId, EntityType.ASSET, relatedEdgeIds); |
142 | } catch (Exception e) { | 145 | } catch (Exception e) { |
143 | logEntityAction(emptyId(EntityType.ASSET), | 146 | logEntityAction(emptyId(EntityType.ASSET), |
144 | null, | 147 | null, |
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; | @@ -19,6 +19,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; | ||
19 | import com.fasterxml.jackson.databind.ObjectMapper; | 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
20 | import com.fasterxml.jackson.databind.node.ArrayNode; | 20 | import com.fasterxml.jackson.databind.node.ArrayNode; |
21 | import com.fasterxml.jackson.databind.node.ObjectNode; | 21 | import com.fasterxml.jackson.databind.node.ObjectNode; |
22 | +import com.google.common.util.concurrent.ListenableFuture; | ||
22 | import lombok.Getter; | 23 | import lombok.Getter; |
23 | import lombok.extern.slf4j.Slf4j; | 24 | import lombok.extern.slf4j.Slf4j; |
24 | import org.apache.commons.lang3.StringUtils; | 25 | import org.apache.commons.lang3.StringUtils; |
@@ -935,6 +936,30 @@ public abstract class BaseController { | @@ -935,6 +936,30 @@ public abstract class BaseController { | ||
935 | } | 936 | } |
936 | } | 937 | } |
937 | 938 | ||
939 | + protected List<EdgeId> findRelatedEdgeIds(TenantId tenantId, EntityId entityId) { | ||
940 | + if (!edgesEnabled) { | ||
941 | + return null; | ||
942 | + } | ||
943 | + List<EdgeId> result = null; | ||
944 | + try { | ||
945 | + result = edgeService.findRelatedEdgeIdsByEntityId(tenantId, entityId).get(); | ||
946 | + } catch (Exception e) { | ||
947 | + log.error("[{}] can't find related edge ids for entity [{}]", tenantId, entityId, e); | ||
948 | + } | ||
949 | + return result; | ||
950 | + } | ||
951 | + | ||
952 | + protected void sendDeleteNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, EntityType entityType, List<EdgeId> edgeIds) { | ||
953 | + if (!edgesEnabled) { | ||
954 | + return; | ||
955 | + } | ||
956 | + if (edgeIds != null && !edgeIds.isEmpty()) { | ||
957 | + for (EdgeId edgeId : edgeIds) { | ||
958 | + sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, entityType, EdgeEventActionType.DELETED); | ||
959 | + } | ||
960 | + } | ||
961 | + } | ||
962 | + | ||
938 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, EntityType entityType, EdgeEventActionType action) { | 963 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, EntityType entityType, EdgeEventActionType action) { |
939 | sendNotificationMsgToEdgeService(tenantId, null, entityId, entityType, action); | 964 | sendNotificationMsgToEdgeService(tenantId, null, entityId, entityType, action); |
940 | } | 965 | } |
@@ -34,6 +34,7 @@ import org.thingsboard.server.common.data.audit.ActionType; | @@ -34,6 +34,7 @@ import org.thingsboard.server.common.data.audit.ActionType; | ||
34 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; | 34 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
35 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 35 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
36 | import org.thingsboard.server.common.data.id.CustomerId; | 36 | import org.thingsboard.server.common.data.id.CustomerId; |
37 | +import org.thingsboard.server.common.data.id.EdgeId; | ||
37 | import org.thingsboard.server.common.data.id.TenantId; | 38 | import org.thingsboard.server.common.data.id.TenantId; |
38 | import org.thingsboard.server.common.data.page.PageData; | 39 | import org.thingsboard.server.common.data.page.PageData; |
39 | import org.thingsboard.server.common.data.page.PageLink; | 40 | import org.thingsboard.server.common.data.page.PageLink; |
@@ -41,6 +42,8 @@ import org.thingsboard.server.queue.util.TbCoreComponent; | @@ -41,6 +42,8 @@ import org.thingsboard.server.queue.util.TbCoreComponent; | ||
41 | import org.thingsboard.server.service.security.permission.Operation; | 42 | import org.thingsboard.server.service.security.permission.Operation; |
42 | import org.thingsboard.server.service.security.permission.Resource; | 43 | import org.thingsboard.server.service.security.permission.Resource; |
43 | 44 | ||
45 | +import java.util.List; | ||
46 | + | ||
44 | @RestController | 47 | @RestController |
45 | @TbCoreComponent | 48 | @TbCoreComponent |
46 | @RequestMapping("/api") | 49 | @RequestMapping("/api") |
@@ -131,13 +134,16 @@ public class CustomerController extends BaseController { | @@ -131,13 +134,16 @@ public class CustomerController extends BaseController { | ||
131 | try { | 134 | try { |
132 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); | 135 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
133 | Customer customer = checkCustomerId(customerId, Operation.DELETE); | 136 | Customer customer = checkCustomerId(customerId, Operation.DELETE); |
137 | + | ||
138 | + List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), customerId); | ||
139 | + | ||
134 | customerService.deleteCustomer(getTenantId(), customerId); | 140 | customerService.deleteCustomer(getTenantId(), customerId); |
135 | 141 | ||
136 | logEntityAction(customerId, customer, | 142 | logEntityAction(customerId, customer, |
137 | customer.getId(), | 143 | customer.getId(), |
138 | ActionType.DELETED, null, strCustomerId); | 144 | ActionType.DELETED, null, strCustomerId); |
139 | 145 | ||
140 | - sendNotificationMsgToEdgeService(getTenantId(), customerId, EntityType.CUSTOMER, EdgeEventActionType.DELETED); | 146 | + sendDeleteNotificationMsgToEdgeService(getTenantId(), customerId, EntityType.CUSTOMER, relatedEdgeIds); |
141 | } catch (Exception e) { | 147 | } catch (Exception e) { |
142 | 148 | ||
143 | logEntityAction(emptyId(EntityType.CUSTOMER), | 149 | logEntityAction(emptyId(EntityType.CUSTOMER), |
@@ -47,6 +47,7 @@ import org.thingsboard.server.service.security.permission.Operation; | @@ -47,6 +47,7 @@ import org.thingsboard.server.service.security.permission.Operation; | ||
47 | import org.thingsboard.server.service.security.permission.Resource; | 47 | import org.thingsboard.server.service.security.permission.Resource; |
48 | 48 | ||
49 | import java.util.HashSet; | 49 | import java.util.HashSet; |
50 | +import java.util.List; | ||
50 | import java.util.Set; | 51 | import java.util.Set; |
51 | 52 | ||
52 | @RestController | 53 | @RestController |
@@ -136,13 +137,16 @@ public class DashboardController extends BaseController { | @@ -136,13 +137,16 @@ public class DashboardController extends BaseController { | ||
136 | try { | 137 | try { |
137 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 138 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
138 | Dashboard dashboard = checkDashboardId(dashboardId, Operation.DELETE); | 139 | Dashboard dashboard = checkDashboardId(dashboardId, Operation.DELETE); |
140 | + | ||
141 | + List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), dashboardId); | ||
142 | + | ||
139 | dashboardService.deleteDashboard(getCurrentUser().getTenantId(), dashboardId); | 143 | dashboardService.deleteDashboard(getCurrentUser().getTenantId(), dashboardId); |
140 | 144 | ||
141 | logEntityAction(dashboardId, dashboard, | 145 | logEntityAction(dashboardId, dashboard, |
142 | null, | 146 | null, |
143 | ActionType.DELETED, null, strDashboardId); | 147 | ActionType.DELETED, null, strDashboardId); |
144 | 148 | ||
145 | - sendNotificationMsgToEdgeService(getTenantId(), dashboardId, EntityType.DASHBOARD, EdgeEventActionType.DELETED); | 149 | + sendDeleteNotificationMsgToEdgeService(getTenantId(), dashboardId, EntityType.DASHBOARD, relatedEdgeIds); |
146 | } catch (Exception e) { | 150 | } catch (Exception e) { |
147 | 151 | ||
148 | logEntityAction(emptyId(EntityType.DASHBOARD), | 152 | logEntityAction(emptyId(EntityType.DASHBOARD), |
@@ -160,6 +160,9 @@ public class DeviceController extends BaseController { | @@ -160,6 +160,9 @@ public class DeviceController extends BaseController { | ||
160 | try { | 160 | try { |
161 | DeviceId deviceId = new DeviceId(toUUID(strDeviceId)); | 161 | DeviceId deviceId = new DeviceId(toUUID(strDeviceId)); |
162 | Device device = checkDeviceId(deviceId, Operation.DELETE); | 162 | Device device = checkDeviceId(deviceId, Operation.DELETE); |
163 | + | ||
164 | + List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), deviceId); | ||
165 | + | ||
163 | deviceService.deleteDevice(getCurrentUser().getTenantId(), deviceId); | 166 | deviceService.deleteDevice(getCurrentUser().getTenantId(), deviceId); |
164 | 167 | ||
165 | tbClusterService.onDeviceDeleted(device, null); | 168 | tbClusterService.onDeviceDeleted(device, null); |
@@ -169,7 +172,7 @@ public class DeviceController extends BaseController { | @@ -169,7 +172,7 @@ public class DeviceController extends BaseController { | ||
169 | device.getCustomerId(), | 172 | device.getCustomerId(), |
170 | ActionType.DELETED, null, strDeviceId); | 173 | ActionType.DELETED, null, strDeviceId); |
171 | 174 | ||
172 | - sendNotificationMsgToEdgeService(getTenantId(), deviceId, EntityType.DEVICE, EdgeEventActionType.DELETED); | 175 | + sendDeleteNotificationMsgToEdgeService(getTenantId(), deviceId, EntityType.DEVICE, relatedEdgeIds); |
173 | 176 | ||
174 | deviceStateService.onDeviceDeleted(device); | 177 | deviceStateService.onDeviceDeleted(device); |
175 | } catch (Exception e) { | 178 | } catch (Exception e) { |
@@ -360,11 +360,14 @@ public class EntityViewController extends BaseController { | @@ -360,11 +360,14 @@ public class EntityViewController extends BaseController { | ||
360 | try { | 360 | try { |
361 | EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId)); | 361 | EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId)); |
362 | EntityView entityView = checkEntityViewId(entityViewId, Operation.DELETE); | 362 | EntityView entityView = checkEntityViewId(entityViewId, Operation.DELETE); |
363 | + | ||
364 | + List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), entityViewId); | ||
365 | + | ||
363 | entityViewService.deleteEntityView(getTenantId(), entityViewId); | 366 | entityViewService.deleteEntityView(getTenantId(), entityViewId); |
364 | logEntityAction(entityViewId, entityView, entityView.getCustomerId(), | 367 | logEntityAction(entityViewId, entityView, entityView.getCustomerId(), |
365 | ActionType.DELETED, null, strEntityViewId); | 368 | ActionType.DELETED, null, strEntityViewId); |
366 | 369 | ||
367 | - sendNotificationMsgToEdgeService(getTenantId(), entityViewId, EntityType.ENTITY_VIEW, EdgeEventActionType.DELETED); | 370 | + sendDeleteNotificationMsgToEdgeService(getTenantId(), entityViewId, EntityType.ENTITY_VIEW, relatedEdgeIds); |
368 | } catch (Exception e) { | 371 | } catch (Exception e) { |
369 | logEntityAction(emptyId(EntityType.ENTITY_VIEW), | 372 | logEntityAction(emptyId(EntityType.ENTITY_VIEW), |
370 | null, | 373 | null, |
@@ -305,6 +305,11 @@ public class RuleChainController extends BaseController { | @@ -305,6 +305,11 @@ public class RuleChainController extends BaseController { | ||
305 | 305 | ||
306 | Set<RuleChainId> referencingRuleChainIds = referencingRuleNodes.stream().map(RuleNode::getRuleChainId).collect(Collectors.toSet()); | 306 | Set<RuleChainId> referencingRuleChainIds = referencingRuleNodes.stream().map(RuleNode::getRuleChainId).collect(Collectors.toSet()); |
307 | 307 | ||
308 | + List<EdgeId> relatedEdgeIds = null; | ||
309 | + if (RuleChainType.EDGE.equals(ruleChain.getType())) { | ||
310 | + relatedEdgeIds = findRelatedEdgeIds(getTenantId(), ruleChainId); | ||
311 | + } | ||
312 | + | ||
308 | ruleChainService.deleteRuleChainById(getTenantId(), ruleChainId); | 313 | ruleChainService.deleteRuleChainById(getTenantId(), ruleChainId); |
309 | 314 | ||
310 | referencingRuleChainIds.remove(ruleChain.getId()); | 315 | referencingRuleChainIds.remove(ruleChain.getId()); |
@@ -321,7 +326,7 @@ public class RuleChainController extends BaseController { | @@ -321,7 +326,7 @@ public class RuleChainController extends BaseController { | ||
321 | ActionType.DELETED, null, strRuleChainId); | 326 | ActionType.DELETED, null, strRuleChainId); |
322 | 327 | ||
323 | if (RuleChainType.EDGE.equals(ruleChain.getType())) { | 328 | if (RuleChainType.EDGE.equals(ruleChain.getType())) { |
324 | - sendNotificationMsgToEdgeService(ruleChain.getTenantId(), ruleChain.getId(), EntityType.RULE_CHAIN, EdgeEventActionType.DELETED); | 329 | + sendDeleteNotificationMsgToEdgeService(ruleChain.getTenantId(), ruleChain.getId(), EntityType.RULE_CHAIN, relatedEdgeIds); |
325 | } | 330 | } |
326 | 331 | ||
327 | } catch (Exception e) { | 332 | } catch (Exception e) { |
@@ -39,6 +39,7 @@ import org.thingsboard.server.common.data.edge.EdgeEventActionType; | @@ -39,6 +39,7 @@ import org.thingsboard.server.common.data.edge.EdgeEventActionType; | ||
39 | import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; | 39 | import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; |
40 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 40 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
41 | import org.thingsboard.server.common.data.id.CustomerId; | 41 | import org.thingsboard.server.common.data.id.CustomerId; |
42 | +import org.thingsboard.server.common.data.id.EdgeId; | ||
42 | import org.thingsboard.server.common.data.id.TenantId; | 43 | import org.thingsboard.server.common.data.id.TenantId; |
43 | import org.thingsboard.server.common.data.id.UserId; | 44 | import org.thingsboard.server.common.data.id.UserId; |
44 | import org.thingsboard.server.common.data.page.PageData; | 45 | import org.thingsboard.server.common.data.page.PageData; |
@@ -54,9 +55,9 @@ import org.thingsboard.server.service.security.model.token.JwtTokenFactory; | @@ -54,9 +55,9 @@ import org.thingsboard.server.service.security.model.token.JwtTokenFactory; | ||
54 | import org.thingsboard.server.service.security.permission.Operation; | 55 | import org.thingsboard.server.service.security.permission.Operation; |
55 | import org.thingsboard.server.service.security.permission.Resource; | 56 | import org.thingsboard.server.service.security.permission.Resource; |
56 | import org.thingsboard.server.service.security.system.SystemSecurityService; | 57 | import org.thingsboard.server.service.security.system.SystemSecurityService; |
57 | -import org.thingsboard.server.utils.MiscUtils; | ||
58 | 58 | ||
59 | import javax.servlet.http.HttpServletRequest; | 59 | import javax.servlet.http.HttpServletRequest; |
60 | +import java.util.List; | ||
60 | 61 | ||
61 | @RestController | 62 | @RestController |
62 | @TbCoreComponent | 63 | @TbCoreComponent |
@@ -239,13 +240,16 @@ public class UserController extends BaseController { | @@ -239,13 +240,16 @@ public class UserController extends BaseController { | ||
239 | try { | 240 | try { |
240 | UserId userId = new UserId(toUUID(strUserId)); | 241 | UserId userId = new UserId(toUUID(strUserId)); |
241 | User user = checkUserId(userId, Operation.DELETE); | 242 | User user = checkUserId(userId, Operation.DELETE); |
243 | + | ||
244 | + List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), userId); | ||
245 | + | ||
242 | userService.deleteUser(getCurrentUser().getTenantId(), userId); | 246 | userService.deleteUser(getCurrentUser().getTenantId(), userId); |
243 | 247 | ||
244 | logEntityAction(userId, user, | 248 | logEntityAction(userId, user, |
245 | user.getCustomerId(), | 249 | user.getCustomerId(), |
246 | ActionType.DELETED, null, strUserId); | 250 | ActionType.DELETED, null, strUserId); |
247 | 251 | ||
248 | - sendNotificationMsgToEdgeService(getTenantId(), user.getId(), EntityType.USER, EdgeEventActionType.DELETED); | 252 | + sendDeleteNotificationMsgToEdgeService(getTenantId(), userId, EntityType.USER, relatedEdgeIds); |
249 | 253 | ||
250 | } catch (Exception e) { | 254 | } catch (Exception e) { |
251 | logEntityAction(emptyId(EntityType.USER), | 255 | logEntityAction(emptyId(EntityType.USER), |
@@ -288,29 +288,28 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -288,29 +288,28 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
288 | private void processCustomer(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { | 288 | private void processCustomer(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { |
289 | EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction()); | 289 | EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction()); |
290 | EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); | 290 | EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); |
291 | - EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | ||
292 | - PageLink pageLink = new PageLink(DEFAULT_LIMIT); | ||
293 | - PageData<Edge> pageData; | ||
294 | - do { | ||
295 | - pageData = edgeService.findEdgesByTenantId(tenantId, pageLink); | ||
296 | - if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { | ||
297 | - for (Edge edge : pageData.getData()) { | ||
298 | - switch (actionType) { | ||
299 | - case UPDATED: | ||
300 | - if (!edge.getCustomerId().isNullUid() && edge.getCustomerId().equals(entityId)) { | ||
301 | - saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); | ||
302 | - } | ||
303 | - break; | ||
304 | - case DELETED: | ||
305 | - saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); | ||
306 | - break; | 291 | + UUID uuid = new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()); |
292 | + CustomerId customerId = new CustomerId(EntityIdFactory.getByEdgeEventTypeAndUuid(type, uuid).getId()); | ||
293 | + switch (actionType) { | ||
294 | + case UPDATED: | ||
295 | + PageLink pageLink = new PageLink(DEFAULT_LIMIT); | ||
296 | + PageData<Edge> pageData; | ||
297 | + do { | ||
298 | + pageData = edgeService.findEdgesByTenantIdAndCustomerId(tenantId, customerId, pageLink); | ||
299 | + if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { | ||
300 | + for (Edge edge : pageData.getData()) { | ||
301 | + saveEdgeEvent(tenantId, edge.getId(), type, actionType, customerId, null); | ||
302 | + } | ||
303 | + if (pageData.hasNext()) { | ||
304 | + pageLink = pageLink.nextPageLink(); | ||
305 | + } | ||
307 | } | 306 | } |
308 | - } | ||
309 | - if (pageData.hasNext()) { | ||
310 | - pageLink = pageLink.nextPageLink(); | ||
311 | - } | ||
312 | - } | ||
313 | - } while (pageData != null && pageData.hasNext()); | 307 | + } while (pageData != null && pageData.hasNext()); |
308 | + case DELETED: | ||
309 | + EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); | ||
310 | + saveEdgeEvent(tenantId, edgeId, type, actionType, customerId, null); | ||
311 | + break; | ||
312 | + } | ||
314 | } | 313 | } |
315 | 314 | ||
316 | private void processEntity(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { | 315 | private void processEntity(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) { |
@@ -318,6 +317,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -318,6 +317,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
318 | EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); | 317 | EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType()); |
319 | EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, | 318 | EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, |
320 | new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); | 319 | new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB())); |
320 | + EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); | ||
321 | ListenableFuture<List<EdgeId>> edgeIdsFuture; | 321 | ListenableFuture<List<EdgeId>> edgeIdsFuture; |
322 | switch (actionType) { | 322 | switch (actionType) { |
323 | case ADDED: // used only for USER entity | 323 | case ADDED: // used only for USER entity |
@@ -377,23 +377,10 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -377,23 +377,10 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
377 | }, dbCallbackExecutorService); | 377 | }, dbCallbackExecutorService); |
378 | break; | 378 | break; |
379 | case DELETED: | 379 | case DELETED: |
380 | - PageLink pageLink = new PageLink(DEFAULT_LIMIT); | ||
381 | - PageData<Edge> pageData; | ||
382 | - do { | ||
383 | - pageData = edgeService.findEdgesByTenantId(tenantId, pageLink); | ||
384 | - if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { | ||
385 | - for (Edge edge : pageData.getData()) { | ||
386 | - saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null); | ||
387 | - } | ||
388 | - if (pageData.hasNext()) { | ||
389 | - pageLink = pageLink.nextPageLink(); | ||
390 | - } | ||
391 | - } | ||
392 | - } while (pageData != null && pageData.hasNext()); | 380 | + saveEdgeEvent(tenantId, edgeId, type, actionType, entityId, null); |
393 | break; | 381 | break; |
394 | case ASSIGNED_TO_EDGE: | 382 | case ASSIGNED_TO_EDGE: |
395 | case UNASSIGNED_FROM_EDGE: | 383 | case UNASSIGNED_FROM_EDGE: |
396 | - EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); | ||
397 | saveEdgeEvent(tenantId, edgeId, type, actionType, entityId, null); | 384 | saveEdgeEvent(tenantId, edgeId, type, actionType, entityId, null); |
398 | if (type.equals(EdgeEventType.RULE_CHAIN)) { | 385 | if (type.equals(EdgeEventType.RULE_CHAIN)) { |
399 | updateDependentRuleChains(tenantId, new RuleChainId(entityId.getId()), edgeId); | 386 | updateDependentRuleChains(tenantId, new RuleChainId(entityId.getId()), edgeId); |