com.basho.riak.client.http.response
Class RiakResponseRuntimeException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.basho.riak.client.http.response.RiakResponseRuntimeException
All Implemented Interfaces:
HttpResponse, Serializable

public class RiakResponseRuntimeException
extends RuntimeException
implements HttpResponse

Thrown when the Riak server returns a malformed response. The HTTP response is returned in the exception.

See Also:
Serialized Form

Constructor Summary
RiakResponseRuntimeException(HttpResponse response)
           
RiakResponseRuntimeException(HttpResponse response, String message)
           
RiakResponseRuntimeException(HttpResponse response, String message, Throwable cause)
           
RiakResponseRuntimeException(HttpResponse response, Throwable cause)
           
 
Method Summary
 void close()
          Releases the underlying the HTTP connection when the response is streamed
 byte[] getBody()
          The HTTP response body or null if isStreamed()
 String getBodyAsString()
           
 String getBucket()
          The target object's bucket
 Map<String,String> getHttpHeaders()
          The HTTP response headers.
 org.apache.http.client.methods.HttpRequestBase getHttpMethod()
          The actual HttpRequestBase used to make the HTTP request.
 org.apache.http.HttpResponse getHttpResponse()
           
 String getKey()
          The target object's key or null if bucket is target
 int getStatusCode()
          Resulting status code from the HTTP request.
 InputStream getStream()
          The HTTP response body as an input stream if isStreamed(); null otherwise
 boolean isError()
          Whether the HTTP request returned a 4xx or 5xx response
 boolean isStreamed()
          Whether the response body is available as an input stream
 boolean isSuccess()
          Whether the HTTP response is considered a success.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RiakResponseRuntimeException

public RiakResponseRuntimeException(HttpResponse response)

RiakResponseRuntimeException

public RiakResponseRuntimeException(HttpResponse response,
                                    String message,
                                    Throwable cause)

RiakResponseRuntimeException

public RiakResponseRuntimeException(HttpResponse response,
                                    String message)

RiakResponseRuntimeException

public RiakResponseRuntimeException(HttpResponse response,
                                    Throwable cause)
Method Detail

getBody

public byte[] getBody()
Description copied from interface: HttpResponse
The HTTP response body or null if isStreamed()

Specified by:
getBody in interface HttpResponse

getBodyAsString

public String getBodyAsString()
Specified by:
getBodyAsString in interface HttpResponse

getStream

public InputStream getStream()
Description copied from interface: HttpResponse
The HTTP response body as an input stream if isStreamed(); null otherwise

Specified by:
getStream in interface HttpResponse

isStreamed

public boolean isStreamed()
Description copied from interface: HttpResponse
Whether the response body is available as an input stream

Specified by:
isStreamed in interface HttpResponse

getBucket

public String getBucket()
Description copied from interface: HttpResponse
The target object's bucket

Specified by:
getBucket in interface HttpResponse

getHttpHeaders

public Map<String,String> getHttpHeaders()
Description copied from interface: HttpResponse
The HTTP response headers.

Specified by:
getHttpHeaders in interface HttpResponse

getHttpMethod

public org.apache.http.client.methods.HttpRequestBase getHttpMethod()
Description copied from interface: HttpResponse
The actual HttpRequestBase used to make the HTTP request. Most of the data here can be retrieved more simply using methods in this class. The method will already be in a finished state.

Specified by:
getHttpMethod in interface HttpResponse

getKey

public String getKey()
Description copied from interface: HttpResponse
The target object's key or null if bucket is target

Specified by:
getKey in interface HttpResponse

getStatusCode

public int getStatusCode()
Description copied from interface: HttpResponse
Resulting status code from the HTTP request.

Specified by:
getStatusCode in interface HttpResponse

isError

public boolean isError()
Description copied from interface: HttpResponse
Whether the HTTP request returned a 4xx or 5xx response

Specified by:
isError in interface HttpResponse

isSuccess

public boolean isSuccess()
Description copied from interface: HttpResponse
Whether the HTTP response is considered a success. Generally this translates to a 2xx for any request, a 304 for GET and HEAD requests, or 404 for DELETE requests.

Specified by:
isSuccess in interface HttpResponse

close

public void close()
Description copied from interface: HttpResponse
Releases the underlying the HTTP connection when the response is streamed

Specified by:
close in interface HttpResponse

getHttpResponse

public org.apache.http.HttpResponse getHttpResponse()
Specified by:
getHttpResponse in interface HttpResponse
Returns:
the original HttpResponse returned by http client


Copyright © 2012. All Rights Reserved.