Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
commit
cb2a6aba52
@ -18,9 +18,7 @@ package org.thingsboard.server.service.device;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.google.common.util.concurrent.Futures;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.MoreExecutors;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.RandomStringUtils;
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -114,6 +112,13 @@ public class DeviceProvisionServiceImpl implements DeviceProvisionService {
|
|||||||
public ProvisionResponse provisionDevice(ProvisionRequest provisionRequest) {
|
public ProvisionResponse provisionDevice(ProvisionRequest provisionRequest) {
|
||||||
String provisionRequestKey = provisionRequest.getCredentials().getProvisionDeviceKey();
|
String provisionRequestKey = provisionRequest.getCredentials().getProvisionDeviceKey();
|
||||||
String provisionRequestSecret = provisionRequest.getCredentials().getProvisionDeviceSecret();
|
String provisionRequestSecret = provisionRequest.getCredentials().getProvisionDeviceSecret();
|
||||||
|
if (provisionRequest.getDeviceName() != null) {
|
||||||
|
provisionRequest.setDeviceName(provisionRequest.getDeviceName().trim());
|
||||||
|
if (StringUtils.isEmpty(provisionRequest.getDeviceName())) {
|
||||||
|
log.warn("Provision request contains empty device name!");
|
||||||
|
throw new ProvisionFailedException(ProvisionResponseStatus.FAILURE.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(provisionRequestKey) || StringUtils.isEmpty(provisionRequestSecret)) {
|
if (StringUtils.isEmpty(provisionRequestKey) || StringUtils.isEmpty(provisionRequestSecret)) {
|
||||||
throw new ProvisionFailedException(ProvisionResponseStatus.NOT_FOUND.name());
|
throw new ProvisionFailedException(ProvisionResponseStatus.NOT_FOUND.name());
|
||||||
|
|||||||
@ -15,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.dao.device;
|
package org.thingsboard.server.dao.device;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import org.thingsboard.server.common.data.Device;
|
|
||||||
import org.thingsboard.server.common.data.DeviceProfile;
|
|
||||||
import org.thingsboard.server.dao.device.provision.ProvisionFailedException;
|
import org.thingsboard.server.dao.device.provision.ProvisionFailedException;
|
||||||
import org.thingsboard.server.dao.device.provision.ProvisionRequest;
|
import org.thingsboard.server.dao.device.provision.ProvisionRequest;
|
||||||
import org.thingsboard.server.dao.device.provision.ProvisionResponse;
|
import org.thingsboard.server.dao.device.provision.ProvisionResponse;
|
||||||
|
|||||||
@ -179,6 +179,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
ctx.close();
|
||||||
throw new RuntimeException("Unsupported topic for provisioning requests!");
|
throw new RuntimeException("Unsupported topic for provisioning requests!");
|
||||||
}
|
}
|
||||||
} catch (RuntimeException | AdaptorException e) {
|
} catch (RuntimeException | AdaptorException e) {
|
||||||
|
|||||||
@ -51,7 +51,9 @@ export enum ActionType {
|
|||||||
LOGOUT = 'LOGOUT',
|
LOGOUT = 'LOGOUT',
|
||||||
LOCKOUT = 'LOCKOUT',
|
LOCKOUT = 'LOCKOUT',
|
||||||
ASSIGNED_FROM_TENANT = 'ASSIGNED_FROM_TENANT',
|
ASSIGNED_FROM_TENANT = 'ASSIGNED_FROM_TENANT',
|
||||||
ASSIGNED_TO_TENANT = 'ASSIGNED_TO_TENANT'
|
ASSIGNED_TO_TENANT = 'ASSIGNED_TO_TENANT',
|
||||||
|
PROVISION_SUCCESS = 'PROVISION_SUCCESS',
|
||||||
|
PROVISION_FAILURE = 'PROVISION_FAILURE'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ActionStatus {
|
export enum ActionStatus {
|
||||||
@ -83,7 +85,9 @@ export const actionTypeTranslations = new Map<ActionType, string>(
|
|||||||
[ActionType.LOGOUT, 'audit-log.type-logout'],
|
[ActionType.LOGOUT, 'audit-log.type-logout'],
|
||||||
[ActionType.LOCKOUT, 'audit-log.type-lockout'],
|
[ActionType.LOCKOUT, 'audit-log.type-lockout'],
|
||||||
[ActionType.ASSIGNED_FROM_TENANT, 'audit-log.type-assigned-from-tenant'],
|
[ActionType.ASSIGNED_FROM_TENANT, 'audit-log.type-assigned-from-tenant'],
|
||||||
[ActionType.ASSIGNED_TO_TENANT, 'audit-log.type-assigned-to-tenant']
|
[ActionType.ASSIGNED_TO_TENANT, 'audit-log.type-assigned-to-tenant'],
|
||||||
|
[ActionType.PROVISION_SUCCESS, 'audit-log.type-provision-success'],
|
||||||
|
[ActionType.PROVISION_FAILURE, 'audit-log.type-provision-failure']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -472,7 +472,9 @@
|
|||||||
"search": "Search audit logs",
|
"search": "Search audit logs",
|
||||||
"clear-search": "Clear search",
|
"clear-search": "Clear search",
|
||||||
"type-assigned-from-tenant": "Assigned from Tenant",
|
"type-assigned-from-tenant": "Assigned from Tenant",
|
||||||
"type-assigned-to-tenant": "Assigned to Tenant"
|
"type-assigned-to-tenant": "Assigned to Tenant",
|
||||||
|
"type-provision-success": "Device provisioned",
|
||||||
|
"type-provision-failure": "Device provisioning was failed"
|
||||||
},
|
},
|
||||||
"confirm-on-exit": {
|
"confirm-on-exit": {
|
||||||
"message": "You have unsaved changes. Are you sure you want to leave this page?",
|
"message": "You have unsaved changes. Are you sure you want to leave this page?",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user