Commit 3d0aa93aaf01c21f85cf2b24d79bd55d0e4c9da9

Authored by Volodymyr Babak
1 parent 37b4db02

Send notification renaming

... ... @@ -93,8 +93,7 @@ public class AlarmController extends BaseController {
93 93 getCurrentUser().getCustomerId(),
94 94 alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
95 95
96   - sendNotificationMsgToEdgeService(getTenantId(), savedAlarm.getId(), EntityType.ALARM,
97   - alarm.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
  96 + sendEntityNotificationMsg(getTenantId(), savedAlarm.getId(), alarm.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
98 97
99 98 return savedAlarm;
100 99 } catch (Exception e) {
... ... @@ -113,7 +112,7 @@ public class AlarmController extends BaseController {
113 112 AlarmId alarmId = new AlarmId(toUUID(strAlarmId));
114 113 checkAlarmId(alarmId, Operation.WRITE);
115 114
116   - sendNotificationMsgToEdgeService(getTenantId(), alarmId, EntityType.ALARM, EdgeEventActionType.DELETED);
  115 + sendEntityNotificationMsg(getTenantId(), alarmId, EdgeEventActionType.DELETED);
117 116
118 117 return alarmService.deleteAlarm(getTenantId(), alarmId);
119 118 } catch (Exception e) {
... ... @@ -135,7 +134,7 @@ public class AlarmController extends BaseController {
135 134 alarm.setStatus(alarm.getStatus().isCleared() ? AlarmStatus.CLEARED_ACK : AlarmStatus.ACTIVE_ACK);
136 135 logEntityAction(alarmId, alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_ACK, null);
137 136
138   - sendNotificationMsgToEdgeService(getTenantId(), alarmId, EntityType.ALARM, EdgeEventActionType.ALARM_ACK);
  137 + sendEntityNotificationMsg(getTenantId(), alarmId, EdgeEventActionType.ALARM_ACK);
139 138 } catch (Exception e) {
140 139 throw handleException(e);
141 140 }
... ... @@ -155,7 +154,7 @@ public class AlarmController extends BaseController {
155 154 alarm.setStatus(alarm.getStatus().isAck() ? AlarmStatus.CLEARED_ACK : AlarmStatus.CLEARED_UNACK);
156 155 logEntityAction(alarmId, alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_CLEAR, null);
157 156
158   - sendNotificationMsgToEdgeService(getTenantId(), alarmId, EntityType.ALARM, EdgeEventActionType.ALARM_CLEAR);
  157 + sendEntityNotificationMsg(getTenantId(), alarmId, EdgeEventActionType.ALARM_CLEAR);
159 158 } catch (Exception e) {
160 159 throw handleException(e);
161 160 }
... ...
... ... @@ -92,7 +92,7 @@ public class AssetController extends BaseController {
92 92 asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
93 93
94 94 if (asset.getId() != null) {
95   - sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(), EntityType.ASSET, EdgeEventActionType.UPDATED);
  95 + sendEntityNotificationMsg(savedAsset.getTenantId(), savedAsset.getId(), EdgeEventActionType.UPDATED);
96 96 }
97 97
98 98 return savedAsset;
... ... @@ -120,7 +120,7 @@ public class AssetController extends BaseController {
120 120 asset.getCustomerId(),
121 121 ActionType.DELETED, null, strAssetId);
122 122
123   - sendDeleteNotificationMsgToEdgeService(getTenantId(), assetId, EntityType.ASSET, relatedEdgeIds);
  123 + sendDeleteNotificationMsg(getTenantId(), assetId, relatedEdgeIds);
124 124 } catch (Exception e) {
125 125 logEntityAction(emptyId(EntityType.ASSET),
126 126 null,
... ... @@ -150,7 +150,7 @@ public class AssetController extends BaseController {
150 150 savedAsset.getCustomerId(),
151 151 ActionType.ASSIGNED_TO_CUSTOMER, null, strAssetId, strCustomerId, customer.getName());
152 152
153   - sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(),
  153 + sendEntityAssignToCustomerNotificationMsg(savedAsset.getTenantId(), savedAsset.getId(),
154 154 customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
155 155
156 156 return savedAsset;
... ... @@ -184,7 +184,7 @@ public class AssetController extends BaseController {
184 184 asset.getCustomerId(),
185 185 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strAssetId, customer.getId().toString(), customer.getName());
186 186
187   - sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(),
  187 + sendEntityAssignToCustomerNotificationMsg(savedAsset.getTenantId(), savedAsset.getId(),
188 188 customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
189 189
190 190 return savedAsset;
... ... @@ -369,7 +369,7 @@ public class AssetController extends BaseController {
369 369 savedAsset.getCustomerId(),
370 370 ActionType.ASSIGNED_TO_EDGE, null, strAssetId, strEdgeId, edge.getName());
371 371
372   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), EntityType.ASSET, EdgeEventActionType.ASSIGNED_TO_EDGE);
  372 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedAsset.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
373 373
374 374 return savedAsset;
375 375 } catch (Exception e) {
... ... @@ -402,7 +402,7 @@ public class AssetController extends BaseController {
402 402 asset.getCustomerId(),
403 403 ActionType.UNASSIGNED_FROM_EDGE, null, strAssetId, strEdgeId, edge.getName());
404 404
405   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), EntityType.ASSET, EdgeEventActionType.UNASSIGNED_FROM_EDGE);
  405 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedAsset.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
406 406
407 407 return savedAsset;
408 408 } catch (Exception e) {
... ...
... ... @@ -33,29 +33,26 @@ import org.springframework.web.bind.annotation.ResponseBody;
33 33 import org.springframework.web.bind.annotation.ResponseStatus;
34 34 import org.springframework.web.bind.annotation.RestController;
35 35 import org.thingsboard.rule.engine.api.MailService;
36   -import org.thingsboard.server.common.data.EntityType;
37 36 import org.thingsboard.server.common.data.User;
38 37 import org.thingsboard.server.common.data.audit.ActionType;
39 38 import org.thingsboard.server.common.data.edge.EdgeEventActionType;
40   -import org.thingsboard.server.common.data.edge.EdgeEventType;
41 39 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
42 40 import org.thingsboard.server.common.data.exception.ThingsboardException;
43 41 import org.thingsboard.server.common.data.id.TenantId;
44 42 import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo;
45 43 import org.thingsboard.server.common.data.security.UserCredentials;
  44 +import org.thingsboard.server.common.data.security.model.SecuritySettings;
  45 +import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
46 46 import org.thingsboard.server.dao.audit.AuditLogService;
47 47 import org.thingsboard.server.dao.oauth2.OAuth2Service;
48 48 import org.thingsboard.server.queue.util.TbCoreComponent;
49 49 import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository;
50 50 import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails;
51   -import org.thingsboard.server.common.data.security.model.SecuritySettings;
52 51 import org.thingsboard.server.service.security.model.SecurityUser;
53   -import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
54 52 import org.thingsboard.server.service.security.model.UserPrincipal;
55 53 import org.thingsboard.server.service.security.model.token.JwtToken;
56 54 import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
57 55 import org.thingsboard.server.service.security.system.SystemSecurityService;
58   -import org.thingsboard.server.utils.MiscUtils;
59 56 import ua_parser.Client;
60 57
61 58 import javax.servlet.http.HttpServletRequest;
... ... @@ -128,7 +125,7 @@ public class AuthController extends BaseController {
128 125 userCredentials.setPassword(passwordEncoder.encode(newPassword));
129 126 userService.replaceUserCredentials(securityUser.getTenantId(), userCredentials);
130 127
131   - sendNotificationMsgToEdgeService(getTenantId(), userCredentials.getUserId(), EntityType.USER, EdgeEventActionType.CREDENTIALS_UPDATED);
  128 + sendEntityNotificationMsg(getTenantId(), userCredentials.getUserId(), EdgeEventActionType.CREDENTIALS_UPDATED);
132 129
133 130 } catch (Exception e) {
134 131 throw handleException(e);
... ... @@ -238,7 +235,7 @@ public class AuthController extends BaseController {
238 235 }
239 236 }
240 237
241   - sendNotificationMsgToEdgeService(user.getTenantId(), user.getId(), EntityType.USER, EdgeEventActionType.CREDENTIALS_UPDATED);
  238 + sendEntityNotificationMsg(user.getTenantId(), user.getId(), EdgeEventActionType.CREDENTIALS_UPDATED);
242 239
243 240 JwtToken accessToken = tokenFactory.createAccessJwtToken(securityUser);
244 241 JwtToken refreshToken = refreshTokenRepository.requestRefreshToken(securityUser);
... ...
... ... @@ -761,35 +761,7 @@ public abstract class BaseController {
761 761 return null;
762 762 }
763 763
764   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, EdgeEventActionType action) {
765   - if (!edgesEnabled) {
766   - return;
767   - }
768   - try {
769   - sendNotificationMsgToEdgeService(tenantId, edgeId, null, json.writeValueAsString(customerId), EdgeEventType.EDGE, action);
770   - } catch (Exception e) {
771   - log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e);
772   - }
773   - }
774   -
775   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) {
776   - if (!edgesEnabled) {
777   - return;
778   - }
779   - EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType());
780   - try {
781   - if (type != null) {
782   - sendNotificationMsgToEdgeService(tenantId, null, entityId, json.writeValueAsString(customerId), type, action);
783   - }
784   - } catch (Exception e) {
785   - log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e);
786   - }
787   - }
788   -
789   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, EdgeEventActionType action) {
790   - if (!edgesEnabled) {
791   - return;
792   - }
  764 + protected void sendRelationNotificationMsg(TenantId tenantId, EntityRelation relation, EdgeEventActionType action) {
793 765 try {
794 766 if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) &&
795 767 !relation.getTo().getEntityType().equals(EntityType.EDGE)) {
... ... @@ -800,45 +772,46 @@ public abstract class BaseController {
800 772 }
801 773 }
802 774
803   - protected List<EdgeId> findRelatedEdgeIds(TenantId tenantId, EntityId entityId) {
804   - if (!edgesEnabled) {
805   - return null;
  775 + protected void sendDeleteNotificationMsg(TenantId tenantId, EntityId entityId, List<EdgeId> edgeIds) {
  776 + if (edgeIds != null && !edgeIds.isEmpty()) {
  777 + for (EdgeId edgeId : edgeIds) {
  778 + sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, null, EdgeEventActionType.DELETED);
  779 + }
806 780 }
807   - List<EdgeId> result = null;
  781 + }
  782 +
  783 + protected void sendEntityAssignToCustomerNotificationMsg(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) {
808 784 try {
809   - result = edgeService.findRelatedEdgeIdsByEntityId(tenantId, entityId).get();
  785 + sendNotificationMsgToEdgeService(tenantId, null, entityId, json.writeValueAsString(customerId), null, action);
810 786 } catch (Exception e) {
811   - log.error("[{}] can't find related edge ids for entity [{}]", tenantId, entityId, e);
  787 + log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e);
812 788 }
813   - return result;
814 789 }
815 790
816   - protected void sendDeleteNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, EntityType entityType, List<EdgeId> edgeIds) {
817   - if (!edgesEnabled) {
818   - return;
819   - }
820   - if (edgeIds != null && !edgeIds.isEmpty()) {
821   - for (EdgeId edgeId : edgeIds) {
822   - sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, entityType, EdgeEventActionType.DELETED);
823   - }
824   - }
  791 + protected void sendEntityNotificationMsg(TenantId tenantId, EntityId entityId, EdgeEventActionType action) {
  792 + sendNotificationMsgToEdgeService(tenantId, null, entityId, null, null, action);
825 793 }
826 794
827   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, EntityType entityType, EdgeEventActionType action) {
828   - sendNotificationMsgToEdgeService(tenantId, null, entityId, entityType, action);
  795 + protected void sendEntityAssignToEdgeNotificationMsg(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventActionType action) {
  796 + sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, null, action);
829 797 }
830 798
831   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, EntityType entityType, EdgeEventActionType action) {
  799 + private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, EdgeEventActionType action) {
832 800 if (!edgesEnabled) {
833 801 return;
834 802 }
835   - EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityType);
836   - if (type != null) {
837   - sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, type, action);
  803 + if (type == null) {
  804 + if (entityId != null) {
  805 + type = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType());
  806 + } else {
  807 + log.trace("[{}] entity id and type are null. Ignoring this notification", tenantId);
  808 + return;
  809 + }
  810 + if (type == null) {
  811 + log.trace("[{}] edge event type is null. Ignoring this notification [{}]", tenantId, entityId);
  812 + return;
  813 + }
