Showing
14 changed files
with
94 additions
and
116 deletions
@@ -93,8 +93,7 @@ public class AlarmController extends BaseController { | @@ -93,8 +93,7 @@ public class AlarmController extends BaseController { | ||
93 | getCurrentUser().getCustomerId(), | 93 | getCurrentUser().getCustomerId(), |
94 | alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); | 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 | return savedAlarm; | 98 | return savedAlarm; |
100 | } catch (Exception e) { | 99 | } catch (Exception e) { |
@@ -113,7 +112,7 @@ public class AlarmController extends BaseController { | @@ -113,7 +112,7 @@ public class AlarmController extends BaseController { | ||
113 | AlarmId alarmId = new AlarmId(toUUID(strAlarmId)); | 112 | AlarmId alarmId = new AlarmId(toUUID(strAlarmId)); |
114 | checkAlarmId(alarmId, Operation.WRITE); | 113 | checkAlarmId(alarmId, Operation.WRITE); |
115 | 114 | ||
116 | - sendNotificationMsgToEdgeService(getTenantId(), alarmId, EntityType.ALARM, EdgeEventActionType.DELETED); | 115 | + sendEntityNotificationMsg(getTenantId(), alarmId, EdgeEventActionType.DELETED); |
117 | 116 | ||
118 | return alarmService.deleteAlarm(getTenantId(), alarmId); | 117 | return alarmService.deleteAlarm(getTenantId(), alarmId); |
119 | } catch (Exception e) { | 118 | } catch (Exception e) { |
@@ -135,7 +134,7 @@ public class AlarmController extends BaseController { | @@ -135,7 +134,7 @@ public class AlarmController extends BaseController { | ||
135 | alarm.setStatus(alarm.getStatus().isCleared() ? AlarmStatus.CLEARED_ACK : AlarmStatus.ACTIVE_ACK); | 134 | alarm.setStatus(alarm.getStatus().isCleared() ? AlarmStatus.CLEARED_ACK : AlarmStatus.ACTIVE_ACK); |
136 | logEntityAction(alarmId, alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_ACK, null); | 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 | } catch (Exception e) { | 138 | } catch (Exception e) { |
140 | throw handleException(e); | 139 | throw handleException(e); |
141 | } | 140 | } |
@@ -155,7 +154,7 @@ public class AlarmController extends BaseController { | @@ -155,7 +154,7 @@ public class AlarmController extends BaseController { | ||
155 | alarm.setStatus(alarm.getStatus().isAck() ? AlarmStatus.CLEARED_ACK : AlarmStatus.CLEARED_UNACK); | 154 | alarm.setStatus(alarm.getStatus().isAck() ? AlarmStatus.CLEARED_ACK : AlarmStatus.CLEARED_UNACK); |
156 | logEntityAction(alarmId, alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_CLEAR, null); | 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 | } catch (Exception e) { | 158 | } catch (Exception e) { |
160 | throw handleException(e); | 159 | throw handleException(e); |
161 | } | 160 | } |
@@ -92,7 +92,7 @@ public class AssetController extends BaseController { | @@ -92,7 +92,7 @@ public class AssetController extends BaseController { | ||
92 | asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); | 92 | asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
93 | 93 | ||
94 | if (asset.getId() != null) { | 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 | return savedAsset; | 98 | return savedAsset; |
@@ -120,7 +120,7 @@ public class AssetController extends BaseController { | @@ -120,7 +120,7 @@ public class AssetController extends BaseController { | ||
120 | asset.getCustomerId(), | 120 | asset.getCustomerId(), |
121 | ActionType.DELETED, null, strAssetId); | 121 | ActionType.DELETED, null, strAssetId); |
122 | 122 | ||
123 | - sendDeleteNotificationMsgToEdgeService(getTenantId(), assetId, EntityType.ASSET, relatedEdgeIds); | 123 | + sendDeleteNotificationMsg(getTenantId(), assetId, relatedEdgeIds); |
124 | } catch (Exception e) { | 124 | } catch (Exception e) { |
125 | logEntityAction(emptyId(EntityType.ASSET), | 125 | logEntityAction(emptyId(EntityType.ASSET), |
126 | null, | 126 | null, |
@@ -150,7 +150,7 @@ public class AssetController extends BaseController { | @@ -150,7 +150,7 @@ public class AssetController extends BaseController { | ||
150 | savedAsset.getCustomerId(), | 150 | savedAsset.getCustomerId(), |
151 | ActionType.ASSIGNED_TO_CUSTOMER, null, strAssetId, strCustomerId, customer.getName()); | 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 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); | 154 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); |
155 | 155 | ||
156 | return savedAsset; | 156 | return savedAsset; |
@@ -184,7 +184,7 @@ public class AssetController extends BaseController { | @@ -184,7 +184,7 @@ public class AssetController extends BaseController { | ||
184 | asset.getCustomerId(), | 184 | asset.getCustomerId(), |
185 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strAssetId, customer.getId().toString(), customer.getName()); | 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 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); | 188 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); |
189 | 189 | ||
190 | return savedAsset; | 190 | return savedAsset; |
@@ -369,7 +369,7 @@ public class AssetController extends BaseController { | @@ -369,7 +369,7 @@ public class AssetController extends BaseController { | ||
369 | savedAsset.getCustomerId(), | 369 | savedAsset.getCustomerId(), |
370 | ActionType.ASSIGNED_TO_EDGE, null, strAssetId, strEdgeId, edge.getName()); | 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 | return savedAsset; | 374 | return savedAsset; |
375 | } catch (Exception e) { | 375 | } catch (Exception e) { |
@@ -402,7 +402,7 @@ public class AssetController extends BaseController { | @@ -402,7 +402,7 @@ public class AssetController extends BaseController { | ||
402 | asset.getCustomerId(), | 402 | asset.getCustomerId(), |
403 | ActionType.UNASSIGNED_FROM_EDGE, null, strAssetId, strEdgeId, edge.getName()); | 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 | return savedAsset; | 407 | return savedAsset; |
408 | } catch (Exception e) { | 408 | } catch (Exception e) { |
@@ -33,29 +33,26 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -33,29 +33,26 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
33 | import org.springframework.web.bind.annotation.ResponseStatus; | 33 | import org.springframework.web.bind.annotation.ResponseStatus; |
34 | import org.springframework.web.bind.annotation.RestController; | 34 | import org.springframework.web.bind.annotation.RestController; |
35 | import org.thingsboard.rule.engine.api.MailService; | 35 | import org.thingsboard.rule.engine.api.MailService; |
36 | -import org.thingsboard.server.common.data.EntityType; | ||
37 | import org.thingsboard.server.common.data.User; | 36 | import org.thingsboard.server.common.data.User; |
38 | import org.thingsboard.server.common.data.audit.ActionType; | 37 | import org.thingsboard.server.common.data.audit.ActionType; |
39 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; | 38 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
40 | -import org.thingsboard.server.common.data.edge.EdgeEventType; | ||
41 | import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; | 39 | import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; |
42 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 40 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
43 | import org.thingsboard.server.common.data.id.TenantId; | 41 | import org.thingsboard.server.common.data.id.TenantId; |
44 | import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; | 42 | import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; |
45 | import org.thingsboard.server.common.data.security.UserCredentials; | 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 | import org.thingsboard.server.dao.audit.AuditLogService; | 46 | import org.thingsboard.server.dao.audit.AuditLogService; |
47 | import org.thingsboard.server.dao.oauth2.OAuth2Service; | 47 | import org.thingsboard.server.dao.oauth2.OAuth2Service; |
48 | import org.thingsboard.server.queue.util.TbCoreComponent; | 48 | import org.thingsboard.server.queue.util.TbCoreComponent; |
49 | import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository; | 49 | import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository; |
50 | import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails; | 50 | import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails; |
51 | -import org.thingsboard.server.common.data.security.model.SecuritySettings; | ||
52 | import org.thingsboard.server.service.security.model.SecurityUser; | 51 | import org.thingsboard.server.service.security.model.SecurityUser; |
53 | -import org.thingsboard.server.common.data.security.model.UserPasswordPolicy; | ||
54 | import org.thingsboard.server.service.security.model.UserPrincipal; | 52 | import org.thingsboard.server.service.security.model.UserPrincipal; |
55 | import org.thingsboard.server.service.security.model.token.JwtToken; | 53 | import org.thingsboard.server.service.security.model.token.JwtToken; |
56 | import org.thingsboard.server.service.security.model.token.JwtTokenFactory; | 54 | import org.thingsboard.server.service.security.model.token.JwtTokenFactory; |
57 | import org.thingsboard.server.service.security.system.SystemSecurityService; | 55 | import org.thingsboard.server.service.security.system.SystemSecurityService; |
58 | -import org.thingsboard.server.utils.MiscUtils; | ||
59 | import ua_parser.Client; | 56 | import ua_parser.Client; |
60 | 57 | ||
61 | import javax.servlet.http.HttpServletRequest; | 58 | import javax.servlet.http.HttpServletRequest; |
@@ -128,7 +125,7 @@ public class AuthController extends BaseController { | @@ -128,7 +125,7 @@ public class AuthController extends BaseController { | ||
128 | userCredentials.setPassword(passwordEncoder.encode(newPassword)); | 125 | userCredentials.setPassword(passwordEncoder.encode(newPassword)); |
129 | userService.replaceUserCredentials(securityUser.getTenantId(), userCredentials); | 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 | } catch (Exception e) { | 130 | } catch (Exception e) { |
134 | throw handleException(e); | 131 | throw handleException(e); |
@@ -238,7 +235,7 @@ public class AuthController extends BaseController { | @@ -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 | JwtToken accessToken = tokenFactory.createAccessJwtToken(securityUser); | 240 | JwtToken accessToken = tokenFactory.createAccessJwtToken(securityUser); |
244 | JwtToken refreshToken = refreshTokenRepository.requestRefreshToken(securityUser); | 241 | JwtToken refreshToken = refreshTokenRepository.requestRefreshToken(securityUser); |
@@ -761,35 +761,7 @@ public abstract class BaseController { | @@ -761,35 +761,7 @@ public abstract class BaseController { | ||
761 | return null; | 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 | try { | 765 | try { |
794 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && | 766 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
795 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { | 767 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
@@ -800,45 +772,46 @@ public abstract class BaseController { | @@ -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 | try { | 784 | try { |
809 | - result = edgeService.findRelatedEdgeIdsByEntityId(tenantId, entityId).get(); | 785 | + sendNotificationMsgToEdgeService(tenantId, null, entityId, json.writeValueAsString(customerId), null, action); |
810 | } catch (Exception e) { | 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 | if (!edgesEnabled) { | 800 | if (!edgesEnabled) { |
833 | return; | 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 | TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder(); | 815 | TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder(); |
843 | builder.setTenantIdMSB(tenantId.getId().getMostSignificantBits()); | 816 | builder.setTenantIdMSB(tenantId.getId().getMostSignificantBits()); |
844 | builder.setTenantIdLSB(tenantId.getId().getLeastSignificantBits()); | 817 | builder.setTenantIdLSB(tenantId.getId().getLeastSignificantBits()); |
@@ -862,4 +835,16 @@ public abstract class BaseController { | @@ -862,4 +835,16 @@ public abstract class BaseController { | ||
862 | TransportProtos.ToCoreMsg.newBuilder().setEdgeNotificationMsg(msg).build(), null); | 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,7 +113,7 @@ public class CustomerController extends BaseController { | ||
113 | customer.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); | 113 | customer.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
114 | 114 | ||
115 | if (customer.getId() != null) { | 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 | return savedCustomer; | 119 | return savedCustomer; |
@@ -143,7 +143,7 @@ public class CustomerController extends BaseController { | @@ -143,7 +143,7 @@ public class CustomerController extends BaseController { | ||
143 | customer.getId(), | 143 | customer.getId(), |
144 | ActionType.DELETED, null, strCustomerId); | 144 | ActionType.DELETED, null, strCustomerId); |
145 | 145 | ||
146 | - sendDeleteNotificationMsgToEdgeService(getTenantId(), customerId, EntityType.CUSTOMER, relatedEdgeIds); | 146 | + sendDeleteNotificationMsg(getTenantId(), customerId, relatedEdgeIds); |
147 | } catch (Exception e) { | 147 | } catch (Exception e) { |
148 | 148 | ||
149 | logEntityAction(emptyId(EntityType.CUSTOMER), | 149 | logEntityAction(emptyId(EntityType.CUSTOMER), |
@@ -119,7 +119,7 @@ public class DashboardController extends BaseController { | @@ -119,7 +119,7 @@ public class DashboardController extends BaseController { | ||
119 | dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); | 119 | dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
120 | 120 | ||
121 | if (dashboard.getId() != null) { | 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 | return savedDashboard; | 125 | return savedDashboard; |
@@ -148,7 +148,7 @@ public class DashboardController extends BaseController { | @@ -148,7 +148,7 @@ public class DashboardController extends BaseController { | ||
148 | null, | 148 | null, |
149 | ActionType.DELETED, null, strDashboardId); | 149 | ActionType.DELETED, null, strDashboardId); |
150 | 150 | ||
151 | - sendDeleteNotificationMsgToEdgeService(getTenantId(), dashboardId, EntityType.DASHBOARD, relatedEdgeIds); | 151 | + sendDeleteNotificationMsg(getTenantId(), dashboardId, relatedEdgeIds); |
152 | } catch (Exception e) { | 152 | } catch (Exception e) { |
153 | 153 | ||
154 | logEntityAction(emptyId(EntityType.DASHBOARD), | 154 | logEntityAction(emptyId(EntityType.DASHBOARD), |
@@ -180,7 +180,7 @@ public class DashboardController extends BaseController { | @@ -180,7 +180,7 @@ public class DashboardController extends BaseController { | ||
180 | customerId, | 180 | customerId, |
181 | ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, strCustomerId, customer.getName()); | 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 | return savedDashboard; | 185 | return savedDashboard; |
186 | } catch (Exception e) { | 186 | } catch (Exception e) { |
@@ -212,7 +212,7 @@ public class DashboardController extends BaseController { | @@ -212,7 +212,7 @@ public class DashboardController extends BaseController { | ||
212 | customerId, | 212 | customerId, |
213 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customer.getId().toString(), customer.getName()); | 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 | return savedDashboard; | 217 | return savedDashboard; |
218 | } catch (Exception e) { | 218 | } catch (Exception e) { |
@@ -269,7 +269,7 @@ public class DashboardController extends BaseController { | @@ -269,7 +269,7 @@ public class DashboardController extends BaseController { | ||
269 | logEntityAction(dashboardId, savedDashboard, | 269 | logEntityAction(dashboardId, savedDashboard, |
270 | customerId, | 270 | customerId, |
271 | ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle()); | 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 | for (CustomerId customerId : removedCustomerIds) { | 274 | for (CustomerId customerId : removedCustomerIds) { |
275 | ShortCustomerInfo customerInfo = dashboard.getAssignedCustomerInfo(customerId); | 275 | ShortCustomerInfo customerInfo = dashboard.getAssignedCustomerInfo(customerId); |
@@ -277,7 +277,7 @@ public class DashboardController extends BaseController { | @@ -277,7 +277,7 @@ public class DashboardController extends BaseController { | ||
277 | logEntityAction(dashboardId, dashboard, | 277 | logEntityAction(dashboardId, dashboard, |
278 | customerId, | 278 | customerId, |
279 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle()); | 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 | return savedDashboard; | 282 | return savedDashboard; |
283 | } | 283 | } |
@@ -321,7 +321,7 @@ public class DashboardController extends BaseController { | @@ -321,7 +321,7 @@ public class DashboardController extends BaseController { | ||
321 | logEntityAction(dashboardId, savedDashboard, | 321 | logEntityAction(dashboardId, savedDashboard, |
322 | customerId, | 322 | customerId, |
323 | ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle()); | 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 | return savedDashboard; | 326 | return savedDashboard; |
327 | } | 327 | } |
@@ -365,7 +365,7 @@ public class DashboardController extends BaseController { | @@ -365,7 +365,7 @@ public class DashboardController extends BaseController { | ||
365 | logEntityAction(dashboardId, dashboard, | 365 | logEntityAction(dashboardId, dashboard, |
366 | customerId, | 366 | customerId, |
367 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle()); | 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 | return savedDashboard; | 370 | return savedDashboard; |
371 | } | 371 | } |
@@ -510,7 +510,7 @@ public class DashboardController extends BaseController { | @@ -510,7 +510,7 @@ public class DashboardController extends BaseController { | ||
510 | null, | 510 | null, |
511 | ActionType.ASSIGNED_TO_EDGE, null, strDashboardId, strEdgeId, edge.getName()); | 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 | return savedDashboard; | 515 | return savedDashboard; |
516 | } catch (Exception e) { | 516 | } catch (Exception e) { |
@@ -542,7 +542,7 @@ public class DashboardController extends BaseController { | @@ -542,7 +542,7 @@ public class DashboardController extends BaseController { | ||
542 | null, | 542 | null, |
543 | ActionType.UNASSIGNED_FROM_EDGE, null, strDashboardId, strEdgeId, edge.getName()); | 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 | return savedDashboard; | 547 | return savedDashboard; |
548 | } catch (Exception e) { | 548 | } catch (Exception e) { |
@@ -114,7 +114,7 @@ public class DeviceController extends BaseController { | @@ -114,7 +114,7 @@ public class DeviceController extends BaseController { | ||
114 | savedDevice.getId(), savedDevice.getName(), savedDevice.getType()), null); | 114 | savedDevice.getId(), savedDevice.getName(), savedDevice.getType()), null); |
115 | 115 | ||
116 | if (device.getId() != null) { | 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 | logEntityAction(savedDevice.getId(), savedDevice, | 120 | logEntityAction(savedDevice.getId(), savedDevice, |
@@ -151,7 +151,7 @@ public class DeviceController extends BaseController { | @@ -151,7 +151,7 @@ public class DeviceController extends BaseController { | ||
151 | device.getCustomerId(), | 151 | device.getCustomerId(), |
152 | ActionType.DELETED, null, strDeviceId); | 152 | ActionType.DELETED, null, strDeviceId); |
153 | 153 | ||
154 | - sendDeleteNotificationMsgToEdgeService(getTenantId(), deviceId, EntityType.DEVICE, relatedEdgeIds); | 154 | + sendDeleteNotificationMsg(getTenantId(), deviceId, relatedEdgeIds); |
155 | 155 | ||
156 | deviceStateService.onDeviceDeleted(device); | 156 | deviceStateService.onDeviceDeleted(device); |
157 | } catch (Exception e) { | 157 | } catch (Exception e) { |
@@ -183,7 +183,7 @@ public class DeviceController extends BaseController { | @@ -183,7 +183,7 @@ public class DeviceController extends BaseController { | ||
183 | savedDevice.getCustomerId(), | 183 | savedDevice.getCustomerId(), |
184 | ActionType.ASSIGNED_TO_CUSTOMER, null, strDeviceId, strCustomerId, customer.getName()); | 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 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); | 187 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); |
188 | 188 | ||
189 | return savedDevice; | 189 | return savedDevice; |
@@ -214,7 +214,7 @@ public class DeviceController extends BaseController { | @@ -214,7 +214,7 @@ public class DeviceController extends BaseController { | ||
214 | device.getCustomerId(), | 214 | device.getCustomerId(), |
215 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDeviceId, customer.getId().toString(), customer.getName()); | 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 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); | 218 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); |
219 | 219 | ||
220 | return savedDevice; | 220 | return savedDevice; |
@@ -282,7 +282,7 @@ public class DeviceController extends BaseController { | @@ -282,7 +282,7 @@ public class DeviceController extends BaseController { | ||
282 | 282 | ||
283 | tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(getCurrentUser().getTenantId(), deviceCredentials.getDeviceId()), null); | 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 | logEntityAction(device.getId(), device, | 287 | logEntityAction(device.getId(), device, |
288 | device.getCustomerId(), | 288 | device.getCustomerId(), |
@@ -586,7 +586,7 @@ public class DeviceController extends BaseController { | @@ -586,7 +586,7 @@ public class DeviceController extends BaseController { | ||
586 | savedDevice.getCustomerId(), | 586 | savedDevice.getCustomerId(), |
587 | ActionType.ASSIGNED_TO_EDGE, null, strDeviceId, strEdgeId, edge.getName()); | 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 | return savedDevice; | 591 | return savedDevice; |
592 | } catch (Exception e) { | 592 | } catch (Exception e) { |
@@ -620,7 +620,7 @@ public class DeviceController extends BaseController { | @@ -620,7 +620,7 @@ public class DeviceController extends BaseController { | ||
620 | device.getCustomerId(), | 620 | device.getCustomerId(), |
621 | ActionType.UNASSIGNED_FROM_EDGE, null, strDeviceId, strEdgeId, edge.getName()); | 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 | return savedDevice; | 625 | return savedDevice; |
626 | } catch (Exception e) { | 626 | } catch (Exception e) { |
@@ -197,7 +197,7 @@ public class EdgeController extends BaseController { | @@ -197,7 +197,7 @@ public class EdgeController extends BaseController { | ||
197 | savedEdge.getCustomerId(), | 197 | savedEdge.getCustomerId(), |
198 | ActionType.ASSIGNED_TO_CUSTOMER, null, strEdgeId, strCustomerId, customer.getName()); | 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 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); | 201 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); |
202 | 202 | ||
203 | return savedEdge; | 203 | return savedEdge; |
@@ -231,7 +231,7 @@ public class EdgeController extends BaseController { | @@ -231,7 +231,7 @@ public class EdgeController extends BaseController { | ||
231 | edge.getCustomerId(), | 231 | edge.getCustomerId(), |
232 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strEdgeId, customer.getId().toString(), customer.getName()); | 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 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); | 235 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); |
236 | 236 | ||
237 | return savedEdge; | 237 | return savedEdge; |
@@ -70,7 +70,7 @@ public class EntityRelationController extends BaseController { | @@ -70,7 +70,7 @@ public class EntityRelationController extends BaseController { | ||
70 | logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(), | 70 | logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(), |
71 | ActionType.RELATION_ADD_OR_UPDATE, null, relation); | 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 | } catch (Exception e) { | 74 | } catch (Exception e) { |
75 | logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(), | 75 | logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(), |
76 | ActionType.RELATION_ADD_OR_UPDATE, e, relation); | 76 | ActionType.RELATION_ADD_OR_UPDATE, e, relation); |
@@ -109,7 +109,7 @@ public class EntityRelationController extends BaseController { | @@ -109,7 +109,7 @@ public class EntityRelationController extends BaseController { | ||
109 | logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(), | 109 | logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(), |
110 | ActionType.RELATION_DELETED, null, relation); | 110 | ActionType.RELATION_DELETED, null, relation); |
111 | 111 | ||
112 | - sendNotificationMsgToEdgeService(getTenantId(), relation, EdgeEventActionType.RELATION_DELETED); | 112 | + sendRelationNotificationMsg(getTenantId(), relation, EdgeEventActionType.RELATION_DELETED); |
113 | } catch (Exception e) { | 113 | } catch (Exception e) { |
114 | logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(), | 114 | logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(), |
115 | ActionType.RELATION_DELETED, e, relation); | 115 | ActionType.RELATION_DELETED, e, relation); |
@@ -119,7 +119,7 @@ public class EntityViewController extends BaseController { | @@ -119,7 +119,7 @@ public class EntityViewController extends BaseController { | ||
119 | entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); | 119 | entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
120 | 120 | ||
121 | if (entityView.getId() != null) { | 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 | return savedEntityView; | 125 | return savedEntityView; |
@@ -195,7 +195,7 @@ public class EntityViewController extends BaseController { | @@ -195,7 +195,7 @@ public class EntityViewController extends BaseController { | ||
195 | logEntityAction(entityViewId, entityView, entityView.getCustomerId(), | 195 | logEntityAction(entityViewId, entityView, entityView.getCustomerId(), |
196 | ActionType.DELETED, null, strEntityViewId); | 196 | ActionType.DELETED, null, strEntityViewId); |
197 | 197 | ||
198 | - sendDeleteNotificationMsgToEdgeService(getTenantId(), entityViewId, EntityType.ENTITY_VIEW, relatedEdgeIds); | 198 | + sendDeleteNotificationMsg(getTenantId(), entityViewId, relatedEdgeIds); |
199 | } catch (Exception e) { | 199 | } catch (Exception e) { |
200 | logEntityAction(emptyId(EntityType.ENTITY_VIEW), | 200 | logEntityAction(emptyId(EntityType.ENTITY_VIEW), |
201 | null, | 201 | null, |
@@ -237,7 +237,7 @@ public class EntityViewController extends BaseController { | @@ -237,7 +237,7 @@ public class EntityViewController extends BaseController { | ||
237 | savedEntityView.getCustomerId(), | 237 | savedEntityView.getCustomerId(), |
238 | ActionType.ASSIGNED_TO_CUSTOMER, null, strEntityViewId, strCustomerId, customer.getName()); | 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 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); | 241 | customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER); |
242 | 242 | ||
243 | return savedEntityView; | 243 | return savedEntityView; |
@@ -266,7 +266,7 @@ public class EntityViewController extends BaseController { | @@ -266,7 +266,7 @@ public class EntityViewController extends BaseController { | ||
266 | entityView.getCustomerId(), | 266 | entityView.getCustomerId(), |
267 | ActionType.UNASSIGNED_FROM_CUSTOMER, null, strEntityViewId, customer.getId().toString(), customer.getName()); | 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 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); | 270 | customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER); |
271 | 271 | ||
272 | return savedEntityView; | 272 | return savedEntityView; |
@@ -408,7 +408,7 @@ public class EntityViewController extends BaseController { | @@ -408,7 +408,7 @@ public class EntityViewController extends BaseController { | ||
408 | savedEntityView.getCustomerId(), | 408 | savedEntityView.getCustomerId(), |
409 | ActionType.ASSIGNED_TO_EDGE, null, strEntityViewId, strEdgeId, edge.getName()); | 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 | return savedEntityView; | 413 | return savedEntityView; |
414 | } catch (Exception e) { | 414 | } catch (Exception e) { |
@@ -438,7 +438,7 @@ public class EntityViewController extends BaseController { | @@ -438,7 +438,7 @@ public class EntityViewController extends BaseController { | ||
438 | entityView.getCustomerId(), | 438 | entityView.getCustomerId(), |
439 | ActionType.UNASSIGNED_FROM_EDGE, null, strEntityViewId, strEdgeId, edge.getName()); | 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 | return savedEntityView; | 443 | return savedEntityView; |
444 | } catch (Exception e) { | 444 | } catch (Exception e) { |
@@ -146,7 +146,7 @@ public class RuleChainController extends BaseController { | @@ -146,7 +146,7 @@ public class RuleChainController extends BaseController { | ||
146 | 146 | ||
147 | if (RuleChainType.EDGE.equals(savedRuleChain.getType())) { | 147 | if (RuleChainType.EDGE.equals(savedRuleChain.getType())) { |
148 | if (!created) { | 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,8 +225,8 @@ public class RuleChainController extends BaseController { | ||
225 | ActionType.UPDATED, null, ruleChainMetaData); | 225 | ActionType.UPDATED, null, ruleChainMetaData); |
226 | 226 | ||
227 | if (RuleChainType.EDGE.equals(ruleChain.getType())) { | 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 | return savedRuleChainMetaData; | 232 | return savedRuleChainMetaData; |
@@ -295,7 +295,7 @@ public class RuleChainController extends BaseController { | @@ -295,7 +295,7 @@ public class RuleChainController extends BaseController { | ||
295 | ActionType.DELETED, null, strRuleChainId); | 295 | ActionType.DELETED, null, strRuleChainId); |
296 | 296 | ||
297 | if (RuleChainType.EDGE.equals(ruleChain.getType())) { | 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 | } catch (Exception e) { | 301 | } catch (Exception e) { |
@@ -427,7 +427,7 @@ public class RuleChainController extends BaseController { | @@ -427,7 +427,7 @@ public class RuleChainController extends BaseController { | ||
427 | null, | 427 | null, |
428 | ActionType.ASSIGNED_TO_EDGE, null, strRuleChainId, strEdgeId, edge.getName()); | 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 | return savedRuleChain; | 432 | return savedRuleChain; |
433 | } catch (Exception e) { | 433 | } catch (Exception e) { |
@@ -459,7 +459,7 @@ public class RuleChainController extends BaseController { | @@ -459,7 +459,7 @@ public class RuleChainController extends BaseController { | ||
459 | null, | 459 | null, |
460 | ActionType.UNASSIGNED_FROM_EDGE, null, strRuleChainId, strEdgeId, edge.getName()); | 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 | return savedRuleChain; | 464 | return savedRuleChain; |
465 | } catch (Exception e) { | 465 | } catch (Exception e) { |
@@ -167,7 +167,7 @@ public class UserController extends BaseController { | @@ -167,7 +167,7 @@ public class UserController extends BaseController { | ||
167 | savedUser.getCustomerId(), | 167 | savedUser.getCustomerId(), |
168 | user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); | 168 | user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
169 | 169 | ||
170 | - sendNotificationMsgToEdgeService(getTenantId(), savedUser.getId(), EntityType.USER, | 170 | + sendEntityNotificationMsg(getTenantId(), savedUser.getId(), |
171 | user.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); | 171 | user.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); |
172 | 172 | ||
173 | return savedUser; | 173 | return savedUser; |
@@ -248,7 +248,7 @@ public class UserController extends BaseController { | @@ -248,7 +248,7 @@ public class UserController extends BaseController { | ||
248 | user.getCustomerId(), | 248 | user.getCustomerId(), |
249 | ActionType.DELETED, null, strUserId); | 249 | ActionType.DELETED, null, strUserId); |
250 | 250 | ||
251 | - sendDeleteNotificationMsgToEdgeService(getTenantId(), userId, EntityType.USER, relatedEdgeIds); | 251 | + sendDeleteNotificationMsg(getTenantId(), userId, relatedEdgeIds); |
252 | 252 | ||
253 | } catch (Exception e) { | 253 | } catch (Exception e) { |
254 | logEntityAction(emptyId(EntityType.USER), | 254 | logEntityAction(emptyId(EntityType.USER), |
@@ -26,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -26,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam; | ||
26 | import org.springframework.web.bind.annotation.ResponseBody; | 26 | import org.springframework.web.bind.annotation.ResponseBody; |
27 | import org.springframework.web.bind.annotation.ResponseStatus; | 27 | import org.springframework.web.bind.annotation.ResponseStatus; |
28 | import org.springframework.web.bind.annotation.RestController; | 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 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; | 29 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
32 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 30 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
33 | import org.thingsboard.server.common.data.id.TenantId; | 31 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -74,7 +72,7 @@ public class WidgetTypeController extends BaseController { | @@ -74,7 +72,7 @@ public class WidgetTypeController extends BaseController { | ||
74 | checkEntity(widgetType.getId(), widgetType, Resource.WIDGET_TYPE); | 72 | checkEntity(widgetType.getId(), widgetType, Resource.WIDGET_TYPE); |
75 | WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType); | 73 | WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType); |
76 | 74 | ||
77 | - sendNotificationMsgToEdgeService(getTenantId(), savedWidgetType.getId(), EntityType.WIDGET_TYPE, | 75 | + sendEntityNotificationMsg(getTenantId(), savedWidgetType.getId(), |
78 | widgetType.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); | 76 | widgetType.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); |
79 | 77 | ||
80 | return checkNotNull(savedWidgetType); | 78 | return checkNotNull(savedWidgetType); |
@@ -93,7 +91,7 @@ public class WidgetTypeController extends BaseController { | @@ -93,7 +91,7 @@ public class WidgetTypeController extends BaseController { | ||
93 | checkWidgetTypeId(widgetTypeId, Operation.DELETE); | 91 | checkWidgetTypeId(widgetTypeId, Operation.DELETE); |
94 | widgetTypeService.deleteWidgetType(getCurrentUser().getTenantId(), widgetTypeId); | 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 | } catch (Exception e) { | 96 | } catch (Exception e) { |
99 | throw handleException(e); | 97 | throw handleException(e); |
@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam; | ||
25 | import org.springframework.web.bind.annotation.ResponseBody; | 25 | import org.springframework.web.bind.annotation.ResponseBody; |
26 | import org.springframework.web.bind.annotation.ResponseStatus; | 26 | import org.springframework.web.bind.annotation.ResponseStatus; |
27 | import org.springframework.web.bind.annotation.RestController; | 27 | import org.springframework.web.bind.annotation.RestController; |
28 | -import org.thingsboard.server.common.data.EntityType; | ||
29 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; | 28 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
30 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 29 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
31 | import org.thingsboard.server.common.data.id.TenantId; | 30 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -72,7 +71,7 @@ public class WidgetsBundleController extends BaseController { | @@ -72,7 +71,7 @@ public class WidgetsBundleController extends BaseController { | ||
72 | checkEntity(widgetsBundle.getId(), widgetsBundle, Resource.WIDGETS_BUNDLE); | 71 | checkEntity(widgetsBundle.getId(), widgetsBundle, Resource.WIDGETS_BUNDLE); |
73 | WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle); | 72 | WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle); |
74 | 73 | ||
75 | - sendNotificationMsgToEdgeService(getTenantId(), savedWidgetsBundle.getId(), EntityType.WIDGETS_BUNDLE, | 74 | + sendEntityNotificationMsg(getTenantId(), savedWidgetsBundle.getId(), |
76 | widgetsBundle.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); | 75 | widgetsBundle.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); |
77 | 76 | ||
78 | return checkNotNull(savedWidgetsBundle); | 77 | return checkNotNull(savedWidgetsBundle); |
@@ -91,7 +90,7 @@ public class WidgetsBundleController extends BaseController { | @@ -91,7 +90,7 @@ public class WidgetsBundleController extends BaseController { | ||
91 | checkWidgetsBundleId(widgetsBundleId, Operation.DELETE); | 90 | checkWidgetsBundleId(widgetsBundleId, Operation.DELETE); |
92 | widgetsBundleService.deleteWidgetsBundle(getTenantId(), widgetsBundleId); | 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 | } catch (Exception e) { | 95 | } catch (Exception e) { |
97 | throw handleException(e); | 96 | throw handleException(e); |