|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- the type of request used for method chainingpublic interface Request<T extends Request<?,?>,RESP extends Response>
Interface Request represents a request to retrieve data. To execute a request call execute(ResponseHandler)
.
Nested Class Summary | |
---|---|
static class |
Request.MethodType
Represents type of network request |
Method Summary | ||
---|---|---|
T |
addAuthentication(Authenticator authenticator)
Adds generic Authenticator to the request. |
|
T |
addBasicAuthentication(String username,
String password)
Adds basic authentication to the request. |
|
T |
addHeader(String headerName,
String headerValue)
Adds the specified header to the request, not overwriting any previous value. |
|
T |
addRequestParameters(String... params)
Sets parameters of the request. |
|
T |
addSeraphAuthentication(String username,
String password)
Adds seraph authentication to the request. |
|
T |
addTrustedTokenAuthentication()
Adds TrustedTokenAuthentication to the request. |
|
T |
addTrustedTokenAuthentication(String username)
Adds TrustedTokenAuthentication to the request. |
|
String |
execute()
Executes a request and if response is successful, returns response as a string. |
|
void |
execute(ResponseHandler<RESP> responseHandler)
Executes the request. |
|
|
executeAndReturn(ReturningResponseHandler<RESP,RET> responseHandler)
Executes the request and returns a result value. |
|
Map<String,List<String>> |
getHeaders()
|
|
T |
setConnectionTimeout(int connectionTimeout)
Setting connection timeout in milliseconds. |
|
T |
setEntity(Object entity)
Set an entity as the request body |
|
T |
setFiles(List<RequestFilePart> files)
Sets file parts of the request. |
|
T |
setFollowRedirects(boolean follow)
Sets whether the request should transparently follow a redirect from the server. |
|
T |
setHeader(String headerName,
String headerValue)
Sets the specified header to the request, overwriting any previous value. |
|
T |
setRequestBody(String requestBody)
Sets the body of the request. |
|
T |
setRequestContentType(String contentType)
Sets Content-Type of the body of the request. |
|
T |
setSoTimeout(int soTimeout)
Setting socket timeout in milliseconds. |
|
T |
setUrl(String url)
|
Method Detail |
---|
T setConnectionTimeout(int connectionTimeout)
connectionTimeout
- The timeout in milliseconds
T setSoTimeout(int soTimeout)
soTimeout
- the timeout in milliseconds
T setUrl(String url)
url
- the url to request
T setRequestBody(String requestBody)
Request.MethodType.POST
and Request.MethodType.PUT
can have a request body.
requestBody
- the body of the request
T setFiles(List<RequestFilePart> files)
Request.MethodType.POST
and Request.MethodType.PUT
can have file parts.
files
- the file parts, cannot be null.
IllegalArgumentException
- if the method of this request is not a POST or PUT or files is NULL.
IllegalStateException
- if the request body for this request has already been set.T setEntity(Object entity)
entity
- the request entity to be marshalled, not null
T setRequestContentType(String contentType)
Request.MethodType.POST
and Request.MethodType.PUT
can have a request body.
contentType
- the contentType of the request
T addRequestParameters(String... params)
Request.MethodType.POST
can have parameters.
For other requests include parameters in url. This method accepts an even number of arguments, in form of name, value, name, value, name, value, etc
params
- parameters of the request in as name, value pairs
T addAuthentication(Authenticator authenticator)
authenticator
- the authenticator to use for authentication
T addTrustedTokenAuthentication()
T addTrustedTokenAuthentication(String username)
username
- The user to make the request with
T addBasicAuthentication(String username, String password)
username
- The user namepassword
- The password
T addSeraphAuthentication(String username, String password)
username
- The user namepassword
- The password
T addHeader(String headerName, String headerValue)
headerName
- the header's nameheaderValue
- the header's value
RequestFactory.supportsHeader()
T setHeader(String headerName, String headerValue)
headerName
- the header's nameheaderValue
- the header's value
RequestFactory.supportsHeader()
T setFollowRedirects(boolean follow)
follow
- set this to false to have the request not transparently follow redirects.
Map<String,List<String>> getHeaders()
void execute(ResponseHandler<RESP> responseHandler) throws ResponseException
responseHandler
- Callback handler of the response.
ResponseProtocolException
- If the server returned a malformed response
ResponseTimeoutException
- If a connection timeout or read timeout occurred
ResponseTransportException
- If an I/O error occurred in request transport
ResponseException
- For all errors not otherwise specifiedString execute() throws ResponseException
Response.getResponseBodyAsString()
ResponseStatusException
- If the server returned a response that contained an error code
ResponseProtocolException
- If the server returned a malformed response
ResponseTimeoutException
- If a connection timeout or read timeout occurred
ResponseTransportException
- If an I/O error occurred in request transport
ResponseException
- For all errors not otherwise specified<RET> RET executeAndReturn(ReturningResponseHandler<RESP,RET> responseHandler) throws ResponseException
responseHandler
- Callback handler of the response.
ResponseProtocolException
- If the server returned a malformed response
ResponseTimeoutException
- If a connection timeout or read timeout occurred
ResponseTransportException
- If an I/O error occurred in request transport
ResponseException
- For all errors not otherwise specified
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |