From: <fg...@us...> - 2009-02-19 13:14:05
|
Revision: 1033 http://openutils.svn.sourceforge.net/openutils/?rev=1033&view=rev Author: fgiust Date: 2009-02-19 11:53:22 +0000 (Thu, 19 Feb 2009) Log Message: ----------- formatting Modified Paths: -------------- trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlMultipartRequestHandler.java trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlRequestProcessorHelper.java Modified: trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlMultipartRequestHandler.java =================================================================== --- trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlMultipartRequestHandler.java 2009-02-19 11:51:21 UTC (rev 1032) +++ trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlMultipartRequestHandler.java 2009-02-19 11:53:22 UTC (rev 1033) @@ -28,10 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.struts.Globals; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; -import org.apache.struts.config.ModuleConfig; import org.apache.struts.upload.FormFile; import org.apache.struts.upload.MultipartRequestHandler; Modified: trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlRequestProcessorHelper.java =================================================================== --- trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlRequestProcessorHelper.java 2009-02-19 11:51:21 UTC (rev 1032) +++ trunk/openutils-mgnlstruts11/src/main/java/it/openutils/mgnlstruts11/process/MgnlRequestProcessorHelper.java 2009-02-19 11:53:22 UTC (rev 1033) @@ -42,29 +42,31 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** * @author fgiust - * @version $Id: MgnlRequestProcessorHelper.java 86 2008-11-04 08:37:44Z fgiust - * $ + * @version $Id$ */ -public class MgnlRequestProcessorHelper { +public class MgnlRequestProcessorHelper +{ /** * Logger. */ - private static Logger log = LoggerFactory - .getLogger(MgnlRequestProcessorHelper.class); + private static Logger log = LoggerFactory.getLogger(MgnlRequestProcessorHelper.class); - public static void doProcessForwardConfig(HttpServletRequest request, - HttpServletResponse response, ForwardConfig forward) - throws IOException, ServletException { + public static void doProcessForwardConfig(HttpServletRequest request, HttpServletResponse response, + ForwardConfig forward) throws IOException, ServletException + { log.info("processForwardConfig " + forward); - if (forward == null) { + if (forward == null) + { return; } - if (log.isDebugEnabled()) { + if (log.isDebugEnabled()) + { log.debug("processForwardConfig(" + forward + ")"); } @@ -74,70 +76,84 @@ // paths not starting with / should be passed through without any // processing // (ie. they're absolute) - if (forwardPath.startsWith("/")) { + if (forwardPath.startsWith("/")) + { uri = RequestUtils.forwardURL(request, forward); // get module - // relative uri - } else { + // relative uri + } + else + { uri = forwardPath; } - if (forward.getRedirect() && !uri.endsWith(".jsp")) { + if (forward.getRedirect() && !uri.endsWith(".jsp")) + { // @todo redirect in templates // only prepend context path for relative uri - if (uri.startsWith("/")) { + if (uri.startsWith("/")) + { uri = request.getContextPath() + uri; } response.sendRedirect(response.encodeRedirectURL(uri)); - } else { + } + else + { doInclude(uri, request, response); } } - public static void doInclude(String uri, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { + public static void doInclude(String uri, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + { // needed for chained forwards, avoid loops! request.setAttribute(StrutsRenderer.PARAGRAPH_PATH, uri); // Unwrap the multipart request, if there is one. - if (request instanceof MultipartRequestWrapper) { + if (request instanceof MultipartRequestWrapper) + { request = ((MultipartRequestWrapper) request).getRequest(); } - RequestDispatcher rd = getWebContext().getServletContext() - .getRequestDispatcher(uri); + RequestDispatcher rd = getWebContext().getServletContext().getRequestDispatcher(uri); getWebContext().include(uri, getOut()); } - public static ActionMapping doProcessMapping(HttpServletRequest request, - HttpServletResponse response, String path, ModuleConfig moduleConfig) - throws IOException { + public static ActionMapping doProcessMapping(HttpServletRequest request, HttpServletResponse response, String path, + ModuleConfig moduleConfig) throws IOException + { log.info("Process mapping " + path); // Is there a directly defined mapping for this path? ActionMapping mapping = (ActionMapping) moduleConfig.findActionConfig(path); - - if (mapping == null) { - // @todo This is almost a copy-paste of the end of RequestProcessor.processPath method, it should be refactored in a "simplify path" somewhere else. + + if (mapping == null) + { + // @todo This is almost a copy-paste of the end of RequestProcessor.processPath method, it should be + // refactored in a "simplify path" somewhere else. // This is a temporary patch to handle forwards correctly. - String retryPath = StringUtils.defaultString(StringUtils.substringAfterLast(StringUtils.substringBeforeLast(path, "."), "/")); + String retryPath = StringUtils.defaultString(StringUtils.substringAfterLast(StringUtils + .substringBeforeLast(path, "."), "/")); retryPath = retryPath.startsWith("/") ? retryPath : ("/" + retryPath); mapping = (ActionMapping) moduleConfig.findActionConfig(retryPath); } - if (mapping != null) { + if (mapping != null) + { request.setAttribute(Globals.MAPPING_KEY, mapping); return (mapping); } // Locate the mapping for unknown paths (if any) ActionConfig configs[] = moduleConfig.findActionConfigs(); - for (int i = 0; i < configs.length; i++) { - if (configs[i].getUnknown()) { + for (int i = 0; i < configs.length; i++) + { + if (configs[i].getUnknown()) + { mapping = (ActionMapping) configs[i]; request.setAttribute(Globals.MAPPING_KEY, mapping); return (mapping); @@ -148,7 +164,8 @@ log.error("Invalid path: " + path); // debug only on admin instances - if (ServerConfiguration.getInstance().isAdmin()) { + if (ServerConfiguration.getInstance().isAdmin()) + { getOut().write("Invalid path: " + path); } @@ -156,7 +173,8 @@ } - private static WebContext getWebContext() { + private static WebContext getWebContext() + { return ((WebContext) MgnlContext.getInstance()); } @@ -164,14 +182,18 @@ * @return * @throws IOException */ - private static Writer getOut() throws IOException { + private static Writer getOut() throws IOException + { Writer out = null; PageContext pageContext = getWebContext().getPageContext(); - if (pageContext != null) { + if (pageContext != null) + { out = pageContext.getOut(); - } else { + } + else + { out = getWebContext().getResponse().getWriter(); } return out; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |