public ControllerConfig getControllerConfig() { return config.getControllerConfig(); }
/** * <p>Set the no-cache headers for all responses, if requested. * <strong>NOTE</strong> - This header will be overridden * automatically if a <code>RequestDispatcher.forward</code> call is * ultimately invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processNoCache(HttpServletRequest request, HttpServletResponse response) { if (moduleConfig.getControllerConfig().getNocache()) { response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); } }
/** * <p>Set the default content type (with optional character encoding) for * all responses if requested. <strong>NOTE</strong> - This header will * be overridden automatically if a <code>RequestDispatcher.forward</code> * call is ultimately invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processContent(HttpServletRequest request, HttpServletResponse response) { String contentType = moduleConfig.getControllerConfig().getContentType(); if (contentType != null) { response.setContentType(contentType); } }
/** * <p>Set the no-cache headers for all responses, if requested. * <strong>NOTE</strong> - This header will be overridden automatically if * a <code>RequestDispatcher.forward</code> call is ultimately * invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processNoCache(HttpServletRequest request, HttpServletResponse response) { if (moduleConfig.getControllerConfig().getNocache()) { response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); } }
/** * <p>Set the default content type (with optional character encoding) for * all responses if requested. <strong>NOTE</strong> - This header will * be overridden automatically if a * <code>RequestDispatcher.forward</code> call is * ultimately invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processContent(HttpServletRequest request, HttpServletResponse response) { String contentType = moduleConfig.getControllerConfig().getContentType(); if (contentType != null) { response.setContentType(contentType); } }
/** * <p>Automatically select a <code>Locale</code> for the current user, if * requested. <strong>NOTE</strong> - configuring Locale selection will * trigger the creation of a new <code>HttpSession</code> if * necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processLocale(HttpServletRequest request, HttpServletResponse response) { // Are we configured to select the Locale automatically? if (!moduleConfig.getControllerConfig().getLocale()) { return; } // Has a Locale already been selected? HttpSession session = request.getSession(); if (session.getAttribute(Globals.LOCALE_KEY) != null) { return; } // Use the Locale returned by the servlet container (if any) Locale locale = request.getLocale(); if (locale != null) { if (log.isDebugEnabled()) { log.debug(" Setting user locale '" + locale + "'"); } session.setAttribute(Globals.LOCALE_KEY, locale); } }
/** * <p> Returns the maximum allowable size, in bytes, of an uploaded file. * The value is obtained from the current module's controller * configuration. </p> * * @param mc The current module's configuration. * @return The maximum allowable file size, in bytes. */ protected long getSizeMax(ModuleConfig mc) { return convertSizeToBytes(mc.getControllerConfig().getMaxFileSize(), DEFAULT_SIZE_MAX); }
/** * <p> Returns the size threshold which determines whether an uploaded * file will be written to disk or cached in memory. </p> * * @param mc The current module's configuration. * @return The size threshold, in bytes. */ protected long getSizeThreshold(ModuleConfig mc) { return convertSizeToBytes(mc.getControllerConfig().getMemFileSize(), DEFAULT_SIZE_THRESHOLD); }
/** * Returns the maximum allowable size, in bytes, of an uploaded file. The * value is obtained from the current module's controller configuration. * * @param mc The current module's configuration. * * @return The maximum allowable file size, in bytes. */ protected long getSizeMax(ModuleConfig mc) { return convertSizeToBytes( mc.getControllerConfig().getMaxFileSize(), DEFAULT_SIZE_MAX); }
/** * Returns the size threshold which determines whether an uploaded file * will be written to disk or cached in memory. * * @param mc The current module's configuration. * * @return The size threshold, in bytes. */ protected long getSizeThreshold(ModuleConfig mc) { return convertSizeToBytes( mc.getControllerConfig().getMemFileSize(), DEFAULT_SIZE_THRESHOLD); }
public static String getMaxFileSize(ActionMapping mapping) { ModuleConfig ac = mapping.getModuleConfig(); return ac.getControllerConfig().getMaxFileSize(); }
/** * <p>Automatically select a <code>Locale</code> for the current user, if requested. * <strong>NOTE</strong> - configuring Locale selection will trigger * the creation of a new <code>HttpSession</code> if necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processLocale(HttpServletRequest request, HttpServletResponse response) { // Are we configured to select the Locale automatically? if (!moduleConfig.getControllerConfig().getLocale()) { return; } // Has a Locale already been selected? HttpSession session = request.getSession(); if (session.getAttribute(Globals.LOCALE_KEY) != null) { return; } // Use the Locale returned by the servlet container (if any) Locale locale = request.getLocale(); if (locale != null) { if (log.isDebugEnabled()) { log.debug(" Setting user locale '" + locale + "'"); } session.setAttribute(Globals.LOCALE_KEY, locale); } }
tempDir = moduleConfig.getControllerConfig().getTempDir();
/** * <p>Select the <code>Locale</code> to be used for this request.</p> * * @param actionCtx The <code>Context</code> for the current request * @return <code>false</code> so that processing continues * @throws Exception if thrown by the Action class */ public boolean execute(ActionContext actionCtx) throws Exception { // Are we configured to select Locale automatically? LOG.trace("retrieve config..."); ModuleConfig moduleConfig = actionCtx.getModuleConfig(); if (!moduleConfig.getControllerConfig().getLocale()) { if (LOG.isDebugEnabled()) { LOG.debug("module is not configured for a specific locale; " + "nothing to do"); } return (false); } // Retrieve and cache appropriate Locale for this request Locale locale = getLocale(actionCtx); if (LOG.isDebugEnabled()) { LOG.debug("set context locale to " + locale); } actionCtx.setLocale(locale); return (false); }
public void init(ActionServlet servlet, ModuleConfig config) throws ServletException { initBeanUtils(); // override the Struts ControllerConfig with our own wrapper that knows how to // dynamically find max file upload size according to Rice run-time settings config.setControllerConfig(new KualiControllerConfig(config.getControllerConfig())); }
private static void registerRequestProcessor(ActionServlet servlet, ModuleConfig config) { S2Container container = SingletonS2ContainerFactory.getContainer(); ControllerConfig controllerConfig = config.getControllerConfig(); String processorClassName = controllerConfig.getProcessorClass(); Class processorClass = ClassUtil.forName(processorClassName); if (ExternalRequestProcessor.class.isAssignableFrom(processorClass)) { register(container, ExternalRequestProcessor.class, processorClass, InstanceDefFactory.PROTOTYPE); } }
/** * <p>Check to see if the controller is configured to prevent caching, and * if so, request no cache flags to be set.</p> * * @param actionCtx The <code>Context</code> for the current request * @return <code>false</code> so that processing continues * @throws Exception if thrown by the Action class */ public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve the ModuleConfig instance ModuleConfig moduleConfig = actionCtx.getModuleConfig(); // If the module is configured for no caching, request no caching if (moduleConfig.getControllerConfig().getNocache()) { requestNoCache(actionCtx); } return (false); }
/** * <p>Check to see if the content type is set, and if so, set it for this * response.</p> * * @param actionCtx The <code>Context</code> for the current request * @return <code>false</code> so that processing continues * @throws Exception if thrown by the Action class */ public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve the ModuleConfig instance ModuleConfig moduleConfig = actionCtx.getModuleConfig(); // If the content type is configured, set it for the response String contentType = moduleConfig.getControllerConfig().getContentType(); if (contentType != null) { setContentType(actionCtx, contentType); } return (false); }
/** * <p>Create (if necessary) and return an {@link ActionForward} that * corresponds to the <code>input</code> property of this Action.</p> * * @since Struts 1.1 */ public ActionForward getInputForward() { if (getModuleConfig().getControllerConfig().getInputForward()) { return (findForward(getInput())); } else { return (new ActionForward(getInput())); } }
/** * <p>Create (if necessary) and return an {@link ActionForward} that * corresponds to the <code>input</code> property of this Action.</p> * * @return The input forward for this action mapping. * @since Struts 1.1 */ public ActionForward getInputForward() { if (getModuleConfig().getControllerConfig().getInputForward()) { return (findForward(getInput())); } else { return (new ActionForward(getInput())); } } }