Package com.iizix.ws.engine
Class RESTfulRequest
- java.lang.Object
- com.iizix.ws.engine.RESTfulRequest
public class RESTfulRequest extends java.lang.Object
Class used to process a RESTful transaction for a defined Web Service transaction.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description RESTfulRequest(IAppSessionGyro appGyro, WebServiceProp wsProp, IRequestContent requestContent, boolean doPerform)
Constructs the transaction for the Web Service.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RESTfulReply
createReply()
Create the reply instance.IAppSessionGyro
getAppSessionGyro()
Returns the application session gyro instance.IWebServiceEngine
getEngine()
Gets the Web Service Engine.java.util.Map<java.lang.String,java.lang.String>
getHTTPRequestProperties()
Gets the HTTP request properties.java.net.HttpURLConnection
getHTTPURLConnection()
Gets the HTTP(S) URLConnection.RESTfulInputProps
getInput()
Gets the Web Service RESTful input properties.Method
getMethod()
Gets the HTTP method for the request.OutputProps
getOutput()
Gets the Web Service output properties.Method
getOverrideMethod()
Gets the override method used for "X-HTTP-Method-Override".java.net.Proxy
getProxy()
Gets the Proxy to use.java.lang.String
getReadEncoding()
Gets the String read encoding.int
getReadTimeout()
Gets the read timeout for the Socket.java.lang.String
getURI()
Gets the URI for the request, without the Query parameters.java.lang.String
getWriteEncoding()
Gets the String write encoding.static java.lang.String
reformatParameterizedURIPath(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String encoding)
Parses and updates the URI path when the URI path is parameterized, e.g.void
reformatParameterizedURIPath(java.util.Map<java.lang.String,java.lang.String> params)
Parses and updates the URI path when the URI path is parameterized, e.g.void
setMethod(Method method)
Sets the HTTP method for the request.void
setOverrideMethod(Method overrideMethod)
Sets the override method.void
setProxy(java.net.Proxy proxy)
Sets the proxy to use.void
setReadEncoding(java.lang.String readEncoding)
Sets the String output encoding.void
setReadTimeout(int readTimeout)
Sets the read timeout.void
setURI(java.lang.String uri)
Sets the URI for the request that will be used for the URL connection.void
setWriteEncoding(java.lang.String writeEncoding)
Sets the String write encoding.WebServiceProp
WebServiceProp()
Gets the Web Service property.
Constructor Detail
RESTfulRequest
public RESTfulRequest(IAppSessionGyro appGyro, WebServiceProp wsProp, IRequestContent requestContent, boolean doPerform) throws java.io.IOException, PropException, java.net.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:
java.io.IOException
- For I/O errors.PropException
- For property errors due to invalid transaction.java.net.URISyntaxException
- When URI syntax is invalid.
Method Detail
createReply
public RESTfulReply createReply() throws java.io.IOException
Create the reply instance.- Returns:
- The REST reply instance.
- Throws:
java.io.IOException
- If URLConenction is not a HTTP URL connection.
getAppSessionGyro
public IAppSessionGyro getAppSessionGyro()
Returns the application session gyro instance.- Returns:
- The instance, or null for the Designer.
WebServiceProp
public WebServiceProp WebServiceProp()
Gets the Web Service property.- Returns:
- The web service properties.
getEngine
public IWebServiceEngine getEngine()
Gets the Web Service Engine.- Returns:
- The web service engine.
getInput
public RESTfulInputProps getInput()
Gets the Web Service RESTful input properties.- Returns:
- The input properties (params, etc).
getOutput
public OutputProps 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
public Method getMethod()
Gets the HTTP method for the request.- Returns:
- The request method.
setMethod
public void setMethod(Method method)
Sets the HTTP method for the request.- Parameters:
method
- The method to use.- Throws:
java.lang.NullPointerException
- If parameter isnull
.
getOverrideMethod
public Method getOverrideMethod()
Gets the override method used for "X-HTTP-Method-Override".- Returns:
null
for none, otherwise GET, POST or PUT.
setOverrideMethod
public void setOverrideMethod(Method overrideMethod)
Sets the override method.- Parameters:
overrideMethod
- The override method, null for none.
getWriteEncoding
public java.lang.String getWriteEncoding()
Gets the String write encoding.- Returns:
- The encoding, default "UTF-8".
setWriteEncoding
public void setWriteEncoding(java.lang.String writeEncoding) throws java.io.UnsupportedEncodingException
Sets the String write encoding.- Parameters:
writeEncoding
- The encoding, default "UTF-8".- Throws:
java.lang.NullPointerException
- If parameter isnull
.java.io.UnsupportedEncodingException
- For unsupported encoding.
getReadEncoding
public java.lang.String getReadEncoding()
Gets the String read encoding.- Returns:
- The encoding, default "UTF-8".
setReadEncoding
public void setReadEncoding(java.lang.String readEncoding) throws java.io.UnsupportedEncodingException
Sets the String output encoding.- Parameters:
readEncoding
- The encoding, default "UTF-8".- Throws:
java.lang.NullPointerException
- If parameter isnull
.java.io.UnsupportedEncodingException
- For unsupported encoding.
getURI
public java.lang.String getURI()
Gets the URI for the request, without the Query parameters.- Returns:
- The URI.
setURI
public void setURI(java.lang.String uri)
Sets the URI for the request that will be used for the URL connection.- Parameters:
uri
- The URI.- Throws:
java.lang.NullPointerException
- If parameter isnull
.
getProxy
public java.net.Proxy getProxy()
Gets the Proxy to use.- Returns:
- The Proxy for the connection, null if not retrieved yet.
setProxy
public void setProxy(java.net.Proxy proxy)
Sets the proxy to use.- Parameters:
proxy
- The proxy.- Throws:
java.lang.NullPointerException
- If parameter isnull
.
getHTTPRequestProperties
public java.util.Map<java.lang.String,java.lang.String> 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
public java.net.HttpURLConnection getHTTPURLConnection()
Gets the HTTP(S) URLConnection.- Returns:
- The HTTP(S) URLConnection, or null if not HTTP/HTTPS protocol.
reformatParameterizedURIPath
public void reformatParameterizedURIPath(java.util.Map<java.lang.String,java.lang.String> params) throws java.net.URISyntaxException, java.io.UnsupportedEncodingException
Parses 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:
java.net.URISyntaxException
- If the URI is in error in regards to parameters.java.lang.NullPointerException
- If a parameter value is null.java.io.UnsupportedEncodingException
- For unsupported encodings.
reformatParameterizedURIPath
public static java.lang.String reformatParameterizedURIPath(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String encoding) throws java.net.URISyntaxException, java.io.UnsupportedEncodingException
Parses 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:
java.net.URISyntaxException
- If the URI is in error in regards to parameters.java.lang.NullPointerException
- If a parameter value is null.java.io.UnsupportedEncodingException
- For unsupported encodings.