public class HalClientBase implements IHalClient
HAL client base class
| Modifier and Type | Class and Description |
|---|---|
static class |
HalClientBase.Companion |
| Modifier and Type | Field and Description |
|---|---|
static HalClientBase.Companion |
Companion |
static java.lang.String |
ROOT |
| Constructor and Description |
|---|
HalClientBase(java.lang.String baseUrl,
java.util.Map<java.lang.String,? extends java.lang.Object> options)
HAL client base class
|
HalClientBase(java.lang.String baseUrl)
HAL client base class
|
| Modifier and Type | Method and Description |
|---|---|
com.google.gson.JsonElement |
fetch(java.lang.String path)
Fetches the HAL document from the provided path
|
com.google.gson.JsonElement |
fetch(java.lang.String path,
boolean encodePath)
Fetches the HAL document from the provided path
|
java.lang.String |
getBaseUrl() |
org.apache.http.impl.client.CloseableHttpClient |
getHttpClient() |
java.lang.String |
getLastUrl() |
java.util.Map<java.lang.String,java.lang.Object> |
getOptions() |
com.google.gson.JsonElement |
getPathInfo() |
java.lang.Object |
handleFailure(org.apache.http.HttpResponse resp,
java.lang.String body,
java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Object> closure) |
void |
initPathInfo() |
IHalClient |
navigate(java.util.Map<java.lang.String,? extends java.lang.Object> options,
java.lang.String link)
Navigates the URL associated with the given link using the current HAL document
|
IHalClient |
navigate(java.lang.String link)
Navigates the URL associated with the given link using the current HAL document
|
java.lang.String |
parseLinkUrl(java.lang.String href,
java.util.Map<java.lang.String,? extends java.lang.Object> options) |
Result<java.lang.Boolean,java.lang.Exception> |
postJson(java.lang.String url,
java.lang.String body)
Upload the JSON document to the provided URL, using a POST request
|
Result<java.lang.Boolean,java.lang.Exception> |
postJson(java.lang.String url,
java.lang.String body,
kotlin.jvm.functions.Function2<? super java.lang.Integer,? super org.apache.http.client.methods.CloseableHttpResponse,java.lang.Boolean> handler)
Upload the JSON document to the provided URL, using a POST request
|
void |
setHttpClient(org.apache.http.impl.client.CloseableHttpClient p) |
void |
setLastUrl(java.lang.String p) |
void |
setOptions(java.util.Map<java.lang.String,? extends java.lang.Object> p) |
void |
setPathInfo(com.google.gson.JsonElement p) |
org.apache.http.impl.client.CloseableHttpClient |
setupHttpClient() |
java.lang.Object |
uploadJson(java.lang.String path,
java.lang.String bodyJson)
Upload the JSON document to the provided path, using a PUT request
|
java.lang.Object |
uploadJson(java.lang.String path,
java.lang.String bodyJson,
java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Object> closure)
Upload the JSON document to the provided path, using a PUT request
|
java.lang.Object |
uploadJson(java.lang.String path,
java.lang.String bodyJson,
java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Object> closure,
boolean encodePath)
Upload the JSON document to the provided path, using a PUT request
|
fetch, fetch, forAll, linkUrl, navigate, navigate, postJson, postJson, uploadJson, uploadJson, uploadJsonpublic static java.lang.String ROOT
public static HalClientBase.Companion Companion
public HalClientBase(java.lang.String baseUrl,
java.util.Map<java.lang.String,? extends java.lang.Object> options)
HAL client base class
public HalClientBase(java.lang.String baseUrl)
HAL client base class
public org.apache.http.impl.client.CloseableHttpClient getHttpClient()
public void setHttpClient(org.apache.http.impl.client.CloseableHttpClient p)
public com.google.gson.JsonElement getPathInfo()
public void setPathInfo(com.google.gson.JsonElement p)
public java.lang.String getLastUrl()
public void setLastUrl(java.lang.String p)
public Result<java.lang.Boolean,java.lang.Exception> postJson(java.lang.String url, java.lang.String body)
Upload the JSON document to the provided URL, using a POST request
url - Url to upload the document tobody - JSON contents for the bodypublic Result<java.lang.Boolean,java.lang.Exception> postJson(java.lang.String url, java.lang.String body, kotlin.jvm.functions.Function2<? super java.lang.Integer,? super org.apache.http.client.methods.CloseableHttpResponse,java.lang.Boolean> handler)
Upload the JSON document to the provided URL, using a POST request
url - Url to upload the document tobody - JSON contents for the bodyhandler - Response handlerpublic org.apache.http.impl.client.CloseableHttpClient setupHttpClient()
public IHalClient navigate(java.util.Map<java.lang.String,? extends java.lang.Object> options, java.lang.String link)
Navigates the URL associated with the given link using the current HAL document
options - Map of key-value pairs to use for parsing templated linkslink - Link name to navigatepublic IHalClient navigate(java.lang.String link)
Navigates the URL associated with the given link using the current HAL document
link - Link name to navigatepublic com.google.gson.JsonElement fetch(java.lang.String path)
Fetches the HAL document from the provided path
path - The path to the HAL document. If it is a relative path, it is relative to the base URLpublic com.google.gson.JsonElement fetch(java.lang.String path,
boolean encodePath)
Fetches the HAL document from the provided path
path - The path to the HAL document. If it is a relative path, it is relative to the base URLencodePath - If the path should be encoded to make a valid URLpublic java.lang.String parseLinkUrl(java.lang.String href,
java.util.Map<java.lang.String,? extends java.lang.Object> options)
public void initPathInfo()
public java.lang.Object uploadJson(java.lang.String path,
java.lang.String bodyJson)
Upload the JSON document to the provided path, using a PUT request
path - Path to upload the documentbodyJson - JSON contents for the bodypublic java.lang.Object uploadJson(java.lang.String path,
java.lang.String bodyJson,
java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Object> closure)
Upload the JSON document to the provided path, using a PUT request
path - Path to upload the documentbodyJson - JSON contents for the bodyclosure - Closure that will be invoked with details about the response. The result from the closure will be
returned.public java.lang.Object uploadJson(java.lang.String path,
java.lang.String bodyJson,
java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Object> closure,
boolean encodePath)
Upload the JSON document to the provided path, using a PUT request
path - Path to upload the documentbodyJson - JSON contents for the bodyclosure - Closure that will be invoked with details about the response. The result from the closure will be
returned.encodePath - If the path must be encoded beforehand.public java.lang.Object handleFailure(org.apache.http.HttpResponse resp,
java.lang.String body,
java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Object> closure)
public java.lang.String getBaseUrl()
public java.util.Map<java.lang.String,java.lang.Object> getOptions()
public void setOptions(java.util.Map<java.lang.String,? extends java.lang.Object> p)