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; } }
/** * {@inheritDoc} */ @Override public String getActionId() { return this.invocation.getProxy().getMethod(); }
/** * {@inheritDoc} */ @Override public String getActionId() { return invocation.getProxy().getMethod(); }
public String intercept(ActionInvocation actionInvocation) throws Exception { ActionConfig config = actionInvocation.getProxy().getConfig(); log.info(config.getParams().get("uri"));
@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() ); }
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 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); }
protected void after(ActionInvocation actionInvocation, String string) throws Exception { UtilTimerStack.pop(makeStackKey(actionInvocation.getProxy())); }
ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ActionProxy proxy = invocation.getProxy(); ActionConfig config = proxy.getConfig(); Map<String, ResultConfig> results = config.getResults(); ResultConfig resultConfig = results.get(Action.SUCCESS); String lastFinalLocation = null; Map<String, String> params = resultConfig.getParams(); if (resultConfig.getClassName().equals("org.apache.struts2.dispatcher.ServletDispatcherResult")) { lastFinalLocation = params.get("location"); } System.out.println("location: " + lastFinalLocation);
/** * @param ac The action context * @return the parameters from the action mapping in the context. If none found, returns * an empty map. */ protected Map<String, String> retrieveParameters(ActionContext ac) { ActionConfig config = ac.getActionInvocation().getProxy().getConfig(); if (config != null) { return config.getParams(); } else { return Collections.emptyMap(); } }
@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); }
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 before(ActionInvocation actionInvocation) throws Exception { UtilTimerStack.push(makeStackKey(actionInvocation.getProxy())); ServletActionContext.getRequest(); // needed to make sure the request is present (I think) }
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 boolean applyInterceptor(ActionInvocation invocation) { String method = invocation.getProxy().getMethod(); // ValidationInterceptor boolean applyMethod = MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, method); if (log.isDebugEnabled()) { if (!applyMethod) { log.debug("Skipping Interceptor... Method [" + method + "] found in exclude list."); } } return applyMethod; }
/** * 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; }
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 String intercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action instanceof ScopedModelDriven) { ScopedModelDriven modelDriven = (ScopedModelDriven) action; Object model = modelDriven.getModel(); if (model != null && model instanceof ActionForm) { Struts1Factory factory = new Struts1Factory(configuration); ActionMapping mapping = factory.createActionMapping(invocation.getProxy().getConfig()); HttpServletRequest req = ServletActionContext.getRequest(); ((ActionForm)model).reset(mapping, req); } } return invocation.invoke(); } }