Class GXHTTPRequestBuilder
- java.lang.Object
-
- org.gcube.common.gxhttp.reference.GXHTTPRequestBuilder
-
public class GXHTTPRequestBuilder extends Object
Builder for GXHTTP Requests.- Author:
- Manuele Simi (ISTI CNR), Luca Frosini (ISTI-CNR)
-
-
Field Summary
Fields Modifier and Type Field Description GXConnectionconnectionprotected static org.slf4j.Loggerloggerstatic StringUUID_REGEX
-
Constructor Summary
Constructors Constructor Description GXHTTPRequestBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all the parameter except the address.HttpURLConnectionconnect()HttpURLConnectiondelete()Sends the DELETE request to the web application.GXHTTPRequestBuilderfrom(String agent)Sets the identity user agent associated to the request.HttpURLConnectionget()Sends the GET request to the web application.HttpURLConnectionhead()Sends the HEAD request to the web application.GXHTTPRequestBuilderheader(String name, String value)Add headers to the request.voidisExternalCall(boolean ext)HttpURLConnectionoptions()HttpURLConnectionpatch()GXHTTPRequestBuilderpath(String path)Adds s positional path parameter to the request.HttpURLConnectionpost()HttpURLConnectionput()GXHTTPRequestBuilderqueryParams(Map<String,String> parameters)Sets the query parameters for the request.voidsetSecurityToken(String token)Overrides the default security token.HttpURLConnectiontrace()
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
connection
public GXConnection connection
-
UUID_REGEX
public static final String UUID_REGEX
- See Also:
- Constant Field Values
-
-
Method Detail
-
from
public GXHTTPRequestBuilder from(String agent)
Sets the identity user agent associated to the request.- Parameters:
agent-- Returns:
- the request
-
path
public GXHTTPRequestBuilder path(String path) throws UnsupportedEncodingException
Adds s positional path parameter to the request.- Parameters:
path-- Returns:
- the request
- Throws:
UnsupportedEncodingException
-
queryParams
public GXHTTPRequestBuilder queryParams(Map<String,String> parameters) throws UnsupportedEncodingException
Sets the query parameters for the request.- Parameters:
parameters- the parameters that go in the URL after the address and the path params.- Returns:
- the request
- Throws:
UnsupportedEncodingException
-
setSecurityToken
public void setSecurityToken(String token)
Overrides the default security token.- Parameters:
token-
-
header
public GXHTTPRequestBuilder header(String name, String value)
Add headers to the request.- Parameters:
name-value-
-
put
public HttpURLConnection put() throws Exception
- Throws:
Exception
-
post
public HttpURLConnection post() throws Exception
- Throws:
Exception
-
get
public HttpURLConnection get() throws Exception
Sends the GET request to the web application.- Returns:
- the response
- Throws:
Exception
-
delete
public HttpURLConnection delete() throws Exception
Sends the DELETE request to the web application.- Returns:
- the response
- Throws:
Exception
-
head
public HttpURLConnection head() throws Exception
Sends the HEAD request to the web application.- Returns:
- the response
- Throws:
Exception
-
clear
public void clear()
Clears all the parameter except the address.
-
trace
public HttpURLConnection trace() throws Exception
- Throws:
Exception
-
patch
public HttpURLConnection patch() throws Exception
- Throws:
Exception
-
options
public HttpURLConnection options() throws Exception
- Throws:
Exception
-
connect
public HttpURLConnection connect() throws Exception
- Throws:
Exception
-
isExternalCall
public void isExternalCall(boolean ext)
-
-