commit
2d1f84a703
@ -15,8 +15,11 @@
|
||||
*/
|
||||
package org.thingsboard.server.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -59,6 +62,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@TbCoreComponent
|
||||
@Slf4j
|
||||
@RequestMapping("/api")
|
||||
public class EdgeController extends BaseController {
|
||||
|
||||
@ -544,27 +548,6 @@ public class EdgeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object checkInstance(@RequestBody Object request) throws ThingsboardException {
|
||||
try {
|
||||
return edgeService.checkInstance(request);
|
||||
} catch (Exception e) {
|
||||
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object activateInstance(@RequestParam String licenseSecret,
|
||||
@RequestParam String releaseDate) throws ThingsboardException {
|
||||
try {
|
||||
return edgeService.activateInstance(licenseSecret, releaseDate);
|
||||
} catch (Exception e) {
|
||||
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@ -583,4 +566,29 @@ public class EdgeController extends BaseController {
|
||||
private void cleanUpLicenseKey(Edge edge) {
|
||||
edge.setEdgeLicenseKey(null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException {
|
||||
log.debug("Checking instance [{}]", request);
|
||||
try {
|
||||
return edgeService.checkInstance(request);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred: [{}]", e.getMessage(), e);
|
||||
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<JsonNode> activateInstance(@RequestParam String licenseSecret,
|
||||
@RequestParam String releaseDate) throws ThingsboardException {
|
||||
log.debug("Activating instance [{}], [{}]", licenseSecret, releaseDate);
|
||||
try {
|
||||
return edgeService.activateInstance(licenseSecret, releaseDate);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred: [{}]", e.getMessage(), e);
|
||||
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +81,11 @@
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.datastax.oss</groupId>
|
||||
<artifactId>java-driver-core</artifactId>
|
||||
|
||||
@ -15,16 +15,16 @@
|
||||
*/
|
||||
package org.thingsboard.server.dao.edge;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.edge.Edge;
|
||||
import org.thingsboard.server.common.data.edge.EdgeInfo;
|
||||
import org.thingsboard.server.common.data.edge.EdgeSearchQuery;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.DashboardId;
|
||||
import org.thingsboard.server.common.data.id.EdgeId;
|
||||
import org.thingsboard.server.common.data.id.EntityId;
|
||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
@ -86,9 +86,9 @@ public interface EdgeService {
|
||||
|
||||
PageData<EdgeId> findRelatedEdgeIdsByEntityId(TenantId tenantId, EntityId entityId, PageLink pageLink);
|
||||
|
||||
Object checkInstance(Object request);
|
||||
ResponseEntity<JsonNode> checkInstance(JsonNode request);
|
||||
|
||||
Object activateInstance(String licenseSecret, String releaseDate);
|
||||
ResponseEntity<JsonNode> activateInstance(String licenseSecret, String releaseDate);
|
||||
|
||||
String findMissingToRelatedRuleChains(TenantId tenantId, EdgeId edgeId);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
|
||||
channel = builder.build();
|
||||
EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel);
|
||||
log.info("[{}] Sending a connect request to the TB!", edgeKey);
|
||||
this.inputStream = stub.handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError));
|
||||
this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError));
|
||||
this.inputStream.onNext(RequestMsg.newBuilder()
|
||||
.setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE)
|
||||
.setConnectRequestMsg(ConnectRequestMsg.newBuilder().setEdgeRoutingKey(edgeKey).setEdgeSecret(edgeSecret).build())
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.thingsboard.server.dao.edge;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@ -34,6 +35,7 @@ import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -543,16 +545,16 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object checkInstance(Object request) {
|
||||
return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/checkInstance", request, Object.class, new Object[0]);
|
||||
public ResponseEntity<JsonNode> checkInstance(JsonNode request) {
|
||||
return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/checkInstance", request, JsonNode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object activateInstance(String edgeLicenseSecret, String releaseDate) {
|
||||
public ResponseEntity<JsonNode> activateInstance(String edgeLicenseSecret, String releaseDate) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("licenseSecret", edgeLicenseSecret);
|
||||
params.put("releaseDate", releaseDate);
|
||||
return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}", (Object) null, Object.class, params);
|
||||
return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/activateInstance?licenseSecret={licenseSecret}&releaseDate={releaseDate}", null, JsonNode.class, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -29,14 +29,14 @@
|
||||
<tb-time-unit-select [labelText]="'device-profile.edrx-cycle'"
|
||||
[requiredText]="'device-profile.edrx-cycle-required'"
|
||||
[patternText]="'device-profile.edrx-cycle-pattern'"
|
||||
[minTime]="20480"
|
||||
[minTime]="5120"
|
||||
[minText]="'device-profile.edrx-cycle-min'"
|
||||
formControlName="edrxCycle">
|
||||
</tb-time-unit-select>
|
||||
<tb-time-unit-select [labelText]="'device-profile.paging-transmission-window'"
|
||||
[requiredText]="'device-profile.paging-transmission-window-required'"
|
||||
[patternText]="'device-profile.paging-transmission-window-pattern'"
|
||||
[minTime]="2000"
|
||||
[minTime]="1280"
|
||||
[minText]="'device-profile.paging-transmission-window-min'"
|
||||
formControlName="pagingTransmissionWindow">
|
||||
</tb-time-unit-select>
|
||||
@ -45,7 +45,7 @@
|
||||
[labelText]="'device-profile.psm-activity-timer'"
|
||||
[requiredText]="'device-profile.psm-activity-timer-required'"
|
||||
[patternText]="'device-profile.psm-activity-timer-pattern'"
|
||||
[minTime]="2000"
|
||||
[minTime]="1280"
|
||||
[minText]="'device-profile.psm-activity-timer-min'"
|
||||
formControlName="psmActivityTimer">
|
||||
</tb-time-unit-select>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user