Browse Source
Merge pull request #3698 from thingsboard/develop/2.5.5
Develop/2.5.5
pull/3703/head
Andrew Shvayka
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
13 additions and
2 deletions
-
application/src/main/java/org/thingsboard/server/controller/TelemetryController.java
-
common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/MqttTransportHandler.java
-
dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java
|
|
|
@ -392,6 +392,11 @@ public class TelemetryController extends BaseController { |
|
|
|
if (attributes.isEmpty()) { |
|
|
|
return getImmediateDeferredResult("No attributes data found in request body!", HttpStatus.BAD_REQUEST); |
|
|
|
} |
|
|
|
for (AttributeKvEntry attributeKvEntry: attributes) { |
|
|
|
if (attributeKvEntry.getKey().isEmpty() || attributeKvEntry.getKey().trim().length() == 0) { |
|
|
|
return getImmediateDeferredResult("Key cannot be empty or contains only spaces", HttpStatus.BAD_REQUEST); |
|
|
|
} |
|
|
|
} |
|
|
|
SecurityUser user = getCurrentUser(); |
|
|
|
return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.WRITE_ATTRIBUTES, entityIdSrc, (result, tenantId, entityId) -> { |
|
|
|
tsSubService.saveAndNotify(tenantId, entityId, scope, attributes, new FutureCallback<Void>() { |
|
|
|
|
|
|
|
@ -122,7 +122,13 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
|
|
|
log.trace("[{}] Processing msg: {}", sessionId, msg); |
|
|
|
try { |
|
|
|
if (msg instanceof MqttMessage) { |
|
|
|
processMqttMsg(ctx, (MqttMessage) msg); |
|
|
|
MqttMessage message = (MqttMessage) msg; |
|
|
|
if (message.decoderResult().isSuccess()) { |
|
|
|
processMqttMsg(ctx, message); |
|
|
|
} else { |
|
|
|
log.error("[{}] Message processing failed: {}", sessionId, message.decoderResult().cause().getMessage()); |
|
|
|
ctx.close(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
ctx.close(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -548,7 +548,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void validateDataImpl(TenantId tenantId, Device device) { |
|
|
|
if (StringUtils.isEmpty(device.getName())) { |
|
|
|
if (StringUtils.isEmpty(device.getName()) || device.getName().trim().length() == 0) { |
|
|
|
throw new DataValidationException("Device name should be specified!"); |
|
|
|
} |
|
|
|
if (device.getTenantId() == null) { |
|
|
|
|