use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncViewIndexManager method upsertDesignDocument.
/**
* Stores the design document on the server under the specified namespace, replacing any existing document
* with the same name.
*
* @param doc document to store
* @param namespace namespace to store it in
* @param options additional optional arguments (timeout, retry, etc.)
*/
public CompletableFuture<Void> upsertDesignDocument(final DesignDocument doc, final DesignDocumentNamespace namespace, final UpsertDesignDocumentOptions options) {
notNull(doc, "DesignDocument", () -> new ReducedViewErrorContext(null, null, bucket));
notNull(namespace, "DesignDocumentNamespace", () -> new ReducedViewErrorContext(doc.name(), null, bucket));
notNull(options, "UpsertDesignDocumentOptions", () -> new ReducedViewErrorContext(doc.name(), null, bucket));
byte[] docBytes = Mapper.encodeAsBytes(toJson(doc));
return coreManager.upsertDesignDocument(doc.name(), docBytes, namespace == PRODUCTION, options.build());
}
use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncViewIndexManager method dropDesignDocument.
/**
* Removes a design document from the server.
*
* @param name name of the document to remove
* @param namespace namespace to remove it from
* @param options additional optional arguments (timeout, retry, etc.)
* @throws DesignDocumentNotFoundException if the namespace does not contain a document with the given name
*/
public CompletableFuture<Void> dropDesignDocument(final String name, final DesignDocumentNamespace namespace, final DropDesignDocumentOptions options) {
notNullOrEmpty(name, "Name", () -> new ReducedViewErrorContext(null, null, bucket));
notNull(namespace, "DesignDocumentNamespace", () -> new ReducedViewErrorContext(name, null, bucket));
notNull(options, "DropDesignDocumentOptions", () -> new ReducedViewErrorContext(name, null, bucket));
return coreManager.dropDesignDocument(name, namespace == PRODUCTION, options.build());
}
use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.
the class ReactiveBucket method viewQuery.
public Mono<ReactiveViewResult> viewQuery(final String designDoc, final String viewName, final ViewOptions options) {
return Mono.defer(() -> {
notNull(options, "ViewOptions", () -> new ReducedViewErrorContext(designDoc, viewName, name()));
ViewOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return ViewAccessor.viewQueryReactive(asyncBucket.core(), asyncBucket.viewRequest(designDoc, viewName, opts), serializer);
});
}
use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.
the class AsyncBucket method viewRequest.
ViewRequest viewRequest(final String designDoc, final String viewName, final ViewOptions.Built opts) {
notNullOrEmpty(designDoc, "DesignDoc", () -> new ReducedViewErrorContext(designDoc, viewName, name));
notNullOrEmpty(viewName, "ViewName", () -> new ReducedViewErrorContext(designDoc, viewName, name));
String query = opts.query();
Optional<byte[]> keysJson = Optional.ofNullable(opts.keys()).map(s -> s.getBytes(StandardCharsets.UTF_8));
boolean development = opts.development();
Duration timeout = opts.timeout().orElse(environment.timeoutConfig().viewTimeout());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
final RequestSpan span = environment().requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_VIEWS, opts.parentSpan().orElse(null));
ViewRequest request = new ViewRequest(timeout, core.context(), retryStrategy, authenticator, name, designDoc, viewName, query, keysJson, development, span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.
the class CoreViewIndexManager method publishDesignDocument.
/**
* Convenience method that gets a the document from the development namespace
* and upserts it to the production namespace.
*
* @param name name of the development design document
* @throws DesignDocumentNotFoundException if the development namespace does not contain a document with the given name
*/
public CompletableFuture<Void> publishDesignDocument(String name, CoreCommonOptions options) {
notNullOrEmpty(name, "Name", () -> new ReducedViewErrorContext(null, null, bucket));
RequestSpan span = buildSpan(TracingIdentifiers.SPAN_REQUEST_MV_PUBLISH_DD, options.parentSpan());
CoreCommonOptions childOptions = options.withParentSpan(span);
return getDesignDocument(name, false, childOptions).thenCompose(doc -> upsertDesignDocument(name, doc, true, childOptions)).whenComplete((r, t) -> span.end());
}
Aggregations