Showing
3 changed files
with
23 additions
and
2 deletions
@@ -104,6 +104,7 @@ import org.thingsboard.server.queue.provider.TbQueueProducerProvider; | @@ -104,6 +104,7 @@ import org.thingsboard.server.queue.provider.TbQueueProducerProvider; | ||
104 | import org.thingsboard.server.queue.util.TbCoreComponent; | 104 | import org.thingsboard.server.queue.util.TbCoreComponent; |
105 | import org.thingsboard.server.service.component.ComponentDiscoveryService; | 105 | import org.thingsboard.server.service.component.ComponentDiscoveryService; |
106 | import org.thingsboard.server.service.edge.EdgeNotificationService; | 106 | import org.thingsboard.server.service.edge.EdgeNotificationService; |
107 | +import org.thingsboard.server.service.edge.rpc.init.SyncEdgeService; | ||
107 | import org.thingsboard.server.service.queue.TbClusterService; | 108 | import org.thingsboard.server.service.queue.TbClusterService; |
108 | import org.thingsboard.server.service.security.model.SecurityUser; | 109 | import org.thingsboard.server.service.security.model.SecurityUser; |
109 | import org.thingsboard.server.service.security.permission.AccessControlService; | 110 | import org.thingsboard.server.service.security.permission.AccessControlService; |
@@ -202,12 +203,15 @@ public abstract class BaseController { | @@ -202,12 +203,15 @@ public abstract class BaseController { | ||
202 | @Autowired | 203 | @Autowired |
203 | protected TbQueueProducerProvider producerProvider; | 204 | protected TbQueueProducerProvider producerProvider; |
204 | 205 | ||
205 | - @Autowired | 206 | + @Autowired(required = false) |
206 | protected EdgeService edgeService; | 207 | protected EdgeService edgeService; |
207 | 208 | ||
208 | - @Autowired | 209 | + @Autowired(required = false) |
209 | protected EdgeNotificationService edgeNotificationService; | 210 | protected EdgeNotificationService edgeNotificationService; |
210 | 211 | ||
212 | + @Autowired(required = false) | ||
213 | + protected SyncEdgeService syncEdgeService; | ||
214 | + | ||
211 | @Value("${server.log_controller_error_stack_trace}") | 215 | @Value("${server.log_controller_error_stack_trace}") |
212 | @Getter | 216 | @Getter |
213 | private boolean logControllerErrorStackTrace; | 217 | private boolean logControllerErrorStackTrace; |
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -26,6 +26,7 @@ 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.AdminSettings; | ||
29 | import org.thingsboard.server.common.data.Customer; | 30 | import org.thingsboard.server.common.data.Customer; |
30 | import org.thingsboard.server.common.data.EntitySubtype; | 31 | import org.thingsboard.server.common.data.EntitySubtype; |
31 | import org.thingsboard.server.common.data.EntityType; | 32 | import org.thingsboard.server.common.data.EntityType; |
@@ -409,6 +410,18 @@ public class EdgeController extends BaseController { | @@ -409,6 +410,18 @@ public class EdgeController extends BaseController { | ||
409 | } | 410 | } |
410 | } | 411 | } |
411 | 412 | ||
413 | + @PreAuthorize("hasAuthority('TENANT_ADMIN')") | ||
414 | + @RequestMapping(value = "/edge/sync", method = RequestMethod.POST) | ||
415 | + public void syncEdge(@RequestBody EdgeId edgeId) throws ThingsboardException { | ||
416 | + try { | ||
417 | + edgeId = checkNotNull(edgeId); | ||
418 | + Edge edge = checkEdgeId(edgeId, Operation.READ); | ||
419 | + syncEdgeService.sync(edge); | ||
420 | + } catch (Exception e) { | ||
421 | + throw handleException(e); | ||
422 | + } | ||
423 | + } | ||
424 | + | ||
412 | @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) | 425 | @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) |
413 | @ResponseBody | 426 | @ResponseBody |
414 | public Object checkInstance(@RequestBody Object request) throws ThingsboardException { | 427 | public Object checkInstance(@RequestBody Object request) throws ThingsboardException { |
@@ -2372,6 +2372,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -2372,6 +2372,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
2372 | params).getBody(); | 2372 | params).getBody(); |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | + public void syncEdge(EdgeId edgeId) { | ||
2376 | + restTemplate.postForEntity(baseURL + "/api/edge/sync", edgeId, EdgeId.class); | ||
2377 | + } | ||
2378 | + | ||
2375 | @Deprecated | 2379 | @Deprecated |
2376 | public Optional<JsonNode> getAttributes(String accessToken, String clientKeys, String sharedKeys) { | 2380 | public Optional<JsonNode> getAttributes(String accessToken, String clientKeys, String sharedKeys) { |
2377 | Map<String, String> params = new HashMap<>(); | 2381 | Map<String, String> params = new HashMap<>(); |