Package com.basho.riak.client.http.response

Examples of com.basho.riak.client.http.response.BucketResponse


    public BucketProperties fetchBucket(String bucketName) throws IOException {
        if (bucketName == null || bucketName.trim().equals("")) {
            throw new IllegalArgumentException("bucketName cannot be null, empty or all whitespace");
        }

        BucketResponse response = client.getBucketSchema(bucketName, null);

        return convert(response);
    }
View Full Code Here


     *
     * @see
     * com.basho.riak.client.raw.RawClient#fetchBucketKeys(java.lang.String)
     */
    public Iterable<String> listKeys(String bucketName) throws IOException {
        final BucketResponse bucketResponse = client.streamBucket(bucketName);
        if (bucketResponse.isSuccess()) {
            final KeySource keyStream = new KeySource(bucketResponse);
            return new Iterable<String>() {
                public Iterator<String> iterator() {
                    return keyStream;
                }
            };
        } else {
            throw new IOException("stream keys for bucket " + bucketName + " failed with response code : " +
                                  bucketResponse.getStatusCode() + ", body: " + bucketResponse.getBodyAsString());
        }
    }
View Full Code Here

    public BucketProperties fetchBucket(String bucketName) throws IOException {
        if (bucketName == null || bucketName.trim().equals("")) {
            throw new IllegalArgumentException("bucketName cannot be null, empty or all whitespace");
        }

        BucketResponse response = client.getBucketSchema(bucketName, null);

        return convert(response);
    }
View Full Code Here

     *
     * @see
     * com.basho.riak.client.raw.RawClient#fetchBucketKeys(java.lang.String)
     */
    public Iterable<String> listKeys(String bucketName) throws IOException {
        final BucketResponse bucketResponse = client.streamBucket(bucketName);
        if (bucketResponse.isSuccess()) {
            final KeySource keyStream = new KeySource(bucketResponse);
            return new Iterable<String>() {
                public Iterator<String> iterator() {
                    return keyStream;
                }
            };
        } else {
            throw new IOException("stream keys for bucket " + bucketName + " failed with response code : " +
                                  bucketResponse.getStatusCode() + ", body: " + bucketResponse.getBodyAsString());
        }
    }
View Full Code Here

        HttpResponse r = helper.getBucketSchema(bucket, meta);
        try {
            return getBucketResponse(r);
        } catch (JSONException e) {
            try {
                return new BucketResponse(helper.toss(new RiakResponseRuntimeException(r, e)));
            } catch (Exception e1) {
                throw new IllegalStateException(
                                                "helper.toss() returns a unsuccessful result, so BucketResponse shouldn't try to parse it or throw");
            }
        } catch (IOException e) {
            try {
                return new BucketResponse(helper.toss(new RiakIORuntimeException(e)));
            } catch (Exception e1) {
                throw new IllegalStateException(
                                                "helper.toss() returns a unsuccessful result, so BucketResponse shouldn't try to read it or throw");
            }
        }
View Full Code Here

        HttpResponse r = helper.listBucket(bucket, meta, streamResponse);
        try {
            return getBucketResponse(r);
        } catch (JSONException e) {
            try {
                return new BucketResponse(helper.toss(new RiakResponseRuntimeException(r, e)));
            } catch (Exception e1) {
                throw new IllegalStateException(
                                                "helper.toss() returns a unsuccessful result, so BucketResponse shouldn't try to parse it or throw");
            }
        } catch (IOException e) {
            try {
                return new BucketResponse(helper.toss(new RiakIORuntimeException(e)));
            } catch (Exception e1) {
                throw new IllegalStateException(
                                                "helper.toss() returns a unsuccessful result, so BucketResponse shouldn't try to read it or throw");
            }
        }
View Full Code Here

        helper.setClientId(clientId);
    }

    // Encapsulate response creation so it can be stubbed for testing
    BucketResponse getBucketResponse(HttpResponse r) throws JSONException, IOException {
        return new BucketResponse(r);
    }
View Full Code Here

     *             If an error occurs during communication with the Riak server.
     * @throws RiakResponseException
     *             if the server does not return the bucket information
     */
    public RiakBucketInfo listBucket(String bucket, RequestMeta meta) throws RiakIOException, RiakResponseException {
        BucketResponse r = impl.listBucket(bucket, meta);

        if (r.getStatusCode() != 200)
            throw new RiakResponseException(new RiakResponseRuntimeException(r, r.getBodyAsString()));

        return r.getBucketInfo();
    }
View Full Code Here

    public BucketProperties fetchBucket(String bucketName) throws IOException {
        if (bucketName == null || bucketName.trim().equals("")) {
            throw new IllegalArgumentException("bucketName cannot be null, empty or all whitespace");
        }

        BucketResponse response = client.getBucketSchema(bucketName, null);

        return convert(response);
    }
View Full Code Here

     *
     * @see
     * com.basho.riak.client.raw.RawClient#fetchBucketKeys(java.lang.String)
     */
    public Iterable<String> listKeys(String bucketName) throws IOException {
        final BucketResponse bucketResponse = client.streamBucket(bucketName);
        if (bucketResponse.isSuccess()) {
            final KeySource keyStream = new KeySource(bucketResponse);
            return new Iterable<String>() {
                public Iterator<String> iterator() {
                    return keyStream;
                }
            };
        } else {
            throw new IOException("stream keys for bucket " + bucketName + " failed with response code : " +
                                  bucketResponse.getStatusCode() + ", body: " + bucketResponse.getBodyAsString());
        }
    }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.http.response.BucketResponse

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.