Search in sources :

Example 1 with TenantWithId

use of org.eclipse.hono.service.management.tenant.TenantWithId in project hono by eclipse.

the class MongoDbBasedTenantDao method find.

/**
 * {@inheritDoc}
 */
@Override
public Future<SearchResult<TenantWithId>> find(final int pageSize, final int pageOffset, final List<Filter> filters, final List<Sort> sortOptions, final SpanContext tracingContext) {
    Objects.requireNonNull(filters);
    Objects.requireNonNull(sortOptions);
    if (pageSize <= 0) {
        throw new IllegalArgumentException("page size must be a positive integer");
    }
    if (pageOffset < 0) {
        throw new IllegalArgumentException("page offset must not be negative");
    }
    final Span span = tracer.buildSpan("find Tenants").addReference(References.CHILD_OF, tracingContext).start();
    final JsonObject filterDocument = MongoDbDocumentBuilder.builder().withTenantFilters(filters).document();
    final JsonObject sortDocument = MongoDbDocumentBuilder.builder().withTenantSortOptions(sortOptions).document();
    return processSearchResource(pageSize, pageOffset, filterDocument, sortDocument, MongoDbBasedTenantDao::getTenantsWithId).onFailure(t -> TracingHelper.logError(span, "error finding tenants", t)).onComplete(r -> span.finish());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) X500Principal(javax.security.auth.x500.X500Principal) Filter(org.eclipse.hono.service.management.Filter) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ClientErrorException(org.eclipse.hono.client.ClientErrorException) Constants(org.eclipse.hono.util.Constants) Tenant(org.eclipse.hono.service.management.tenant.Tenant) ArrayList(java.util.ArrayList) Status(io.vertx.ext.healthchecks.Status) Sort(org.eclipse.hono.service.management.Sort) HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler) HealthCheckProvider(org.eclipse.hono.service.HealthCheckProvider) SearchResult(org.eclipse.hono.service.management.SearchResult) References(io.opentracing.References) JsonObject(io.vertx.core.json.JsonObject) TracingHelper(org.eclipse.hono.tracing.TracingHelper) TenantDto(org.eclipse.hono.service.management.tenant.TenantDto) RegistryManagementConstants(org.eclipse.hono.util.RegistryManagementConstants) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Promise(io.vertx.core.Promise) TenantWithId(org.eclipse.hono.service.management.tenant.TenantWithId) MongoClient(io.vertx.ext.mongo.MongoClient) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) SpanContext(io.opentracing.SpanContext) Objects(java.util.Objects) List(java.util.List) IndexOptions(io.vertx.ext.mongo.IndexOptions) Optional(java.util.Optional) Span(io.opentracing.Span) FindOptions(io.vertx.ext.mongo.FindOptions) UpdateOptions(io.vertx.ext.mongo.UpdateOptions) MongoDbDocumentBuilder(org.eclipse.hono.deviceregistry.mongodb.utils.MongoDbDocumentBuilder) JsonObject(io.vertx.core.json.JsonObject) Span(io.opentracing.Span)

Aggregations

References (io.opentracing.References)1 Span (io.opentracing.Span)1 SpanContext (io.opentracing.SpanContext)1 Tracer (io.opentracing.Tracer)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 JsonObject (io.vertx.core.json.JsonObject)1 HealthCheckHandler (io.vertx.ext.healthchecks.HealthCheckHandler)1 Status (io.vertx.ext.healthchecks.Status)1 FindOptions (io.vertx.ext.mongo.FindOptions)1 IndexOptions (io.vertx.ext.mongo.IndexOptions)1 MongoClient (io.vertx.ext.mongo.MongoClient)1 UpdateOptions (io.vertx.ext.mongo.UpdateOptions)1 HttpURLConnection (java.net.HttpURLConnection)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1