838 814 }
839   - }
840   -
841   - private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, EdgeEventActionType action) {
842 815 TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder();
843 816 builder.setTenantIdMSB(tenantId.getId().getMostSignificantBits());
844 817 builder.setTenantIdLSB(tenantId.getId().getLeastSignificantBits());
... ... @@ -862,4 +835,16 @@ public abstract class BaseController {
862 835 TransportProtos.ToCoreMsg.newBuilder().setEdgeNotificationMsg(msg).build(), null);
863 836 }
864 837
  838 + protected List<EdgeId> findRelatedEdgeIds(TenantId tenantId, EntityId entityId) {
  839 + if (!edgesEnabled) {
  840 + return null;
  841 + }
  842 + List<EdgeId> result = null;
  843 + try {
  844 + result = edgeService.findRelatedEdgeIdsByEntityId(tenantId, entityId).get();
  845 + } catch (Exception e) {
  846 + log.error("[{}] can't find related edge ids for entity [{}]", tenantId, entityId, e);
  847 + }
  848 + return result;
  849 + }
865 850 }
... ...
... ... @@ -113,7 +113,7 @@ public class CustomerController extends BaseController {
113 113 customer.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
114 114
115 115 if (customer.getId() != null) {
116   - sendNotificationMsgToEdgeService(savedCustomer.getTenantId(), savedCustomer.getId(), EntityType.CUSTOMER, EdgeEventActionType.UPDATED);
  116 + sendEntityNotificationMsg(savedCustomer.getTenantId(), savedCustomer.getId(), EdgeEventActionType.UPDATED);
117 117 }
118 118
119 119 return savedCustomer;
... ... @@ -143,7 +143,7 @@ public class CustomerController extends BaseController {
143 143 customer.getId(),
144 144 ActionType.DELETED, null, strCustomerId);
145 145
146   - sendDeleteNotificationMsgToEdgeService(getTenantId(), customerId, EntityType.CUSTOMER, relatedEdgeIds);
  146 + sendDeleteNotificationMsg(getTenantId(), customerId, relatedEdgeIds);
147 147 } catch (Exception e) {
148 148
149 149 logEntityAction(emptyId(EntityType.CUSTOMER),
... ...
... ... @@ -119,7 +119,7 @@ public class DashboardController extends BaseController {
119 119 dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
120 120
121 121 if (dashboard.getId() != null) {
122   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), EntityType.DASHBOARD, EdgeEventActionType.UPDATED);
  122 + sendEntityNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), EdgeEventActionType.UPDATED);
