|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.gsm.oneapi.server.OneAPIServlet
public class OneAPIServlet
Provides constants and utilities to the individual OneAPI servlets
Field Summary | |
---|---|
static int |
ACCEPTED
|
static int |
AUTHENTICATION_FAILURE
|
static int |
BAD_REQUEST
|
static int |
CREATED
|
static boolean |
dumpRequestAndResponse
|
static int |
FORBIDDEN
|
static int |
METHOD_NOT_SUPPORTED
|
static int |
NOCONTENT
|
static int |
NONAUTHORITATIVE
|
static int |
NOT_FOUND
|
static int |
OK
|
static long |
serialVersionUID
|
Constructor Summary | |
---|---|
OneAPIServlet()
|
Method Summary | |
---|---|
static boolean |
checkRequestParameters(javax.servlet.http.HttpServletResponse response,
ValidationRule[] rules)
This function implements the specific parameter validation rules applying to each OneAPI servlet (specifically request parameters). |
void |
doDelete(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP delete requests return a not supported error. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP get requests return a not supported error. |
void |
doHead(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP head requests return a not supported error. |
void |
doOptions(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP options requests return a not supported error. |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP post requests return a not supported error. |
void |
doPut(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP put requests return a not supported error. |
void |
doTrace(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
By default make HTTP trace requests return a not supported error. |
protected void |
dumpRequestDetails(javax.servlet.http.HttpServletRequest request,
org.apache.log4j.Logger callerLogger)
Output the request details to the log4j output |
static java.lang.String |
getRequestHostnameAndContext(javax.servlet.http.HttpServletRequest request)
Get the base URL based on the incoming request |
static java.lang.String[] |
getRequestParts(javax.servlet.http.HttpServletRequest request)
Get the slash separated path components from the incoming request |
void |
init()
Default servlet initialisation method - should be overridden by the individual servlet |
static boolean |
isAuthorizationFailed(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Is a starter function to check the request Basic authorization |
static boolean |
isCorrectlyFormattedNumber(java.lang.String tel)
Check on valid telephone number formats. |
static boolean |
isCorrectlyFormattedURL(java.lang.String url)
Check on valid URL formats. |
static boolean |
isTrue(java.lang.String s)
Convert to a boolean value |
java.util.Date |
makeUTCDateTime(int year,
int month,
int day,
int hour,
int minute,
int second)
Utility function to create a java.util.Date object from constituent date/ time fields (UTC clock) |
static java.lang.String |
nullOrTrimmed(java.lang.String s)
Ensure the input value is either a null value or a trimmed string |
static boolean |
parseBoolean(java.lang.String s)
Alternate function name to convert to a boolean value |
static double |
parseDouble(java.lang.String s)
Convert to a double value |
static int |
parseInt(java.lang.String s)
Convert to an integer value |
static long |
parseLong(java.lang.String s)
Convert to a long value |
static void |
sendError(javax.servlet.http.HttpServletResponse response,
int errorCode,
int errorType,
java.lang.String messageId,
java.lang.String errorText,
java.lang.String errorInformation)
This is a helper to send an error response |
static void |
sendJSONResponse(javax.servlet.http.HttpServletResponse response,
java.lang.String jsonResponse,
int status,
java.lang.String location)
This is a helper to send the formed JSON response |
static java.lang.String |
urlEncode(java.lang.String s)
Do basic URL encoding based on UTF-8 |
static boolean |
validateRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String[] requestParts,
java.lang.String[] validationRules)
This function implements initial checks on the format of the requested URL |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long serialVersionUID
public static final int BAD_REQUEST
public static final int AUTHENTICATION_FAILURE
public static final int FORBIDDEN
public static final int NOT_FOUND
public static final int METHOD_NOT_SUPPORTED
public static final int OK
public static final int CREATED
public static final int ACCEPTED
public static final int NONAUTHORITATIVE
public static final int NOCONTENT
public static boolean dumpRequestAndResponse
Constructor Detail |
---|
public OneAPIServlet()
Method Detail |
---|
public static java.lang.String nullOrTrimmed(java.lang.String s)
public static int parseInt(java.lang.String s)
public static long parseLong(java.lang.String s)
public static boolean isTrue(java.lang.String s)
public static boolean parseBoolean(java.lang.String s)
public static double parseDouble(java.lang.String s)
public static java.lang.String urlEncode(java.lang.String s)
public void init() throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
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.HttpServlet
java.io.IOException
javax.servlet.ServletException
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doPost
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
public void doDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doDelete
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
public void doPut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doPut
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
public void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doHead
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
public void doTrace(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doTrace
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
public void doOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doOptions
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
public static void sendJSONResponse(javax.servlet.http.HttpServletResponse response, java.lang.String jsonResponse, int status, java.lang.String location) throws java.io.IOException
response
- jsonResponse
- status
- location
-
java.io.IOException
public static void sendError(javax.servlet.http.HttpServletResponse response, int errorCode, int errorType, java.lang.String messageId, java.lang.String errorText, java.lang.String errorInformation)
response
- errorCode
- errorType
- messageId
- errorText
- errorInformation
- public static java.lang.String getRequestHostnameAndContext(javax.servlet.http.HttpServletRequest request)
request
- public static java.lang.String[] getRequestParts(javax.servlet.http.HttpServletRequest request)
request
- protected void dumpRequestDetails(javax.servlet.http.HttpServletRequest request, org.apache.log4j.Logger callerLogger)
request
- callerLogger
- public static boolean isAuthorizationFailed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- response
- public static boolean validateRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String[] requestParts, java.lang.String[] validationRules)
request
- response
- requestParts
- validationRules
-
public static boolean checkRequestParameters(javax.servlet.http.HttpServletResponse response, ValidationRule[] rules)
response
- rules
-
ValidationRule
public java.util.Date makeUTCDateTime(int year, int month, int day, int hour, int minute, int second)
year
- month
- day
- hour
- minute
- second
- public static boolean isCorrectlyFormattedNumber(java.lang.String tel)
public static boolean isCorrectlyFormattedURL(java.lang.String url)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |