From 42e18ee8cb6ccfc50d6a4e8b4a4d9bfdb1fa7111 Mon Sep 17 00:00:00 2001 From: jensp Date: Mon, 17 Oct 2016 06:57:02 +0000 Subject: [PATCH] CCM NG/ccm-core: Dispatcher used none-locale save DateFormat git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4382 8810af33-2d31-482b-a856-94f89814c4df --- .../dispatcher/DispatcherHelper.java | 576 ++++++++++-------- 1 file changed, 321 insertions(+), 255 deletions(-) diff --git a/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java b/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java index 202876dac..588516c64 100644 --- a/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java +++ b/ccm-core/src/main/java/com/arsdigita/dispatcher/DispatcherHelper.java @@ -54,19 +54,21 @@ import org.apache.log4j.Logger; import java.net.URLEncoder; /** - * Class static helper methods for request dispatching. - * Contains various generally useful procedural abstractions. + * Class static helper methods for request dispatching. Contains various + * generally useful procedural abstractions. * * @author Bill Schneider - * @since 4.5 + * @since 4.5 * @version $Id$ */ public final class DispatcherHelper implements DispatcherConstants { - /** Internal logger instance to faciliate debugging. Enable logging output - * by editing /WEB-INF/conf/log4j.properties int hte runtime environment - * and set com.arsdigita.dispatcher.DispatcherHelper=DEBUG - * by uncommenting or adding the line. */ + /** + * Internal logger instance to faciliate debugging. Enable logging output by + * editing /WEB-INF/conf/log4j.properties int hte runtime environment and + * set com.arsdigita.dispatcher.DispatcherHelper=DEBUG by uncommenting or + * adding the line. + */ private static final Logger s_log = Logger.getLogger(DispatcherHelper.class); private static String s_webappCtx; private static String s_staticURL; @@ -80,7 +82,8 @@ public final class DispatcherHelper implements DispatcherConstants { return; } - rfc1123_formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); + rfc1123_formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", + Locale.ROOT); rfc1123_formatter.setTimeZone(TimeZone.getTimeZone("GMT")); s_staticURL = DispatcherConfig.getConfig().getStaticUrlPrefix(); @@ -90,18 +93,21 @@ public final class DispatcherHelper implements DispatcherConstants { initialized = true; } - /** The current HttpServletRequest. */ + /** + * The current HttpServletRequest. + */ private static final ThreadLocal s_request = new ThreadLocal(); - /** null constructor, private so no one can instantiate! */ + /** + * null constructor, private so no one can instantiate! + */ private DispatcherHelper() { } /** - * Return default cache expiry. - * Default is specified in the configuration file (registry) if not - * otherweise set. - * + * Return default cache expiry. Default is specified in the configuration + * file (registry) if not otherweise set. + * * @return default cache expiry */ public static int getDefaultCacheExpiry() { @@ -125,12 +131,12 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * Returns the URL path (relative to the webapp root) for the - * current (calling) resource. This works around the quirk that, - * if servlet A includes servlet B, calling getRequestURI() in B - * returns "A" and not "B". + * Returns the URL path (relative to the webapp root) for the current + * (calling) resource. This works around the quirk that, if servlet A + * includes servlet B, calling getRequestURI() in B returns "A" and not "B". * * @param req + * * @return the URL path (relative to the webapp root) for the currently * executing resource. */ @@ -156,7 +162,9 @@ public final class DispatcherHelper implements DispatcherConstants { /** * Gets the application context from the request attributes. + * * @param req + * * @return the application context from the request attributes. */ public static RequestContext getRequestContext(HttpServletRequest req) { @@ -177,21 +185,23 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * Sets the current request context as a request attribute for - * later retrieval. + * Sets the current request context as a request attribute for later + * retrieval. * * @param req the current request object - * @param ac the current request context + * @param ac the current request context + * * @post DispatcherHelper.getRequestContext(req) == ac */ - public static void setRequestContext(HttpServletRequest req, RequestContext ac) { + public static void setRequestContext(HttpServletRequest req, + RequestContext ac) { req.setAttribute(REQUEST_CONTEXT_ATTR, ac); } private static void forwardHelper(javax.servlet.RequestDispatcher rd, HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + throws ServletException, IOException { Object attr = req.getAttribute(INCLUDE_URI); @@ -219,26 +229,28 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * Forwards the request from this resource to another resource at - * the servlet-container level. This is a wrapper for - * javax.servlet.RequestDispatcher - * and is intended to hide the fact that you can't "forward" a request - * once you've done an "include" in it. - * @param path the URL of the resource, relative to the webapp - * root. For example, if you request a JSP page with /context/foo/bar, - * you would call this method with path == /foo/bar. - * @param req the current request + * Forwards the request from this resource to another resource at the + * servlet-container level. This is a wrapper for + * javax.servlet.RequestDispatcher and is intended to hide the fact that you + * can't "forward" a request once you've done an "include" in it. + * + * @param path the URL of the resource, relative to the webapp root. For + * example, if you request a JSP page with /context/foo/bar, you + * would call this method with path == /foo/bar. + * @param req the current request * @param resp the current response * @param sctx the current servlet context - * @exception java.io.IOException may be propagated from target resource - * @exception javax.servlet.ServletException may be - * propagated from target resource + * + * @exception java.io.IOException may be propagated from target + * resource + * @exception javax.servlet.ServletException may be propagated from target + * resource */ public static void forwardRequestByPath(String path, HttpServletRequest req, HttpServletResponse resp, ServletContext sctx) - throws IOException, ServletException { + throws IOException, ServletException { RequestDispatcher rd = sctx.getRequestDispatcher(path); forwardHelper(rd, req, resp); } @@ -246,42 +258,45 @@ public final class DispatcherHelper implements DispatcherConstants { /** * Equivalent to forwardRequestByPath(path, req, resp, * DispatcherHelper.getRequestContext(req).getServletContext()). + * * @param path * @param req * @param resp + * * @throws java.io.IOException * @throws javax.servlet.ServletException */ public static void forwardRequestByPath(String path, HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { - ServletContext sctx = - DispatcherHelper.getRequestContext(req).getServletContext(); + throws IOException, ServletException { + ServletContext sctx = DispatcherHelper.getRequestContext(req) + .getServletContext(); forwardRequestByPath(path, req, resp, sctx); } /** - * Forwards the request from this resource to another resource at - * the JSP container level. This is a wrapper for - * PageContext.forward and PageContext.include - * and is intended to transparently switch between "forward" and - * "include" depending on whether or not an include has already been - * done on the request. + * Forwards the request from this resource to another resource at the JSP + * container level. This is a wrapper for PageContext.forward + * and PageContext.include and is intended to transparently + * switch between "forward" and "include" depending on whether or not an + * include has already been done on the request. * - * @param path the URL of the resource, relative to the webapp - * root. For example, if you request a JSP page with /context/foo/bar, - * you would call this method with path == /foo/bar. + * @param path the URL of the resource, relative to the webapp root. + * For example, if you request a JSP page with + * /context/foo/bar, you would call this method with path + * == /foo/bar. * * @param pageContext the JSP page context * - * @exception java.io.IOException may be propagated from target resource - * @exception javax.servlet.ServletException may be - * propagated from target resource + * @exception java.io.IOException may be propagated from target + * resource + * @exception javax.servlet.ServletException may be propagated from target + * resource */ public static void forwardRequestByPath(String path, PageContext pageContext) - throws IOException, ServletException { + throws IOException, ServletException { ServletRequest req = pageContext.getRequest(); Object attr = req.getAttribute(INCLUDE_URI); @@ -300,24 +315,26 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * Forwards the request from this resource to a servlet resource - * (named in server.xml) at the servlet-container level. This is a - * wrapper for javax.servlet.RequestDispatcher and is intended to hide - * the fact that you can't "forward" a request once you've done an - * "include" in it. + * Forwards the request from this resource to a servlet resource (named in + * server.xml) at the servlet-container level. This is a wrapper for + * javax.servlet.RequestDispatcher and is intended to hide the fact that you + * can't "forward" a request once you've done an "include" in it. + * * @param name the named servlet to forward to - * @param req the current request + * @param req the current request * @param resp the current response * @param sctx the current servlet context - * @exception java.io.IOException may be propagated from target resource - * @exception javax.servlet.ServletException may be - * propagated from target resource + * + * @exception java.io.IOException may be propagated from target + * resource + * @exception javax.servlet.ServletException may be propagated from target + * resource */ public static void forwardRequestByName(String name, HttpServletRequest req, HttpServletResponse resp, ServletContext sctx) - throws IOException, ServletException { + throws IOException, ServletException { RequestDispatcher rd = sctx.getNamedDispatcher(name); forwardHelper(rd, req, resp); } @@ -325,49 +342,61 @@ public final class DispatcherHelper implements DispatcherConstants { /** * Equivalent to forwardRequestByName(name, req, resp, * DispatcherHelper.getRequestContext(req).getServletContext()). - * + * * @param name * @param req * @param resp + * * @throws java.io.IOException * @throws javax.servlet.ServletException */ public static void forwardRequestByName(String name, HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { ServletContext sc = getRequestContext(req).getServletContext(); forwardRequestByName(name, req, resp, sc); } /** * Given the name of a resource in the file system that is missing an - * extension, picks an extension that matches. Serves a file - * with a .jsp extension first, if available. - * Otherwise picks any file that matches. For directories, it tacks on - * the "index" filename plus the extension. + * extension, picks an extension that matches. Serves a file with a + * .jsp extension first, if available. Otherwise picks any file + * that matches. For directories, it tacks on the "index" filename plus the + * extension. * * Unsupported * * @param abstractFile the extensionless file - * @param actx the current application context - * @return a filename suffix (".jsp", "index.html", etc.) such - * that (abstractFile.getAbsolutePath() + suffix) is a valid file - * in the filesystem + * @param actx the current application context * - * @exception com.arsdigita.dispatcher.RedirectException if the - * requested file is a directory and the original request URL does - * not end with a trailing slash. - * @exception java.io.FileNotFoundException if no matching - * file exists. + * @return a filename suffix (".jsp", "index.html", etc.) such that + * (abstractFile.getAbsolutePath() + suffix) is a valid file in the + * filesystem + * + * @exception com.arsdigita.dispatcher.RedirectException if the + * requested + * file is a + * directory + * and the + * original + * request URL + * does not + * end with a + * trailing + * slash. + * @exception java.io.FileNotFoundException if no + * matching + * file + * exists. * @throws com.arsdigita.dispatcher.DirectoryListingException - * @deprecated abstract URLs are no longer supported. Use - * extensions when your file on disk has an extension. + * @deprecated abstract URLs are no longer supported. Use extensions when + * your file on disk has an extension. */ public static String resolveAbstractFile(File abstractFile, RequestContext actx) - throws RedirectException, DirectoryListingException, - java.io.FileNotFoundException { + throws RedirectException, DirectoryListingException, + java.io.FileNotFoundException { s_log.debug("Resolving abstract file"); File dirToSearch = null; @@ -392,19 +421,18 @@ public final class DispatcherHelper implements DispatcherConstants { dirToSearch = new File(abstractFile.getParent()); } - File filesInDir[] = dirToSearch.listFiles(); final String extensionSearchList[] = {".jsp"}; if (filesInDir != null) { for (String searchExtension : extensionSearchList) { //1.5 enhanced loop - File possibleFile = new File(dirToSearch, + File possibleFile = new File(dirToSearch, filenameStub + searchExtension); for (int i = 0; i < filesInDir.length; i++) { if (filesInDir[i].equals(possibleFile)) { - return (indexPage ? File.separator + "index" : "") - + searchExtension; + return (indexPage ? File.separator + "index" : "") + + searchExtension; } } } @@ -444,18 +472,21 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * If the given servlet request is wrapped in one of our own classes, returns - * the original (unwrapped) request object and stores a reference - * to the request wrapper in the request attributes of the returned request. + * If the given servlet request is wrapped in one of our own classes, + * returns the original (unwrapped) request object and stores a reference to + * the request wrapper in the request attributes of the returned request. * Otherwise just returns the request object. * * @param req the servlet request - * @return the original servlet request object, as created by - * the servlet container. This can be used as a parameter for forward(). + * + * @return the original servlet request object, as created by the servlet + * container. This can be used as a parameter for forward(). */ - public static HttpServletRequest restoreOriginalRequest(HttpServletRequest req) { + public static HttpServletRequest restoreOriginalRequest( + HttpServletRequest req) { if (req instanceof MultipartHttpServletRequest) { - HttpServletRequest oldReq = (HttpServletRequest) req.getAttribute(ORIGINAL_REQUEST_ATTR); + HttpServletRequest oldReq = (HttpServletRequest) req.getAttribute( + ORIGINAL_REQUEST_ATTR); oldReq.setAttribute(WRAPPED_REQUEST_ATTR, req); req = oldReq; } @@ -463,53 +494,56 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * If we've stored a reference to a request wrapper as a request - * attribute to the current servlet request, returns the wrapper object. - * Otherwise, returns the request object. + * If we've stored a reference to a request wrapper as a request attribute + * to the current servlet request, returns the wrapper object. Otherwise, + * returns the request object. * * @param req the current servlet request + * * @return the previously created wrapper around the current servlet - * request, if any; - * otherwise returns the request object. + * request, if any; otherwise returns the request object. */ - public static HttpServletRequest restoreRequestWrapper(HttpServletRequest req) { + public static HttpServletRequest restoreRequestWrapper( + HttpServletRequest req) { // switch back wrapped request if we're forwarded // from somewhere else. Object maybeWrappedReq = req.getAttribute(WRAPPED_REQUEST_ATTR); if (maybeWrappedReq != null - && !(req instanceof MultipartHttpServletRequest)) { + && !(req instanceof MultipartHttpServletRequest)) { req = (HttpServletRequest) maybeWrappedReq; } return req; } /** - * This method will optionally wrap the request if it is a multipart POST, + * This method will optionally wrap the request if it is a multipart POST, * or restore the original wrapper if it was already wrapped. - * + * * @param sreq - * @return - * @throws java.io.IOException - * @throws javax.servlet.ServletException + * + * @return + * + * @throws java.io.IOException + * @throws javax.servlet.ServletException */ public static HttpServletRequest maybeWrapRequest(HttpServletRequest sreq) - throws IOException, ServletException { + throws IOException, ServletException { final String type = sreq.getContentType(); if (sreq.getMethod().toUpperCase().equals("POST") - && type != null - && type.toLowerCase().startsWith("multipart")) { + && type != null + && type.toLowerCase().startsWith("multipart")) { final HttpServletRequest orig = sreq; - final HttpServletRequest previous = - DispatcherHelper.restoreRequestWrapper(orig); + final HttpServletRequest previous = DispatcherHelper + .restoreRequestWrapper(orig); if (previous instanceof MultipartHttpServletRequest) { s_log.debug("Build new multipart request from previous " - + previous + " and current " + orig); + + previous + " and current " + orig); - MultipartHttpServletRequest previousmp = - (MultipartHttpServletRequest) previous; + MultipartHttpServletRequest previousmp + = (MultipartHttpServletRequest) previous; sreq = new MultipartHttpServletRequest(previousmp, orig); @@ -519,8 +553,9 @@ public final class DispatcherHelper implements DispatcherConstants { s_log.debug("The main request is now " + sreq); } else { - s_log.debug("The request is a new multipart; wrapping the request " - + "object"); + s_log.debug( + "The request is a new multipart; wrapping the request " + + "object"); try { sreq = new MultipartHttpServletRequest(sreq); } catch (MessagingException me) { @@ -531,14 +566,15 @@ public final class DispatcherHelper implements DispatcherConstants { } } else { s_log.debug("The request is not multipart; proceeding " - + "without wrapping the request"); + + "without wrapping the request"); } return sreq; } /** * Stores req as request attribute of oldReq. - * @param req the current servlet request (wrapper) + * + * @param req the current servlet request (wrapper) * @param oldReq the original servlet request */ public static void saveOriginalRequest(HttpServletRequest req, @@ -547,22 +583,22 @@ public final class DispatcherHelper implements DispatcherConstants { } /** - * Redirects the client to the given URL without rewriting it. Delegates - * to the sendExternalRedirect method. + * Redirects the client to the given URL without rewriting it. Delegates to + * the sendExternalRedirect method. * * @throws java.io.IOException - * @deprecated This method does not rewrite URLs. Use + * @deprecated This method does not rewrite URLs. Use * sendRedirect(HttpServletRequest, HttpServletResponse, String) for - * redirects within this ACS or - * sendExternalRedirect(HttpServletResponse, String) for redirects to - * sites outside this ACS. + * redirects within this ACS or sendExternalRedirect(HttpServletResponse, + * String) for redirects to sites outside this ACS. * * @param resp the current response - * @param url the destination URL for redirect - **/ + * @param url the destination URL for redirect + * + */ public static void sendRedirect(HttpServletResponse resp, String url) - throws IOException { + throws IOException { sendExternalRedirect(resp, url); } @@ -570,30 +606,34 @@ public final class DispatcherHelper implements DispatcherConstants { * Rewrites the given URL and redirects the client to the rewritten URL. * This method should be used for redirects within this ACS. * - * @param req the current request; used as a source for parameters - * for URL rewriting + * @param req the current request; used as a source for parameters for URL + * rewriting * @param resp the current response - * @param url the destination URL for redirect + * @param url the destination URL for redirect + * * @throws java.io.IOException - **/ + * + */ public static void sendRedirect(HttpServletRequest req, HttpServletResponse resp, String url) - throws IOException { + throws IOException { sendExternalRedirect(resp, url); } /** - * Redirects the client to the given URL without rewriting it. This - * method should be used for redirects to sites outside this ACS. + * Redirects the client to the given URL without rewriting it. This method + * should be used for redirects to sites outside this ACS. * * @param resp the current response - * @param url the destination URL for redirect + * @param url the destination URL for redirect + * * @throws java.io.IOException - **/ + * + */ public static void sendExternalRedirect(HttpServletResponse resp, String url) - throws IOException { + throws IOException { if (s_log.isDebugEnabled()) { s_log.debug("Redirecting to URL '" + url + "'", new Throwable()); } @@ -611,7 +651,7 @@ public final class DispatcherHelper implements DispatcherConstants { HttpServletRequest req = getRequest(); Object attr; if (req != null - && (attr = req.getAttribute(REENTRANCE_ATTRIBUTE)) != null) { + && (attr = req.getAttribute(REENTRANCE_ATTRIBUTE)) != null) { req.getSession(true).setAttribute(REDIRECT_SEMAPHORE, attr); } @@ -634,19 +674,20 @@ public final class DispatcherHelper implements DispatcherConstants { s_log.debug("Setting destination to " + destination); } } else { - final ParameterMap params = ParameterMap.fromString(url.substring(sep + 1)); + final ParameterMap params = ParameterMap.fromString(url + .substring(sep + 1)); destination = URL.there(req, url.substring(0, sep), params); if (s_log.isDebugEnabled()) { s_log.debug("Setting destination with map to " - + destination); + + destination); } } throw new RedirectSignal(destination, true); } else { if (s_log.isDebugEnabled()) { s_log.debug("Redirecting to URL without using URL.there. " - + "URL is " + url); + + "URL is " + url); } throw new RedirectSignal(url, true); } @@ -655,11 +696,12 @@ public final class DispatcherHelper implements DispatcherConstants { /** * Adds a ParameterProvider to the URLRewriter engine. * ParameterProviders are used when - * encodeRedirectURL and encodeURL are - * called. They add global state parameters like the session ID (for - * cookieless login) to URLs for links and redirects. + * encodeRedirectURL and encodeURL are called. + * They add global state parameters like the session ID (for cookieless + * login) to URLs for links and redirects. * * @param provider the parameter provider to add + * * @see com.arsdigita.util.URLRewriter#addParameterProvider * @deprecated use URLRewriter.addParameterProvider */ @@ -669,9 +711,11 @@ public final class DispatcherHelper implements DispatcherConstants { /** * Clears all parameter providers. + * * @deprecated use URLRewriter#clearParameterProviders() instead * @see com.arsdigita.util.URLRewriter#clearParameterProviders() - **/ + * + */ public static void clearParameterProviders() { URLRewriter.clearParameterProviders(); } @@ -681,53 +725,62 @@ public final class DispatcherHelper implements DispatcherConstants { * provider is set. * * @return a set of Bebop parameter models. + * * @deprecated use URLRewriter.getGlobalModels instead * @see com.arsdigita.util.URLRewriter#getGlobalModels() - **/ + * + */ public static Set getGlobalModels() { return URLRewriter.getGlobalModels(); } /** - * Returns the set of global URL parameters for the given request, or - * the empty set if no provider is set. + * Returns the set of global URL parameters for the given request, or the + * empty set if no provider is set. * * @param req the current request + * * @return a Set of Bebop parameter data. + * * @deprecated use URLRewriter.getGlobalParams instead - **/ + * + */ public static Set getGlobalParams(HttpServletRequest req) { return URLRewriter.getGlobalParams(req); } /** - * Prepares the given URL for a client link. If no providers are - * set, has no effect. + * Prepares the given URL for a client link. If no providers are set, has no + * effect. * * @param url the target URL to prepare - * @return the prepared URL with global parameters added from - * providers * - * @deprecated This method does not encode the servlet session ID. Use + * @return the prepared URL with global parameters added from providers + * + * @deprecated This method does not encode the servlet session ID. Use * encodeURL(req, res, url) instead. - **/ + * + */ public static String prepareURL(String url, HttpServletRequest req) { return URLRewriter.prepareURL(url, req); } /** - * Encodes the given URL for the client. Adds ACS global parameters and - * servlet session parameters to the URL. If the URL will be used for + * Encodes the given URL for the client. Adds ACS global parameters and + * servlet session parameters to the URL. If the URL will be used for * redirection, use sendRedirect(req, resp, url) instead. * - * @param req the current request + * @param req the current request * @param resp the current response - * @param url the target URL (for a link) to encode - * @return the new URL, with extra URL variables added - * from parameter providers + * @param url the target URL (for a link) to encode + * + * @return the new URL, with extra URL variables added from parameter + * providers + * * @deprecated use URLRewriter.encodeURL instead * @see com.arsdigita.util.URLRewriter - **/ + * + */ public static String encodeURL(HttpServletRequest req, HttpServletResponse resp, String url) { @@ -737,8 +790,8 @@ public final class DispatcherHelper implements DispatcherConstants { /** * Returns a global URL prefix for referencing static assets (images, CSS, * etc.) on disk in href attributes. This can be on the same server - * ("/STATIC/") or a different server/port ("http://server:port/dir/"). - * The return value is guaranteed to end with a trailing slash. + * ("/STATIC/") or a different server/port ("http://server:port/dir/"). The + * return value is guaranteed to end with a trailing slash. * * Usage example: *
@@ -754,11 +807,12 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * sets the  global URL prefix for referencing static assets (images, CSS,
-     * etc.) from user-agents in href attributes.
-     * Package visibility is intentional.
+     * sets the global URL prefix for referencing static assets (images, CSS,
+     * etc.) from user-agents in href attributes. Package visibility is
+     * intentional.
      *
      * @param s the static asset URL
