use of org.eclipse.hono.util.RegistrationResult in project hono by eclipse.
the class BaseRegistrationService method processUpdateRequest.
private Future<EventBusMessage> processUpdateRequest(final EventBusMessage request) {
final String tenantId = request.getTenant();
final String deviceId = request.getDeviceId();
final JsonObject payload = getRequestPayload(request.getJsonPayload());
if (tenantId == null || deviceId == null) {
return Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST));
} else {
log.debug("updating registration information for device [{}] of tenant [{}]", deviceId, tenantId);
final Future<RegistrationResult> result = Future.future();
updateDevice(tenantId, deviceId, payload, result.completer());
return result.map(res -> {
return request.getResponse(res.getStatus()).setDeviceId(deviceId).setCacheDirective(res.getCacheDirective());
});
}
}
use of org.eclipse.hono.util.RegistrationResult in project hono by eclipse.
the class BaseRegistrationService method processRegisterRequest.
private Future<EventBusMessage> processRegisterRequest(final EventBusMessage request) {
final String tenantId = request.getTenant();
final String deviceId = request.getDeviceId();
final JsonObject payload = getRequestPayload(request.getJsonPayload());
if (tenantId == null || deviceId == null) {
return Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST));
} else {
log.debug("registering device [{}] for tenant [{}]", deviceId, tenantId);
final Future<RegistrationResult> result = Future.future();
addDevice(tenantId, deviceId, payload, result.completer());
return result.map(res -> {
return request.getResponse(res.getStatus()).setDeviceId(deviceId).setCacheDirective(res.getCacheDirective());
});
}
}
Aggregations