use of com.vmware.xenon.services.common.QueryTask.Query in project photon-model by vmware.
the class SslTrustCertificateServiceUtils method subscribe.
/**
* Subscribes a consumer to the given continuous query.
*/
static void subscribe(ServiceHost host, Consumer<Operation> consumer) {
QueryTask task = getQueryTask();
QueryUtils.createQueryTaskOperation(host, task, null).setReferer(host.getUri()).setCompletion((o, e) -> {
if (e != null && o.getStatusCode() != Operation.STATUS_CODE_CONFLICT) {
host.log(Level.SEVERE, Utils.toString(e));
return;
}
String taskUriPath = UriUtils.buildUriPath(ServiceUriPaths.CORE_LOCAL_QUERY_TASKS, task.documentSelfLink);
Operation subscribePost = Operation.createPost(host, taskUriPath).setReferer(host.getUri()).setConnectionSharing(true).setCompletion((op, ex) -> {
if (ex != null) {
host.log(Level.SEVERE, Utils.toString(ex));
}
});
host.log(Level.INFO, "Subscribing to a continuous task: %s", taskUriPath);
host.startSubscriptionService(subscribePost, consumer, ServiceSubscriber.create(false));
}).sendWith(host);
}
Aggregations