Search in sources :

Example 6 with TenantResult

use of org.eclipse.hono.util.TenantResult in project hono by eclipse.

the class BaseTenantService method processRemoveRequest.

private Future<EventBusMessage> processRemoveRequest(final EventBusMessage request) {
    final String tenantId = request.getTenant();
    if (tenantId == null) {
        log.debug("request does not contain mandatory property [{}]", MessageHelper.APP_PROPERTY_TENANT_ID);
        return Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST));
    } else {
        log.debug("deleting tenant [{}]", tenantId);
        final Future<TenantResult<JsonObject>> removeResult = Future.future();
        remove(tenantId, removeResult.completer());
        return removeResult.map(tr -> {
            return EventBusMessage.forStatusCode(tr.getStatus()).setJsonPayload(tr.getPayload()).setTenant(tenantId).setCacheDirective(tr.getCacheDirective());
        });
    }
}
Also used : ClientErrorException(org.eclipse.hono.client.ClientErrorException) TenantResult(org.eclipse.hono.util.TenantResult)

Aggregations

TenantResult (org.eclipse.hono.util.TenantResult)6 Handler (io.vertx.core.Handler)5 JsonObject (io.vertx.core.json.JsonObject)5 HttpURLConnection (java.net.HttpURLConnection)5 MessageHelper (org.eclipse.hono.util.MessageHelper)5 TenantConstants (org.eclipse.hono.util.TenantConstants)5 ClientErrorException (org.eclipse.hono.client.ClientErrorException)4 AsyncResult (io.vertx.core.AsyncResult)3 Future (io.vertx.core.Future)3 JsonArray (io.vertx.core.json.JsonArray)3 Objects (java.util.Objects)3 ServerErrorException (org.eclipse.hono.client.ServerErrorException)3 Context (io.vertx.core.Context)2 Vertx (io.vertx.core.Vertx)2 Async (io.vertx.ext.unit.Async)2 TestContext (io.vertx.ext.unit.TestContext)2 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)2 ProtonDelivery (io.vertx.proton.ProtonDelivery)2 ProtonHelper (io.vertx.proton.ProtonHelper)2 ProtonReceiver (io.vertx.proton.ProtonReceiver)2