/** * Returns the Validation key. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return validation key - the action element's 'path' attribute in this case */ public String getValidationKey(ActionMapping mapping, HttpServletRequest request) { return mapping.getPath(); }
/** * Returns the Validation key. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return validation key - the action element's 'path' attribute in this case */ public String getValidationKey(ActionMapping mapping, HttpServletRequest request) { return mapping.getPath(); }
/** * {@link ActionConfig}を登録します。 * * @param config * @param actionConfig * @return */ public static boolean registeredActionConfig(ModuleConfig config, ActionConfig actionConfig) { ActionConfig[] actionConfigs = config.findActionConfigs(); for (int i = 0; i < actionConfigs.length; ++i) { if (actionConfig.getPath().equals(actionConfigs[i].getPath())) { return true; } } return false; }
/** * Remove the specified action configuration instance. * * @param config ActionConfig instance to be removed * * @exception IllegalStateException if this module configuration * has been frozen */ public void removeActionConfig(ActionConfig config) { if (configured) { throw new IllegalStateException("Configuration is frozen"); } config.setModuleConfig(null); actionConfigs.remove(config.getPath()); actionConfigList.remove(config); }
/** * Add a new <code>ActionConfig</code> instance to the set associated * with this module. * * @param config The new configuration instance to be added * * @exception java.lang.IllegalStateException if this module configuration * has been frozen */ public void addActionConfig(ActionConfig config) { if (configured) { throw new IllegalStateException("Configuration is frozen"); } config.setModuleConfig(this); actionConfigs.put(config.getPath(), config); actionConfigList.add(config); }
/** * <p> Remove the specified action configuration instance. </p> * * @param config ActionConfig instance to be removed * @throws IllegalStateException if this module configuration has been * frozen */ public void removeActionConfig(ActionConfig config) { throwIfConfigured(); config.setModuleConfig(null); actionConfigs.remove(config.getPath()); actionConfigList.remove(config); }
public Object invoke(MethodInvocation invocation) throws Throwable { ModuleConfig config = (ModuleConfig) invocation.getThis(); String path = (String) invocation.getArguments()[0]; ModuleConfig reloadConfig = this.moduleConfigLoader.load(config.getPrefix()); ActionConfig[] actionConfigs = reloadConfig.findActionConfigs(); for (int i = 0; i < actionConfigs.length; i++) { if (path.equals(actionConfigs[i].getPath())) { return actionConfigs[i]; } } return invocation.proceed(); }
/** * Method which is dispatched to when there is no value for the * parameter in the ActionMapping. Subclasses of * <code>MappingDispatchAction</code> should override this method * if they wish to provide default behavior different than throwing a * ServletException. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @return Return an <code>ActionForward</code> instance describing where * and how control should be forwarded, or <code>null</code> if * the response has already been completed. * * @exception Exception if an exception occurs */ protected ActionForward unspecified( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String message = messages.getMessage("mapping.parameter", mapping.getPath()); log.error(message); throw new ServletException(message); }
/** * <p>Return the context-relative URL that corresponds to the specified * {@link ActionConfig}, relative to the module associated with the * current modules's {@link ModuleConfig}.</p> * * @param request The servlet request we are processing * @param action ActionConfig to be evaluated * @param pattern URL pattern used to map the controller servlet * @return context-relative URL relative to the module * @since Struts 1.1 */ public static String actionURL(HttpServletRequest request, ActionConfig action, String pattern) { StringBuffer sb = new StringBuffer(); if (pattern.endsWith("/*")) { sb.append(pattern.substring(0, pattern.length() - 2)); sb.append(action.getPath()); } else if (pattern.startsWith("*.")) { ModuleConfig appConfig = ModuleUtils.getInstance().getModuleConfig(request); sb.append(appConfig.getPrefix()); sb.append(action.getPath()); sb.append(pattern.substring(1)); } else { throw new IllegalArgumentException(pattern); } return sb.toString(); }
/** * <p> Finds and precompiles the wildcard patterns from the ActionConfig * "path" attributes. ActionConfig's will be evaluated in the order they * exist in the Struts config file. Only paths that actually contain a * wildcard will be compiled. </p> * * @param configs An array of ActionConfig's to process */ public ActionConfigMatcher(ActionConfig[] configs) { compiledPaths = new ArrayList(); int[] pattern; String path; for (int x = 0; x < configs.length; x++) { path = configs[x].getPath(); if ((path != null) && (path.indexOf('*') > -1)) { if ((path.length() > 0) && (path.charAt(0) == '/')) { path = path.substring(1); } if (log.isDebugEnabled()) { log.debug("Compiling action config path '" + path + "'"); } pattern = wildcard.compilePattern(path); compiledPaths.add(new Mapping(pattern, configs[x])); } } }
/** * Finds and precompiles the wildcard patterns from the ActionConfig * "path" attributes. * ActionConfig's will be evaluated in the order they exist in the * Struts config file. Only paths that actually contain a wildcard * will be compiled. * * @param configs An array of ActionConfig's to process */ public ActionConfigMatcher(ActionConfig[] configs) { compiledPaths = new ArrayList(); int[] pattern; String path; for (int x = 0; x < configs.length; x++) { path = configs[x].getPath(); if (path != null && path.indexOf('*') > -1) { if (path.length() > 0 && path.charAt(0) == '/') { path = path.substring(1); } if (log.isDebugEnabled()) { log.debug("Compiling action config path '" + path + "'"); } pattern = wildcard.compilePattern(path); compiledPaths.add(new Mapping(pattern, configs[x])); } } }
/** * Method which is dispatched to when there is no value for specified * request parameter included in the request. Subclasses of * <code>DispatchAction</code> should override this method if they wish * to provide default behavior different than throwing a ServletException. */ protected ActionForward unspecified( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String message = messages.getMessage( "dispatch.parameter", mapping.getPath(), mapping.getParameter()); log.error(message); throw new ServletException(message); }
/** * <p>Returns the parameter value.</p> * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @return The <code>ActionMapping</code> parameter's value * @throws Exception if the parameter is missing. */ protected String getParameter(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Identify the request parameter containing the method name String parameter = mapping.getParameter(); if (parameter == null) { String message = messages.getMessage("dispatch.handler", mapping.getPath()); log.error(message); throw new ServletException(message); } return parameter; }
/** * Method which is dispatched to when there is no value for specified * request parameter included in the request. Subclasses of * <code>DispatchAction</code> should override this method if they wish to * provide default behavior different than throwing a ServletException. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The non-HTTP request we are processing * @param response The non-HTTP response we are creating * @return The forward to which control should be transferred, or * <code>null</code> if the response has been completed. * @throws Exception if the application business logic throws an * exception. */ protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String message = messages.getMessage("event.parameter", mapping.getPath(), mapping.getParameter()); LOG.error(message + " " + mapping.getParameter()); throw new ServletException(message); }
protected String getErrorMessage(ActionContext context, ActionConfig actionConfig) { ServletActionContext servletActionContext = (ServletActionContext) context; // Retrieve internal message resources ActionServlet servlet = servletActionContext.getActionServlet(); MessageResources resources = servlet.getInternal(); return resources.getMessage("notAuthorized", actionConfig.getPath()); } }
/** * Dispatch to the specified method. */ protected ActionForward dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String name) throws Exception { // Make sure we have a valid method name to call. // This may be null if the user hacks the query string. if (name == null) { return this.unspecified(mapping, form, request, response); } // Identify the method object to be dispatched to Method method = null; try { method = getMethod(name); } catch (NoSuchMethodException e) { String message = messages.getMessage("dispatch.method", mapping.getPath(), name); log.error(message, e); String userMsg = messages.getMessage("dispatch.method.user", mapping.getPath()); throw new NoSuchMethodException(userMsg); } return dispatchMethod(mapping, form, request, response, name, method); }
/** * <p>Traces the hierarchy of this object to check if any of the ancestors * is extending this instance.</p> * * @param moduleConfig The configuration for the module being configured. * @return true if circular inheritance was detected. */ protected boolean checkCircularInheritance(ModuleConfig moduleConfig) { String ancestorPath = getExtends(); while (ancestorPath != null) { // check if we have the same path as an ancestor if (getPath().equals(ancestorPath)) { return true; } // get our ancestor's ancestor ActionConfig ancestor = moduleConfig.findActionConfig(ancestorPath); if (ancestor != null) { ancestorPath = ancestor.getExtends(); } else { ancestorPath = null; } } return false; }
/** * <p>Dispatches to the target class' <code>unspecified</code> method, * if present, otherwise throws a ServletException. Classes utilizing * <code>ActionDispatcher</code> should provide an <code>unspecified</code> * method if they wish to provide behavior different than * throwing a ServletException..</p> */ protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Identify if there is an "unspecified" method to be dispatched to String name = "unspecified"; Method method = null; try { method = getMethod(name); } catch (NoSuchMethodException e) { String message = messages.getMessage("dispatch.parameter", mapping.getPath(), mapping.getParameter()); log.error(message); throw new ServletException(message); } return dispatchMethod(mapping, form, request, response, name, method); }