class WebService extends java.lang.Object
| Modifiers | Name | Description |
|---|---|---|
class |
WebService.1 |
| Type | Name and description |
|---|---|
static java.lang.String |
CHAR_ENCODING |
static java.lang.String |
DEFAULT_API_KEY_HEADER |
static java.lang.String |
DEFAULT_AUTH_HEADER |
static int |
DEFAULT_TIMEOUT_MILLIS |
static java.nio.charset.Charset |
UTF_8 |
au.org.ala.web.AuthService |
authService |
java.lang.Object |
grailsApplication |
TokenService |
tokenService |
| Constructor and description |
|---|
WebService
() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static org.grails.web.json.JSONElement |
decodeJSON(org.apache.http.HttpResponse httpResponse)Decode an Apache HTTP Response as JSON using the Grails JSON support |
|
java.util.Map |
delete(java.lang.String url, java.util.Map params, groovyx.net.http.ContentType contentType, boolean includeApiKey, boolean includeUser, java.util.Map customHeaders)Sends a HTTP DELETE request to the specified URL. |
|
static java.lang.String |
enc(java.lang.String str) |
|
static org.apache.http.HttpEntity |
encodeJSON(java.lang.Object model, java.lang.Object contentType)Use Grails JSON to encode an object as JSON. |
|
java.util.Map |
get(java.lang.String url, java.util.Map params, groovyx.net.http.ContentType contentType, boolean includeApiKey, boolean includeUser, java.util.Map customHeaders)Sends an HTTP GET request to the specified URL. |
|
void |
includeAuthTokens(java.lang.Boolean includeUser, java.lang.Boolean includeApiKey, au.org.ala.web.UserDetails user, java.net.URLConnection conn) |
|
void |
includeAuthTokensJwt(java.lang.Object includeUser, java.lang.Object includeApiKey, java.lang.Object user, java.lang.Object headerSetter) |
|
void |
includeAuthTokensLegacy(java.lang.Object includeUser, java.lang.Object includeApiKey, java.lang.Object user, java.lang.Object headerSetter) |
|
groovyx.net.http.HTTPBuilder |
newHttpBuilder(java.lang.String url, groovyx.net.http.ContentType contentType) |
|
java.util.Map |
post(java.lang.String url, java.util.Map body, java.util.Map params, groovyx.net.http.ContentType contentType, boolean includeApiKey, boolean includeUser, java.util.Map customHeaders)Sends an HTTP POST request to the specified URL. |
|
java.util.Map |
postMultipart(java.lang.String url, java.util.Map body, java.util.Map params, java.util.List files, groovyx.net.http.ContentType partContentType, boolean includeApiKey, boolean includeUser, java.util.Map customHeaders)Sends a multipart HTTP POST request to the specified URL. |
|
void |
proxyGetRequest(javax.servlet.http.HttpServletResponse response, java.lang.String url, boolean includeApiKey, boolean includeUser)Proxies a request URL but doesn't assume the response is text based. |
|
void |
proxyPostRequest(javax.servlet.http.HttpServletResponse response, java.lang.String url, java.lang.Object postBody, groovyx.net.http.ContentType contentType, boolean includeApiKey, boolean includeUser, java.util.Map cookies)Proxies a request URL with post data but doesn't assume the response is text based. |
|
java.util.Map |
put(java.lang.String url, java.util.Map body, java.util.Map params, groovyx.net.http.ContentType contentType, boolean includeApiKey, boolean includeUser, java.util.Map customHeaders)Sends an HTTP PUT request to the specified URL. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Decode an Apache HTTP Response as JSON using the Grails JSON support
httpResponse - The HTTP Response to decode as JSONSends a HTTP DELETE request to the specified URL. The URL must already be URL-encoded (if necessary). Note: by default, the Accept header will be set to the same content type as the ContentType provided. To override this default behaviour, include an 'Accept' header in the 'customHeaders' parameter.
url - The url-encoded url to send the request toparams - Map of parameters to be appended to the query string. Parameters will be URL-encoded automatically.contentType - the desired content type for the request. Defaults to application/jsonincludeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.customHeaders - Map of [headerName:value] for any extra HTTP headers to be sent with the request. Default = [:].Use Grails JSON to encode an object as JSON. If the object is a String, assume that it's already a well formed JSON document and return it as such. Otherwise, convert the object to JSON using `o as JSON` and then return an entity that will write the result to an OutputStream.
model - The model to convert to JSONcontentType - The content type. Could be anything.Sends an HTTP GET request to the specified URL. The URL must already be URL-encoded (if necessary). Note: by default, the Accept header will be set to the same content type as the ContentType provided. To override this default behaviour, include an 'Accept' header in the 'customHeaders' parameter.
url - The url-encoded URL to send the request toparams - Map of parameters to be appended to the query string. Parameters will be URL-encoded automatically.contentType - the desired content type for the request. Defaults to application/jsonincludeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.customHeaders - Map of [headerName:value] for any extra HTTP headers to be sent with the request. Default = [:].Sends an HTTP POST request to the specified URL. The URL must already be URL-encoded (if necessary). Note: by default, the Accept header will be set to the same content type as the ContentType provided. To override this default behaviour, include an 'Accept' header in the 'customHeaders' parameter. The body map will be sent as the body of the request (i.e. use request.getJSON() on the receiving end).
url - The url-encoded url to send the request tobody - Map containing the data to be sent as the post bodyparams - Map of parameters to be appended to the query string. Parameters will be URL-encoded automatically.contentType - the desired content type for the request. Defaults to application/jsonincludeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.customHeaders - Map of [headerName:value] for any extra HTTP headers to be sent with the request. Default = [:].Sends a multipart HTTP POST request to the specified URL. The URL must already be URL-encoded (if necessary). Note: by default, the Accept header will be set to the same content type as the ContentType provided. To override this default behaviour, include an 'Accept' header in the 'customHeaders' parameter. Each item in the body map will be sent as a separate Part in the Multipart Request. To send the entire map as a single part, you will need too use the format [data: body]. Files can be one of the following types:
url - The url-encoded url to send the request tobody - Map containing the data to be sent as the post bodyparams - Map of parameters to be appended to the query string. Parameters will be URL-encoded automatically.files - List of 0 or more files to be included in the multipart request (note: if files is null, then the request will NOT be multipart)partContentType - the desired content type for the request PARTS (the request itself will always be sent as multipart/form-data). Defaults to application/json. All non-file parts will have the same content type.includeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.customHeaders - Map of [headerName:value] for any extra HTTP headers to be sent with the request. Default = [:].Proxies a request URL but doesn't assume the response is text based. Used for operations like proxying a download request from one application to another.
response - The HttpServletResponse of the calling request: the response from the proxied request will be written to this objecturl - The URL of the service to proxy toincludeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.Proxies a request URL with post data but doesn't assume the response is text based.
response - The HttpServletResponse of the calling request: the response from the proxied request will be written to this objecturl - The URL of the service to proxy topostBody - The POST data to send with the proxied request. If it is a Collection, then it will be converted to JSON, otherwise it will be sent as a String.contentType - the desired content type for the request. Defaults to application/json.includeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.Sends an HTTP PUT request to the specified URL. The URL must already be URL-encoded (if necessary). Note: by default, the Accept header will be set to the same content type as the ContentType provided. To override this default behaviour, include an 'Accept' header in the 'customHeaders' parameter. The body map will be sent as the JSON body of the request (i.e. use request.getJSON() on the receiving end).
url - The url-encoded url to send the request tobody - Map containing the data to be sent as the post bodyparams - Map of parameters to be appended to the query string. Parameters will be URL-encoded automatically.contentType - the desired content type for the request. Defaults to application/jsonincludeApiKey - true to include the service's API Key in the request headers (uses property 'service.apiKey'). If using JWTs, instead sends a JWT Bearer tokens Default = true.includeUser - true to include the userId and email in the request headers and the ALA-Auth cookie. If using JWTs sends the current user's access token, if false only sends a ClientCredentials grant token for this apps client id Default = true.customHeaders - Map of [headerName:value] for any extra HTTP headers to be sent with the request. Default = [:].Groovy Documentation