123 123 }
124 124
125 125 return savedDashboard;
... ... @@ -148,7 +148,7 @@ public class DashboardController extends BaseController {
148 148 null,
149 149 ActionType.DELETED, null, strDashboardId);
150 150
151   - sendDeleteNotificationMsgToEdgeService(getTenantId(), dashboardId, EntityType.DASHBOARD, relatedEdgeIds);
  151 + sendDeleteNotificationMsg(getTenantId(), dashboardId, relatedEdgeIds);
152 152 } catch (Exception e) {
153 153
154 154 logEntityAction(emptyId(EntityType.DASHBOARD),
... ... @@ -180,7 +180,7 @@ public class DashboardController extends BaseController {
180 180 customerId,
181 181 ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, strCustomerId, customer.getName());
182 182
183   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
  183 + sendEntityAssignToCustomerNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
184 184
185 185 return savedDashboard;
186 186 } catch (Exception e) {
... ... @@ -212,7 +212,7 @@ public class DashboardController extends BaseController {
212 212 customerId,
213 213 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customer.getId().toString(), customer.getName());
214 214
215   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
  215 + sendEntityAssignToCustomerNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
216 216
217 217 return savedDashboard;
218 218 } catch (Exception e) {
... ... @@ -269,7 +269,7 @@ public class DashboardController extends BaseController {
269 269 logEntityAction(dashboardId, savedDashboard,
270 270 customerId,
271 271 ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
272   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
  272 + sendEntityAssignToCustomerNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
273 273 }
274 274 for (CustomerId customerId : removedCustomerIds) {
275 275 ShortCustomerInfo customerInfo = dashboard.getAssignedCustomerInfo(customerId);
... ... @@ -277,7 +277,7 @@ public class DashboardController extends BaseController {
277 277 logEntityAction(dashboardId, dashboard,
278 278 customerId,
279 279 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
280   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
  280 + sendEntityAssignToCustomerNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
281 281 }
282 282 return savedDashboard;
283 283 }
... ... @@ -321,7 +321,7 @@ public class DashboardController extends BaseController {
321 321 logEntityAction(dashboardId, savedDashboard,
322 322 customerId,
323 323 ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
324   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
  324 + sendEntityAssignToCustomerNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
325 325 }
326 326 return savedDashboard;
327 327 }
... ... @@ -365,7 +365,7 @@ public class DashboardController extends BaseController {
365 365 logEntityAction(dashboardId, dashboard,
366 366 customerId,
367 367 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
368   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
  368 + sendEntityAssignToCustomerNotificationMsg(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
369 369 }
370 370 return savedDashboard;
371 371 }
... ... @@ -510,7 +510,7 @@ public class DashboardController extends BaseController {
510 510 null,
511 511 ActionType.ASSIGNED_TO_EDGE, null, strDashboardId, strEdgeId, edge.getName());
512 512
513   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), EntityType.DASHBOARD, EdgeEventActionType.ASSIGNED_TO_EDGE);
  513 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedDashboard.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
514 514
515 515 return savedDashboard;
516 516 } catch (Exception e) {
... ... @@ -542,7 +542,7 @@ public class DashboardController extends BaseController {
542 542 null,
543 543 ActionType.UNASSIGNED_FROM_EDGE, null, strDashboardId, strEdgeId, edge.getName());
544 544
545   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), EntityType.DASHBOARD, EdgeEventActionType.UNASSIGNED_FROM_EDGE);
  545 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedDashboard.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
546 546
547 547 return savedDashboard;
548 548 } catch (Exception e) {
... ...
... ... @@ -114,7 +114,7 @@ public class DeviceController extends BaseController {
114 114 savedDevice.getId(), savedDevice.getName(), savedDevice.getType()), null);
115 115
116 116 if (device.getId() != null) {
117   - sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(), EntityType.DEVICE, EdgeEventActionType.UPDATED);
  117 + sendEntityNotificationMsg(savedDevice.getTenantId(), savedDevice.getId(), EdgeEventActionType.UPDATED);
118 118 }
119 119
120 120 logEntityAction(savedDevice.getId(), savedDevice,
... ... @@ -151,7 +151,7 @@ public class DeviceController extends BaseController {
151 151 device.getCustomerId(),
152 152 ActionType.DELETED, null, strDeviceId);
153 153
154   - sendDeleteNotificationMsgToEdgeService(getTenantId(), deviceId, EntityType.DEVICE, relatedEdgeIds);
  154 + sendDeleteNotificationMsg(getTenantId(), deviceId, relatedEdgeIds);
155 155
156 156 deviceStateService.onDeviceDeleted(device);
157 157 } catch (Exception e) {
... ... @@ -183,7 +183,7 @@ public class DeviceController extends BaseController {
183 183 savedDevice.getCustomerId(),
184 184 ActionType.ASSIGNED_TO_CUSTOMER, null, strDeviceId, strCustomerId, customer.getName());
185 185
186   - sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(),
  186 + sendEntityAssignToCustomerNotificationMsg(savedDevice.getTenantId(), savedDevice.getId(),
187 187 customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
188 188
189 189 return savedDevice;
... ... @@ -214,7 +214,7 @@ public class DeviceController extends BaseController {
214 214 device.getCustomerId(),
215 215 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDeviceId, customer.getId().toString(), customer.getName());
216 216
217   - sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(),
  217 + sendEntityAssignToCustomerNotificationMsg(savedDevice.getTenantId(), savedDevice.getId(),
218 218 customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
219 219
220 220 return savedDevice;
... ... @@ -282,7 +282,7 @@ public class DeviceController extends BaseController {
282 282
283 283 tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(getCurrentUser().getTenantId(), deviceCredentials.getDeviceId()), null);
284 284
285   - sendNotificationMsgToEdgeService(getTenantId(), device.getId(), EntityType.DEVICE, EdgeEventActionType.CREDENTIALS_UPDATED);
  285 + sendEntityNotificationMsg(getTenantId(), device.getId(), EdgeEventActionType.CREDENTIALS_UPDATED);
286 286
287 287 logEntityAction(device.getId(), device,
288 288 device.getCustomerId(),
... ... @@ -586,7 +586,7 @@ public class DeviceController extends BaseController {
586 586 savedDevice.getCustomerId(),
587 587 ActionType.ASSIGNED_TO_EDGE, null, strDeviceId, strEdgeId, edge.getName());
588 588
589   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), EntityType.DEVICE, EdgeEventActionType.ASSIGNED_TO_EDGE);
  589 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedDevice.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
590 590
591 591 return savedDevice;
592 592 } catch (Exception e) {
... ... @@ -620,7 +620,7 @@ public class DeviceController extends BaseController {
620 620 device.getCustomerId(),
621 621 ActionType.UNASSIGNED_FROM_EDGE, null, strDeviceId, strEdgeId, edge.getName());
622 622
623   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), EntityType.DEVICE, EdgeEventActionType.UNASSIGNED_FROM_EDGE);
  623 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedDevice.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
