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

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


                    newURI = new URIBuilder(originalURI)
                                 .setQuery(URLEncodedUtils.format(newQuery, "UTF-8"))
                                 .build();
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                    throw new RiakIORuntimeException(e);
                }
                httpMethod.setURI(newURI);
            }
        }
        HttpEntity entity = null;
        try {
            org.apache.http.HttpResponse response =  httpClient.execute(httpMethod);

            int status = 0;
            if (response.getStatusLine() != null) {
                status = response.getStatusLine().getStatusCode();
            }

            Map<String, String> headers = ClientUtils.asHeaderMap(response.getAllHeaders());
            byte[] body = null;
            InputStream stream = null;
            entity = response.getEntity();

            if (streamResponse) {
                stream = entity.getContent();
            } else {
                if(null != entity) {
                    body = EntityUtils.toByteArray(entity);
                }
            }

            key = extractKeyFromResponseIfItWasNotAlreadyProvided(key, response);

            return new DefaultHttpResponse(bucket, key, status, headers, body, stream, response, httpMethod);
        } catch (IOException e) {
            httpMethod.abort();
            return toss(new RiakIORuntimeException(e));
        } finally {
            if(!streamResponse && entity != null) {
                try {
                    EntityUtils.consume(entity);
                } catch (IOException e) {
View Full Code Here


                                                           originalURI.getPort(),
                                                           originalURI.getRawPath(),
                                                           URLEncodedUtils.format(newQuery, "UTF-8"), null);
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                    throw new RiakIORuntimeException(e);
                }
                httpMethod.setURI(newURI);
            }
        }
        HttpEntity entity = null;
        try {
            org.apache.http.HttpResponse response =  httpClient.execute(httpMethod);

            int status = 0;
            if (response.getStatusLine() != null) {
                status = response.getStatusLine().getStatusCode();
            }

            Map<String, String> headers = ClientUtils.asHeaderMap(response.getAllHeaders());
            byte[] body = null;
            InputStream stream = null;
            entity = response.getEntity();

            if (streamResponse) {
                stream = entity.getContent();
            } else {
                if(null != entity) {
                    body = EntityUtils.toByteArray(entity);
                }
            }

            key = extractKeyFromResponseIfItWasNotAlreadyProvided(key, response);

            return new DefaultHttpResponse(bucket, key, status, headers, body, stream, response, httpMethod);
        } catch (IOException e) {
            httpMethod.abort();
            return toss(new RiakIORuntimeException(e));
        } finally {
            if(!streamResponse && entity != null) {
                try {
                    EntityUtils.consume(entity);
                } catch (IOException e) {
View Full Code Here

                    newURI = new URIBuilder(originalURI)
                                 .setQuery(URLEncodedUtils.format(newQuery, "UTF-8"))
                                 .build();
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                    throw new RiakIORuntimeException(e);
                }
                httpMethod.setURI(newURI);
            }
        }
        HttpEntity entity = null;
        try {
            org.apache.http.HttpResponse response =  httpClient.execute(httpMethod);

            int status = 0;
            if (response.getStatusLine() != null) {
                status = response.getStatusLine().getStatusCode();
            }

            Map<String, String> headers = ClientUtils.asHeaderMap(response.getAllHeaders());
            byte[] body = null;
            InputStream stream = null;
            entity = response.getEntity();

            if (streamResponse) {
                stream = entity.getContent();
            } else {
                if(null != entity) {
                    body = EntityUtils.toByteArray(entity);
                }
            }

            key = extractKeyFromResponseIfItWasNotAlreadyProvided(key, response);

            return new DefaultHttpResponse(bucket, key, status, headers, body, stream, response, httpMethod);
        } catch (IOException e) {
            httpMethod.abort();
            return toss(new RiakIORuntimeException(e));
        } finally {
            if(!streamResponse && entity != null) {
                try {
                    EntityUtils.consume(entity);
                } catch (IOException e) {
View Full Code Here

            while ((l = valueStream.read(data)) >= 0) {
                tmp.write(data, 0, l);
            }
            return tmp.toByteArray();
        } catch (IOException e) {
            throw new RiakIORuntimeException(e);
        }
    }
View Full Code Here

TOP

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

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.