Package com.iizix.ws.engine
Class RESTfulRequest
java.lang.Object
com.iizix.ws.engine.RESTfulRequest
Class used to process a RESTful transaction for a defined Web Service transaction.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorDescriptionRESTfulRequest
(IAppSessionGyro appGyro, WebServiceProp wsProp, IRequestContent requestContent, boolean doPerform) Constructs the transaction for the Web Service.Method Summary
Modifier and TypeMethodDescriptionCreate the reply instance.Returns the application session gyro instance.Gets the Web Service Engine.Gets the HTTP request properties.Gets the HTTP(S) URLConnection.getInput()
Gets the Web Service RESTful input properties.Gets the HTTP method for the request.Gets the Web Service output properties.Gets the override method used for "X-HTTP-Method-Override".getProxy()
Gets the Proxy to use.Gets the String read encoding.int
Gets the read timeout for the Socket.getURI()
Gets the URI for the request, without the Query parameters.Gets the String write encoding.static String
Parses and updates the URI path when the URI path is parameterized, e.g.void
reformatParameterizedURIPath
(Map<String, String> params) Parses and updates the URI path when the URI path is parameterized, e.g.void
Sets the HTTP method for the request.void
setOverrideMethod
(Method overrideMethod) Sets the override method.void
Sets the proxy to use.void
setReadEncoding
(String readEncoding) Sets the String output encoding.void
setReadTimeout
(int readTimeout) Sets the read timeout.void
Sets the URI for the request that will be used for the URL connection.void
setWriteEncoding
(String writeEncoding) Sets the String write encoding.Gets the Web Service property.
Constructor Details
RESTfulRequest
public RESTfulRequest(IAppSessionGyro appGyro, WebServiceProp wsProp, IRequestContent requestContent, boolean doPerform) throws IOException, PropException, URISyntaxException Constructs the transaction for the Web Service.- Parameters:
wsProp
- The Web Service property.requestContent
- The request content.doPerform
- Flag to perform the transaction or false to test validity.- Throws:
IOException
- For I/O errors.PropException
- For property errors due to invalid transaction.URISyntaxException
- When URI syntax is invalid.
Method Details
createReply
Create the reply instance.- Returns:
- The REST reply instance.
- Throws:
IOException
- If URLConenction is not a HTTP URL connection.
getAppSessionGyro
Returns the application session gyro instance.- Returns:
- The instance, or null for the Designer.
WebServiceProp
Gets the Web Service property.- Returns:
- The web service properties.
getEngine
Gets the Web Service Engine.- Returns:
- The web service engine.
getInput
Gets the Web Service RESTful input properties.- Returns:
- The input properties (params, etc).
getOutput
Gets the Web Service output properties.- Returns:
- The output properties, processors, variable mappings, etc.
getReadTimeout
public int getReadTimeout()Gets the read timeout for the Socket.- Returns:
- Read timeout in milliseconds.
setReadTimeout
public void setReadTimeout(int readTimeout) Sets the read timeout.- Parameters:
readTimeout
- Timeout in milliseconds for the Socket.
getMethod
Gets the HTTP method for the request.- Returns:
- The request method.
setMethod
Sets the HTTP method for the request.- Parameters:
method
- The method to use.- Throws:
NullPointerException
- If parameter isnull
.
getOverrideMethod
Gets the override method used for "X-HTTP-Method-Override".- Returns:
null
for none, otherwise GET, POST or PUT.
setOverrideMethod
Sets the override method.- Parameters:
overrideMethod
- The override method, null for none.
getWriteEncoding
Gets the String write encoding.- Returns:
- The encoding, default "UTF-8".
setWriteEncoding
Sets the String write encoding.- Parameters:
writeEncoding
- The encoding, default "UTF-8".- Throws:
NullPointerException
- If parameter isnull
.UnsupportedEncodingException
- For unsupported encoding.
getReadEncoding
Gets the String read encoding.- Returns:
- The encoding, default "UTF-8".
setReadEncoding
Sets the String output encoding.- Parameters:
readEncoding
- The encoding, default "UTF-8".- Throws:
NullPointerException
- If parameter isnull
.UnsupportedEncodingException
- For unsupported encoding.
getURI
Gets the URI for the request, without the Query parameters.- Returns:
- The URI.
setURI
Sets the URI for the request that will be used for the URL connection.- Parameters:
uri
- The URI.- Throws:
NullPointerException
- If parameter isnull
.
getProxy
Gets the Proxy to use.- Returns:
- The Proxy for the connection, null if not retrieved yet.
setProxy
Sets the proxy to use.- Parameters:
proxy
- The proxy.- Throws:
NullPointerException
- If parameter isnull
.
getHTTPRequestProperties
Gets the HTTP request properties.- Returns:
- A map with the property names as keys (e.g. "Content-Type", or "Accept-Charset") and their values.
getHTTPURLConnection
Gets the HTTP(S) URLConnection.- Returns:
- The HTTP(S) URLConnection, or null if not HTTP/HTTPS protocol.
reformatParameterizedURIPath
public void reformatParameterizedURIPath(Map<String, String> params) throws URISyntaxException, UnsupportedEncodingExceptionParses and updates the URI path when the URI path is parameterized, e.g. a path such as "https://host.com/path/{param1}{param2}/{param3}". The variables found are taken from the list of parameters that must be of type "isURIPathParameter".- Parameters:
params
- The parameters list map. The key is the parameter name and the value is a non-null String.- Throws:
URISyntaxException
- If the URI is in error in regards to parameters.NullPointerException
- If a parameter value is null.UnsupportedEncodingException
- For unsupported encodings.
reformatParameterizedURIPath
public static String reformatParameterizedURIPath(String uri, Map<String, String> params, String encoding) throws URISyntaxException, UnsupportedEncodingExceptionParses and updates the URI path when the URI path is parameterized, e.g. a path such as "https://host.com/path/{param1}{param2}/{param3}". The variables found are taken from the list of parameters that must be of type "isURIPathParameter".- Parameters:
params
- The parameters list map. The key is the parameter name and the value is a non-null String.- Returns:
- The new URI (if changed).
- Throws:
URISyntaxException
- If the URI is in error in regards to parameters.NullPointerException
- If a parameter value is null.UnsupportedEncodingException
- For unsupported encodings.