Removed edge license and cloud endpoint from edge instance - refactoring edge ce
This commit is contained in:
parent
92842e0f0e
commit
ffcc5be0ae
@ -123,7 +123,6 @@ import org.thingsboard.server.queue.provider.TbQueueProducerProvider;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.action.EntityActionService;
|
||||
import org.thingsboard.server.service.component.ComponentDiscoveryService;
|
||||
import org.thingsboard.server.service.edge.EdgeLicenseService;
|
||||
import org.thingsboard.server.service.edge.EdgeNotificationService;
|
||||
import org.thingsboard.server.service.edge.rpc.EdgeRpcService;
|
||||
import org.thingsboard.server.service.ota.OtaPackageStateService;
|
||||
@ -269,9 +268,6 @@ public abstract class BaseController {
|
||||
@Autowired(required = false)
|
||||
protected EdgeRpcService edgeGrpcService;
|
||||
|
||||
@Autowired(required = false)
|
||||
protected EdgeLicenseService edgeLicenseService;
|
||||
|
||||
@Autowired
|
||||
protected EntityActionService entityActionService;
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.thingsboard.server.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
@ -23,7 +22,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.PostMapping;
|
||||
@ -52,7 +50,6 @@ import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
|
||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||
import org.thingsboard.server.common.data.security.Authority;
|
||||
import org.thingsboard.server.dao.exception.DataValidationException;
|
||||
import org.thingsboard.server.dao.exception.IncorrectParameterException;
|
||||
import org.thingsboard.server.dao.model.ModelConstants;
|
||||
@ -118,11 +115,7 @@ public class EdgeController extends BaseController {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
Edge edge = checkEdgeId(edgeId, Operation.READ);
|
||||
if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) {
|
||||
cleanUpLicenseKey(edge);
|
||||
}
|
||||
return edge;
|
||||
return checkEdgeId(edgeId, Operation.READ);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
@ -139,11 +132,7 @@ public class EdgeController extends BaseController {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
EdgeInfo edgeInfo = checkEdgeInfoId(edgeId, Operation.READ);
|
||||
if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) {
|
||||
cleanUpLicenseKey(edgeInfo);
|
||||
}
|
||||
return edgeInfo;
|
||||
return checkEdgeInfoId(edgeId, Operation.READ);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
@ -525,11 +514,6 @@ public class EdgeController extends BaseController {
|
||||
} else {
|
||||
result = edgeService.findEdgesByTenantIdAndCustomerId(tenantId, customerId, pageLink);
|
||||
}
|
||||
if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
|
||||
for (Edge edge : result.getData()) {
|
||||
cleanUpLicenseKey(edge);
|
||||
}
|
||||
}
|
||||
return checkNotNull(result);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
@ -570,11 +554,6 @@ public class EdgeController extends BaseController {
|
||||
} else {
|
||||
result = edgeService.findEdgeInfosByTenantIdAndCustomerId(tenantId, customerId, pageLink);
|
||||
}
|
||||
if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
|
||||
for (Edge edge : result.getData()) {
|
||||
cleanUpLicenseKey(edge);
|
||||
}
|
||||
}
|
||||
return checkNotNull(result);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
@ -606,11 +585,6 @@ public class EdgeController extends BaseController {
|
||||
edgesFuture = edgeService.findEdgesByTenantIdCustomerIdAndIdsAsync(tenantId, customerId, edgeIds);
|
||||
}
|
||||
List<Edge> edges = edgesFuture.get();
|
||||
if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
|
||||
for (Edge edge : edges) {
|
||||
cleanUpLicenseKey(edge);
|
||||
}
|
||||
}
|
||||
return checkNotNull(edges);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
@ -642,11 +616,6 @@ public class EdgeController extends BaseController {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
|
||||
for (Edge edge : edges) {
|
||||
cleanUpLicenseKey(edge);
|
||||
}
|
||||
}
|
||||
return edges;
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
@ -732,39 +701,4 @@ public class EdgeController extends BaseController {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void cleanUpLicenseKey(Edge edge) {
|
||||
edge.setEdgeLicenseKey(null);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Check edge license (checkInstance)",
|
||||
notes = "Checks license request from edge service by forwarding request to license portal.",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException {
|
||||
log.debug("Checking instance [{}]", request);
|
||||
try {
|
||||
return edgeLicenseService.checkInstance(request);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred: [{}]", e.getMessage(), e);
|
||||
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Activate edge instance (activateInstance)",
|
||||
notes = "Activates edge license on license portal.",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@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 edgeLicenseService.activateInstance(licenseSecret, releaseDate);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred: [{}]", e.getMessage(), e);
|
||||
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,110 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2022 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.service.edge;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
@Service
|
||||
@TbCoreComponent
|
||||
@Slf4j
|
||||
public class DefaultEdgeLicenseService implements EdgeLicenseService {
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
private static final String EDGE_LICENSE_SERVER_ENDPOINT = "https://license.thingsboard.io";
|
||||
|
||||
@Value("${edges.enabled:false}")
|
||||
private boolean edgesEnabled;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (edgesEnabled) {
|
||||
initRestTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<JsonNode> checkInstance(JsonNode request) {
|
||||
return this.restTemplate.postForEntity(EDGE_LICENSE_SERVER_ENDPOINT + "/api/license/checkInstance", request, JsonNode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
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}", null, JsonNode.class, params);
|
||||
}
|
||||
|
||||
private void initRestTemplate() {
|
||||
boolean jdkHttpClientEnabled = isNotEmpty(System.getProperty("tb.proxy.jdk")) && System.getProperty("tb.proxy.jdk").equalsIgnoreCase("true");
|
||||
boolean systemProxyEnabled = isNotEmpty(System.getProperty("tb.proxy.system")) && System.getProperty("tb.proxy.system").equalsIgnoreCase("true");
|
||||
boolean proxyEnabled = isNotEmpty(System.getProperty("tb.proxy.host")) && isNotEmpty(System.getProperty("tb.proxy.port"));
|
||||
if (jdkHttpClientEnabled) {
|
||||
log.warn("Going to use plain JDK Http Client!");
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
if (proxyEnabled) {
|
||||
log.warn("Going to use Proxy Server: [{}:{}]", System.getProperty("tb.proxy.host"), System.getProperty("tb.proxy.port"));
|
||||
factory.setProxy(new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(System.getProperty("tb.proxy.host"), Integer.parseInt(System.getProperty("tb.proxy.port")))));
|
||||
}
|
||||
|
||||
this.restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
|
||||
} else {
|
||||
CloseableHttpClient httpClient;
|
||||
HttpComponentsClientHttpRequestFactory requestFactory;
|
||||
if (systemProxyEnabled) {
|
||||
log.warn("Going to use System Proxy Server!");
|
||||
httpClient = HttpClients.createSystem();
|
||||
requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||
requestFactory.setHttpClient(httpClient);
|
||||
this.restTemplate = new RestTemplate(requestFactory);
|
||||
} else if (proxyEnabled) {
|
||||
log.warn("Going to use Proxy Server: [{}:{}]", System.getProperty("tb.proxy.host"), System.getProperty("tb.proxy.port"));
|
||||
httpClient = HttpClients.custom().setSSLHostnameVerifier(new DefaultHostnameVerifier()).setProxy(new HttpHost(System.getProperty("tb.proxy.host"), Integer.parseInt(System.getProperty("tb.proxy.port")), "https")).build();
|
||||
requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||
requestFactory.setHttpClient(httpClient);
|
||||
this.restTemplate = new RestTemplate(requestFactory);
|
||||
} else {
|
||||
httpClient = HttpClients.custom().setSSLHostnameVerifier(new DefaultHostnameVerifier()).build();
|
||||
requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||
requestFactory.setHttpClient(httpClient);
|
||||
this.restTemplate = new RestTemplate(requestFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,12 +55,6 @@ public class EdgeBulkImportService extends AbstractBulkImportService<Edge> {
|
||||
case DESCRIPTION:
|
||||
additionalInfo.set("description", new TextNode(value));
|
||||
break;
|
||||
case EDGE_LICENSE_KEY:
|
||||
entity.setEdgeLicenseKey(value);
|
||||
break;
|
||||
case CLOUD_ENDPOINT:
|
||||
entity.setCloudEndpoint(value);
|
||||
break;
|
||||
case ROUTING_KEY:
|
||||
entity.setRoutingKey(value);
|
||||
break;
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2022 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.service.edge;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
public interface EdgeLicenseService {
|
||||
|
||||
ResponseEntity<JsonNode> checkInstance(JsonNode request);
|
||||
|
||||
ResponseEntity<JsonNode> activateInstance(String licenseSecret, String releaseDate);
|
||||
}
|
||||
@ -690,8 +690,6 @@ public final class EdgeGrpcSession implements Closeable {
|
||||
.setType(edge.getType())
|
||||
.setRoutingKey(edge.getRoutingKey())
|
||||
.setSecret(edge.getSecret())
|
||||
.setEdgeLicenseKey(edge.getEdgeLicenseKey())
|
||||
.setCloudEndpoint(edge.getCloudEndpoint())
|
||||
.setAdditionalInfo(JacksonUtil.toString(edge.getAdditionalInfo()))
|
||||
.setCloudType("CE");
|
||||
if (edge.getCustomerId() != null) {
|
||||
|
||||
@ -45,8 +45,6 @@ public enum BulkImportColumnType {
|
||||
LWM2M_SERVER_CLIENT_SECRET_KEY("clientSecretKey"),
|
||||
IS_GATEWAY,
|
||||
DESCRIPTION,
|
||||
EDGE_LICENSE_KEY,
|
||||
CLOUD_ENDPOINT,
|
||||
ROUTING_KEY,
|
||||
SECRET;
|
||||
|
||||
|
||||
@ -606,8 +606,6 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
|
||||
edge.setType(type);
|
||||
edge.setSecret(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setEdgeLicenseKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setCloudEndpoint("http://localhost:8080");
|
||||
return edge;
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,8 +105,6 @@ public abstract class BaseEdgeControllerTest extends AbstractControllerTest {
|
||||
Assert.assertNotNull(savedEdge.getCustomerId());
|
||||
Assert.assertEquals(NULL_UUID, savedEdge.getCustomerId().getId());
|
||||
Assert.assertEquals(edge.getName(), savedEdge.getName());
|
||||
Assert.assertTrue(StringUtils.isNoneBlank(savedEdge.getEdgeLicenseKey()));
|
||||
Assert.assertTrue(StringUtils.isNoneBlank(savedEdge.getCloudEndpoint()));
|
||||
|
||||
savedEdge.setName("My new edge");
|
||||
doPost("/api/edge", savedEdge, Edge.class);
|
||||
|
||||
@ -57,12 +57,6 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H
|
||||
@NoXss
|
||||
@Length(fieldName = "secret")
|
||||
private String secret;
|
||||
@NoXss
|
||||
@Length(fieldName = "edgeLicenseKey", max = 30)
|
||||
private String edgeLicenseKey;
|
||||
@NoXss
|
||||
@Length(fieldName = "cloudEndpoint")
|
||||
private String cloudEndpoint;
|
||||
|
||||
public Edge() {
|
||||
super();
|
||||
@ -82,8 +76,6 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H
|
||||
this.name = edge.getName();
|
||||
this.routingKey = edge.getRoutingKey();
|
||||
this.secret = edge.getSecret();
|
||||
this.edgeLicenseKey = edge.getEdgeLicenseKey();
|
||||
this.cloudEndpoint = edge.getCloudEndpoint();
|
||||
}
|
||||
|
||||
public void update(Edge edge) {
|
||||
@ -95,8 +87,6 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H
|
||||
this.name = edge.getName();
|
||||
this.routingKey = edge.getRoutingKey();
|
||||
this.secret = edge.getSecret();
|
||||
this.edgeLicenseKey = edge.getEdgeLicenseKey();
|
||||
this.cloudEndpoint = edge.getCloudEndpoint();
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 1, value = "JSON object with the Edge Id. " +
|
||||
@ -162,14 +152,4 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H
|
||||
return this.secret;
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 11, required = true, value = "Edge license key obtained from license portal", example = "AgcnI24Z06XC&m6Sxsdgf")
|
||||
public String getEdgeLicenseKey() {
|
||||
return this.edgeLicenseKey;
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 12, required = true, value = "Edge uses this cloud URL to activate and periodically check it's license", example = "https://thingsboard.cloud")
|
||||
public String getCloudEndpoint() {
|
||||
return this.cloudEndpoint;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -99,10 +99,8 @@ message EdgeConfiguration {
|
||||
string type = 8;
|
||||
string routingKey = 9;
|
||||
string secret = 10;
|
||||
string edgeLicenseKey = 11;
|
||||
string cloudEndpoint = 12;
|
||||
string additionalInfo = 13;
|
||||
string cloudType = 14;
|
||||
string additionalInfo = 11;
|
||||
string cloudType = 12;
|
||||
}
|
||||
|
||||
enum UpdateMsgType {
|
||||
|
||||
@ -404,12 +404,6 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
|
||||
if (StringUtils.isEmpty(edge.getRoutingKey())) {
|
||||
throw new DataValidationException("Edge routing key should be specified!");
|
||||
}
|
||||
if (StringUtils.isEmpty(edge.getEdgeLicenseKey())) {
|
||||
throw new DataValidationException("Edge license key should be specified!");
|
||||
}
|
||||
if (StringUtils.isEmpty(edge.getCloudEndpoint())) {
|
||||
throw new DataValidationException("Cloud endpoint should be specified!");
|
||||
}
|
||||
if (edge.getTenantId() == null) {
|
||||
throw new DataValidationException("Edge should be assigned to tenant!");
|
||||
} else {
|
||||
|
||||
@ -544,8 +544,6 @@ public class ModelConstants {
|
||||
|
||||
public static final String EDGE_ROUTING_KEY_PROPERTY = "routing_key";
|
||||
public static final String EDGE_SECRET_PROPERTY = "secret";
|
||||
public static final String EDGE_LICENSE_KEY_PROPERTY = "edge_license_key";
|
||||
public static final String EDGE_CLOUD_ENDPOINT_KEY_PROPERTY = "cloud_endpoint";
|
||||
|
||||
/**
|
||||
* Edge queue constants.
|
||||
|
||||
@ -35,10 +35,8 @@ import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_CLOUD_ENDPOINT_KEY_PROPERTY;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_CUSTOMER_ID_PROPERTY;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_LABEL_PROPERTY;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_LICENSE_KEY_PROPERTY;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_NAME_PROPERTY;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_ROOT_RULE_CHAIN_ID_PROPERTY;
|
||||
import static org.thingsboard.server.dao.model.ModelConstants.EDGE_ROUTING_KEY_PROPERTY;
|
||||
@ -80,12 +78,6 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
|
||||
@Column(name = EDGE_SECRET_PROPERTY)
|
||||
private String secret;
|
||||
|
||||
@Column(name = EDGE_LICENSE_KEY_PROPERTY)
|
||||
private String edgeLicenseKey;
|
||||
|
||||
@Column(name = EDGE_CLOUD_ENDPOINT_KEY_PROPERTY)
|
||||
private String cloudEndpoint;
|
||||
|
||||
@Type(type = "json")
|
||||
@Column(name = ModelConstants.EDGE_ADDITIONAL_INFO_PROPERTY)
|
||||
private JsonNode additionalInfo;
|
||||
@ -113,8 +105,6 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
|
||||
this.label = edge.getLabel();
|
||||
this.routingKey = edge.getRoutingKey();
|
||||
this.secret = edge.getSecret();
|
||||
this.edgeLicenseKey = edge.getEdgeLicenseKey();
|
||||
this.cloudEndpoint = edge.getCloudEndpoint();
|
||||
this.additionalInfo = edge.getAdditionalInfo();
|
||||
}
|
||||
|
||||
@ -130,8 +120,6 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
|
||||
this.searchText = edgeEntity.getSearchText();
|
||||
this.routingKey = edgeEntity.getRoutingKey();
|
||||
this.secret = edgeEntity.getSecret();
|
||||
this.edgeLicenseKey = edgeEntity.getEdgeLicenseKey();
|
||||
this.cloudEndpoint = edgeEntity.getCloudEndpoint();
|
||||
this.additionalInfo = edgeEntity.getAdditionalInfo();
|
||||
}
|
||||
|
||||
@ -166,8 +154,6 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
|
||||
edge.setLabel(label);
|
||||
edge.setRoutingKey(routingKey);
|
||||
edge.setSecret(secret);
|
||||
edge.setEdgeLicenseKey(edgeLicenseKey);
|
||||
edge.setCloudEndpoint(cloudEndpoint);
|
||||
edge.setAdditionalInfo(additionalInfo);
|
||||
return edge;
|
||||
}
|
||||
|
||||
@ -601,8 +601,6 @@ CREATE TABLE IF NOT EXISTS edge (
|
||||
label varchar(255),
|
||||
routing_key varchar(255),
|
||||
secret varchar(255),
|
||||
edge_license_key varchar(30),
|
||||
cloud_endpoint varchar(255),
|
||||
search_text varchar(255),
|
||||
tenant_id uuid,
|
||||
CONSTRAINT edge_name_unq_key UNIQUE (tenant_id, name),
|
||||
|
||||
@ -249,8 +249,6 @@ public abstract class AbstractServiceTest {
|
||||
edge.setType(type);
|
||||
edge.setSecret(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setEdgeLicenseKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setCloudEndpoint("http://localhost:8080");
|
||||
return edge;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,13 +32,11 @@ import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.common.data.page.SortOrder;
|
||||
import org.thingsboard.server.common.data.page.TimePageLink;
|
||||
import org.thingsboard.server.dao.exception.DataValidationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@ -420,8 +418,6 @@ public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
|
||||
edge.setType("default");
|
||||
edge.setSecret(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setEdgeLicenseKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setCloudEndpoint("http://localhost:8080");
|
||||
edge = edgeService.saveEdge(edge, true);
|
||||
try {
|
||||
dashboardService.assignDashboardToEdge(tenantId, dashboard.getId(), edge.getId());
|
||||
|
||||
@ -314,8 +314,6 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest {
|
||||
edge.setLabel("EdgeLabel" + i);
|
||||
edge.setSecret(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setEdgeLicenseKey(RandomStringUtils.randomAlphanumeric(20));
|
||||
edge.setCloudEndpoint("http://localhost:8080");
|
||||
return edge;
|
||||
}
|
||||
|
||||
|
||||
@ -1050,8 +1050,6 @@ export class EntityService {
|
||||
additionalInfo: {
|
||||
description: edgeEntityData.description
|
||||
},
|
||||
edgeLicenseKey: edgeEntityData.edgeLicenseKey,
|
||||
cloudEndpoint: edgeEntityData.cloudEndpoint !== '' ? edgeEntityData.cloudEndpoint : window.location.origin,
|
||||
routingKey: edgeEntityData.routingKey !== '' ? edgeEntityData.routingKey : guid(),
|
||||
secret: edgeEntityData.secret !== '' ? edgeEntityData.secret : generateSecret(20)
|
||||
};
|
||||
@ -1099,8 +1097,6 @@ export class EntityService {
|
||||
const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
||||
if (result.label !== edgeEntityData.label ||
|
||||
result.type !== edgeEntityData.type ||
|
||||
(edgeEntityData.cloudEndpoint !== '' && result.cloudEndpoint !== edgeEntityData.cloudEndpoint) ||
|
||||
(edgeEntityData.edgeLicenseKey !== '' && result.edgeLicenseKey !== edgeEntityData.edgeLicenseKey) ||
|
||||
(edgeEntityData.routingKey !== '' && result.routingKey !== edgeEntityData.routingKey) ||
|
||||
(edgeEntityData.secret !== '' && result.secret !== edgeEntityData.secret) ||
|
||||
additionalInfo.description !== edgeEntityData.description) {
|
||||
@ -1108,12 +1104,6 @@ export class EntityService {
|
||||
result.type = edgeEntityData.type;
|
||||
result.additionalInfo = additionalInfo;
|
||||
result.additionalInfo.description = edgeEntityData.description;
|
||||
if (edgeEntityData.cloudEndpoint !== '') {
|
||||
result.cloudEndpoint = edgeEntityData.cloudEndpoint;
|
||||
}
|
||||
if (edgeEntityData.edgeLicenseKey !== '') {
|
||||
result.edgeLicenseKey = edgeEntityData.edgeLicenseKey;
|
||||
}
|
||||
if (edgeEntityData.routingKey !== '') {
|
||||
result.routingKey = edgeEntityData.routingKey;
|
||||
}
|
||||
|
||||
@ -66,8 +66,6 @@ export enum ImportEntityColumnType {
|
||||
lwm2mServerClientSecretKey = 'LWM2M_SERVER_CLIENT_SECRET_KEY',
|
||||
isGateway = 'IS_GATEWAY',
|
||||
description = 'DESCRIPTION',
|
||||
edgeLicenseKey = 'EDGE_LICENSE_KEY',
|
||||
cloudEndpoint = 'CLOUD_ENDPOINT',
|
||||
routingKey = 'ROUTING_KEY',
|
||||
secret = 'SECRET'
|
||||
}
|
||||
@ -102,8 +100,6 @@ export const importEntityColumnTypeTranslations = new Map<ImportEntityColumnType
|
||||
[ImportEntityColumnType.lwm2mServerClientSecretKey, 'import.column-type.lwm2m.lwm2m-server-secret-key'],
|
||||
[ImportEntityColumnType.isGateway, 'import.column-type.isgateway'],
|
||||
[ImportEntityColumnType.description, 'import.column-type.description'],
|
||||
[ImportEntityColumnType.edgeLicenseKey, 'import.column-type.edge-license-key'],
|
||||
[ImportEntityColumnType.cloudEndpoint, 'import.column-type.cloud-endpoint'],
|
||||
[ImportEntityColumnType.routingKey, 'import.column-type.routing-key'],
|
||||
[ImportEntityColumnType.secret, 'import.column-type.secret']
|
||||
]
|
||||
|
||||
@ -116,8 +116,6 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
|
||||
break;
|
||||
case EntityType.EDGE:
|
||||
this.columnTypes.push(
|
||||
{ value: ImportEntityColumnType.edgeLicenseKey },
|
||||
{ value: ImportEntityColumnType.cloudEndpoint },
|
||||
{ value: ImportEntityColumnType.routingKey },
|
||||
{ value: ImportEntityColumnType.secret }
|
||||
);
|
||||
@ -145,8 +143,6 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
|
||||
const isSelectType = this.columns.findIndex((column) => column.type === ImportEntityColumnType.type) > -1;
|
||||
const isSelectLabel = this.columns.findIndex((column) => column.type === ImportEntityColumnType.label) > -1;
|
||||
const isSelectDescription = this.columns.findIndex((column) => column.type === ImportEntityColumnType.description) > -1;
|
||||
const isSelectEdgeLicenseKey = this.columns.findIndex((column) => column.type === ImportEntityColumnType.edgeLicenseKey) > -1;
|
||||
const isSelectCloudEndpoint = this.columns.findIndex((column) => column.type === ImportEntityColumnType.cloudEndpoint) > -1;
|
||||
const isSelectRoutingKey = this.columns.findIndex((column) => column.type === ImportEntityColumnType.routingKey) > -1;
|
||||
const isSelectSecret = this.columns.findIndex((column) => column.type === ImportEntityColumnType.secret) > -1;
|
||||
const hasInvalidColumn = this.columns.findIndex((column) => !this.columnValid(column)) > -1;
|
||||
@ -171,14 +167,6 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
|
||||
});
|
||||
}
|
||||
|
||||
const edgeLicenseKeyColumnType = this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.edgeLicenseKey);
|
||||
if (edgeLicenseKeyColumnType) {
|
||||
edgeLicenseKeyColumnType.disabled = isSelectEdgeLicenseKey;
|
||||
}
|
||||
const cloudEndpointColumnType = this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.cloudEndpoint);
|
||||
if (cloudEndpointColumnType) {
|
||||
cloudEndpointColumnType.disabled = isSelectCloudEndpoint;
|
||||
}
|
||||
const routingKeyColumnType = this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.routingKey);
|
||||
if (routingKeyColumnType) {
|
||||
routingKeyColumnType.disabled = isSelectRoutingKey;
|
||||
|
||||
@ -141,32 +141,6 @@
|
||||
[required]="true"
|
||||
[entityType]="entityType.EDGE">
|
||||
</tb-entity-subtype-autocomplete>
|
||||
<div [fxShow]="edgeScope !== 'customer_user'">
|
||||
<div class="tb-hint" [innerHTML]="'edge.edge-license-key-hint' | translate"></div>
|
||||
<mat-form-field class="mat-block">
|
||||
<mat-label translate>edge.edge-license-key</mat-label>
|
||||
<input matInput formControlName="edgeLicenseKey" required>
|
||||
<mat-error *ngIf="entityForm.get('edgeLicenseKey').hasError('required')">
|
||||
{{ 'edge.edge-license-key-required' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="entityForm.get('edgeLicenseKey').hasError('maxlength')">
|
||||
{{ 'edge.edge-license-key-max-length' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div [fxShow]="edgeScope !== 'customer_user'">
|
||||
<div translate class="tb-hint">edge.cloud-endpoint-hint</div>
|
||||
<mat-form-field class="mat-block">
|
||||
<mat-label translate>edge.cloud-endpoint</mat-label>
|
||||
<input matInput formControlName="cloudEndpoint" required>
|
||||
<mat-error *ngIf="entityForm.get('cloudEndpoint').hasError('required')">
|
||||
{{ 'edge.cloud-endpoint-required' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="entityForm.get('cloudEndpoint').hasError('maxlength')">
|
||||
{{ 'edge.cloud-endpoint-max-length' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div fxLayout="row" [fxShow]="edgeScope !== 'customer_user'">
|
||||
<mat-form-field class="mat-block" fxFlex>
|
||||
|
||||
@ -49,9 +49,6 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
|
||||
|
||||
ngOnInit() {
|
||||
this.edgeScope = this.entitiesTableConfig.componentsData.edgeScope;
|
||||
this.entityForm.patchValue({
|
||||
cloudEndpoint: window.location.origin
|
||||
});
|
||||
super.ngOnInit();
|
||||
}
|
||||
|
||||
@ -73,8 +70,6 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
|
||||
name: [entity ? entity.name : '', [Validators.required, Validators.maxLength(255)]],
|
||||
type: [entity?.type ? entity.type : 'default', [Validators.required, Validators.maxLength(255)]],
|
||||
label: [entity ? entity.label : '', Validators.maxLength(255)],
|
||||
cloudEndpoint: [null, [Validators.required, Validators.maxLength(255)]],
|
||||
edgeLicenseKey: ['', [Validators.required, Validators.maxLength(30)]],
|
||||
routingKey: this.fb.control({value: entity ? entity.routingKey : null, disabled: true}),
|
||||
secret: this.fb.control({value: entity ? entity.secret : null, disabled: true}),
|
||||
additionalInfo: this.fb.group(
|
||||
@ -93,8 +88,6 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
|
||||
name: entity.name,
|
||||
type: entity.type,
|
||||
label: entity.label,
|
||||
cloudEndpoint: entity.cloudEndpoint ? entity.cloudEndpoint : window.location.origin,
|
||||
edgeLicenseKey: entity.edgeLicenseKey,
|
||||
routingKey: entity.routingKey,
|
||||
secret: entity.secret,
|
||||
additionalInfo: {
|
||||
|
||||
@ -30,8 +30,6 @@ export interface Edge extends BaseData<EdgeId> {
|
||||
type: string;
|
||||
secret: string;
|
||||
routingKey: string;
|
||||
cloudEndpoint: string;
|
||||
edgeLicenseKey: string;
|
||||
label?: string;
|
||||
additionalInfo?: any;
|
||||
rootRuleChainId?: RuleChainId;
|
||||
|
||||
@ -56,8 +56,6 @@ export interface ImportEntityData {
|
||||
export interface EdgeImportEntityData extends ImportEntityData {
|
||||
secret: string;
|
||||
routingKey: string;
|
||||
cloudEndpoint: string;
|
||||
edgeLicenseKey: string;
|
||||
}
|
||||
|
||||
export interface ImportEntitiesResultInfo {
|
||||
|
||||
@ -1389,12 +1389,6 @@
|
||||
"name": "Název",
|
||||
"name-starts-with": "Název edge začíná",
|
||||
"name-required": "Název je povinný.",
|
||||
"edge-license-key": "Licenční klíč edge",
|
||||
"edge-license-key-required": "Licenční klíč edge je povinný.",
|
||||
"edge-license-key-hint": "Pro získání licence jděte na <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> a vyberte is vhodnou licenci.",
|
||||
"cloud-endpoint": "Cloud Endpoint",
|
||||
"cloud-endpoint-required": "Cloud Endpoint je povinný.",
|
||||
"cloud-endpoint-hint": "Edge vyžaduje HTTP(s) přístup do Cloudu (ThingsBoard CE/PE) pro ověření licenčního klíče. Zadejte prosím Cloud URL, ke které se může edge připojit.",
|
||||
"description": "Popis",
|
||||
"details": "Detail",
|
||||
"events": "Události",
|
||||
@ -2168,8 +2162,6 @@
|
||||
"isgateway": "Je bránou",
|
||||
"activity-time-from-gateway-device": "Čas aktivity ze zařízení brány",
|
||||
"description": "Popis",
|
||||
"edge-license-key": "Licenční klíč",
|
||||
"cloud-endpoint": "Cloud Endpoint",
|
||||
"routing-key": "Klíč edge",
|
||||
"secret": "Edge secret"
|
||||
},
|
||||
|
||||
@ -752,12 +752,6 @@
|
||||
"name": "Name",
|
||||
"name-starts-with": "Der Kantenname beginnt mit",
|
||||
"name-required": "Name ist erforderlich.",
|
||||
"edge-license-key": "Edge Lizenzschlüssel",
|
||||
"edge-license-key-required": "Edge Lizenzschlüssel ist erforderlich.",
|
||||
"edge-license-key-hint": "Um Ihre Lizenz zu erhalten, navigieren Sie zur <a href='https://thingsboard.io/pricing/?active=thingsboard-edge'arget='_blank'> Preisseite </a> und wählen Sie die beste Lizenzoption für Ihre aus Fall.",
|
||||
"cloud-endpoint": "Cloud-Endpunkt",
|
||||
"cloud-endpoint-required": "Cloud-Endpunkt ist erforderlich.",
|
||||
"cloud-endpoint-hint": "Edge erfordert HTTP-Zugriff auf die Cloud (ThingsBoard CE / PE), um den Lizenzschlüssel zu überprüfen. Bitte geben Sie die Cloud-URL an, zu der Edge eine Verbindung herstellen kann.",
|
||||
"description": "Beschreibung",
|
||||
"details": "Details",
|
||||
"events": "Ereignisse",
|
||||
|
||||
@ -1487,14 +1487,6 @@
|
||||
"name": "Name",
|
||||
"name-starts-with": "Edge name starts with",
|
||||
"name-required": "Name is required.",
|
||||
"edge-license-key": "Edge License Key",
|
||||
"edge-license-key-required": "Edge License Key is required.",
|
||||
"edge-license-key-max-length": "Edge License Key should be less than 31",
|
||||
"edge-license-key-hint": "To obtain your license please navigate to the <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> and select the best license option for your case.",
|
||||
"cloud-endpoint": "Cloud Endpoint",
|
||||
"cloud-endpoint-required": "Cloud Endpoint is required.",
|
||||
"cloud-endpoint-max-length": "Cloud Endpoint should be less than 256",
|
||||
"cloud-endpoint-hint": "Edge requires HTTP(s) access to Cloud (ThingsBoard CE/PE) to verify the license key. Please specify Cloud URL that Edge is able to connect to.",
|
||||
"description": "Description",
|
||||
"details": "Details",
|
||||
"events": "Events",
|
||||
@ -2300,8 +2292,6 @@
|
||||
"isgateway": "Is Gateway",
|
||||
"activity-time-from-gateway-device": "Activity time from gateway device",
|
||||
"description": "Description",
|
||||
"edge-license-key": "License Key",
|
||||
"cloud-endpoint": "Cloud Endpoint",
|
||||
"routing-key": "Edge key",
|
||||
"secret": "Edge secret"
|
||||
},
|
||||
|
||||
@ -1126,12 +1126,6 @@
|
||||
"name": "Nombre",
|
||||
"name-starts-with": "Edge name starts with",
|
||||
"name-required": "Se requiere nombre",
|
||||
"edge-license-key": "Edge Clave de licencia",
|
||||
"edge-license-key-required": "Se requiere edge clave de licencia",
|
||||
"edge-license-key-hint": "Para obtener su licencia, vaya a la <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'> página de precios </a> y seleccione la mejor opción de licencia para su caso.",
|
||||
"cloud-endpoint": "Punto final de la nube",
|
||||
"cloud-endpoint-required": "Se requiere punto final de la nube",
|
||||
"cloud-endpoint-hint": "Edge requiere acceso HTTP (s) a la nube (ThingsBoard CE / PE) para verificar la clave de licencia. Especifique la URL de la nube a la que Edge puede conectarse.",
|
||||
"description": "Descripción",
|
||||
"details": "Detalles",
|
||||
"events": "Eventos",
|
||||
|
||||
@ -758,12 +758,6 @@
|
||||
"name": "Nom",
|
||||
"name-starts-with": "Le nom du bord commence par",
|
||||
"name-required": "Le nom de la bordure est requis",
|
||||
"edge-license-key": "Edge Clé de licence",
|
||||
"edge-license-key-required": "La edge clé de licence est requise",
|
||||
"edge-license-key-hint": "Pour obtenir votre licence, accédez à la <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'> page de tarification</a> and select the best license option for your case.",
|
||||
"cloud-endpoint": "Clé de licence",
|
||||
"cloud-endpoint-required": "La clé de licence est requise",
|
||||
"cloud-endpoint-hint": "Edge nécessite un accès HTTP (s) au Cloud (ThingsBoard CE / PE) pour vérifier la clé de licence. Veuillez spécifier l'URL du cloud à laquelle Edge peut se connecter.",
|
||||
"description": "Dispositifs",
|
||||
"details": "Détails de l'entité",
|
||||
"events": "Événements",
|
||||
|
||||
@ -1404,12 +1404,6 @@
|
||||
"name": "Name",
|
||||
"name-starts-with": "Edge name starts with",
|
||||
"name-required": "Name is required.",
|
||||
"edge-license-key": "Edge License Key",
|
||||
"edge-license-key-required": "Edge License Key is required.",
|
||||
"edge-license-key-hint": "To obtain your license please navigate to the <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> and select the best license option for your case.",
|
||||
"cloud-endpoint": "Cloud Endpoint",
|
||||
"cloud-endpoint-required": "Cloud Endpoint is required.",
|
||||
"cloud-endpoint-hint": "Edge requires HTTP(s) access to Cloud (ThingsBoard CE/PE) to verify the license key. Please specify Cloud URL that Edge is able to connect to.",
|
||||
"description": "Description",
|
||||
"details": "Details",
|
||||
"events": "Events",
|
||||
@ -2183,8 +2177,6 @@
|
||||
"isgateway": "Ağ Geçidi",
|
||||
"activity-time-from-gateway-device": "Ağ geçidi cihazından etkinlik süresi",
|
||||
"description": "Açıklama",
|
||||
"edge-license-key": "Lisans anahtarı",
|
||||
"cloud-endpoint": "Bulut Uç Noktası",
|
||||
"routing-key": "Uç Anahtarı",
|
||||
"secret": "Uç Secret"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user