protected String getRequestName(ActionInvocation invocation) { // final String actionName = invocation.getInvocationContext().getName(); final String actionName; final ActionProxy proxy = invocation.getProxy(); final String action = proxy.getActionName(); final String method = proxy.getMethod(); final String namespace = proxy.getNamespace(); if (method == null || "execute".equals(method)) { actionName = namespace + '/' + action; } else { actionName = namespace + '/' + action + '!' + method; } return actionName; } }
@Override public String getNamespace() { return this.parentProxy.getNamespace(); }
public String getPath(){ ActionProxy proxy = ActionContext.getContext().getActionInvocation().getProxy(); String namespace = proxy.getNamespace(); String name = proxy.getActionName(); return namespace+(name == null || name.equals("/") ?"":("/"+name)); }
private void doRedirect(ActionInvocation invocation,HttpServletRequest request, HttpServletResponse response, String redirectLocation) throws IOException { if(isPathUrl(redirectLocation)) { if(!redirectLocation.startsWith("/")) { String namespace = invocation.getProxy().getNamespace(); if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) { redirectLocation = namespace + "/" + redirectLocation; } else { redirectLocation = "/" + redirectLocation; } } if (prependServletContext && (request.getContextPath() != null) && (request.getContextPath().length() > 0)) { redirectLocation = request.getContextPath() + redirectLocation; } } if(_log.isInfoEnabled()) _log.info("Redirect to location:"+redirectLocation); response.sendRedirect(response.encodeRedirectURL(redirectLocation)); }
private void logMessage(ActionInvocation invocation, String baseMessage) { if (LOG.isInfoEnabled()) { StringBuilder message = new StringBuilder(baseMessage); String namespace = invocation.getProxy().getNamespace(); if ((namespace != null) && (namespace.trim().length() > 0)) { message.append(namespace).append("/"); } message.append(invocation.getProxy().getActionName()); if (LOG.isInfoEnabled()) { LOG.info(message.toString()); } } }
protected String getRequestName(ActionInvocation invocation) { // final String actionName = invocation.getInvocationContext().getName(); final String actionName; final ActionProxy proxy = invocation.getProxy(); final String action = proxy.getActionName(); final String method = proxy.getMethod(); final String namespace = proxy.getNamespace(); if (method == null || "execute".equals(method)) { actionName = namespace + '/' + action; } else { actionName = namespace + '/' + action + '!' + method; } return actionName; } }
protected void logUserInteraction(Object... objects) { Map<String, Object> entry = _userInteractionLoggingService.isInteractionLoggedForCurrentUser(); if (entry == null) return; ActionContext context = ActionContext.getContext(); ActionInvocation invocation = context.getActionInvocation(); ActionProxy proxy = invocation.getProxy(); entry.put("interface", "phone"); entry.put("namespace", proxy.getNamespace()); entry.put("actionName", proxy.getActionName()); entry.put("method", proxy.getMethod()); if( objects.length % 2 != 0 ) throw new IllegalStateException("expected an even number of arguments"); for( int i=0; i<objects.length; i+= 2) entry.put(objects[i].toString(),objects[i+1]); _userInteractionLoggingService.logInteraction(entry); } }
protected String invoke(ActionInvocation invocation) throws Exception { Logger log = ApsSystemUtils.getLogger(); HttpSession session = ServletActionContext.getRequest().getSession(); UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); String message = "Action invoked '" + invocation.getProxy().getActionName() + "' on namespace '" + invocation.getProxy().getNamespace() + "' from user '" + currentUser.getUsername() + "'"; log.info(message); return super.invoke(invocation); }
/** * Initializes the validation resources */ private void initResources(ServletContext servletContext) { if (pathnames != null) { ActionContext ctx = ActionContext.getContext(); try { ValidatorResources resources = this.loadResources(servletContext); String prefix = ctx.getActionInvocation().getProxy().getNamespace(); servletContext.setAttribute(ValidatorPlugIn.VALIDATOR_KEY + prefix, resources); servletContext.setAttribute(ValidatorPlugIn.STOP_ON_ERROR_KEY + '.' + prefix, (this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE)); } catch (Exception e) { throw new StrutsException( "Cannot load a validator resource from '" + pathnames + "'", e); } } }
@SuppressWarnings("unchecked") public SavedActionInvocation( ActionInvocation invocation ) { namespace = invocation.getProxy().getNamespace(); actionName = invocation.getProxy().getActionName(); methodName = invocation.getProxy().getMethod(); parameterMap = new HashMap<String, Object>(); parameterMap.putAll( invocation.getInvocationContext().getParameters() ); }
@Override protected String invoke(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action instanceof BaseAction) { Set<String> requiredPermissions = super.extractAllRequiredPermissions(); ((BaseAction) action).setRequiredPermissions(requiredPermissions); } HttpSession session = ServletActionContext.getRequest().getSession(); UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); _logger.debug("Action invoked '{}' on namespace '{}' from user '{}'", invocation.getProxy().getActionName(), invocation.getProxy().getNamespace(), currentUser.getUsername()); return super.invoke(invocation); }
@Override protected String invoke(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action instanceof BaseAction) { Set<String> requiredPermissions = super.extractAllRequiredPermissions(); ((BaseAction) action).setRequiredPermissions(requiredPermissions); } HttpSession session = ServletActionContext.getRequest().getSession(); UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER); _logger.debug("Action invoked '{}' on namespace '{}' from user '{}'", invocation.getProxy().getActionName(), invocation.getProxy().getNamespace(), currentUser.getUsername()); return super.invoke(invocation); }
private String makeStackKey(ActionProxy proxy) { String methodName = proxy.getConfig().getMethodName(); if (methodName == null) methodName = "execute"; String actionClazz = ProfilingUtils.getJustClassName(proxy.getConfig().getClassName()); return "XW Interceptor: " + (location != null ? location + ": " : "") + proxy.getNamespace() + "/" + proxy.getActionName() + ".action (" + actionClazz + "." + methodName + "())"; }
private String getDetails(ActionInvocation invocation) { ActionProxy proxy = invocation.getProxy(); String methodName = proxy.getConfig().getMethodName(); if (methodName == null) methodName = "execute"; String actionClazz = ProfilingUtils.getJustClassName(proxy.getConfig().getClassName()); return proxy.getNamespace() + "/" + proxy.getActionName() + ".action (" + actionClazz + "." + methodName + "())"; }
@Override public void execute(ActionInvocation invocation) throws Exception { this.actionName = this.conditionalParse(this.actionName, invocation); if (this.namespace == null) { this.namespace = invocation.getProxy().getNamespace(); } else { this.namespace = this.conditionalParse(this.namespace, invocation); } if (this.method == null) { this.method = ""; } else { this.method = this.conditionalParse(this.method, invocation); } StringBuilder tmpLocation = new StringBuilder(this.actionMapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null))); if (null != this.getAnchorDest()) { this.setAnchor(this.getAnchorDest()); } setLocation(tmpLocation.toString()); super.execute(invocation); }
@Override public void execute(ActionInvocation invocation) throws Exception { this.actionName = this.conditionalParse(this.actionName, invocation); if (this.namespace == null) { this.namespace = invocation.getProxy().getNamespace(); } else { this.namespace = this.conditionalParse(this.namespace, invocation); } if (this.method == null) { this.method = ""; } else { this.method = this.conditionalParse(this.method, invocation); } StringBuilder tmpLocation = new StringBuilder(this.actionMapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null))); if (null != this.getAnchorDest()) { this.setAnchor(this.getAnchorDest()); } setLocation(tmpLocation.toString()); super.execute(invocation); }
/** * Build an {@link ActionLoggerRecord} object related to the current action * @param invocation * @return an {@link ActionLoggerRecord} for the current action */ private ActionLogRecord buildActionRecord(ActionInvocation invocation) { ActionLogRecord record = new ActionLogRecord(); String username = this.getCurrentUsername(); String namespace = invocation.getProxy().getNamespace(); String actionName = invocation.getProxy().getActionName(); String parameters = this.getParameters(); record.setUsername(username); record.setNamespace(namespace); record.setActionName(actionName); record.setParameters(parameters); return record; }
/** * Build an {@link ActionLoggerRecord} object related to the current action * @param invocation * @return an {@link ActionLoggerRecord} for the current action */ private ActionLogRecord buildActionRecord(ActionInvocation invocation) { ActionLogRecord record = new ActionLogRecord(); String username = this.getCurrentUsername(); String namespace = invocation.getProxy().getNamespace(); String actionName = invocation.getProxy().getActionName(); String parameters = this.getParameters(); record.setUsername(username); record.setNamespace(namespace); record.setActionName(actionName); record.setParameters(parameters); return record; }
/** * Build an {@link ActionLoggerRecord} object related to the current action * * @param invocation * @return an {@link ActionLoggerRecord} for the current action */ private ActionLogRecord buildActionRecord(ActionInvocation invocation) { ActionLogRecord record = new ActionLogRecord(); String username = this.getCurrentUsername(); String namespace = invocation.getProxy().getNamespace(); String actionName = invocation.getProxy().getActionName(); String parameters = this.getParameters(); record.setUsername(username); record.setNamespace(namespace); record.setActionName(actionName); record.setParameters(parameters); return record; }
@Override public String intercept(ActionInvocation invocation) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("intercept '#0/#1' {", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName()); } LocaleFinder localeFinder = new LocaleFinder(invocation); Locale locale = getLocaleFromParam(localeFinder.getRequestedLocale()); locale = storeLocale(invocation, locale, localeFinder.getStorage()); saveLocale(invocation, locale); if (LOG.isDebugEnabled()) { LOG.debug("before Locale=#0", invocation.getStack().findValue("locale")); } final String result = invocation.invoke(); if (LOG.isDebugEnabled()) { LOG.debug("after Locale=#0", invocation.getStack().findValue("locale")); LOG.debug("intercept } "); } return result; }