Commit 2d1f84a703e7e37d2cc89e3eeb0939905e234e84
Committed by
GitHub
Merge pull request #5137 from thingsboard/develop/3.3.1
Develop/3.3.1
Showing
6 changed files
with
48 additions
and
33 deletions
... | ... | @@ -15,8 +15,11 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.controller; |
17 | 17 | |
18 | +import com.fasterxml.jackson.databind.JsonNode; | |
18 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | +import lombok.extern.slf4j.Slf4j; | |
19 | 21 | import org.springframework.http.HttpStatus; |
22 | +import org.springframework.http.ResponseEntity; | |
20 | 23 | import org.springframework.security.access.prepost.PreAuthorize; |
21 | 24 | import org.springframework.web.bind.annotation.PathVariable; |
22 | 25 | import org.springframework.web.bind.annotation.RequestBody; |
... | ... | @@ -59,6 +62,7 @@ import java.util.stream.Collectors; |
59 | 62 | |
60 | 63 | @RestController |
61 | 64 | @TbCoreComponent |
65 | +@Slf4j | |
62 | 66 | @RequestMapping("/api") |
63 | 67 | public class EdgeController extends BaseController { |
64 | 68 | |
... | ... | @@ -544,27 +548,6 @@ public class EdgeController extends BaseController { |
544 | 548 | } |
545 | 549 | } |
546 | 550 | |
547 | - @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) | |
548 | - @ResponseBody | |
549 | - public Object checkInstance(@RequestBody Object request) throws ThingsboardException { | |
550 | - try { | |
551 | - return edgeService.checkInstance(request); | |
552 | - } catch (Exception e) { | |
553 | - throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); | |
554 | - } | |
555 | - } | |
556 | - | |
557 | - @RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST) | |
558 | - @ResponseBody | |
559 | - public Object activateInstance(@RequestParam String licenseSecret, | |
560 | - @RequestParam String releaseDate) throws ThingsboardException { | |
561 | - try { | |
562 | - return edgeService.activateInstance(licenseSecret, releaseDate); | |
563 | - } catch (Exception e) { | |
564 | - throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); | |
565 | - } | |
566 | - } | |
567 | - | |
568 | 551 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
569 | 552 | @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) |
570 | 553 | @ResponseBody |
... | ... | @@ -583,4 +566,29 @@ public class EdgeController extends BaseController { |
583 | 566 | private void cleanUpLicenseKey(Edge edge) { |
584 | 567 | edge.setEdgeLicenseKey(null); |
585 | 568 | } |
569 | + | |
570 | + @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) | |
571 | + @ResponseBody | |
572 | + public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException { | |
573 | + log.debug("Checking instance [{}]", request); | |
574 | + try { | |
575 | + return edgeService.checkInstance(request); | |
576 | + } catch (Exception e) { | |
577 | + log.error("Error occurred: [{}]", e.getMessage(), e); | |
578 | + throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); | |
579 | + } | |
580 | + } | |
581 | + | |
582 | + @RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST) | |
583 | + @ResponseBody | |
584 | + public ResponseEntity<JsonNode> activateInstance(@RequestParam String licenseSecret, | |
585 | + @RequestParam String releaseDate) throws ThingsboardException { | |
586 | + log.debug("Activating instance [{}], [{}]", licenseSecret, releaseDate); | |
587 | + try { | |
588 | + return edgeService.activateInstance(licenseSecret, releaseDate); | |
589 | + } catch (Exception e) { | |
590 | + log.error("Error occurred: [{}]", e.getMessage(), e); | |
591 | + throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); | |
592 | + } | |
593 | + } | |
586 | 594 | } | ... | ... |
... | ... | @@ -82,6 +82,11 @@ |
82 | 82 | <scope>provided</scope> |
83 | 83 | </dependency> |
84 | 84 | <dependency> |
85 | + <groupId>org.springframework</groupId> | |
86 | + <artifactId>spring-web</artifactId> | |
87 | + <scope>provided</scope> | |
88 | + </dependency> | |
89 | + <dependency> | |
85 | 90 | <groupId>com.datastax.oss</groupId> |
86 | 91 | <artifactId>java-driver-core</artifactId> |
87 | 92 | <scope>provided</scope> | ... | ... |
... | ... | @@ -15,16 +15,16 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.dao.edge; |
17 | 17 | |
18 | +import com.fasterxml.jackson.databind.JsonNode; | |
18 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | +import org.springframework.http.ResponseEntity; | |
19 | 21 | import org.thingsboard.server.common.data.EntitySubtype; |
20 | 22 | import org.thingsboard.server.common.data.edge.Edge; |
21 | 23 | import org.thingsboard.server.common.data.edge.EdgeInfo; |
22 | 24 | import org.thingsboard.server.common.data.edge.EdgeSearchQuery; |
23 | 25 | import org.thingsboard.server.common.data.id.CustomerId; |
24 | -import org.thingsboard.server.common.data.id.DashboardId; | |
25 | 26 | import org.thingsboard.server.common.data.id.EdgeId; |
26 | 27 | import org.thingsboard.server.common.data.id.EntityId; |
27 | -import org.thingsboard.server.common.data.id.RuleChainId; | |
28 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
29 | 29 | import org.thingsboard.server.common.data.page.PageData; |
30 | 30 | import org.thingsboard.server.common.data.page.PageLink; |
... | ... | @@ -86,9 +86,9 @@ public interface EdgeService { |
86 | 86 | |
87 | 87 | PageData<EdgeId> findRelatedEdgeIdsByEntityId(TenantId tenantId, EntityId entityId, PageLink pageLink); |
88 | 88 | |
89 | - Object checkInstance(Object request); | |
89 | + ResponseEntity<JsonNode> checkInstance(JsonNode request); | |
90 | 90 | |
91 | - Object activateInstance(String licenseSecret, String releaseDate); | |
91 | + ResponseEntity<JsonNode> activateInstance(String licenseSecret, String releaseDate); | |
92 | 92 | |
93 | 93 | String findMissingToRelatedRuleChains(TenantId tenantId, EdgeId edgeId); |
94 | 94 | } | ... | ... |
... | ... | @@ -92,7 +92,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { |
92 | 92 | channel = builder.build(); |
93 | 93 | EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); |
94 | 94 | log.info("[{}] Sending a connect request to the TB!", edgeKey); |
95 | - this.inputStream = stub.handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); | |
95 | + this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); | |
96 | 96 | this.inputStream.onNext(RequestMsg.newBuilder() |
97 | 97 | .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) |
98 | 98 | .setConnectRequestMsg(ConnectRequestMsg.newBuilder().setEdgeRoutingKey(edgeKey).setEdgeSecret(edgeSecret).build()) | ... | ... |
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.dao.edge; |
17 | 17 | |
18 | +import com.fasterxml.jackson.databind.JsonNode; | |
18 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
19 | 20 | import com.fasterxml.jackson.databind.node.ArrayNode; |
20 | 21 | import com.fasterxml.jackson.databind.node.ObjectNode; |
... | ... | @@ -34,6 +35,7 @@ import org.springframework.cache.Cache; |
34 | 35 | import org.springframework.cache.CacheManager; |
35 | 36 | import org.springframework.cache.annotation.CacheEvict; |
36 | 37 | import org.springframework.cache.annotation.Cacheable; |
38 | +import org.springframework.http.ResponseEntity; | |
37 | 39 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
38 | 40 | import org.springframework.http.client.SimpleClientHttpRequestFactory; |
39 | 41 | import org.springframework.stereotype.Service; |
... | ... | @@ -543,16 +545,16 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic |
543 | 545 | } |
544 | 546 | |
545 | 547 | @Override |
546 | - public Object checkInstance(Object request) { | |
547 | - return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/checkInstance", request, Object.class, new Object[0]); | |
548 | + public ResponseEntity<JsonNode> checkInstance(JsonNode request) { | |
549 | + return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/checkInstance", request, JsonNode.class); | |
548 | 550 | } |
549 | 551 | |
550 | 552 | @Override |
551 | - public Object activateInstance(String edgeLicenseSecret, String releaseDate) { | |
553 | + public ResponseEntity<JsonNode> activateInstance(String edgeLicenseSecret, String releaseDate) { | |
552 | 554 | Map<String, String> params = new HashMap<>(); |
553 | 555 | params.put("licenseSecret", edgeLicenseSecret); |
554 | 556 | params.put("releaseDate", releaseDate); |
555 | - return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}", (Object) null, Object.class, params); | |
557 | + return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}", null, JsonNode.class, params); | |
556 | 558 | } |
557 | 559 | |
558 | 560 | @Override | ... | ... |
... | ... | @@ -29,14 +29,14 @@ |
29 | 29 | <tb-time-unit-select [labelText]="'device-profile.edrx-cycle'" |
30 | 30 | [requiredText]="'device-profile.edrx-cycle-required'" |
31 | 31 | [patternText]="'device-profile.edrx-cycle-pattern'" |
32 | - [minTime]="20480" | |
32 | + [minTime]="5120" | |
33 | 33 | [minText]="'device-profile.edrx-cycle-min'" |
34 | 34 | formControlName="edrxCycle"> |
35 | 35 | </tb-time-unit-select> |
36 | 36 | <tb-time-unit-select [labelText]="'device-profile.paging-transmission-window'" |
37 | 37 | [requiredText]="'device-profile.paging-transmission-window-required'" |
38 | 38 | [patternText]="'device-profile.paging-transmission-window-pattern'" |
39 | - [minTime]="2000" | |
39 | + [minTime]="1280" | |
40 | 40 | [minText]="'device-profile.paging-transmission-window-min'" |
41 | 41 | formControlName="pagingTransmissionWindow"> |
42 | 42 | </tb-time-unit-select> |
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | [labelText]="'device-profile.psm-activity-timer'" |
46 | 46 | [requiredText]="'device-profile.psm-activity-timer-required'" |
47 | 47 | [patternText]="'device-profile.psm-activity-timer-pattern'" |
48 | - [minTime]="2000" | |
48 | + [minTime]="1280" | |
49 | 49 | [minText]="'device-profile.psm-activity-timer-min'" |
50 | 50 | formControlName="psmActivityTimer"> |
51 | 51 | </tb-time-unit-select> | ... | ... |