624 624
625 625 return savedDevice;
626 626 } catch (Exception e) {
... ...
... ... @@ -197,7 +197,7 @@ public class EdgeController extends BaseController {
197 197 savedEdge.getCustomerId(),
198 198 ActionType.ASSIGNED_TO_CUSTOMER, null, strEdgeId, strCustomerId, customer.getName());
199 199
200   - sendNotificationMsgToEdgeService(savedEdge.getTenantId(), savedEdge.getId(),
  200 + sendEntityAssignToCustomerNotificationMsg(savedEdge.getTenantId(), savedEdge.getId(),
201 201 customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
202 202
203 203 return savedEdge;
... ... @@ -231,7 +231,7 @@ public class EdgeController extends BaseController {
231 231 edge.getCustomerId(),
232 232 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strEdgeId, customer.getId().toString(), customer.getName());
233 233
234   - sendNotificationMsgToEdgeService(savedEdge.getTenantId(), savedEdge.getId(),
  234 + sendEntityAssignToCustomerNotificationMsg(savedEdge.getTenantId(), savedEdge.getId(),
235 235 customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
236 236
237 237 return savedEdge;
... ...
... ... @@ -70,7 +70,7 @@ public class EntityRelationController extends BaseController {
70 70 logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(),
71 71 ActionType.RELATION_ADD_OR_UPDATE, null, relation);
72 72
73   - sendNotificationMsgToEdgeService(getTenantId(), relation, EdgeEventActionType.RELATION_ADD_OR_UPDATE);
  73 + sendRelationNotificationMsg(getTenantId(), relation, EdgeEventActionType.RELATION_ADD_OR_UPDATE);
74 74 } catch (Exception e) {
75 75 logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
76 76 ActionType.RELATION_ADD_OR_UPDATE, e, relation);
... ... @@ -109,7 +109,7 @@ public class EntityRelationController extends BaseController {
109 109 logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(),
110 110 ActionType.RELATION_DELETED, null, relation);
111 111
112   - sendNotificationMsgToEdgeService(getTenantId(), relation, EdgeEventActionType.RELATION_DELETED);
  112 + sendRelationNotificationMsg(getTenantId(), relation, EdgeEventActionType.RELATION_DELETED);
113 113 } catch (Exception e) {
114 114 logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
115 115 ActionType.RELATION_DELETED, e, relation);
... ...
... ... @@ -119,7 +119,7 @@ public class EntityViewController extends BaseController {
119 119 entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
120 120
121 121 if (entityView.getId() != null) {
122   - sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(), EntityType.ENTITY_VIEW, EdgeEventActionType.UPDATED);
  122 + sendEntityNotificationMsg(savedEntityView.getTenantId(), savedEntityView.getId(), EdgeEventActionType.UPDATED);
123 123 }
124 124
125 125 return savedEntityView;
... ... @@ -195,7 +195,7 @@ public class EntityViewController extends BaseController {
195 195 logEntityAction(entityViewId, entityView, entityView.getCustomerId(),
196 196 ActionType.DELETED, null, strEntityViewId);
197 197
198   - sendDeleteNotificationMsgToEdgeService(getTenantId(), entityViewId, EntityType.ENTITY_VIEW, relatedEdgeIds);
  198 + sendDeleteNotificationMsg(getTenantId(), entityViewId, relatedEdgeIds);
199 199 } catch (Exception e) {
200 200 logEntityAction(emptyId(EntityType.ENTITY_VIEW),
201 201 null,
... ... @@ -237,7 +237,7 @@ public class EntityViewController extends BaseController {
237 237 savedEntityView.getCustomerId(),
238 238 ActionType.ASSIGNED_TO_CUSTOMER, null, strEntityViewId, strCustomerId, customer.getName());
239 239
240   - sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(),
  240 + sendEntityAssignToCustomerNotificationMsg(savedEntityView.getTenantId(), savedEntityView.getId(),
241 241 customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
242 242
243 243 return savedEntityView;
... ... @@ -266,7 +266,7 @@ public class EntityViewController extends BaseController {
266 266 entityView.getCustomerId(),
267 267 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strEntityViewId, customer.getId().toString(), customer.getName());
268 268
269   - sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(),
  269 + sendEntityAssignToCustomerNotificationMsg(savedEntityView.getTenantId(), savedEntityView.getId(),
270 270 customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
271 271
272 272 return savedEntityView;
... ... @@ -408,7 +408,7 @@ public class EntityViewController extends BaseController {
408 408 savedEntityView.getCustomerId(),
409 409 ActionType.ASSIGNED_TO_EDGE, null, strEntityViewId, strEdgeId, edge.getName());
410 410
411   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), EntityType.ENTITY_VIEW, EdgeEventActionType.ASSIGNED_TO_EDGE);
  411 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedEntityView.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
412 412
413 413 return savedEntityView;
414 414 } catch (Exception e) {
... ... @@ -438,7 +438,7 @@ public class EntityViewController extends BaseController {
438 438 entityView.getCustomerId(),
439 439 ActionType.UNASSIGNED_FROM_EDGE, null, strEntityViewId, strEdgeId, edge.getName());
440 440
441   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), EntityType.ENTITY_VIEW, EdgeEventActionType.UNASSIGNED_FROM_EDGE);
  441 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedEntityView.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
442 442
443 443 return savedEntityView;
444 444 } catch (Exception e) {
... ...
... ... @@ -146,7 +146,7 @@ public class RuleChainController extends BaseController {
146 146
147 147 if (RuleChainType.EDGE.equals(savedRuleChain.getType())) {
148 148 if (!created) {
149   - sendNotificationMsgToEdgeService(savedRuleChain.getTenantId(), savedRuleChain.getId(), EntityType.RULE_CHAIN, EdgeEventActionType.UPDATED);
  149 + sendEntityNotificationMsg(savedRuleChain.getTenantId(), savedRuleChain.getId(), EdgeEventActionType.UPDATED);
150 150 }
151 151 }
152 152
... ... @@ -225,8 +225,8 @@ public class RuleChainController extends BaseController {
225 225 ActionType.UPDATED, null, ruleChainMetaData);
226 226
227 227 if (RuleChainType.EDGE.equals(ruleChain.getType())) {
228   - sendNotificationMsgToEdgeService(ruleChain.getTenantId(),
229   - ruleChain.getId(), EntityType.RULE_CHAIN, EdgeEventActionType.UPDATED);
  228 + sendEntityNotificationMsg(ruleChain.getTenantId(),
  229 + ruleChain.getId(), EdgeEventActionType.UPDATED);
230 230 }
231 231
232 232 return savedRuleChainMetaData;
... ... @@ -295,7 +295,7 @@ public class RuleChainController extends BaseController {
295 295 ActionType.DELETED, null, strRuleChainId);
296 296
297 297 if (RuleChainType.EDGE.equals(ruleChain.getType())) {
298   - sendDeleteNotificationMsgToEdgeService(ruleChain.getTenantId(), ruleChain.getId(), EntityType.RULE_CHAIN, relatedEdgeIds);
  298 + sendDeleteNotificationMsg(ruleChain.getTenantId(), ruleChain.getId(), relatedEdgeIds);
299 299 }
300 300
301 301 } catch (Exception e) {
... ... @@ -427,7 +427,7 @@ public class RuleChainController extends BaseController {
427 427 null,
428 428 ActionType.ASSIGNED_TO_EDGE, null, strRuleChainId, strEdgeId, edge.getName());
429 429
430   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), EntityType.RULE_CHAIN, EdgeEventActionType.ASSIGNED_TO_EDGE);
  430 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedRuleChain.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
431 431
432 432 return savedRuleChain;
433 433 } catch (Exception e) {
... ... @@ -459,7 +459,7 @@ public class RuleChainController extends BaseController {
459 459 null,
460 460 ActionType.UNASSIGNED_FROM_EDGE, null, strRuleChainId, strEdgeId, edge.getName());
461 461
462   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), EntityType.RULE_CHAIN, EdgeEventActionType.UNASSIGNED_FROM_EDGE);
  462 + sendEntityAssignToEdgeNotificationMsg(getTenantId(), edgeId, savedRuleChain.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
463 463
464 464 return savedRuleChain;
465 465 } catch (Exception e) {
... ...
... ... @@ -167,7 +167,7 @@ public class UserController extends BaseController {
167 167 savedUser.getCustomerId(),
168 168 user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
169 169
170   - sendNotificationMsgToEdgeService(getTenantId(), savedUser.getId(), EntityType.USER,
  170 + sendEntityNotificationMsg(getTenantId(), savedUser.getId(),
171 171 user.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
172 172
173 173 return savedUser;
... ... @@ -248,7 +248,7 @@ public class UserController extends BaseController {
248 248 user.getCustomerId(),
249 249 ActionType.DELETED, null, strUserId);
250 250
251   - sendDeleteNotificationMsgToEdgeService(getTenantId(), userId, EntityType.USER, relatedEdgeIds);
  251 + sendDeleteNotificationMsg(getTenantId(), userId, relatedEdgeIds);
252 252
253 253 } catch (Exception e) {
254 254 logEntityAction(emptyId(EntityType.USER),
... ...
... ... @@ -26,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
26 26 import org.springframework.web.bind.annotation.ResponseBody;
27 27 import org.springframework.web.bind.annotation.ResponseStatus;
28 28 import org.springframework.web.bind.annotation.RestController;
29   -import org.thingsboard.server.common.data.EntityType;
30   -import org.thingsboard.server.common.data.audit.ActionType;
31 29 import org.thingsboard.server.common.data.edge.EdgeEventActionType;
32 30 import org.thingsboard.server.common.data.exception.ThingsboardException;
33 31 import org.thingsboard.server.common.data.id.TenantId;
... ... @@ -74,7 +72,7 @@ public class WidgetTypeController extends BaseController {
74 72 checkEntity(widgetType.getId(), widgetType, Resource.WIDGET_TYPE);
75 73 WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType);
76 74
77   - sendNotificationMsgToEdgeService(getTenantId(), savedWidgetType.getId(), EntityType.WIDGET_TYPE,
  75 + sendEntityNotificationMsg(getTenantId(), savedWidgetType.getId(),
78 76 widgetType.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
79 77
80 78 return checkNotNull(savedWidgetType);
... ... @@ -93,7 +91,7 @@ public class WidgetTypeController extends BaseController {
93 91 checkWidgetTypeId(widgetTypeId, Operation.DELETE);
94 92 widgetTypeService.deleteWidgetType(getCurrentUser().getTenantId(), widgetTypeId);
95 93
96   - sendNotificationMsgToEdgeService(getTenantId(), widgetTypeId, EntityType.WIDGET_TYPE, EdgeEventActionType.DELETED);
  94 + sendEntityNotificationMsg(getTenantId(), widgetTypeId, EdgeEventActionType.DELETED);
97 95
98 96 } catch (Exception e) {
99 97 throw handleException(e);
... ...
... ... @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam;
25 25 import org.springframework.web.bind.annotation.ResponseBody;
26 26 import org.springframework.web.bind.annotation.ResponseStatus;
27 27 import org.springframework.web.bind.annotation.RestController;
28   -import org.thingsboard.server.common.data.EntityType;
29 28 import org.thingsboard.server.common.data.edge.EdgeEventActionType;
30 29 import org.thingsboard.server.common.data.exception.ThingsboardException;
31 30 import org.thingsboard.server.common.data.id.TenantId;
... ... @@ -72,7 +71,7 @@ public class WidgetsBundleController extends BaseController {
72 71 checkEntity(widgetsBundle.getId(), widgetsBundle, Resource.WIDGETS_BUNDLE);
73 72 WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle);
74 73
75   - sendNotificationMsgToEdgeService(getTenantId(), savedWidgetsBundle.getId(), EntityType.WIDGETS_BUNDLE,
  74 + sendEntityNotificationMsg(getTenantId(), savedWidgetsBundle.getId(),
76 75 widgetsBundle.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
77 76
78 77 return checkNotNull(savedWidgetsBundle);
... ... @@ -91,7 +90,7 @@ public class WidgetsBundleController extends BaseController {
91 90 checkWidgetsBundleId(widgetsBundleId, Operation.DELETE);
92 91 widgetsBundleService.deleteWidgetsBundle(getTenantId(), widgetsBundleId);
93 92
94   - sendNotificationMsgToEdgeService(getTenantId(), widgetsBundleId, EntityType.WIDGETS_BUNDLE, EdgeEventActionType.DELETED);
  93 + sendEntityNotificationMsg(getTenantId(), widgetsBundleId, EdgeEventActionType.DELETED);
95 94
96 95 } catch (Exception e) {
97 96 throw handleException(e);
... ...