com.veriplace.client
Class AsyncCapableAPI<TRequestStatus extends AsyncRequestStatus>

java.lang.Object
  extended by com.veriplace.client.AsyncCapableAPI<TRequestStatus>
Direct Known Subclasses:
GetLocationAPI, InvitationAPI

public abstract class AsyncCapableAPI<TRequestStatus extends AsyncRequestStatus>
extends java.lang.Object

Base class for Veriplace APIs that deliver an asynchronous response. The response may be posted to a callback URL, or the application may poll for it, or both. Depending on the API, there may also be a synchronous equivalent.


Method Summary
 TRequestStatus getCallbackResult(HttpServletRequest request, HttpServletResponse response)
          Process the parameters of an HTTP callback request that was posted from Veriplace in response to an asynchronous request.
 TRequestStatus getResult(TRequestStatus request)
          Attempt to retrieve the result of an asynchronous request that was previously submitted with GetLocationAPI.requestLocation(Token, User, String, String) or InvitationAPI.inviteGetLocation(String, String, boolean).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResult

public TRequestStatus getResult(TRequestStatus request)
                                                    throws RequestNotFoundException,
                                                           UnexpectedException
Attempt to retrieve the result of an asynchronous request that was previously submitted with GetLocationAPI.requestLocation(Token, User, String, String) or InvitationAPI.inviteGetLocation(String, String, boolean). Use this method if you did not specify a callback URI in the original request.

If the request is still in progress, this will return the same request status object. If the request has completed, either successfully or unsuccessfully, it will return an updated request status object whose AsyncRequestStatus.isReady() method will return true, and whose other properties will describe the result.

Parameters:
request - the request status object that was returned by the original asynchronous request method
Returns:
a request status object of the same type
Throws:
RequestNotFoundException - if the request is no longer valid, i.e. it has expired or the result was already delivered via a callback notification
UnexpectedException - if there was an unexpected OAuth error or I/O error, or if the request is no longer valid

getCallbackResult

public TRequestStatus getCallbackResult(HttpServletRequest request,
                                        HttpServletResponse response)
                                                            throws UnexpectedException
Process the parameters of an HTTP callback request that was posted from Veriplace in response to an asynchronous request. The resulting status object's properties will describe the result of the request.

To confirm receipt of the callback, this method also sends an immediate HTTP 200 ("OK") response to Veriplace, completing the HTTP response. Do not try to do anything else with the response object after this; if your application returned anything else, or did not respond, Veriplace would repeat the callback.

Parameters:
request - the current HTTP request
response - the current HTTP response (see above)
Returns:
a status object of the appropriate type for the request
Throws:
UnexpectedException - if the request did not contain valid parameters