Package com.couchbase.client.core

Examples of com.couchbase.client.core.CouchbaseException


     */
    public static BucketConfig parse(final String input) {
        try {
            return OBJECT_MAPPER.readValue(input, BucketConfig.class);
        } catch (IOException e) {
            throw new CouchbaseException("Could not parse configuration", e);
        }
    }
View Full Code Here


        @JsonProperty("ports") Map<String, Integer> ports) {
        this.viewUri = viewUri;
        try {
            this.hostname = InetAddress.getByName(trimPort(hostname));
        } catch (UnknownHostException e) {
            throw new CouchbaseException("Could not analyze hostname from config.", e);
        }
        this.directServices = parseDirectServices(ports);
        this.sslServices = new HashMap<ServiceType, Integer>();
    }
View Full Code Here

        } else if (input.startsWith("couchbases://")) {
            return Scheme.COUCHBASES;
        } else if (input.startsWith("http://")) {
            return Scheme.HTTP;
        } else {
            throw new CouchbaseException("Could not parse Scheme of connection string: " + input);
        }
    }
View Full Code Here

                    params.put(pair[0], pair[1]);
                }
            }
            return params;
        } catch(Exception ex) {
            throw new CouchbaseException("Could not parse Params of connection string: " + input, ex);
        }
    }
View Full Code Here

                public Observable<? extends Boolean> call(FlushResponse flushResponse) {
                    if (flushResponse.status() == ResponseStatus.FAILURE) {
                        if (flushResponse.content().contains("disabled")) {
                            return Observable.error(new FlushDisabledException("Flush is disabled for this bucket."));
                        } else {
                            return Observable.error(new CouchbaseException("Flush failed because of: "
                                + flushResponse.content()));
                        }
                    }
                    if (flushResponse.isDone()) {
                        return Observable.just(true);
View Full Code Here

            })
            .map(new Func1<InsertBucketResponse, BucketSettings>() {
                @Override
                public BucketSettings call(InsertBucketResponse response) {
                    if (!response.status().isSuccess()) {
                        throw new CouchbaseException("Could not insert bucket: " + response.config());
                    }
                    return settings;
                }
            });
    }
View Full Code Here

                }
            }).map(new Func1<UpdateBucketResponse, BucketSettings>() {
                @Override
                public BucketSettings call(UpdateBucketResponse response) {
                    if (!response.status().isSuccess()) {
                        throw new CouchbaseException("Could not update bucket: " + response.config());
                    }
                    return settings;
                }
            });
    }
View Full Code Here

                @Override
                public InetAddress call(String hostname) {
                    try {
                        return InetAddress.getByName(hostname);
                    } catch(UnknownHostException e) {
                        throw new CouchbaseException(e);
                    }
                }
            })
            .flatMap(new Func1<InetAddress, Observable<AddServiceResponse>>() {
                @Override
                public Observable<AddServiceResponse> call(final InetAddress hostname) {
                    return core
                        .<AddNodeResponse>send(new AddNodeRequest(hostname))
                        .flatMap(new Func1<AddNodeResponse, Observable<AddServiceResponse>>() {
                            @Override
                            public Observable<AddServiceResponse> call(AddNodeResponse response) {
                                int port = environment.sslEnabled()
                                    ? environment.bootstrapHttpSslPort() : environment.bootstrapHttpDirectPort();
                                return core.send(new AddServiceRequest(ServiceType.CONFIG, username, password,
                                    port, hostname));
                            }
                        });
                }
            })
            .map(new Func1<AddServiceResponse, Boolean>() {
                @Override
                public Boolean call(AddServiceResponse addServiceResponse) {
                    if (!addServiceResponse.status().isSuccess()) {
                        throw new CouchbaseException("Could not enable ClusterManager service to function properly.");
                    }
                    return true;
                }
            });
    }
View Full Code Here

            .send(new OpenBucketRequest(name, password))
            .map(new Func1<CouchbaseResponse, AsyncBucket>() {
                @Override
                public AsyncBucket call(CouchbaseResponse response) {
                    if (response.status() != ResponseStatus.SUCCESS) {
                        throw new CouchbaseException("Could not open bucket.");
                    }

                    return new CouchbaseAsyncBucket(core, name, password, trans);
                }
            }).onErrorReturn(new Func1<Throwable, AsyncBucket>() {
                @Override
                public AsyncBucket call(Throwable throwable) {
                    if (throwable instanceof CouchbaseException) {
                        throw (CouchbaseException) throwable;
                    }

                    throw new CouchbaseException(throwable);
                }
            });
    }
View Full Code Here

            .send(new OpenBucketRequest(name, password))
            .map(new Func1<CouchbaseResponse, AsyncBucket>() {
                @Override
                public AsyncBucket call(CouchbaseResponse response) {
                    if (response.status() != ResponseStatus.SUCCESS) {
                        throw new CouchbaseException("Could not open bucket.");
                    }

                    return new CouchbaseAsyncBucket(core, name, password, trans);
                }
            }).onErrorResumeNext(new Func1<Throwable, Observable<AsyncBucket>>() {
                @Override
                public Observable<AsyncBucket> call(final Throwable throwable) {
                    if (throwable instanceof ConfigurationException) {
                        if (throwable.getCause() instanceof IllegalStateException
                            && throwable.getCause().getMessage().contains("NOT_EXISTS")) {
                            return Observable.error(new BucketDoesNotExistException("Bucket \"" + name
                                + "\" does not exist."));
                        } else if (throwable.getCause() instanceof IllegalStateException
                            && throwable.getCause().getMessage().contains("Unauthorized")) {
                            return Observable.error(new InvalidPasswordException("Passwords for bucket \"" + name
                                +"\" do not match."));
                        } else {
                            return Observable.error(throwable);
                        }
                    } else if (throwable instanceof CouchbaseException) {
                        return Observable.error(throwable);
                    } else {
                        return Observable.error(new CouchbaseException(throwable));
                    }
                }
            });
    }
View Full Code Here

TOP

Related Classes of com.couchbase.client.core.CouchbaseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.