Package com.cloudofficeprint.Resources
Class RESTResource
- java.lang.Object
-
- com.cloudofficeprint.RenderElements.RenderElement
-
- com.cloudofficeprint.Resources.ExternalResource
-
- com.cloudofficeprint.Resources.RESTResource
-
public class RESTResource extends ExternalResource
Class for working with a REST endpoint as Resource.
-
-
Constructor Summary
Constructors Constructor Description RESTResource(java.lang.String endpoint, java.lang.String method, java.lang.String body, java.lang.String fileName, com.google.gson.JsonArray headers, java.lang.String auth)
Resource from an REST endpoint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getBody()
com.google.gson.JsonObject
getJSON()
java.lang.String
getMethod()
java.util.Set<java.lang.String>
getTemplateTags()
Cannot be used for a resource.void
setBody(java.lang.String body)
void
setMethod(java.lang.String method)
-
Methods inherited from class com.cloudofficeprint.Resources.ExternalResource
getAuth, getDataSource, getEndpoint, getFileName, getHeaders, setAuth, setDataSource, setEndpoint, setFileName, setHeaders
-
Methods inherited from class com.cloudofficeprint.RenderElements.RenderElement
getName, getValue, setName, setValue
-
-
-
-
Constructor Detail
-
RESTResource
public RESTResource(java.lang.String endpoint, java.lang.String method, java.lang.String body, java.lang.String fileName, com.google.gson.JsonArray headers, java.lang.String auth)
Resource from an REST endpoint.- Parameters:
endpoint
- URL of the data source from where the JSON needs to be read.method
- HTTP method of the request. "GET" by default.body
- Body of HTTP request (can be left empty for GET requests)fileName
- Name of the output file.headers
- HTTP headers, e.g. [{"Content-Type":"application/json"},{"Custom-Auth-Token":"xysazxklj4568asdf46a5sd4f"}]auth
- Basic authentication i.e. 'user:password' to compute an Authorization header.
-
-
Method Detail
-
getMethod
public java.lang.String getMethod()
- Returns:
- HTTP method of the request.
-
setMethod
public void setMethod(java.lang.String method)
- Parameters:
method
- HTTP method of the request. "GET" by default.
-
getBody
public java.lang.String getBody()
- Returns:
- Body of HTTP request (can be left empty for GET requests).
-
setBody
public void setBody(java.lang.String body)
- Parameters:
body
- Body of HTTP request (can be left empty for GET requests).
-
getJSON
public com.google.gson.JsonObject getJSON()
- Overrides:
getJSON
in classExternalResource
- Returns:
- JSONObject with the tags for this element for the Cloud Office Print server.
-
getTemplateTags
public java.util.Set<java.lang.String> getTemplateTags()
Cannot be used for a resource.- Specified by:
getTemplateTags
in classRenderElement
- Returns:
- null
-
-