public class ClientRequest
extends javax.servlet.http.HttpServlet
| Modifier and Type | Class and Description |
|---|---|
class |
ClientRequest.Context
Inner class used to store servlet context information.
|
class |
ClientRequest.DisplayableAttribute
Inner class used to define a displayable product attribute.
|
class |
ClientRequest.OrderLine
Inner class used to define the data for an uploaded order line.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONTENT_TYPE_JSON |
private static long |
serialVersionUID
The class' serialization version id.
|
| Constructor and Description |
|---|
ClientRequest() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createCart(ClientRequest.Context ctx,
java.util.ArrayList<ClientRequest.OrderLine> orderLines,
org.json.JSONArray rejects)
Create the cart and cartlines in the database.
|
protected ClientRequest.Context |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates the servlet context inner class.
|
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handles HTTP GET requests.
|
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handles HTTP POST requests.
|
protected void |
dumpParms(javax.servlet.http.HttpServletRequest request)
Dump servlet parameters to system.out for testing/debugging.
|
protected void |
errorResult(org.json.JSONObject results,
java.lang.String errName)
Sets an error result status and error message.
|
protected void |
errorResult(org.json.JSONObject results,
java.lang.String errName,
java.lang.String value)
Sets an error result status and error message.
|
protected void |
findProduct(ClientRequest.Context ctx,
org.json.JSONObject results)
Find a product based on given criteria.
|
protected java.lang.String |
getTemplateMessage(java.lang.String msgidsfx)
Returns the message text for a given message id suffix.
|
protected java.lang.String |
getTemplateMessage(java.lang.String msgidsfx,
java.lang.String value)
Returns the message text for a given message id suffix with the given
substitution values inserted into the message text.
|
protected void |
logon(ClientRequest.Context ctx,
org.json.JSONObject results)
Find a product based on given criteria.
|
protected void |
missingParm(org.json.JSONObject results,
java.lang.String parmName)
Sets up a missing parameter error message in the return object.
|
protected void |
processRequest(ClientRequest.Context ctx,
org.json.JSONObject results)
Process the client client request.
|
protected void |
setTemplateProductAttributes(ClientRequest.Context ctx)
Retrieve and set the product attributes data required by the html template.
|
protected void |
uploadCart(ClientRequest.Context ctx,
org.json.JSONObject results)
Upload a cart from remote client.
|
protected void |
writeResponse(ClientRequest.Context ctx,
javax.servlet.http.HttpServletResponse response,
org.json.JSONObject results)
Writes a JSON formatted response to the http response output stream for
the given set of search result data.
|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, serviceprivate static final long serialVersionUID
public static java.lang.String CONTENT_TYPE_JSON
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
doGet in class javax.servlet.http.HttpServletrequest - (HttpServletRequest) The servlet's incoming request.response - (HttpServletResponse) The servlet's outgoing response.java.io.IOException - - if an error occurs while processing the
request or response.javax.servlet.ServletException - - if an error occurs while
processing the request or response.public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class javax.servlet.http.HttpServletrequest - (HttpServletRequest) The servlet's incoming request.response - (HttpServletResponse) The servlet's outgoing response.java.io.IOException - - if an error occurs while processing the
request or response.javax.servlet.ServletException - - if an error occurs while
processing the request or response.protected void processRequest(ClientRequest.Context ctx, org.json.JSONObject results)
ctx - (Context) The current servlet context.results - (JSONObject) The result data.protected void logon(ClientRequest.Context ctx, org.json.JSONObject results)
ctx - (Context) The servlet's current context.results - (JSONObject) The result data to populate.protected void missingParm(org.json.JSONObject results,
java.lang.String parmName)
results - (JSONObject) The result data to populate.parmName - (String) The name of the missing parameter.protected void findProduct(ClientRequest.Context ctx, org.json.JSONObject results)
ctx - (Context) The servlet's current context.results - (JSONObject) The result data to populate.protected void uploadCart(ClientRequest.Context ctx, org.json.JSONObject results)
ctx - (Context) The servlet's current context.results - (JSONObject) The result data to populate.protected void createCart(ClientRequest.Context ctx, java.util.ArrayList<ClientRequest.OrderLine> orderLines, org.json.JSONArray rejects)
ctx - (Context) The servlet's current context.protected void setTemplateProductAttributes(ClientRequest.Context ctx)
ctx - (Context) The servlet's current context.protected void dumpParms(javax.servlet.http.HttpServletRequest request)
request - (HttpServletRequest) The servlet's incoming request.protected void errorResult(org.json.JSONObject results,
java.lang.String errName)
results - (JSONObject) The result data to populate.errName - (String) The name of error that is to be set, used
to determine which message (or messages) to retrieve from the
message properties.protected void errorResult(org.json.JSONObject results,
java.lang.String errName,
java.lang.String value)
results - (JSONObject) The result data to populate.errName - (String) The name of error that is to be set, used
to determine which message (or messages) to retrieve from the
message properties.value - (String) The value that is to be substituted into the
message text.protected void writeResponse(ClientRequest.Context ctx, javax.servlet.http.HttpServletResponse response, org.json.JSONObject results)
ctx - (Context) The servlet's current context.response - (HttpServletResponse) The servlet's outgoing response.results - (JSONObject) The result data to format and write.protected java.lang.String getTemplateMessage(java.lang.String msgidsfx)
msgidsfx - (String) The resource key suffix for the message to
retrieve. The supplied value is automatically prefixed with
"MSG." plus the invoking servlet's class name.protected java.lang.String getTemplateMessage(java.lang.String msgidsfx,
java.lang.String value)
msgidsfx - (String) The resource key suffix for the message to
retrieve. The supplied value is automatically prefixed with
"MSG." plus the invoking servlet's class name.value - (String) The value that is to be substituted into the
message text.protected ClientRequest.Context createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
doPost method.request - (HttpServletRequest) The servlet's incoming request.response - (HttpServletResponse) The servlet's outgoing response.