com.atlassian.httpclient.api
Interface BaseResponsePromise<V>

All Superinterfaces:
java.util.concurrent.Future<V>, com.google.common.util.concurrent.ListenableFuture<V>, com.atlassian.util.concurrent.Promise<V>
All Known Subinterfaces:
ResponsePromise, ResponsesPromise

public interface BaseResponsePromise<V>
extends com.atlassian.util.concurrent.Promise<V>

Adds rich response-code callback registration to the base Promise interface.


Method Summary
 BaseResponsePromise<V> badRequest(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'bad request' (400) HTTP responses.
 BaseResponsePromise<V> clientError(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'client error' (4xx) HTTP responses.
 BaseResponsePromise<V> conflict(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'conflict' (409) HTTP responses.
 BaseResponsePromise<V> created(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'created' (201) HTTP responses.
 BaseResponsePromise<V> done(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to all completed (1xx, 2xx, 3xx, 4xx, and 5xx) HTTP responses.
 BaseResponsePromise<V> error(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to all error (4xx and 5xx) HTTP responses.
 BaseResponsePromise<V> fail(com.atlassian.util.concurrent.Effect<java.lang.Throwable> callback)
          Register a callback to respond to exceptions thrown while executing the HTTP request.
 BaseResponsePromise<V> forbidden(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'forbidden' (403) HTTP responses.
 BaseResponsePromise<V> informational(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'informational' (1xx) HTTP responses.
 BaseResponsePromise<V> internalServerError(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'internal server error' (500) HTTP responses.
 BaseResponsePromise<V> noContent(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'no content' (204) HTTP responses.
 BaseResponsePromise<V> notFound(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'not found' (404) HTTP responses.
 BaseResponsePromise<V> notModified(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'not modified' (304) HTTP responses.
 BaseResponsePromise<V> notSuccessful(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to all non-'successful' (1xx, 3xx, 4xx, 5xx) HTTP responses.
 BaseResponsePromise<V> ok(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'ok' (200) HTTP responses.
 BaseResponsePromise<V> on(int statusCode, com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to HTTP responses with a specific status code.
 BaseResponsePromise<V> others(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to all other HTTP responses (i.e.
 BaseResponsePromise<V> otherwise(com.atlassian.util.concurrent.Effect<java.lang.Throwable> callback)
          Registers the specified callback as a handler for both of the following events: Any value passed to fail() Any value passed to others(), converted into an exception
 BaseResponsePromise<V> redirection(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'redirection' (3xx) HTTP responses.
 BaseResponsePromise<V> seeOther(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'see other' (303) HTTP responses.
 BaseResponsePromise<V> serverError(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'server error' (5xx) HTTP responses.
 BaseResponsePromise<V> serviceUnavailable(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'service unavailable' (503) HTTP responses.
 BaseResponsePromise<V> successful(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'successful' (2xx) HTTP responses.
 BaseResponsePromise<V> then(com.google.common.util.concurrent.FutureCallback<V> callback)
          Register a future callback to respond to all completed HTTP responses and exceptions thrown while executing the HTTP request.
 BaseResponsePromise<V> unauthorized(com.atlassian.util.concurrent.Effect<V> callback)
          Register a callback to respond to 'unauthorized' (401) HTTP responses.
 
Methods inherited from interface com.atlassian.util.concurrent.Promise
claim, flatMap, map
 
Methods inherited from interface com.google.common.util.concurrent.ListenableFuture
addListener
 
Methods inherited from interface java.util.concurrent.Future
cancel, get, get, isCancelled, isDone
 

Method Detail

on

BaseResponsePromise<V> on(int statusCode,
                          com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to HTTP responses with a specific status code. Use this as a fallback if the status code you're interested in does not have a more explicit registration method for it.

Parameters:
statusCode - The code to select on
callback - The callback
Returns:
This instance for chaining

informational

BaseResponsePromise<V> informational(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'informational' (1xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

successful

BaseResponsePromise<V> successful(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'successful' (2xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

ok

BaseResponsePromise<V> ok(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'ok' (200) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

created

BaseResponsePromise<V> created(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'created' (201) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

noContent

BaseResponsePromise<V> noContent(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'no content' (204) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

redirection

BaseResponsePromise<V> redirection(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'redirection' (3xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

seeOther

BaseResponsePromise<V> seeOther(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'see other' (303) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

notModified

BaseResponsePromise<V> notModified(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'not modified' (304) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

clientError

BaseResponsePromise<V> clientError(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'client error' (4xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

badRequest

BaseResponsePromise<V> badRequest(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'bad request' (400) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

unauthorized

BaseResponsePromise<V> unauthorized(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'unauthorized' (401) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

forbidden

BaseResponsePromise<V> forbidden(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'forbidden' (403) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

notFound

BaseResponsePromise<V> notFound(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'not found' (404) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

conflict

BaseResponsePromise<V> conflict(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'conflict' (409) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

serverError

BaseResponsePromise<V> serverError(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'server error' (5xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

internalServerError

BaseResponsePromise<V> internalServerError(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'internal server error' (500) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

serviceUnavailable

BaseResponsePromise<V> serviceUnavailable(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to 'service unavailable' (503) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

error

BaseResponsePromise<V> error(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to all error (4xx and 5xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

notSuccessful

BaseResponsePromise<V> notSuccessful(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to all non-'successful' (1xx, 3xx, 4xx, 5xx) HTTP responses.

Parameters:
callback - The callback
Returns:
This instance for chaining

others

BaseResponsePromise<V> others(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to all other HTTP responses (i.e. those not explicitly registered for).

Parameters:
callback - The callback
Returns:
This instance for chaining

otherwise

BaseResponsePromise<V> otherwise(com.atlassian.util.concurrent.Effect<java.lang.Throwable> callback)
Registers the specified callback as a handler for both of the following events:

Parameters:
callback - The callback
Returns:
This instance for chaining

done

BaseResponsePromise<V> done(com.atlassian.util.concurrent.Effect<V> callback)
Register a callback to respond to all completed (1xx, 2xx, 3xx, 4xx, and 5xx) HTTP responses.

Specified by:
done in interface com.atlassian.util.concurrent.Promise<V>
Parameters:
callback - The callback
Returns:
This instance for chaining

fail

BaseResponsePromise<V> fail(com.atlassian.util.concurrent.Effect<java.lang.Throwable> callback)
Register a callback to respond to exceptions thrown while executing the HTTP request.

Specified by:
fail in interface com.atlassian.util.concurrent.Promise<V>
Parameters:
callback - The callback
Returns:
This instance for chaining

then

BaseResponsePromise<V> then(com.google.common.util.concurrent.FutureCallback<V> callback)
Register a future callback to respond to all completed HTTP responses and exceptions thrown while executing the HTTP request.

Specified by:
then in interface com.atlassian.util.concurrent.Promise<V>
Parameters:
callback - The callback
Returns:
This instance for chaining


Copyright © 2012 Atlassian. All Rights Reserved.