private void doUnregisterDevice(final RoutingContext ctx) { final String deviceId = getDeviceIdParam(ctx); final String tenantId = getTenantParam(ctx); logger.debug("removing registration information for device [tenant: {}, device: {}]", tenantId, deviceId); final JsonObject requestMsg = EventBusMessage.forOperation(RegistrationConstants.ACTION_DEREGISTER) .setTenant(tenantId) .setDeviceId(deviceId) .toJson(); sendAction(ctx, requestMsg, getDefaultResponseHandler(ctx)); }
private void doUpdateRegistrationJson(final RoutingContext ctx) { try { JsonObject payload = null; if (ctx.getBody().length() > 0) { payload = ctx.getBodyAsJson(); } updateRegistration(getDeviceIdParam(ctx), payload, ctx); } catch (final DecodeException e) { HttpUtils.badRequest(ctx, "body does not contain a valid JSON object"); } }
private void doUpdateRegistrationJson(final RoutingContext ctx) { try { JsonObject payload = null; if (ctx.getBody().length() > 0) { payload = ctx.getBodyAsJson(); } updateRegistration(getDeviceIdParam(ctx), payload, ctx); } catch (final DecodeException e) { HttpUtils.badRequest(ctx, "body does not contain a valid JSON object"); } }
private void doUnregisterDevice(final RoutingContext ctx) { final String deviceId = getDeviceIdParam(ctx); final String tenantId = getTenantParam(ctx); logger.debug("removing registration information for device [tenant: {}, device: {}]", tenantId, deviceId); final JsonObject requestMsg = EventBusMessage.forOperation(RegistrationConstants.ACTION_DEREGISTER) .setTenant(tenantId) .setDeviceId(deviceId) .toJson(); sendAction(ctx, requestMsg, getDefaultResponseHandler(ctx)); }
private void doGetDevice(final RoutingContext ctx) { final String deviceId = getDeviceIdParam(ctx); final String tenantId = getTenantParam(ctx); final HttpServerResponse response = ctx.response(); final JsonObject requestMsg = EventBusMessage.forOperation(RegistrationConstants.ACTION_GET) .setTenant(tenantId) .setDeviceId(deviceId) .toJson(); sendAction(ctx, requestMsg, (status, registrationResult) -> { response.setStatusCode(status); switch (status) { case HttpURLConnection.HTTP_OK: HttpUtils.setResponseBody(ctx.response(), registrationResult); default: response.end(); } }); }
private void doGetDevice(final RoutingContext ctx) { final String deviceId = getDeviceIdParam(ctx); final String tenantId = getTenantParam(ctx); final HttpServerResponse response = ctx.response(); final JsonObject requestMsg = EventBusMessage.forOperation(RegistrationConstants.ACTION_GET) .setTenant(tenantId) .setDeviceId(deviceId) .toJson(); sendAction(ctx, requestMsg, (status, registrationResult) -> { response.setStatusCode(status); switch (status) { case HttpURLConnection.HTTP_OK: HttpUtils.setResponseBody(ctx.response(), registrationResult); default: response.end(); } }); }