Added validation for deviceName/attribute key contains only spaces situation
This commit is contained in:
parent
eeec6bac9f
commit
92ba5907b0
@ -393,6 +393,11 @@ public class TelemetryController extends BaseController {
|
|||||||
if (attributes.isEmpty()) {
|
if (attributes.isEmpty()) {
|
||||||
return getImmediateDeferredResult("No attributes data found in request body!", HttpStatus.BAD_REQUEST);
|
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();
|
SecurityUser user = getCurrentUser();
|
||||||
return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.WRITE_ATTRIBUTES, entityIdSrc, (result, tenantId, entityId) -> {
|
return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.WRITE_ATTRIBUTES, entityIdSrc, (result, tenantId, entityId) -> {
|
||||||
tsSubService.saveAndNotify(tenantId, entityId, scope, attributes, new FutureCallback<Void>() {
|
tsSubService.saveAndNotify(tenantId, entityId, scope, attributes, new FutureCallback<Void>() {
|
||||||
|
|||||||
@ -388,7 +388,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
|
|||||||
if (StringUtils.isEmpty(device.getType())) {
|
if (StringUtils.isEmpty(device.getType())) {
|
||||||
throw new DataValidationException("Device type should be specified!");
|
throw new DataValidationException("Device type should be specified!");
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(device.getName())) {
|
if (StringUtils.isEmpty(device.getName()) || device.getName().trim().length() == 0) {
|
||||||
throw new DataValidationException("Device name should be specified!");
|
throw new DataValidationException("Device name should be specified!");
|
||||||
}
|
}
|
||||||
if (device.getTenantId() == null) {
|
if (device.getTenantId() == null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user