Refine search
private String constructRedirectPath(final ActionMapping mapping, final HttpServletRequest request, final StringBuilder path) { final String result = GenericChecksumRewriter.injectChecksumInUrl(request.getContextPath(), path.toString(), request.getSession()); return result.substring(mapping.getModuleConfig().getPrefix().length()); }
public Object invoke(MethodInvocation invocation) throws Throwable { ModuleConfig config = (ModuleConfig) invocation.getThis(); String name = (String) invocation.getArguments()[0]; ModuleConfig reloadConfig = this.moduleConfigLoader.load(config.getPrefix()); FormBeanConfig formConfig = reloadConfig.findFormBeanConfig(name); if (formConfig != null) { return formConfig; } return invocation.proceed(); }
public ControllerConfig getControllerConfig() { return config.getControllerConfig(); }
private void removeActionAndForm(String siteName, String actionName, String formName) { ModuleConfig moduleConfig = getModuleConfig(); if (moduleConfig == null) { return; } FormBeanConfig formBeanConfig = moduleConfig .findFormBeanConfig(formName); try { ActionConfig actionConfig = moduleConfig .findActionConfig(actionName); if (formBeanConfig != null) { moduleConfig.removeFormBeanConfig(formBeanConfig); } if (actionConfig != null) { moduleConfig.removeActionConfig(actionConfig); } } catch (NullPointerException ne) { //config is null. do nothing } } }
public Object invoke(MethodInvocation invocation) throws Throwable { ActionConfig[] result = (ActionConfig[]) invocation.proceed(); ModuleConfig config = (ModuleConfig) invocation.getThis(); ModuleConfig reloadConfig = this.moduleConfigLoader.load(config.getPrefix()); ActionConfig[] actionConfigs = reloadConfig.findActionConfigs(); List mergeActionConfigs = new ArrayList(); if (result != null) { mergeActionConfigs.addAll(Arrays.asList(result)); } if (actionConfigs != null) { mergeActionConfigs.addAll(Arrays.asList(actionConfigs)); } return mergeActionConfigs.toArray(new ActionConfig[mergeActionConfigs.size()]); }
path = request.getPathInfo(); path = request.getServletPath(); String prefix = moduleConfig.getPrefix(); if (!path.startsWith(prefix)) { String msg = getInternal().getMessage("processPath"); log.error(msg + " " + request.getRequestURI()); response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
private ActionForm createNewActionForm(ActionMapping mapping, HttpServletRequest request) { String name = mapping.getName(); FormBeanConfig config = moduleConfig.findFormBeanConfig(name); if (config == null) { log.warn("No FormBeanConfig found under '" + name + "'"); return (null); } ActionForm instance = RequestUtils.createActionForm(config, servlet); if ("request".equals(mapping.getScope())) { request.setAttribute(mapping.getAttribute(), instance); } else { HttpSession session = request.getSession(); session.setAttribute(mapping.getAttribute(), instance); } return instance; } }
/** * Get definition factory for the module attached to specified moduleConfig. * @param servletContext Current servlet context. * @param moduleConfig Module config of the module for which the factory is requested. * @return Definitions factory or null if not found. */ public DefinitionsFactory getDefinitionsFactory( ServletContext servletContext, ModuleConfig moduleConfig) { return (DefinitionsFactory) servletContext.getAttribute( DEFINITIONS_FACTORY + moduleConfig.getPrefix()); }
request.setAttribute(Globals.MODULE_KEY, config); config.findMessageResourcesConfigs(); (MessageResources) context.getAttribute(key + prefix); request.setAttribute(key, resources); } else { request.removeAttribute(key);
/** * Retrieve <code>MessageResources</code> for the module and bundle. * * @param application the servlet context * @param request the servlet request * @param bundle the bundle key */ public static MessageResources getMessageResources( ServletContext application, HttpServletRequest request, String bundle) { if (bundle == null) { bundle = Globals.MESSAGES_KEY; } MessageResources resources = (MessageResources) request.getAttribute(bundle); if (resources == null) { ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, application); resources = (MessageResources) application.getAttribute(bundle + moduleConfig.getPrefix()); } if (resources == null) { resources = (MessageResources) application.getAttribute(bundle); } if (resources == null) { throw new NullPointerException( "No message resources found for bundle: " + bundle); } return resources; }
/** * <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); } }
private void initValidatorResources(ServletContext context, ModuleConfig config) { S2Container container = getContainer(); if (!container.hasComponentDef(ValidatorResourcesWrapper.class)) { return; } ValidatorResourcesWrapper resourcesWrapper = (ValidatorResourcesWrapper) container .getComponent(ValidatorResourcesWrapper.class); ValidatorResources resources = (ValidatorResources) context.getAttribute(ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix()); resourcesWrapper.init(resources); context.setAttribute(ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix(), resourcesWrapper); }
private void initMessageResources(ServletContext context, ModuleConfig config) { S2Container container = getContainer(); if (!container.hasComponentDef(ReloadMessageResourcesFactory.class)) { return; } ReloadMessageResourcesFactory reloadResourcesFactory = (ReloadMessageResourcesFactory) container .getComponent(ReloadMessageResourcesFactory.class); MessageResourcesConfig[] mrcs = config.findMessageResourcesConfigs(); for (int i = 0; i < mrcs.length; i++) { MessageResources resources = (MessageResources) context.getAttribute(mrcs[i].getKey() + config.getPrefix()); MessageResources reloadResources = reloadResourcesFactory.createResources(resources); context.setAttribute(mrcs[i].getKey() + config.getPrefix(), reloadResources); } }
/** * @return If the action is not specified returns the original request uri. */ public String getPostbackAction() { final HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String tempPostbackAction = (String) request.getAttribute(Globals.ORIGINAL_URI_KEY); final String prefix = moduleConfig.getPrefix(); if (tempPostbackAction != null && prefix.length() > 0 && tempPostbackAction.startsWith(prefix)) { tempPostbackAction = tempPostbackAction.substring(prefix.length()); } return tempPostbackAction; }
/** * <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); } }
(ModuleConfig) request.getAttribute(Globals.MODULE_KEY); moduleConfig.findMessageResourcesConfigs(); String text = resources.getMessage(userLocale, key);
@Override protected ActionMapping processMapping(HttpServletRequest request, HttpServletResponse response, String path) throws IOException { S2ActionMapping mapping = (S2ActionMapping) moduleConfig .findActionConfig(path); if (mapping != null) { request.setAttribute(Globals.MAPPING_KEY, mapping); return mapping; } response.sendError(HttpServletResponse.SC_NOT_FOUND, path + " not found."); return null; }
protected MessageResources getResources(HttpServletRequest request, String key) { ServletContext context = request.getServletContext(); ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context); return (MessageResources) context.getAttribute(key + moduleConfig.getPrefix()); }
/** * <p> Store the mesasage resources for the current module under the given * request attribute key. </p> * * @param key Request attribute key * @param resources Message resouces to store */ public void setMessageResources(String key, MessageResources resources) { this.getRequest().setAttribute(key + getModuleConfig().getPrefix(), resources); }
(ActionMapping) moduleConfig.findActionConfig(path); request.setAttribute(Globals.MAPPING_KEY, mapping); ActionConfig[] configs = moduleConfig.findActionConfigs(); request.setAttribute(Globals.MAPPING_KEY, mapping); String msg = getInternal().getMessage("processInvalid");