use of org.eclipse.hono.service.management.device.DeviceWithId in project hono by eclipse.
the class MongoDbBasedDeviceDao method find.
/**
* {@inheritDoc}
*/
@Override
public Future<SearchResult<DeviceWithId>> find(final String tenantId, final int pageSize, final int pageOffset, final List<Filter> filters, final List<Sort> sortOptions, final SpanContext tracingContext) {
Objects.requireNonNull(tenantId);
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 Devices").addReference(References.CHILD_OF, tracingContext).start();
final JsonObject filterDocument = MongoDbDocumentBuilder.builder().withTenantId(tenantId).withDeviceFilters(filters).document();
final JsonObject sortDocument = MongoDbDocumentBuilder.builder().withDeviceSortOptions(sortOptions).document();
return processSearchResource(pageSize, pageOffset, filterDocument, sortDocument, MongoDbBasedDeviceDao::getDevicesWithId).onFailure(t -> TracingHelper.logError(span, "error finding devices", t)).onComplete(r -> span.finish());
}
Aggregations