+     *
      * @pre s != null
      */
     static void setStaticURL(String s) {
@@ -773,13 +827,13 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * sets the webapp Context using the webappContext parameter in enterprise.init.
-     * This is an optional parameter.  If it is not specified, null will be used and
-     * the value of s_webappContext will be set when there is a request.
-     * Package visibility is intentional.
+     * sets the webapp Context using the webappContext parameter in
+     * enterprise.init. This is an optional parameter. If it is not specified,
+     * null will be used and the value of s_webappContext will be set when there
+     * is a request. Package visibility is intentional.
      *
-     * @param webappCtx the webappContext specified in enterprise.init. 
-     *        Normally this wouldbe "/".
+     * @param webappCtx the webappContext specified in enterprise.init. Normally
+     *                  this wouldbe "/".
      */
     static void setWebappContext(String webappCtx) {
         init();
@@ -796,14 +850,12 @@ public final class DispatcherHelper implements DispatcherConstants {
     /**
      * Gets the webapp Context using the following procedure:
      *
-     * 1. If there is a request, get the value from the request.
-     * 2. If there is no request, get the value saved from a previous
-     *    request.
-     * 3. If there is no request or previous request, use the value
-     *    specified by the enterprise.init webappContext parameter.
-     * 4. Lastly, return null.
-     * 
-     * @return 
+     * 1. If there is a request, get the value from the request. 2. If there is
+     * no request, get the value saved from a previous request. 3. If there is
+     * no request or previous request, use the value specified by the
+     * enterprise.init webappContext parameter. 4. Lastly, return null.
+     *
+     * @return
      */
     public static String getWebappContext() {
         init();
@@ -820,10 +872,11 @@ public final class DispatcherHelper implements DispatcherConstants {
                 }
                 if (!s_webappCtx.equals(webappCtx)) {
                     s_log.warn(
-                            "webappContext changed. Expected='" + s_webappCtx
-                            + "' found='" + webappCtx + "'.\nPerhaps the enterprise.init "
+                        "webappContext changed. Expected='" + s_webappCtx
+                            + "' found='" + webappCtx
+                        + "'.\nPerhaps the enterprise.init "
                             + "com.arsdigita.dispatcher.Initializer webappContext "
-                            + "parameter is wrong.");
+                        + "parameter is wrong.");
                     // Save the webappCtx from the request for future use.
                     s_webappCtx = webappCtx;
                 }
@@ -838,23 +891,24 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Aborts all processing of the current request and treat it
-     * as successfully completed.  We abort the request by percolating
-     * an unchecked Error up through the call stack.  Then the
-     * BaseDispatcherServlet.service method traps this and commits
-     * whatever DML has already happened on the transaction.
+     * Aborts all processing of the current request and treat it as successfully
+     * completed. We abort the request by percolating an unchecked Error up
+     * through the call stack. Then the BaseDispatcherServlet.service method
+     * traps this and commits whatever DML has already happened on the
+     * transaction.
      *
-     * @exception com.arsdigita.dispatcher.AbortRequestSignal Error thrown
-     * to abort current request
+     * @exception com.arsdigita.dispatcher.AbortRequestSignal Error thrown to
+     *                                                        abort current
+     *                                                        request
      */
     public static void abortRequest() {
         throw new AbortRequestSignal();
     }
 
     /**
-     * Stores the HttpServletRequest in a ThreadLocal so that it can be
-     * accessed globally.
-     * 
+     * Stores the HttpServletRequest in a ThreadLocal so that it can be accessed
+     * globally.
+     *
      * @param r
      */
     public static void setRequest(HttpServletRequest r) {
@@ -864,6 +918,7 @@ public final class DispatcherHelper implements DispatcherConstants {
 
     /**
      * Gets the current HttpServletRequest for this thread.
+     *
      * @return the current HttpServletRequest for this thread.
      */
     public static HttpServletRequest getRequest() {
@@ -871,18 +926,23 @@ public final class DispatcherHelper implements DispatcherConstants {
         return (HttpServletRequest) s_request.get();
     }
 
-    /***************************************************/
-    /*        !!! Danger Will Robinson!!!!             */
-    /*                                                 */
-    /* Don't go making changes to the cache headers    */
-    /* without reading *and* fully understanding the   */
-    /* sections on caching in RFC 2616 (HTTP 1.1)      */
-    /*                                                 */
-    /*    -- Daniel Berrange      */
-    /***************************************************/
     /**
-     * If no existing cache policy is set, then call
-     * cacheDisable to disable all caching of the response.
+     * ************************************************
+     */
+    /*        !!! Danger Will Robinson!!!!             */
+ /*                                                 */
+ /* Don't go making changes to the cache headers    */
+ /* without reading *and* fully understanding the   */
+ /* sections on caching in RFC 2616 (HTTP 1.1)      */
+ /*                                                 */
+ /*    -- Daniel Berrange      */
+    /**
+     * ************************************************
+     */
+    /**
+     * If no existing cache policy is set, then call cacheDisable to disable all
+     * caching of the response.
+     *
      * @param response
      */
     public static void maybeCacheDisable(HttpServletResponse response) {
@@ -893,7 +953,7 @@ public final class DispatcherHelper implements DispatcherConstants {
 
     /**
      * Aggressively disable all caching of the response.
-     * 
+     *
      * @param response
      */
     public static void cacheDisable(HttpServletResponse response) {
@@ -914,8 +974,8 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * 
-     * @param response 
+     *
+     * @param response
      */
     public static void forceCacheDisable(HttpServletResponse response) {
         init();
@@ -931,9 +991,9 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * If no existing cache policy is set, then
-     * call cacheForUser to enable caching for a user.
-     * 
+     * If no existing cache policy is set, then call cacheForUser to enable
+     * caching for a user.
+     *
      * @param response
      */
     public static void maybeCacheForUser(HttpServletResponse response) {
@@ -943,10 +1003,10 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Allow caching of the response for this user only, as identified
-     * by the Cookie header. The response will expire according
-     * to the default age setting.
-     * 
+     * Allow caching of the response for this user only, as identified by the
+     * Cookie header. The response will expire according to the default age
+     * setting.
+     *
      * @param response
      */
     public static void cacheForUser(HttpServletResponse response) {
@@ -954,11 +1014,11 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * If no existing cache policy is set, then
-     * call cacheForUser to enable caching for a user
+     * If no existing cache policy is set, then call cacheForUser to enable
+     * caching for a user
      *
      * @param response
-     * @param maxage the max time in second until this expires
+     * @param maxage   the max time in second until this expires
      */
     public static void maybeCacheForUser(HttpServletResponse response,
                                          int maxage) {
@@ -968,11 +1028,11 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * If no existing cache policy is set, then
-     * call cacheForUser to enable caching for a user
+     * If no existing cache policy is set, then call cacheForUser to enable
+     * caching for a user
      *
      * @param response
-     * @param expiry the time at which to expire
+     * @param expiry   the time at which to expire
      */
     public static void maybeCacheForUser(HttpServletResponse response,
                                          Date expiry) {
@@ -982,11 +1042,11 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Allow caching of the response for this user only,
-     * as identified by the Cookie header. The response
-     * will expire in 'age' seconds time.
+     * Allow caching of the response for this user only, as identified by the
+     * Cookie header. The response will expire in 'age' seconds time.
+     *
      * @param response
-     * @param maxage the max life of the response in seconds
+     * @param maxage   the max life of the response in seconds
      */
     public static void cacheForUser(HttpServletResponse response,
                                     int maxage) {
@@ -1002,7 +1062,8 @@ public final class DispatcherHelper implements DispatcherConstants {
 
         // For HTTP/1.1 user agents, we tell them only cache
         // for the original person  making the request
-        response.setHeader("Last-Modified", rfc1123_formatter.format(new Date()));
+        response
+            .setHeader("Last-Modified", rfc1123_formatter.format(new Date()));
         response.setHeader("Cache-Control", "private, max-age=" + maxage);
 
         // NB. THis line is delibrately *NOT* using the actual expiry date
@@ -1014,21 +1075,23 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Allowing caching of the response for this user only.
-     * The response will expire at time given in the expiry parameter
+     * Allowing caching of the response for this user only. The response will
+     * expire at time given in the expiry parameter
+     *
      * @param response
-     * @param expiry time at which to expire
+     * @param expiry   time at which to expire
      */
     public static void cacheForUser(HttpServletResponse response,
                                     Date expiry) {
-        cacheForUser(response, (int) ((expiry.getTime() - (new Date()).getTime()) / 1000l));
+        cacheForUser(response,
+                     (int) ((expiry.getTime() - (new Date()).getTime()) / 1000l));
     }
 
     /**
      * If no existing cache policy is set, then call cacheForUser to enable
-     * caching for the world. The response expiry will take the default
-     * age setting.
-     * 
+     * caching for the world. The response expiry will take the default age
+     * setting.
+     *
      * @param response
      */
     public static void maybeCacheForWorld(HttpServletResponse response) {
@@ -1038,9 +1101,9 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Allow caching of this response for anyone in the world.
-     * The response take the default expiry time.
-     * 
+     * Allow caching of this response for anyone in the world. The response take
+     * the default expiry time.
+     *
      * @param response
      */
     public static void cacheForWorld(HttpServletResponse response) {
@@ -1050,9 +1113,9 @@ public final class DispatcherHelper implements DispatcherConstants {
     /**
      * If no existing cache policy is set, then call cacheForUser to enable
      * caching for the world.
-     * 
+     *
      * @param response
-     * @param maxage the time in seconds until expiry
+     * @param maxage   the time in seconds until expiry
      */
     public static void maybeCacheForWorld(HttpServletResponse response,
                                           int maxage) {
@@ -1062,11 +1125,11 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * If no existing cache policy is set, then call cacheForUser to
-     * enable caching for the world.
-     * 
+     * If no existing cache policy is set, then call cacheForUser to enable
+     * caching for the world.
+     *
      * @param response
-     * @param expiry the time at which it will expire
+     * @param expiry   the time at which it will expire
      */
     public static void maybeCacheForWorld(HttpServletResponse response,
                                           Date expiry) {
@@ -1076,11 +1139,11 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Allow caching of this response for anyone in the
-     * world. The response will expire at the current time
-     * plus maxage seconds.
+     * Allow caching of this response for anyone in the world. The response will
+     * expire at the current time plus maxage seconds.
+     *
      * @param response
-     * @param maxage time in seconds until this expires
+     * @param maxage   time in seconds until this expires
      */
     public static void cacheForWorld(HttpServletResponse response,
                                      int maxage) {
@@ -1104,20 +1167,21 @@ public final class DispatcherHelper implements DispatcherConstants {
     }
 
     /**
-     * Allow caching of this response for anyone in the world.
-     * THe response will  expire at the time given.
-     * 
+     * Allow caching of this response for anyone in the world. THe response will
+     * expire at the time given.
+     *
      * @param response
      * @param expiry
      */
     public static void cacheForWorld(HttpServletResponse response,
                                      Date expiry) {
-        cacheForWorld(response, (int) ((expiry.getTime() - (new Date()).getTime()) / 1000l));
+        cacheForWorld(response, (int) ((expiry.getTime() - (new Date())
+                                        .getTime()) / 1000l));
     }
 
     /**
-     * This method returns the best matching locale for the request. In contrast 
-     * to the other methods available this one will also respect the 
+     * This method returns the best matching locale for the request. In contrast
+     * to the other methods available this one will also respect the
      * supported_languages config entry.
      *
      * @return The negotiated locale
@@ -1127,14 +1191,16 @@ public final class DispatcherHelper implements DispatcherConstants {
 
         // Set the preferedLocale to the default locale (first entry in the 
         // config parameter list)
-        Locale preferedLocale = new Locale(kernelConfig.getDefaultLanguage(), "", "");
+        Locale preferedLocale
+               = new Locale(kernelConfig.getDefaultLanguage(), "", "");
 
         // The ACCEPTED_LANGUAGES from the client
         Enumeration locales = null;
 
         // Try to get the RequestContext
         try {
-            locales = ((ServletRequest) DispatcherHelper.getRequest()).getLocales();
+            locales = ((ServletRequest) DispatcherHelper.getRequest())
+                .getLocales();
 
             // For everey element in the enumerator
             while (locales.hasMoreElements()) {
@@ -1161,8 +1227,8 @@ public final class DispatcherHelper implements DispatcherConstants {
     /**
      * Encodes the given request into a return URL parameter. Returns
      * URLencode(returnURL) where returnURL is
-     * returnURI?key=URLencode(val)&.... The original parameter values are
-     * doubly-encoded so that they are decoded appropriately.
+     * returnURI?key=URLencode(val)&.... The original parameter
+     * values are doubly-encoded so that they are decoded appropriately.
      *
      *
      * @param req the request to encode
@@ -1195,5 +1261,5 @@ public final class DispatcherHelper implements DispatcherConstants {
 
         return URLEncoder.encode(returnURL.toString());
     }
-    
+
 }