public ActionMapping getMapping(HttpServletRequest request) { ActionMapping mapping = new ActionMapping(); String uri = getUri(request); parseNameAndNamespace(uri, mapping); handleSpecialParameters(request, mapping); if (mapping.getName() == null) { return null; } // handle "name!method" convention. String name = mapping.getName(); int exclamation = name.lastIndexOf("!"); if (exclamation != -1) { mapping.setName(name.substring(0, exclamation)); mapping.setMethod(name.substring(exclamation + 1)); } return mapping; }
public String getUriFromActionMapping(ActionMapping mapping) { StringBuffer uri = new StringBuffer(); uri.append(mapping.getNamespace()); if(!"/".equals(mapping.getNamespace())) { uri.append("/"); } String name = mapping.getName(); String params = ""; if ( name.indexOf('?') != -1) { params = name.substring(name.indexOf('?')); name = name.substring(0, name.indexOf('?')); } uri.append(name); if (null != mapping.getMethod() && !"".equals(mapping.getMethod())) { uri.append("!").append(mapping.getMethod()); } String extension = getDefaultExtension(); if ( extension != null && uri.indexOf( '.' + extension) == -1 ) { uri.append(".").append(extension); if ( params.length() > 0) { uri.append(params); } } return uri.toString(); }
public String getUriFromActionMapping(ActionMapping mapping) { String base = mapping.getNamespace() + mapping.getName(); for (Iterator iterator = mapping.getParams().entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); String name = (String) entry.getKey(); if (name.equals(mapping.getName() + "Id")) { base = base + "/" + entry.getValue(); break; } } return base; } }
protected void parseNameAndNamespace(String uri, ActionMapping mapping) { String namespace, name; int lastSlash = uri.lastIndexOf("/"); if (lastSlash == -1) { namespace = ""; name = uri; } else if (lastSlash == 0) { // ww-1046, assume it is the root namespace, it will fallback to default // namespace anyway if not found in root namespace. namespace = "/"; name = uri.substring(lastSlash + 1); } else { namespace = uri.substring(0, lastSlash); name = uri.substring(lastSlash + 1); } mapping.setNamespace(namespace); mapping.setName(dropExtension(name)); }
String namespace = mapping.getNamespace(); String name = mapping.getName(); String method = mapping.getMethod(); if (mapping.getResult() != null) { Result result = mapping.getResult(); result.execute(proxy.getInvocation()); } else {
ActionMapping mapping = new ActionMapping(); mapping.setName(getActionName(fullPath.toString())); mapping.setNamespace(getNamespace(fullPath.toString())); actionMap.put(portletMode, mapping);
return new ActionMapping(actionName, "", "", parameters);
getPortletConfig(), phase); PortletMode mode = request.getPortletMode(); String actionName = mapping.getName(); String namespace = mapping.getNamespace(); try { LOG.debug("Creating action proxy for name = " + actionName
String namespace = ActionMapperFactory.getMapper().getMapping(request).getNamespace();
public Map createContextMap(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping, ServletContext context) { // request map wrapping the http request objects Map requestMap = new RequestMap(request); // parameters map wrapping the http paraneters. Map params = null; if (mapping != null) { params = mapping.getParams(); } Map requestParams = new HashMap(request.getParameterMap()); if (params != null) { params.putAll(requestParams); } else { params = requestParams; } // session map wrapping the http session Map session = new SessionMap(request); // application map wrapping the ServletContext Map application = new ApplicationMap(context); return createContextMap(requestMap, params, session, application, request, response, context); }
ActionMapping mapping = new ActionMapping(); if (resetAction(request)) { mapping = (ActionMapping) actionMap.get(request.getPortletMode()); action = actionPath.substring(idx + 1); mapping.setName(action); mapping.setNamespace(namespace);
/** * */ protected ActionMapping getActionMapping(ActionDefinition actionDefinition, Map<String, String> params) { ActionMapping actionMapping = new ActionMapping(actionDefinition.getAction(), actionDefinition.getNamespace(), actionDefinition.getMethod(), params); return actionMapping; }
public static String buildNamespace(OgnlValueStack stack, HttpServletRequest request) { ActionContext context = new ActionContext(stack.getContext()); ActionInvocation invocation = context.getActionInvocation(); if (invocation == null) { ActionMapper mapper = ActionMapperFactory.getMapper(); ActionMapping mapping = mapper.getMapping(request); if (mapping != null) { return mapping.getNamespace(); } else { // well, if the ActionMapper can't tell us, and there is no existing action invocation, // let's just go with a default guess that the namespace is the last the path minus the // last part (/foo/bar/baz.xyz -> /foo/bar) String path = RequestUtils.getServletPath(request); return path.substring(0, path.lastIndexOf("/")); } } else { return invocation.getProxy().getNamespace(); } } }
StringBuffer tmpLocation = new StringBuffer(mapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null))); UrlHelper.buildParametersString(requestParameters, tmpLocation, "&");
/** * Renders an action URL by consulting the {@link com.opensymphony.webwork.dispatcher.mapper.ActionMapper}. * @param action the action * @param namespace the namespace * @param method the method * @param req HTTP request * @param res HTTP response * @param parameters parameters * @param scheme http or https * @param includeContext should the context path be included or not * @param encodeResult should the url be encoded * @return the action url. */ protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult, boolean escapeXml) { String finalAction = findString(action); String finalNamespace = determineNamespace(namespace, getStack(), req); ActionMapping mapping = new ActionMapping(finalAction, finalNamespace, method, parameters); ActionMapper mapper = ActionMapperFactory.getMapper(); String uri = mapper.getUriFromActionMapping(mapping); return UrlHelper.buildUrl(uri, req, res, parameters, scheme, includeContext, encodeResult, false, escapeXml); }
if (actionConfig != null) { ActionMapping mapping = new ActionMapping(action, namespace, actionMethod, parameters); String result = UrlHelper.buildUrl(ActionMapperFactory.getMapper().getUriFromActionMapping(mapping), request, response, null); addParameter("action", result);