|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sakaiproject.entitybroker.util.request.RequestUtils
public class RequestUtils
Contains a set of static utility methods for working with requests
| Nested Class Summary | |
|---|---|
static class |
RequestUtils.ShortestStringLastComparator
Comparator which puts the longest strings first and the shortest last |
| Field Summary | |
|---|---|
static Map<String,String> |
extensionsToFormat
A map from extensions to format constants |
static Map<String,String> |
formatToMimeType
A map from format constants to mimetypes |
static String[] |
ignoreForSearch
|
static Map<String,String> |
mimeTypeToFormat
A map from mimetypes to format constants |
| Constructor Summary | |
|---|---|
RequestUtils()
|
|
| Method Summary | |
|---|---|
static String |
findAndHandleFormat(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
String defaultFormat)
This method will correctly extract the format constant from a request (extension first and then Accepts header) and then set it in the response as the correct return type, if none is found then the default will be used |
static String |
getServletContext(javax.servlet.http.HttpServletRequest req)
This finds the correct servlet path or returns the default one, will not return "" or null |
static void |
handleURLRedirect(String redirectURL,
boolean forward,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Handles the redirect to a URL from the current location, the URL should be relative for a forward, otherwise it will be a redirect NOTE: You should perform no actions after call this method, you should simply pass control back to the handler |
static boolean |
isRequestOutput(javax.servlet.http.HttpServletRequest req,
EntityView view)
Gets the correct info out of the request method and places it into the entity view and identifies if this is an output (read) or input (write) request |
static Search |
makeSearchFromRequestParams(Map<String,Object> params)
This looks at request parameters and returns anything it finds in the request parameters that can be put into the search, supports the page params and sorting params |
static void |
setResponseEncoding(String format,
javax.servlet.http.HttpServletResponse res)
This will set the response mime type correctly based on the format constant, also sets the response encoding to UTF_8 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static Map<String,String> mimeTypeToFormat
public static Map<String,String> formatToMimeType
public static Map<String,String> extensionsToFormat
public static String[] ignoreForSearch
| Constructor Detail |
|---|
public RequestUtils()
| Method Detail |
|---|
public static void handleURLRedirect(String redirectURL,
boolean forward,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
redirectURL - the URL to redirect to (relative or absolute)forward - if false, use redirect (this should be the default),
if true use forward, note that we can only forward from your webapp back to your servlets and
a check will be performed to see if this is the case, if it is not
(anything with a "http", a non-matching prefix, and anything with a query string) will be switched to redirect automaticallyreq - the current requestres - the current response
IllegalArgumentException - is the params are invalid
public static boolean isRequestOutput(javax.servlet.http.HttpServletRequest req,
EntityView view)
req - the requestview - the entity view to update
EntityException - if the request has problems
public static String findAndHandleFormat(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
String defaultFormat)
req - the Servlet requestres - the Servlet responsedefaultFormat - (OPTIONAL) if this is set then it will be the default format assigned when none can be found,
otherwise the default format is Formats.HTML
Formats.XMLpublic static Search makeSearchFromRequestParams(Map<String,Object> params)
params - the request params from a request (do not include headers)
public static void setResponseEncoding(String format,
javax.servlet.http.HttpServletResponse res)
format - the format constant, example Formats.XMLres - the current outgoing responsepublic static String getServletContext(javax.servlet.http.HttpServletRequest req)
req - the incoming request
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||