Commit e58af8fb2266a16962151253c8eb43426b0dd90b

Authored by Volodymyr Babak
1 parent df11b383

Added findMissingToRelatedRuleChains method

@@ -389,10 +389,12 @@ public class EdgeController extends BaseController { @@ -389,10 +389,12 @@ public class EdgeController extends BaseController {
389 checkNotNull(query.getEdgeTypes()); 389 checkNotNull(query.getEdgeTypes());
390 checkEntityId(query.getParameters().getEntityId(), Operation.READ); 390 checkEntityId(query.getParameters().getEntityId(), Operation.READ);
391 try { 391 try {
392 - List<Edge> edges = checkNotNull(edgeService.findEdgesByQuery(getCurrentUser().getTenantId(), query).get()); 392 + SecurityUser user = getCurrentUser();
  393 + TenantId tenantId = user.getTenantId();
  394 + List<Edge> edges = checkNotNull(edgeService.findEdgesByQuery(tenantId, query).get());
393 edges = edges.stream().filter(edge -> { 395 edges = edges.stream().filter(edge -> {
394 try { 396 try {
395 - accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, Operation.READ, edge.getId(), edge); 397 + accessControlService.checkPermission(user, Resource.EDGE, Operation.READ, edge.getId(), edge);
396 return true; 398 return true;
397 } catch (ThingsboardException e) { 399 } catch (ThingsboardException e) {
398 return false; 400 return false;
@@ -419,14 +421,18 @@ public class EdgeController extends BaseController { @@ -419,14 +421,18 @@ public class EdgeController extends BaseController {
419 } 421 }
420 422
421 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 423 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
422 - @RequestMapping(value = "/edge/sync", method = RequestMethod.POST)  
423 - public void syncEdge(@RequestBody EdgeId edgeId) throws ThingsboardException { 424 + @RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST)
  425 + public void syncEdge(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
  426 + checkParameter("edgeId", strEdgeId);
424 try { 427 try {
425 - edgeId = checkNotNull(edgeId);  
426 if (isEdgesEnabled()) { 428 if (isEdgesEnabled()) {
427 - EdgeGrpcSession session = edgeGrpcService.getEdgeGrpcSessionById(edgeId); 429 + EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
  430 + edgeId = checkNotNull(edgeId);
  431 + SecurityUser user = getCurrentUser();
  432 + TenantId tenantId = user.getTenantId();
  433 + EdgeGrpcSession session = edgeGrpcService.getEdgeGrpcSessionById(tenantId, edgeId);
428 Edge edge = session.getEdge(); 434 Edge edge = session.getEdge();
429 - syncEdgeService.sync(edge); 435 + syncEdgeService.sync(tenantId, edge);
430 } else { 436 } else {
431 throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL); 437 throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
432 } 438 }
@@ -455,4 +461,19 @@ public class EdgeController extends BaseController { @@ -455,4 +461,19 @@ public class EdgeController extends BaseController {
455 throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); 461 throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
456 } 462 }
457 } 463 }
  464 +
  465 + @PreAuthorize("hasAuthority('TENANT_ADMIN')")
  466 + @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
  467 + @ResponseBody
  468 + public String findMissingToRelatedRuleChains(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
  469 + try {
  470 + EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
  471 + edgeId = checkNotNull(edgeId);
  472 + SecurityUser user = getCurrentUser();
  473 + TenantId tenantId = user.getTenantId();
  474 + return edgeService.findMissingToRelatedRuleChains(tenantId, edgeId);
  475 + } catch (Exception e) {
  476 + throw handleException(e);
  477 + }
  478 + }
458 } 479 }
@@ -114,11 +114,6 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { @@ -114,11 +114,6 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
114 } 114 }
115 115
116 @Override 116 @Override
117 - public TimePageData<EdgeEvent> findEdgeEvents(TenantId tenantId, EdgeId edgeId, TimePageLink pageLink) {  
118 - return edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, true);  
119 - }  
120 -  
121 - @Override  
122 public Edge setEdgeRootRuleChain(TenantId tenantId, Edge edge, RuleChainId ruleChainId) throws IOException { 117 public Edge setEdgeRootRuleChain(TenantId tenantId, Edge edge, RuleChainId ruleChainId) throws IOException {
123 edge.setRootRuleChainId(ruleChainId); 118 edge.setRootRuleChainId(ruleChainId);
124 Edge savedEdge = edgeService.saveEdge(edge); 119 Edge savedEdge = edgeService.saveEdge(edge);
@@ -28,6 +28,7 @@ import org.thingsboard.server.dao.customer.CustomerService; @@ -28,6 +28,7 @@ import org.thingsboard.server.dao.customer.CustomerService;
28 import org.thingsboard.server.dao.dashboard.DashboardService; 28 import org.thingsboard.server.dao.dashboard.DashboardService;
29 import org.thingsboard.server.dao.device.DeviceCredentialsService; 29 import org.thingsboard.server.dao.device.DeviceCredentialsService;
30 import org.thingsboard.server.dao.device.DeviceService; 30 import org.thingsboard.server.dao.device.DeviceService;
  31 +import org.thingsboard.server.dao.edge.EdgeEventService;
31 import org.thingsboard.server.dao.edge.EdgeService; 32 import org.thingsboard.server.dao.edge.EdgeService;
32 import org.thingsboard.server.dao.entityview.EntityViewService; 33 import org.thingsboard.server.dao.entityview.EntityViewService;
33 import org.thingsboard.server.dao.relation.RelationService; 34 import org.thingsboard.server.dao.relation.RelationService;
@@ -74,7 +75,7 @@ public class EdgeContextComponent { @@ -74,7 +75,7 @@ public class EdgeContextComponent {
74 75
75 @Lazy 76 @Lazy
76 @Autowired 77 @Autowired
77 - private EdgeNotificationService edgeNotificationService; 78 + private EdgeEventService edgeEventService;
78 79
79 @Lazy 80 @Lazy
80 @Autowired 81 @Autowired
@@ -15,14 +15,9 @@ @@ -15,14 +15,9 @@
15 */ 15 */
16 package org.thingsboard.server.service.edge; 16 package org.thingsboard.server.service.edge;
17 17
18 -import org.thingsboard.server.common.data.Event;  
19 import org.thingsboard.server.common.data.edge.Edge; 18 import org.thingsboard.server.common.data.edge.Edge;
20 -import org.thingsboard.server.common.data.edge.EdgeEvent;  
21 -import org.thingsboard.server.common.data.id.EdgeId;  
22 import org.thingsboard.server.common.data.id.RuleChainId; 19 import org.thingsboard.server.common.data.id.RuleChainId;
23 import org.thingsboard.server.common.data.id.TenantId; 20 import org.thingsboard.server.common.data.id.TenantId;
24 -import org.thingsboard.server.common.data.page.TimePageData;  
25 -import org.thingsboard.server.common.data.page.TimePageLink;  
26 import org.thingsboard.server.common.msg.queue.TbCallback; 21 import org.thingsboard.server.common.msg.queue.TbCallback;
27 import org.thingsboard.server.gen.transport.TransportProtos; 22 import org.thingsboard.server.gen.transport.TransportProtos;
28 23
@@ -30,8 +25,6 @@ import java.io.IOException; @@ -30,8 +25,6 @@ import java.io.IOException;
30 25
31 public interface EdgeNotificationService { 26 public interface EdgeNotificationService {
32 27
33 - TimePageData<EdgeEvent> findEdgeEvents(TenantId tenantId, EdgeId edgeId, TimePageLink pageLink);  
34 -  
35 Edge setEdgeRootRuleChain(TenantId tenantId, Edge edge, RuleChainId ruleChainId) throws IOException; 28 Edge setEdgeRootRuleChain(TenantId tenantId, Edge edge, RuleChainId ruleChainId) throws IOException;
36 29
37 void pushNotificationToEdge(TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg, TbCallback callback); 30 void pushNotificationToEdge(TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg, TbCallback callback);
@@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
28 import org.springframework.stereotype.Service; 28 import org.springframework.stereotype.Service;
29 import org.thingsboard.common.util.ThingsBoardThreadFactory; 29 import org.thingsboard.common.util.ThingsBoardThreadFactory;
30 import org.thingsboard.server.common.data.DataConstants; 30 import org.thingsboard.server.common.data.DataConstants;
  31 +import org.thingsboard.server.common.data.Tenant;
31 import org.thingsboard.server.common.data.edge.Edge; 32 import org.thingsboard.server.common.data.edge.Edge;
32 import org.thingsboard.server.common.data.id.EdgeId; 33 import org.thingsboard.server.common.data.id.EdgeId;
33 import org.thingsboard.server.common.data.id.TenantId; 34 import org.thingsboard.server.common.data.id.TenantId;
@@ -186,11 +187,12 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i @@ -186,11 +187,12 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i
186 scheduleEdgeEventsCheck(edgeGrpcSession); 187 scheduleEdgeEventsCheck(edgeGrpcSession);
187 } 188 }
188 189
189 - public EdgeGrpcSession getEdgeGrpcSessionById(EdgeId edgeId) { 190 + public EdgeGrpcSession getEdgeGrpcSessionById(TenantId tenantId, EdgeId edgeId) {
190 EdgeGrpcSession session = sessions.get(edgeId); 191 EdgeGrpcSession session = sessions.get(edgeId);
191 if (session != null && session.isConnected()) { 192 if (session != null && session.isConnected()) {
192 return session; 193 return session;
193 } else { 194 } else {
  195 + log.error("[{}] Edge is not connected [{}]", tenantId, edgeId);
194 throw new RuntimeException("Edge is not connected"); 196 throw new RuntimeException("Edge is not connected");
195 } 197 }
196 } 198 }
@@ -165,7 +165,7 @@ public final class EdgeGrpcSession implements Closeable { @@ -165,7 +165,7 @@ public final class EdgeGrpcSession implements Closeable {
165 } 165 }
166 } 166 }
167 if (connected && requestMsg.getMsgType().equals(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE)) { 167 if (connected && requestMsg.getMsgType().equals(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE)) {
168 - ctx.getSyncEdgeService().sync(edge); 168 + ctx.getSyncEdgeService().sync(edge.getTenantId(), edge);
169 } 169 }
170 if (connected) { 170 if (connected) {
171 if (requestMsg.getMsgType().equals(RequestMsgType.UPLINK_RPC_MESSAGE) && requestMsg.hasUplinkMsg()) { 171 if (requestMsg.getMsgType().equals(RequestMsgType.UPLINK_RPC_MESSAGE) && requestMsg.hasUplinkMsg()) {
@@ -267,7 +267,7 @@ public final class EdgeGrpcSession implements Closeable { @@ -267,7 +267,7 @@ public final class EdgeGrpcSession implements Closeable {
267 UUID ifOffset = null; 267 UUID ifOffset = null;
268 boolean success = true; 268 boolean success = true;
269 do { 269 do {
270 - pageData = ctx.getEdgeNotificationService().findEdgeEvents(edge.getTenantId(), edge.getId(), pageLink); 270 + pageData = ctx.getEdgeEventService().findEdgeEvents(edge.getTenantId(), edge.getId(), pageLink, true);
271 if (isConnected() && !pageData.getData().isEmpty()) { 271 if (isConnected() && !pageData.getData().isEmpty()) {
272 log.trace("[{}] [{}] event(s) are going to be processed.", this.sessionId, pageData.getData().size()); 272 log.trace("[{}] [{}] event(s) are going to be processed.", this.sessionId, pageData.getData().size());
273 List<DownlinkMsg> downlinkMsgsPack = convertToDownlinkMsgsPack(pageData.getData()); 273 List<DownlinkMsg> downlinkMsgsPack = convertToDownlinkMsgsPack(pageData.getData());
@@ -899,27 +899,27 @@ public final class EdgeGrpcSession implements Closeable { @@ -899,27 +899,27 @@ public final class EdgeGrpcSession implements Closeable {
899 } 899 }
900 if (uplinkMsg.getRuleChainMetadataRequestMsgList() != null && !uplinkMsg.getRuleChainMetadataRequestMsgList().isEmpty()) { 900 if (uplinkMsg.getRuleChainMetadataRequestMsgList() != null && !uplinkMsg.getRuleChainMetadataRequestMsgList().isEmpty()) {
901 for (RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg : uplinkMsg.getRuleChainMetadataRequestMsgList()) { 901 for (RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg : uplinkMsg.getRuleChainMetadataRequestMsgList()) {
902 - result.add(ctx.getSyncEdgeService().processRuleChainMetadataRequestMsg(edge, ruleChainMetadataRequestMsg)); 902 + result.add(ctx.getSyncEdgeService().processRuleChainMetadataRequestMsg(edge.getTenantId(), edge, ruleChainMetadataRequestMsg));
903 } 903 }
904 } 904 }
905 if (uplinkMsg.getAttributesRequestMsgList() != null && !uplinkMsg.getAttributesRequestMsgList().isEmpty()) { 905 if (uplinkMsg.getAttributesRequestMsgList() != null && !uplinkMsg.getAttributesRequestMsgList().isEmpty()) {
906 for (AttributesRequestMsg attributesRequestMsg : uplinkMsg.getAttributesRequestMsgList()) { 906 for (AttributesRequestMsg attributesRequestMsg : uplinkMsg.getAttributesRequestMsgList()) {
907 - result.add(ctx.getSyncEdgeService().processAttributesRequestMsg(edge, attributesRequestMsg)); 907 + result.add(ctx.getSyncEdgeService().processAttributesRequestMsg(edge.getTenantId(), edge, attributesRequestMsg));
908 } 908 }
909 } 909 }
910 if (uplinkMsg.getRelationRequestMsgList() != null && !uplinkMsg.getRelationRequestMsgList().isEmpty()) { 910 if (uplinkMsg.getRelationRequestMsgList() != null && !uplinkMsg.getRelationRequestMsgList().isEmpty()) {
911 for (RelationRequestMsg relationRequestMsg : uplinkMsg.getRelationRequestMsgList()) { 911 for (RelationRequestMsg relationRequestMsg : uplinkMsg.getRelationRequestMsgList()) {
912 - result.add(ctx.getSyncEdgeService().processRelationRequestMsg(edge, relationRequestMsg)); 912 + result.add(ctx.getSyncEdgeService().processRelationRequestMsg(edge.getTenantId(), edge, relationRequestMsg));
913 } 913 }
914 } 914 }
915 if (uplinkMsg.getUserCredentialsRequestMsgList() != null && !uplinkMsg.getUserCredentialsRequestMsgList().isEmpty()) { 915 if (uplinkMsg.getUserCredentialsRequestMsgList() != null && !uplinkMsg.getUserCredentialsRequestMsgList().isEmpty()) {
916 for (UserCredentialsRequestMsg userCredentialsRequestMsg : uplinkMsg.getUserCredentialsRequestMsgList()) { 916 for (UserCredentialsRequestMsg userCredentialsRequestMsg : uplinkMsg.getUserCredentialsRequestMsgList()) {
917 - result.add(ctx.getSyncEdgeService().processUserCredentialsRequestMsg(edge, userCredentialsRequestMsg)); 917 + result.add(ctx.getSyncEdgeService().processUserCredentialsRequestMsg(edge.getTenantId(), edge, userCredentialsRequestMsg));
918 } 918 }
919 } 919 }
920 if (uplinkMsg.getDeviceCredentialsRequestMsgList() != null && !uplinkMsg.getDeviceCredentialsRequestMsgList().isEmpty()) { 920 if (uplinkMsg.getDeviceCredentialsRequestMsgList() != null && !uplinkMsg.getDeviceCredentialsRequestMsgList().isEmpty()) {
921 for (DeviceCredentialsRequestMsg deviceCredentialsRequestMsg : uplinkMsg.getDeviceCredentialsRequestMsgList()) { 921 for (DeviceCredentialsRequestMsg deviceCredentialsRequestMsg : uplinkMsg.getDeviceCredentialsRequestMsgList()) {
922 - result.add(ctx.getSyncEdgeService().processDeviceCredentialsRequestMsg(edge, deviceCredentialsRequestMsg)); 922 + result.add(ctx.getSyncEdgeService().processDeviceCredentialsRequestMsg(edge.getTenantId(), edge, deviceCredentialsRequestMsg));
923 } 923 }
924 } 924 }
925 if (uplinkMsg.getDeviceRpcCallMsgList() != null && !uplinkMsg.getDeviceRpcCallMsgList().isEmpty()) { 925 if (uplinkMsg.getDeviceRpcCallMsgList() != null && !uplinkMsg.getDeviceRpcCallMsgList().isEmpty()) {
@@ -33,7 +33,6 @@ import org.springframework.core.io.DefaultResourceLoader; @@ -33,7 +33,6 @@ import org.springframework.core.io.DefaultResourceLoader;
33 import org.springframework.stereotype.Service; 33 import org.springframework.stereotype.Service;
34 import org.thingsboard.server.common.data.AdminSettings; 34 import org.thingsboard.server.common.data.AdminSettings;
35 import org.thingsboard.server.common.data.DashboardInfo; 35 import org.thingsboard.server.common.data.DashboardInfo;
36 -import org.thingsboard.server.common.data.DataConstants;  
37 import org.thingsboard.server.common.data.Device; 36 import org.thingsboard.server.common.data.Device;
38 import org.thingsboard.server.common.data.EdgeUtils; 37 import org.thingsboard.server.common.data.EdgeUtils;
39 import org.thingsboard.server.common.data.EntityType; 38 import org.thingsboard.server.common.data.EntityType;
@@ -146,37 +145,37 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -146,37 +145,37 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
146 private TbClusterService tbClusterService; 145 private TbClusterService tbClusterService;
147 146
148 @Override 147 @Override
149 - public void sync(Edge edge) {  
150 - log.trace("[{}][{}] Staring edge sync process", edge.getTenantId(), edge.getId()); 148 + public void sync(TenantId tenantId, Edge edge) {
  149 + log.trace("[{}][{}] Staring edge sync process", tenantId, edge.getId());
151 try { 150 try {
152 - syncWidgetsBundleAndWidgetTypes(edge);  
153 - syncAdminSettings(edge);  
154 - syncRuleChains(edge, new TimePageLink(DEFAULT_LIMIT));  
155 - syncUsers(edge, new TextPageLink(DEFAULT_LIMIT));  
156 - syncDevices(edge, new TimePageLink(DEFAULT_LIMIT));  
157 - syncAssets(edge, new TimePageLink(DEFAULT_LIMIT));  
158 - syncEntityViews(edge, new TimePageLink(DEFAULT_LIMIT));  
159 - syncDashboards(edge, new TimePageLink(DEFAULT_LIMIT)); 151 + syncWidgetsBundleAndWidgetTypes(tenantId, edge);
  152 + syncAdminSettings(tenantId, edge);
  153 + syncRuleChains(tenantId, edge, new TimePageLink(DEFAULT_LIMIT));
  154 + syncUsers(tenantId, edge, new TextPageLink(DEFAULT_LIMIT));
  155 + syncDevices(tenantId, edge, new TimePageLink(DEFAULT_LIMIT));
  156 + syncAssets(tenantId, edge, new TimePageLink(DEFAULT_LIMIT));
  157 + syncEntityViews(tenantId, edge, new TimePageLink(DEFAULT_LIMIT));
  158 + syncDashboards(tenantId, edge, new TimePageLink(DEFAULT_LIMIT));
160 } catch (Exception e) { 159 } catch (Exception e) {
161 - log.error("[{}][{}] Exception during sync process", edge.getTenantId(), edge.getId(), e); 160 + log.error("[{}][{}] Exception during sync process", tenantId, edge.getId(), e);
162 } 161 }
163 } 162 }
164 163
165 - private void syncRuleChains(Edge edge, TimePageLink pageLink) {  
166 - log.trace("[{}] syncRuleChains [{}] [{}]", edge.getTenantId(), edge.getName(), pageLink); 164 + private void syncRuleChains(TenantId tenantId, Edge edge, TimePageLink pageLink) {
  165 + log.trace("[{}] syncRuleChains [{}] [{}]", tenantId, edge.getName(), pageLink);
167 try { 166 try {
168 ListenableFuture<TimePageData<RuleChain>> future = 167 ListenableFuture<TimePageData<RuleChain>> future =
169 - ruleChainService.findRuleChainsByTenantIdAndEdgeId(edge.getTenantId(), edge.getId(), pageLink); 168 + ruleChainService.findRuleChainsByTenantIdAndEdgeId(tenantId, edge.getId(), pageLink);
170 Futures.addCallback(future, new FutureCallback<TimePageData<RuleChain>>() { 169 Futures.addCallback(future, new FutureCallback<TimePageData<RuleChain>>() {
171 @Override 170 @Override
172 public void onSuccess(@Nullable TimePageData<RuleChain> pageData) { 171 public void onSuccess(@Nullable TimePageData<RuleChain> pageData) {
173 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { 172 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
174 log.trace("[{}] [{}] rule chains(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size()); 173 log.trace("[{}] [{}] rule chains(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
175 for (RuleChain ruleChain : pageData.getData()) { 174 for (RuleChain ruleChain : pageData.getData()) {
176 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.RULE_CHAIN, EdgeEventActionType.ADDED, ruleChain.getId(), null); 175 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.RULE_CHAIN, EdgeEventActionType.ADDED, ruleChain.getId(), null);
177 } 176 }
178 if (pageData.hasNext()) { 177 if (pageData.hasNext()) {
179 - syncRuleChains(edge, pageData.getNextPageLink()); 178 + syncRuleChains(tenantId, edge, pageData.getNextPageLink());
180 } 179 }
181 } 180 }
182 } 181 }
@@ -191,21 +190,21 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -191,21 +190,21 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
191 } 190 }
192 } 191 }
193 192
194 - private void syncDevices(Edge edge, TimePageLink pageLink) {  
195 - log.trace("[{}] syncDevices [{}]", edge.getTenantId(), edge.getName()); 193 + private void syncDevices(TenantId tenantId, Edge edge, TimePageLink pageLink) {
  194 + log.trace("[{}] syncDevices [{}]", tenantId, edge.getName());
196 try { 195 try {
197 ListenableFuture<TimePageData<Device>> future = 196 ListenableFuture<TimePageData<Device>> future =
198 - deviceService.findDevicesByTenantIdAndEdgeId(edge.getTenantId(), edge.getId(), pageLink); 197 + deviceService.findDevicesByTenantIdAndEdgeId(tenantId, edge.getId(), pageLink);
199 Futures.addCallback(future, new FutureCallback<TimePageData<Device>>() { 198 Futures.addCallback(future, new FutureCallback<TimePageData<Device>>() {
200 @Override 199 @Override
201 public void onSuccess(@Nullable TimePageData<Device> pageData) { 200 public void onSuccess(@Nullable TimePageData<Device> pageData) {
202 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { 201 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
203 log.trace("[{}] [{}] device(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size()); 202 log.trace("[{}] [{}] device(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
204 for (Device device : pageData.getData()) { 203 for (Device device : pageData.getData()) {
205 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.ADDED, device.getId(), null); 204 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.ADDED, device.getId(), null);
206 } 205 }
207 if (pageData.hasNext()) { 206 if (pageData.hasNext()) {
208 - syncDevices(edge, pageData.getNextPageLink()); 207 + syncDevices(tenantId, edge, pageData.getNextPageLink());
209 } 208 }
210 } 209 }
211 } 210 }
@@ -220,20 +219,20 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -220,20 +219,20 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
220 } 219 }
221 } 220 }
222 221
223 - private void syncAssets(Edge edge, TimePageLink pageLink) {  
224 - log.trace("[{}] syncAssets [{}]", edge.getTenantId(), edge.getName()); 222 + private void syncAssets(TenantId tenantId, Edge edge, TimePageLink pageLink) {
  223 + log.trace("[{}] syncAssets [{}]", tenantId, edge.getName());
225 try { 224 try {
226 - ListenableFuture<TimePageData<Asset>> future = assetService.findAssetsByTenantIdAndEdgeId(edge.getTenantId(), edge.getId(), pageLink); 225 + ListenableFuture<TimePageData<Asset>> future = assetService.findAssetsByTenantIdAndEdgeId(tenantId, edge.getId(), pageLink);
227 Futures.addCallback(future, new FutureCallback<TimePageData<Asset>>() { 226 Futures.addCallback(future, new FutureCallback<TimePageData<Asset>>() {
228 @Override 227 @Override
229 public void onSuccess(@Nullable TimePageData<Asset> pageData) { 228 public void onSuccess(@Nullable TimePageData<Asset> pageData) {
230 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { 229 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
231 log.trace("[{}] [{}] asset(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size()); 230 log.trace("[{}] [{}] asset(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
232 for (Asset asset : pageData.getData()) { 231 for (Asset asset : pageData.getData()) {
233 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ASSET, EdgeEventActionType.ADDED, asset.getId(), null); 232 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.ASSET, EdgeEventActionType.ADDED, asset.getId(), null);
234 } 233 }
235 if (pageData.hasNext()) { 234 if (pageData.hasNext()) {
236 - syncAssets(edge, pageData.getNextPageLink()); 235 + syncAssets(tenantId, edge, pageData.getNextPageLink());
237 } 236 }
238 } 237 }
239 } 238 }
@@ -248,20 +247,20 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -248,20 +247,20 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
248 } 247 }
249 } 248 }
250 249
251 - private void syncEntityViews(Edge edge, TimePageLink pageLink) {  
252 - log.trace("[{}] syncEntityViews [{}]", edge.getTenantId(), edge.getName()); 250 + private void syncEntityViews(TenantId tenantId, Edge edge, TimePageLink pageLink) {
  251 + log.trace("[{}] syncEntityViews [{}]", tenantId, edge.getName());
253 try { 252 try {
254 - ListenableFuture<TimePageData<EntityView>> future = entityViewService.findEntityViewsByTenantIdAndEdgeId(edge.getTenantId(), edge.getId(), pageLink); 253 + ListenableFuture<TimePageData<EntityView>> future = entityViewService.findEntityViewsByTenantIdAndEdgeId(tenantId, edge.getId(), pageLink);
255 Futures.addCallback(future, new FutureCallback<TimePageData<EntityView>>() { 254 Futures.addCallback(future, new FutureCallback<TimePageData<EntityView>>() {
256 @Override 255 @Override
257 public void onSuccess(@Nullable TimePageData<EntityView> pageData) { 256 public void onSuccess(@Nullable TimePageData<EntityView> pageData) {
258 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { 257 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
259 log.trace("[{}] [{}] entity view(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size()); 258 log.trace("[{}] [{}] entity view(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
260 for (EntityView entityView : pageData.getData()) { 259 for (EntityView entityView : pageData.getData()) {
261 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ENTITY_VIEW, EdgeEventActionType.ADDED, entityView.getId(), null); 260 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.ENTITY_VIEW, EdgeEventActionType.ADDED, entityView.getId(), null);
262 } 261 }
263 if (pageData.hasNext()) { 262 if (pageData.hasNext()) {
264 - syncEntityViews(edge, pageData.getNextPageLink()); 263 + syncEntityViews(tenantId, edge, pageData.getNextPageLink());
265 } 264 }
266 } 265 }
267 } 266 }
@@ -276,20 +275,20 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -276,20 +275,20 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
276 } 275 }
277 } 276 }
278 277
279 - private void syncDashboards(Edge edge, TimePageLink pageLink) {  
280 - log.trace("[{}] syncDashboards [{}]", edge.getTenantId(), edge.getName()); 278 + private void syncDashboards(TenantId tenantId, Edge edge, TimePageLink pageLink) {
  279 + log.trace("[{}] syncDashboards [{}]", tenantId, edge.getName());
281 try { 280 try {
282 - ListenableFuture<TimePageData<DashboardInfo>> future = dashboardService.findDashboardsByTenantIdAndEdgeId(edge.getTenantId(), edge.getId(), pageLink); 281 + ListenableFuture<TimePageData<DashboardInfo>> future = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edge.getId(), pageLink);
283 Futures.addCallback(future, new FutureCallback<TimePageData<DashboardInfo>>() { 282 Futures.addCallback(future, new FutureCallback<TimePageData<DashboardInfo>>() {
284 @Override 283 @Override
285 public void onSuccess(@Nullable TimePageData<DashboardInfo> pageData) { 284 public void onSuccess(@Nullable TimePageData<DashboardInfo> pageData) {
286 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { 285 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
287 log.trace("[{}] [{}] dashboard(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size()); 286 log.trace("[{}] [{}] dashboard(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
288 for (DashboardInfo dashboardInfo : pageData.getData()) { 287 for (DashboardInfo dashboardInfo : pageData.getData()) {
289 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DASHBOARD, EdgeEventActionType.ADDED, dashboardInfo.getId(), null); 288 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DASHBOARD, EdgeEventActionType.ADDED, dashboardInfo.getId(), null);
290 } 289 }
291 if (pageData.hasNext()) { 290 if (pageData.hasNext()) {
292 - syncDashboards(edge, pageData.getNextPageLink()); 291 + syncDashboards(tenantId, edge, pageData.getNextPageLink());
293 } 292 }
294 } 293 }
295 } 294 }
@@ -304,31 +303,31 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -304,31 +303,31 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
304 } 303 }
305 } 304 }
306 305
307 - private void syncUsers(Edge edge, TextPageLink pageLink) {  
308 - log.trace("[{}] syncUsers [{}]", edge.getTenantId(), edge.getName()); 306 + private void syncUsers(TenantId tenantId, Edge edge, TextPageLink pageLink) {
  307 + log.trace("[{}] syncUsers [{}]", tenantId, edge.getName());
309 try { 308 try {
310 TextPageData<User> pageData; 309 TextPageData<User> pageData;
311 do { 310 do {
312 - pageData = userService.findTenantAdmins(edge.getTenantId(), pageLink);  
313 - pushUsersToEdge(pageData, edge); 311 + pageData = userService.findTenantAdmins(tenantId, pageLink);
  312 + pushUsersToEdge(tenantId, pageData, edge);
314 if (pageData != null && pageData.hasNext()) { 313 if (pageData != null && pageData.hasNext()) {
315 pageLink = pageData.getNextPageLink(); 314 pageLink = pageData.getNextPageLink();
316 } 315 }
317 } while (pageData != null && pageData.hasNext()); 316 } while (pageData != null && pageData.hasNext());
318 - syncCustomerUsers(edge); 317 + syncCustomerUsers(tenantId, edge);
319 } catch (Exception e) { 318 } catch (Exception e) {
320 log.error("Exception during loading edge user(s) on sync!", e); 319 log.error("Exception during loading edge user(s) on sync!", e);
321 } 320 }
322 } 321 }
323 322
324 - private void syncCustomerUsers(Edge edge) { 323 + private void syncCustomerUsers(TenantId tenantId, Edge edge) {
325 if (edge.getCustomerId() != null && !EntityId.NULL_UUID.equals(edge.getCustomerId().getId())) { 324 if (edge.getCustomerId() != null && !EntityId.NULL_UUID.equals(edge.getCustomerId().getId())) {
326 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, EdgeEventActionType.ADDED, edge.getCustomerId(), null); 325 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.CUSTOMER, EdgeEventActionType.ADDED, edge.getCustomerId(), null);
327 TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT); 326 TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT);
328 TextPageData<User> pageData; 327 TextPageData<User> pageData;
329 do { 328 do {
330 - pageData = userService.findCustomerUsers(edge.getTenantId(), edge.getCustomerId(), pageLink);  
331 - pushUsersToEdge(pageData, edge); 329 + pageData = userService.findCustomerUsers(tenantId, edge.getCustomerId(), pageLink);
  330 + pushUsersToEdge(tenantId, pageData, edge);
332 if (pageData != null && pageData.hasNext()) { 331 if (pageData != null && pageData.hasNext()) {
333 pageLink = pageData.getNextPageLink(); 332 pageLink = pageData.getNextPageLink();
334 } 333 }
@@ -336,45 +335,45 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -336,45 +335,45 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
336 } 335 }
337 } 336 }
338 337
339 - private void pushUsersToEdge(TextPageData<User> pageData, Edge edge) { 338 + private void pushUsersToEdge(TenantId tenantId, TextPageData<User> pageData, Edge edge) {
340 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) { 339 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
341 log.trace("[{}] [{}] user(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size()); 340 log.trace("[{}] [{}] user(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
342 for (User user : pageData.getData()) { 341 for (User user : pageData.getData()) {
343 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, EdgeEventActionType.ADDED, user.getId(), null); 342 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.USER, EdgeEventActionType.ADDED, user.getId(), null);
344 } 343 }
345 } 344 }
346 } 345 }
347 346
348 - private void syncWidgetsBundleAndWidgetTypes(Edge edge) {  
349 - log.trace("[{}] syncWidgetsBundleAndWidgetTypes [{}]", edge.getTenantId(), edge.getName()); 347 + private void syncWidgetsBundleAndWidgetTypes(TenantId tenantId, Edge edge) {
  348 + log.trace("[{}] syncWidgetsBundleAndWidgetTypes [{}]", tenantId, edge.getName());
350 List<WidgetsBundle> widgetsBundlesToPush = new ArrayList<>(); 349 List<WidgetsBundle> widgetsBundlesToPush = new ArrayList<>();
351 List<WidgetType> widgetTypesToPush = new ArrayList<>(); 350 List<WidgetType> widgetTypesToPush = new ArrayList<>();
352 - widgetsBundlesToPush.addAll(widgetsBundleService.findAllTenantWidgetsBundlesByTenantId(edge.getTenantId()));  
353 - widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(edge.getTenantId())); 351 + widgetsBundlesToPush.addAll(widgetsBundleService.findAllTenantWidgetsBundlesByTenantId(tenantId));
  352 + widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(tenantId));
354 try { 353 try {
355 for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) { 354 for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) {
356 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGETS_BUNDLE, EdgeEventActionType.ADDED, widgetsBundle.getId(), null); 355 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.WIDGETS_BUNDLE, EdgeEventActionType.ADDED, widgetsBundle.getId(), null);
357 widgetTypesToPush.addAll(widgetTypeService.findWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias())); 356 widgetTypesToPush.addAll(widgetTypeService.findWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias()));
358 } 357 }
359 for (WidgetType widgetType: widgetTypesToPush) { 358 for (WidgetType widgetType: widgetTypesToPush) {
360 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGET_TYPE, EdgeEventActionType.ADDED, widgetType.getId(), null); 359 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.WIDGET_TYPE, EdgeEventActionType.ADDED, widgetType.getId(), null);
361 } 360 }
362 } catch (Exception e) { 361 } catch (Exception e) {
363 log.error("Exception during loading widgets bundle(s) and widget type(s) on sync!", e); 362 log.error("Exception during loading widgets bundle(s) and widget type(s) on sync!", e);
364 } 363 }
365 } 364 }
366 365
367 - private void syncAdminSettings(Edge edge) {  
368 - log.trace("[{}] syncAdminSettings [{}]", edge.getTenantId(), edge.getName()); 366 + private void syncAdminSettings(TenantId tenantId, Edge edge) {
  367 + log.trace("[{}] syncAdminSettings [{}]", tenantId, edge.getName());
369 try { 368 try {
370 AdminSettings systemMailSettings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail"); 369 AdminSettings systemMailSettings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail");
371 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(systemMailSettings)); 370 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(systemMailSettings));
372 AdminSettings tenantMailSettings = convertToTenantAdminSettings(systemMailSettings.getKey(), (ObjectNode) systemMailSettings.getJsonValue()); 371 AdminSettings tenantMailSettings = convertToTenantAdminSettings(systemMailSettings.getKey(), (ObjectNode) systemMailSettings.getJsonValue());
373 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(tenantMailSettings)); 372 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(tenantMailSettings));
374 AdminSettings systemMailTemplates = loadMailTemplates(); 373 AdminSettings systemMailTemplates = loadMailTemplates();
375 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(systemMailTemplates)); 374 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(systemMailTemplates));
376 AdminSettings tenantMailTemplates = convertToTenantAdminSettings(systemMailTemplates.getKey(), (ObjectNode) systemMailTemplates.getJsonValue()); 375 AdminSettings tenantMailTemplates = convertToTenantAdminSettings(systemMailTemplates.getKey(), (ObjectNode) systemMailTemplates.getJsonValue());
377 - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(tenantMailTemplates)); 376 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(tenantMailTemplates));
378 } catch (Exception e) { 377 } catch (Exception e) {
379 log.error("Can't load admin settings", e); 378 log.error("Can't load admin settings", e);
380 } 379 }
@@ -433,13 +432,13 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -433,13 +432,13 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
433 } 432 }
434 433
435 @Override 434 @Override
436 - public ListenableFuture<Void> processRuleChainMetadataRequestMsg(Edge edge, RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg) {  
437 - log.trace("[{}] processRuleChainMetadataRequestMsg [{}][{}]", edge.getTenantId(), edge.getName(), ruleChainMetadataRequestMsg); 435 + public ListenableFuture<Void> processRuleChainMetadataRequestMsg(TenantId tenantId, Edge edge, RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg) {
  436 + log.trace("[{}] processRuleChainMetadataRequestMsg [{}][{}]", tenantId, edge.getName(), ruleChainMetadataRequestMsg);
438 SettableFuture<Void> futureToSet = SettableFuture.create(); 437 SettableFuture<Void> futureToSet = SettableFuture.create();
439 if (ruleChainMetadataRequestMsg.getRuleChainIdMSB() != 0 && ruleChainMetadataRequestMsg.getRuleChainIdLSB() != 0) { 438 if (ruleChainMetadataRequestMsg.getRuleChainIdMSB() != 0 && ruleChainMetadataRequestMsg.getRuleChainIdLSB() != 0) {
440 RuleChainId ruleChainId = 439 RuleChainId ruleChainId =
441 new RuleChainId(new UUID(ruleChainMetadataRequestMsg.getRuleChainIdMSB(), ruleChainMetadataRequestMsg.getRuleChainIdLSB())); 440 new RuleChainId(new UUID(ruleChainMetadataRequestMsg.getRuleChainIdMSB(), ruleChainMetadataRequestMsg.getRuleChainIdLSB()));
442 - ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.RULE_CHAIN_METADATA, EdgeEventActionType.ADDED, ruleChainId, null); 441 + ListenableFuture<EdgeEvent> future = saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.RULE_CHAIN_METADATA, EdgeEventActionType.ADDED, ruleChainId, null);
443 Futures.addCallback(future, new FutureCallback<EdgeEvent>() { 442 Futures.addCallback(future, new FutureCallback<EdgeEvent>() {
444 @Override 443 @Override
445 public void onSuccess(@Nullable EdgeEvent result) { 444 public void onSuccess(@Nullable EdgeEvent result) {
@@ -457,8 +456,8 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -457,8 +456,8 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
457 } 456 }
458 457
459 @Override 458 @Override
460 - public ListenableFuture<Void> processAttributesRequestMsg(Edge edge, AttributesRequestMsg attributesRequestMsg) {  
461 - log.trace("[{}] processAttributesRequestMsg [{}][{}]", edge.getTenantId(), edge.getName(), attributesRequestMsg); 459 + public ListenableFuture<Void> processAttributesRequestMsg(TenantId tenantId, Edge edge, AttributesRequestMsg attributesRequestMsg) {
  460 + log.trace("[{}] processAttributesRequestMsg [{}][{}]", tenantId, edge.getName(), attributesRequestMsg);
462 EntityId entityId = EntityIdFactory.getByTypeAndUuid( 461 EntityId entityId = EntityIdFactory.getByTypeAndUuid(
463 EntityType.valueOf(attributesRequestMsg.getEntityType()), 462 EntityType.valueOf(attributesRequestMsg.getEntityType()),
464 new UUID(attributesRequestMsg.getEntityIdMSB(), attributesRequestMsg.getEntityIdLSB())); 463 new UUID(attributesRequestMsg.getEntityIdMSB(), attributesRequestMsg.getEntityIdLSB()));
@@ -466,7 +465,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -466,7 +465,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
466 if (type != null) { 465 if (type != null) {
467 SettableFuture<Void> futureToSet = SettableFuture.create(); 466 SettableFuture<Void> futureToSet = SettableFuture.create();
468 String scope = attributesRequestMsg.getScope(); 467 String scope = attributesRequestMsg.getScope();
469 - ListenableFuture<List<AttributeKvEntry>> ssAttrFuture = attributesService.findAll(edge.getTenantId(), entityId, scope); 468 + ListenableFuture<List<AttributeKvEntry>> ssAttrFuture = attributesService.findAll(tenantId, entityId, scope);
470 Futures.addCallback(ssAttrFuture, new FutureCallback<List<AttributeKvEntry>>() { 469 Futures.addCallback(ssAttrFuture, new FutureCallback<List<AttributeKvEntry>>() {
471 @Override 470 @Override
472 public void onSuccess(@Nullable List<AttributeKvEntry> ssAttributes) { 471 public void onSuccess(@Nullable List<AttributeKvEntry> ssAttributes) {
@@ -489,7 +488,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -489,7 +488,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
489 entityData.put("scope", scope); 488 entityData.put("scope", scope);
490 JsonNode body = mapper.valueToTree(entityData); 489 JsonNode body = mapper.valueToTree(entityData);
491 log.debug("Sending attributes data msg, entityId [{}], attributes [{}]", entityId, body); 490 log.debug("Sending attributes data msg, entityId [{}], attributes [{}]", entityId, body);
492 - saveEdgeEvent(edge.getTenantId(), 491 + saveEdgeEvent(tenantId,
493 edge.getId(), 492 edge.getId(),
494 type, 493 type,
495 EdgeEventActionType.ATTRIBUTES_UPDATED, 494 EdgeEventActionType.ATTRIBUTES_UPDATED,
@@ -500,7 +499,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -500,7 +499,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
500 throw new RuntimeException("[" + edge.getName() + "] Failed to send attribute updates to the edge", e); 499 throw new RuntimeException("[" + edge.getName() + "] Failed to send attribute updates to the edge", e);
501 } 500 }
502 } else { 501 } else {
503 - log.trace("[{}][{}] No attributes found for entity {} [{}]", edge.getTenantId(), 502 + log.trace("[{}][{}] No attributes found for entity {} [{}]", tenantId,
504 edge.getName(), 503 edge.getName(),
505 entityId.getEntityType(), 504 entityId.getEntityType(),
506 entityId.getId()); 505 entityId.getId());
@@ -516,21 +515,21 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -516,21 +515,21 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
516 }, dbCallbackExecutorService); 515 }, dbCallbackExecutorService);
517 return futureToSet; 516 return futureToSet;
518 } else { 517 } else {
519 - log.warn("[{}] Type doesn't supported {}", edge.getTenantId(), entityId.getEntityType()); 518 + log.warn("[{}] Type doesn't supported {}", tenantId, entityId.getEntityType());
520 return Futures.immediateFuture(null); 519 return Futures.immediateFuture(null);
521 } 520 }
522 } 521 }
523 522
524 @Override 523 @Override
525 - public ListenableFuture<Void> processRelationRequestMsg(Edge edge, RelationRequestMsg relationRequestMsg) {  
526 - log.trace("[{}] processRelationRequestMsg [{}][{}]", edge.getTenantId(), edge.getName(), relationRequestMsg); 524 + public ListenableFuture<Void> processRelationRequestMsg(TenantId tenantId, Edge edge, RelationRequestMsg relationRequestMsg) {
  525 + log.trace("[{}] processRelationRequestMsg [{}][{}]", tenantId, edge.getName(), relationRequestMsg);
527 EntityId entityId = EntityIdFactory.getByTypeAndUuid( 526 EntityId entityId = EntityIdFactory.getByTypeAndUuid(
528 EntityType.valueOf(relationRequestMsg.getEntityType()), 527 EntityType.valueOf(relationRequestMsg.getEntityType()),
529 new UUID(relationRequestMsg.getEntityIdMSB(), relationRequestMsg.getEntityIdLSB())); 528 new UUID(relationRequestMsg.getEntityIdMSB(), relationRequestMsg.getEntityIdLSB()));
530 529
531 List<ListenableFuture<List<EntityRelation>>> futures = new ArrayList<>(); 530 List<ListenableFuture<List<EntityRelation>>> futures = new ArrayList<>();
532 - futures.add(findRelationByQuery(edge, entityId, EntitySearchDirection.FROM));  
533 - futures.add(findRelationByQuery(edge, entityId, EntitySearchDirection.TO)); 531 + futures.add(findRelationByQuery(tenantId, edge, entityId, EntitySearchDirection.FROM));
  532 + futures.add(findRelationByQuery(tenantId, edge, entityId, EntitySearchDirection.TO));
534 ListenableFuture<List<List<EntityRelation>>> relationsListFuture = Futures.allAsList(futures); 533 ListenableFuture<List<List<EntityRelation>>> relationsListFuture = Futures.allAsList(futures);
535 SettableFuture<Void> futureToSet = SettableFuture.create(); 534 SettableFuture<Void> futureToSet = SettableFuture.create();
536 Futures.addCallback(relationsListFuture, new FutureCallback<List<List<EntityRelation>>>() { 535 Futures.addCallback(relationsListFuture, new FutureCallback<List<List<EntityRelation>>>() {
@@ -544,7 +543,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -544,7 +543,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
544 try { 543 try {
545 if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && 544 if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) &&
546 !relation.getTo().getEntityType().equals(EntityType.EDGE)) { 545 !relation.getTo().getEntityType().equals(EntityType.EDGE)) {
547 - saveEdgeEvent(edge.getTenantId(), 546 + saveEdgeEvent(tenantId,
548 edge.getId(), 547 edge.getId(),
549 EdgeEventType.RELATION, 548 EdgeEventType.RELATION,
550 EdgeEventActionType.ADDED, 549 EdgeEventActionType.ADDED,
@@ -568,26 +567,26 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -568,26 +567,26 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
568 567
569 @Override 568 @Override
570 public void onFailure(Throwable t) { 569 public void onFailure(Throwable t) {
571 - log.error("[{}] Can't find relation by query. Entity id [{}]", edge.getTenantId(), entityId, t); 570 + log.error("[{}] Can't find relation by query. Entity id [{}]", tenantId, entityId, t);
572 futureToSet.setException(t); 571 futureToSet.setException(t);
573 } 572 }
574 }, dbCallbackExecutorService); 573 }, dbCallbackExecutorService);
575 return futureToSet; 574 return futureToSet;
576 } 575 }
577 576
578 - private ListenableFuture<List<EntityRelation>> findRelationByQuery(Edge edge, EntityId entityId, EntitySearchDirection direction) { 577 + private ListenableFuture<List<EntityRelation>> findRelationByQuery(TenantId tenantId, Edge edge, EntityId entityId, EntitySearchDirection direction) {
579 EntityRelationsQuery query = new EntityRelationsQuery(); 578 EntityRelationsQuery query = new EntityRelationsQuery();
580 query.setParameters(new RelationsSearchParameters(entityId, direction, -1, false)); 579 query.setParameters(new RelationsSearchParameters(entityId, direction, -1, false));
581 - return relationService.findByQuery(edge.getTenantId(), query); 580 + return relationService.findByQuery(tenantId, query);
582 } 581 }
583 582
584 @Override 583 @Override
585 - public ListenableFuture<Void> processDeviceCredentialsRequestMsg(Edge edge, DeviceCredentialsRequestMsg deviceCredentialsRequestMsg) {  
586 - log.trace("[{}] processDeviceCredentialsRequestMsg [{}][{}]", edge.getTenantId(), edge.getName(), deviceCredentialsRequestMsg); 584 + public ListenableFuture<Void> processDeviceCredentialsRequestMsg(TenantId tenantId, Edge edge, DeviceCredentialsRequestMsg deviceCredentialsRequestMsg) {
  585 + log.trace("[{}] processDeviceCredentialsRequestMsg [{}][{}]", tenantId, edge.getName(), deviceCredentialsRequestMsg);
587 SettableFuture<Void> futureToSet = SettableFuture.create(); 586 SettableFuture<Void> futureToSet = SettableFuture.create();
588 if (deviceCredentialsRequestMsg.getDeviceIdMSB() != 0 && deviceCredentialsRequestMsg.getDeviceIdLSB() != 0) { 587 if (deviceCredentialsRequestMsg.getDeviceIdMSB() != 0 && deviceCredentialsRequestMsg.getDeviceIdLSB() != 0) {
589 DeviceId deviceId = new DeviceId(new UUID(deviceCredentialsRequestMsg.getDeviceIdMSB(), deviceCredentialsRequestMsg.getDeviceIdLSB())); 588 DeviceId deviceId = new DeviceId(new UUID(deviceCredentialsRequestMsg.getDeviceIdMSB(), deviceCredentialsRequestMsg.getDeviceIdLSB()));
590 - ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_UPDATED, deviceId, null); 589 + ListenableFuture<EdgeEvent> future = saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_UPDATED, deviceId, null);
591 Futures.addCallback(future, new FutureCallback<EdgeEvent>() { 590 Futures.addCallback(future, new FutureCallback<EdgeEvent>() {
592 @Override 591 @Override
593 public void onSuccess(@Nullable EdgeEvent result) { 592 public void onSuccess(@Nullable EdgeEvent result) {
@@ -605,12 +604,12 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -605,12 +604,12 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
605 } 604 }
606 605
607 @Override 606 @Override
608 - public ListenableFuture<Void> processUserCredentialsRequestMsg(Edge edge, UserCredentialsRequestMsg userCredentialsRequestMsg) {  
609 - log.trace("[{}] processUserCredentialsRequestMsg [{}][{}]", edge.getTenantId(), edge.getName(), userCredentialsRequestMsg); 607 + public ListenableFuture<Void> processUserCredentialsRequestMsg(TenantId tenantId, Edge edge, UserCredentialsRequestMsg userCredentialsRequestMsg) {
  608 + log.trace("[{}] processUserCredentialsRequestMsg [{}][{}]", tenantId, edge.getName(), userCredentialsRequestMsg);
610 SettableFuture<Void> futureToSet = SettableFuture.create(); 609 SettableFuture<Void> futureToSet = SettableFuture.create();
611 if (userCredentialsRequestMsg.getUserIdMSB() != 0 && userCredentialsRequestMsg.getUserIdLSB() != 0) { 610 if (userCredentialsRequestMsg.getUserIdMSB() != 0 && userCredentialsRequestMsg.getUserIdLSB() != 0) {
612 UserId userId = new UserId(new UUID(userCredentialsRequestMsg.getUserIdMSB(), userCredentialsRequestMsg.getUserIdLSB())); 611 UserId userId = new UserId(new UUID(userCredentialsRequestMsg.getUserIdMSB(), userCredentialsRequestMsg.getUserIdLSB()));
613 - ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, EdgeEventActionType.CREDENTIALS_UPDATED, userId, null); 612 + ListenableFuture<EdgeEvent> future = saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.USER, EdgeEventActionType.CREDENTIALS_UPDATED, userId, null);
614 Futures.addCallback(future, new FutureCallback<EdgeEvent>() { 613 Futures.addCallback(future, new FutureCallback<EdgeEvent>() {
615 @Override 614 @Override
616 public void onSuccess(@Nullable EdgeEvent result) { 615 public void onSuccess(@Nullable EdgeEvent result) {
@@ -17,6 +17,7 @@ package org.thingsboard.server.service.edge.rpc.init; @@ -17,6 +17,7 @@ package org.thingsboard.server.service.edge.rpc.init;
17 17
18 import com.google.common.util.concurrent.ListenableFuture; 18 import com.google.common.util.concurrent.ListenableFuture;
19 import org.thingsboard.server.common.data.edge.Edge; 19 import org.thingsboard.server.common.data.edge.Edge;
  20 +import org.thingsboard.server.common.data.id.TenantId;
20 import org.thingsboard.server.gen.edge.AttributesRequestMsg; 21 import org.thingsboard.server.gen.edge.AttributesRequestMsg;
21 import org.thingsboard.server.gen.edge.DeviceCredentialsRequestMsg; 22 import org.thingsboard.server.gen.edge.DeviceCredentialsRequestMsg;
22 import org.thingsboard.server.gen.edge.RelationRequestMsg; 23 import org.thingsboard.server.gen.edge.RelationRequestMsg;
@@ -25,15 +26,15 @@ import org.thingsboard.server.gen.edge.UserCredentialsRequestMsg; @@ -25,15 +26,15 @@ import org.thingsboard.server.gen.edge.UserCredentialsRequestMsg;
25 26
26 public interface SyncEdgeService { 27 public interface SyncEdgeService {
27 28
28 - void sync(Edge edge); 29 + void sync(TenantId tenantId, Edge edge);
29 30
30 - ListenableFuture<Void> processRuleChainMetadataRequestMsg(Edge edge, RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg); 31 + ListenableFuture<Void> processRuleChainMetadataRequestMsg(TenantId tenantId, Edge edge, RuleChainMetadataRequestMsg ruleChainMetadataRequestMsg);
31 32
32 - ListenableFuture<Void> processAttributesRequestMsg(Edge edge, AttributesRequestMsg attributesRequestMsg); 33 + ListenableFuture<Void> processAttributesRequestMsg(TenantId tenantId, Edge edge, AttributesRequestMsg attributesRequestMsg);
33 34
34 - ListenableFuture<Void> processRelationRequestMsg(Edge edge, RelationRequestMsg relationRequestMsg); 35 + ListenableFuture<Void> processRelationRequestMsg(TenantId tenantId, Edge edge, RelationRequestMsg relationRequestMsg);
35 36
36 - ListenableFuture<Void> processDeviceCredentialsRequestMsg(Edge edge, DeviceCredentialsRequestMsg deviceCredentialsRequestMsg); 37 + ListenableFuture<Void> processDeviceCredentialsRequestMsg(TenantId tenantId, Edge edge, DeviceCredentialsRequestMsg deviceCredentialsRequestMsg);
37 38
38 - ListenableFuture<Void> processUserCredentialsRequestMsg(Edge edge, UserCredentialsRequestMsg userCredentialsRequestMsg); 39 + ListenableFuture<Void> processUserCredentialsRequestMsg(TenantId tenantId, Edge edge, UserCredentialsRequestMsg userCredentialsRequestMsg);
39 } 40 }
@@ -80,4 +80,6 @@ public interface EdgeService { @@ -80,4 +80,6 @@ public interface EdgeService {
80 Object checkInstance(Object request); 80 Object checkInstance(Object request);
81 81
82 Object activateInstance(String licenseSecret, String releaseDate); 82 Object activateInstance(String licenseSecret, String releaseDate);
  83 +
  84 + String findMissingToRelatedRuleChains(TenantId tenantId, EdgeId edgeId);
83 } 85 }
@@ -15,6 +15,9 @@ @@ -15,6 +15,9 @@
15 */ 15 */
16 package org.thingsboard.server.dao.edge; 16 package org.thingsboard.server.dao.edge;
17 17
  18 +import com.fasterxml.jackson.databind.ObjectMapper;
  19 +import com.fasterxml.jackson.databind.node.ArrayNode;
  20 +import com.fasterxml.jackson.databind.node.ObjectNode;
18 import com.google.common.base.Function; 21 import com.google.common.base.Function;
19 import com.google.common.util.concurrent.FutureCallback; 22 import com.google.common.util.concurrent.FutureCallback;
20 import com.google.common.util.concurrent.Futures; 23 import com.google.common.util.concurrent.Futures;
@@ -54,10 +57,13 @@ import org.thingsboard.server.common.data.id.TenantId; @@ -54,10 +57,13 @@ import org.thingsboard.server.common.data.id.TenantId;
54 import org.thingsboard.server.common.data.id.UserId; 57 import org.thingsboard.server.common.data.id.UserId;
55 import org.thingsboard.server.common.data.page.TextPageData; 58 import org.thingsboard.server.common.data.page.TextPageData;
56 import org.thingsboard.server.common.data.page.TextPageLink; 59 import org.thingsboard.server.common.data.page.TextPageLink;
  60 +import org.thingsboard.server.common.data.page.TimePageData;
  61 +import org.thingsboard.server.common.data.page.TimePageLink;
57 import org.thingsboard.server.common.data.relation.EntityRelation; 62 import org.thingsboard.server.common.data.relation.EntityRelation;
58 import org.thingsboard.server.common.data.relation.EntitySearchDirection; 63 import org.thingsboard.server.common.data.relation.EntitySearchDirection;
59 import org.thingsboard.server.common.data.relation.RelationTypeGroup; 64 import org.thingsboard.server.common.data.relation.RelationTypeGroup;
60 import org.thingsboard.server.common.data.rule.RuleChain; 65 import org.thingsboard.server.common.data.rule.RuleChain;
  66 +import org.thingsboard.server.common.data.rule.RuleChainConnectionInfo;
61 import org.thingsboard.server.dao.customer.CustomerDao; 67 import org.thingsboard.server.dao.customer.CustomerDao;
62 import org.thingsboard.server.dao.entity.AbstractEntityService; 68 import org.thingsboard.server.dao.entity.AbstractEntityService;
63 import org.thingsboard.server.dao.exception.DataValidationException; 69 import org.thingsboard.server.dao.exception.DataValidationException;
@@ -100,6 +106,8 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic @@ -100,6 +106,8 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
100 public static final String INCORRECT_CUSTOMER_ID = "Incorrect customerId "; 106 public static final String INCORRECT_CUSTOMER_ID = "Incorrect customerId ";
101 public static final String INCORRECT_EDGE_ID = "Incorrect edgeId "; 107 public static final String INCORRECT_EDGE_ID = "Incorrect edgeId ";
102 108
  109 + private static final ObjectMapper mapper = new ObjectMapper();
  110 +
103 private static final int DEFAULT_LIMIT = 100; 111 private static final int DEFAULT_LIMIT = 100;
104 112
105 private RestTemplate restTemplate; 113 private RestTemplate restTemplate;
@@ -575,6 +583,56 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic @@ -575,6 +583,56 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
575 return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}", (Object) null, Object.class, params); 583 return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}", (Object) null, Object.class, params);
576 } 584 }
577 585
  586 + @Override
  587 + public String findMissingToRelatedRuleChains(TenantId tenantId, EdgeId edgeId) {
  588 + List<RuleChain> edgeRuleChains = findEdgeRuleChains(tenantId, edgeId);
  589 + List<RuleChainId> edgeRuleChainIds = edgeRuleChains.stream().map(IdBased::getId).collect(Collectors.toList());
  590 + ObjectNode result = mapper.createObjectNode();
  591 + for (RuleChain edgeRuleChain : edgeRuleChains) {
  592 + List<RuleChainConnectionInfo> connectionInfos =
  593 + ruleChainService.loadRuleChainMetaData(edgeRuleChain.getTenantId(), edgeRuleChain.getId()).getRuleChainConnections();
  594 + if (connectionInfos != null && !connectionInfos.isEmpty()) {
  595 + List<RuleChainId> connectedRuleChains =
  596 + connectionInfos.stream().map(RuleChainConnectionInfo::getTargetRuleChainId).collect(Collectors.toList());
  597 + List<String> missingRuleChains = new ArrayList<>();
  598 + for (RuleChainId connectedRuleChain : connectedRuleChains) {
  599 + if (!edgeRuleChainIds.contains(connectedRuleChain)) {
  600 + RuleChain ruleChainById = ruleChainService.findRuleChainById(tenantId, connectedRuleChain);
  601 + missingRuleChains.add(ruleChainById.getName());
  602 + }
  603 + }
  604 + if (!missingRuleChains.isEmpty()) {
  605 + ArrayNode array = mapper.createArrayNode();
  606 + for (String missingRuleChain : missingRuleChains) {
  607 + array.add(missingRuleChain);
  608 + }
  609 + result.set(edgeRuleChain.getName(), array);
  610 + }
  611 + }
  612 + }
  613 + return result.toString();
  614 + }
  615 +
  616 + private List<RuleChain> findEdgeRuleChains(TenantId tenantId, EdgeId edgeId) {
  617 + List<RuleChain> result = new ArrayList<>();
  618 + TimePageLink pageLink = new TimePageLink(DEFAULT_LIMIT);
  619 + TimePageData<RuleChain> pageData;
  620 + try {
  621 + do {
  622 + pageData = ruleChainService.findRuleChainsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
  623 + if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
  624 + result.addAll(pageData.getData());
  625 + if (pageData.hasNext()) {
  626 + pageLink = pageData.getNextPageLink();
  627 + }
  628 + }
  629 + } while (pageData != null && pageData.hasNext());
  630 + } catch (Exception e) {
  631 + log.error("[{}] Can't find edge rule chains [{}]", tenantId, edgeId, e);
  632 + }
  633 + return result;
  634 + }
  635 +
578 private void initRestTemplate() { 636 private void initRestTemplate() {
579 boolean jdkHttpClientEnabled = isNotEmpty(System.getProperty("tb.proxy.jdk")) && System.getProperty("tb.proxy.jdk").equalsIgnoreCase("true"); 637 boolean jdkHttpClientEnabled = isNotEmpty(System.getProperty("tb.proxy.jdk")) && System.getProperty("tb.proxy.jdk").equalsIgnoreCase("true");
580 boolean systemProxyEnabled = isNotEmpty(System.getProperty("tb.proxy.system")) && System.getProperty("tb.proxy.system").equalsIgnoreCase("true"); 638 boolean systemProxyEnabled = isNotEmpty(System.getProperty("tb.proxy.system")) && System.getProperty("tb.proxy.system").equalsIgnoreCase("true");
@@ -2384,7 +2384,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { @@ -2384,7 +2384,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
2384 } 2384 }
2385 2385
2386 public void syncEdge(EdgeId edgeId) { 2386 public void syncEdge(EdgeId edgeId) {
2387 - restTemplate.postForEntity(baseURL + "/api/edge/sync", edgeId, EdgeId.class); 2387 + Map<String, String> params = new HashMap<>();
  2388 + params.put("edgeId", edgeId.toString());
  2389 + restTemplate.postForEntity(baseURL + "/api/edge/sync/{edgeId}", null, EdgeId.class, params);
2388 } 2390 }
2389 2391
2390 @Deprecated 2392 @Deprecated
@@ -297,8 +297,8 @@ function EdgeService($http, $q, customerService) { @@ -297,8 +297,8 @@ function EdgeService($http, $q, customerService) {
297 297
298 function syncEdge(edgeId) { 298 function syncEdge(edgeId) {
299 var deferred = $q.defer(); 299 var deferred = $q.defer();
300 - var url = '/api/edge/sync';  
301 - $http.post(url, edgeId).then(function success(response) { 300 + var url = '/api/edge/sync/' + edgeId;
  301 + $http.post(url, null).then(function success(response) {
302 deferred.resolve(response); 302 deferred.resolve(response);
303 }, function fail(response) { 303 }, function fail(response) {
304 deferred.reject(response.data); 304 deferred.reject(response.data);
@@ -70,7 +70,7 @@ export default function EdgeDirective($compile, $templateCache, $translate, $mdD @@ -70,7 +70,7 @@ export default function EdgeDirective($compile, $templateCache, $translate, $mdD
70 }; 70 };
71 71
72 scope.onEdgeSync = function (edgeId) { 72 scope.onEdgeSync = function (edgeId) {
73 - edgeService.syncEdge(edgeId).then( 73 + edgeService.syncEdge(edgeId.id).then(
74 function success() { 74 function success() {
75 toast.showSuccess($translate.instant('edge.sync-message'), 750, angular.element(element).parent().parent(), 'bottom left'); 75 toast.showSuccess($translate.instant('edge.sync-message'), 750, angular.element(element).parent().parent(), 'bottom left');
76 }, 76 },