public final class HttpLowLevel extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AUTH_REQUIRED_CODE |
static javax.ws.rs.core.MediaType |
CSV_TYPE |
protected static int |
DEFAULT_MAX_RETRIES |
static long |
DEFAULT_RETRY_TIME |
static javax.ws.rs.core.MediaType |
JSON_TYPE |
static com.sun.jersey.api.client.GenericType<List<Object>> |
MAP_OBJECT_TYPE |
static String |
SOCRATA_TOKEN_HEADER |
static String |
SODA_VERSION |
static String |
UNEXPECTED_ERROR |
static Map<String,String> |
UTF_PARAMS |
static javax.ws.rs.core.MediaType |
UTF8_TEXT_TYPE |
Constructor and Description |
---|
HttpLowLevel(com.sun.jersey.api.client.Client client,
String url)
Constructor
|
Modifier and Type | Method and Description |
---|---|
com.sun.jersey.api.client.ClientResponse |
deleteRaw(URI uri)
Raw version of the API for issuing a delete, doing common error processing and returning the ClientResponse.
|
com.sun.jersey.api.client.ClientResponse |
follow202(URI uri,
javax.ws.rs.core.MediaType mediaType,
long retryTime,
SodaRequest request2Rerun)
Follows a 202 response that comes back for long running queries.
|
<T> T |
getAsyncResults(URI uri,
long waitTime,
long numRetries,
Class<T> cls,
SodaRequest request2Rerun)
Method to check the async callbacks for new responses.
|
<T> T |
getAsyncResults(URI uri,
javax.ws.rs.core.MediaType mediaType,
long waitTime,
long numRetries,
com.sun.jersey.api.client.GenericType<T> cls,
SodaRequest request2Rerun)
Method to check the async callbacks for new responses.
|
com.sun.jersey.api.client.ClientResponse |
getAsyncResults(URI uri,
javax.ws.rs.core.MediaType mediaType,
long waitTime,
long numRetries,
SodaRequest request2Rerun)
Method to check the async callbacks for new responses.
|
com.sun.jersey.api.client.Client |
getClient()
Returns the Jersey Client object this connection will use.
|
long |
getMaxRetries()
Gets the max number of times to follow a 202 before failing
|
long |
getRetryTime()
Gets the number of milliseconds to wait before following a 202
|
static HttpLowLevel |
instantiate(String url)
Create an anonymous connection to a SODA2 domain rooted at
url |
static HttpLowLevel |
instantiateBasic(String url,
String userName,
String password,
String token)
Create an HttpLowLevel object that is set-up with the appropriate authentication credentials.
|
com.sun.jersey.api.client.ClientResponse |
postFileRaw(URI uri,
javax.ws.rs.core.MediaType mediaType,
File file) |
com.sun.jersey.api.client.ClientResponse |
postFileRaw(URI uri,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MediaType acceptType,
File file) |
com.sun.jersey.api.client.ClientResponse |
postRaw(URI uri,
javax.ws.rs.core.MediaType mediaType,
Object object)
Issues a raw POST to a URI.
|
com.sun.jersey.api.client.ClientResponse |
putFileRaw(URI uri,
javax.ws.rs.core.MediaType mediaType,
File file) |
com.sun.jersey.api.client.ClientResponse |
putFileRaw(URI uri,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MediaType acceptType,
File file) |
<T> com.sun.jersey.api.client.ClientResponse |
putRaw(URI uri,
javax.ws.rs.core.MediaType mediaType,
Object object)
Issues a raw PUT to a URI.
|
com.sun.jersey.api.client.ClientResponse |
queryRaw(URI uri,
javax.ws.rs.core.MediaType acceptType)
Issues a raw GET to a URI.
|
void |
setMaxRetries(long maxRetries)
Sets the max number of times to follow a 202 before failing
|
void |
setRetryTime(long retryTime)
Sets the number of milliseconds to wait before following a 202
|
javax.ws.rs.core.UriBuilder |
uriBuilder() |
protected static final int DEFAULT_MAX_RETRIES
public static final long DEFAULT_RETRY_TIME
public static final String SODA_VERSION
public static final String SOCRATA_TOKEN_HEADER
public static final String AUTH_REQUIRED_CODE
public static final String UNEXPECTED_ERROR
public static final javax.ws.rs.core.MediaType JSON_TYPE
public static final javax.ws.rs.core.MediaType CSV_TYPE
public static final javax.ws.rs.core.MediaType UTF8_TEXT_TYPE
public HttpLowLevel(com.sun.jersey.api.client.Client client, String url)
client
- the Jersey Client class that will be used for actually issuing requestsurl
- the base URL for the SODA2 domain to access.public static final HttpLowLevel instantiate(@Nonnull String url)
url
url
- the base URL for the SODA2 domain to access.public static final HttpLowLevel instantiateBasic(@Nonnull String url, @Nonnull String userName, @Nonnull String password, @Nullable String token)
url
- the base URL for the SODA2 domain to access.userName
- user name to log in aspassword
- password to log in withtoken
- the App Token to use for authorization and usage tracking. If this is null
, no value will be sent.public com.sun.jersey.api.client.Client getClient()
public long getRetryTime()
public void setRetryTime(long retryTime)
retryTime
- number of milliseconds to wait before following a 202public long getMaxRetries()
public void setMaxRetries(long maxRetries)
maxRetries
- max number of times to follow a 202 before failingpublic javax.ws.rs.core.UriBuilder uriBuilder()
public com.sun.jersey.api.client.ClientResponse follow202(URI uri, javax.ws.rs.core.MediaType mediaType, long retryTime, SodaRequest request2Rerun) throws InterruptedException, LongRunningQueryException, SodaError
uri
- the URI to go back toretryTime
- the amount of time to wait for a retryInterruptedException
- if this thread is interruptedLongRunningQueryException
- thrown if this query is long running and a 202 is returned. In this case,
the caller likely wants to call follow202.SodaError
- thrown if there is an error. Investigate the structure for more information.public final <T> T getAsyncResults(URI uri, long waitTime, long numRetries, Class<T> cls, SodaRequest request2Rerun) throws SodaError, InterruptedException
uri
- the URI to go to for responses.waitTime
- the time to wait until the first responsenumRetries
- the total number of times to retry before failing.cls
- the class of the object to return.SodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public final <T> T getAsyncResults(URI uri, javax.ws.rs.core.MediaType mediaType, long waitTime, long numRetries, com.sun.jersey.api.client.GenericType<T> cls, SodaRequest request2Rerun) throws SodaError, InterruptedException
uri
- the URI to go to for responses.waitTime
- the time to wait until the first responsenumRetries
- the total number of times to retry before failing.cls
- the GenericType describing the class of the object to return.SodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public final com.sun.jersey.api.client.ClientResponse getAsyncResults(URI uri, javax.ws.rs.core.MediaType mediaType, long waitTime, long numRetries, SodaRequest request2Rerun) throws SodaError, InterruptedException
uri
- the URI to go to for responses.waitTime
- the time to wait until the first responsenumRetries
- the total number of times to retry before failing.request2Rerun
- the object to use to re-run the request.SodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public com.sun.jersey.api.client.ClientResponse deleteRaw(URI uri) throws LongRunningQueryException, SodaError
uri
- URI to issue a request to. Any id information should have already been added.LongRunningQueryException
- thrown if this query is long running and a 202 is returned. In this case,
the caller likely wants to call follow202.SodaError
- thrown if there is an error. Investigate the structure for more information.public com.sun.jersey.api.client.ClientResponse queryRaw(URI uri, javax.ws.rs.core.MediaType acceptType) throws LongRunningQueryException, SodaError
uri
- URI to issue a request to. Any id information should have already been added.acceptType
- the MIME Type accepted by this clientLongRunningQueryException
- thrown if this query is long running and a 202 is returned. In this case,
the caller likely wants to call follow202.SodaError
- thrown if there is an error. Investigate the structure for more information.public com.sun.jersey.api.client.ClientResponse postRaw(URI uri, javax.ws.rs.core.MediaType mediaType, Object object) throws LongRunningQueryException, SodaError
uri
- URI to issue a request to. Any id information should have already been added.mediaType
- the MIME type the object is to be sent to the server as.object
- the object to send down to the server. This can be a Jackson serializable object or a raw
InputStream.LongRunningQueryException
- thrown if this query is long running and a 202 is returned. In this case,
the caller likely wants to call follow202.SodaError
- thrown if there is an error. Investigate the structure for more information.public com.sun.jersey.api.client.ClientResponse postFileRaw(URI uri, javax.ws.rs.core.MediaType mediaType, File file) throws LongRunningQueryException, SodaError
LongRunningQueryException
SodaError
public com.sun.jersey.api.client.ClientResponse postFileRaw(URI uri, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MediaType acceptType, File file) throws LongRunningQueryException, SodaError
LongRunningQueryException
SodaError
public <T> com.sun.jersey.api.client.ClientResponse putRaw(URI uri, javax.ws.rs.core.MediaType mediaType, Object object) throws LongRunningQueryException, SodaError
uri
- URI to issue a request to. Any id information should have already been added.mediaType
- the MIME type the object is to be sent to the server as.object
- the object to send down to the server. This can be a Jackson serializable object or a raw
InputStream.LongRunningQueryException
- thrown if this query is long running and a 202 is returned. In this case,
the caller likely wants to call follow202.SodaError
- thrown if there is an error. Investigate the structure for more information.public com.sun.jersey.api.client.ClientResponse putFileRaw(URI uri, javax.ws.rs.core.MediaType mediaType, File file) throws LongRunningQueryException, SodaError
LongRunningQueryException
SodaError
public com.sun.jersey.api.client.ClientResponse putFileRaw(URI uri, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MediaType acceptType, File file) throws LongRunningQueryException, SodaError
LongRunningQueryException
SodaError
Copyright © 2013. All Rights Reserved.