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 getActionName() { return this.parentProxy.getActionName(); }
/** * Returns the context that will be used by the * {@link ActionValidatorManager} to associate the action invocation with * the appropriate {@link ValidatorConfig ValidatorConfigs}. * <p> * The context returned is used in the pattern * <i>ActionClass-context-validation.xml</i> * <p> * The default context is the action name from the URL, but the method can * be overridden to implement custom contexts. * <p> * This can be useful in cases in which a single action and a single model * require vastly different validation based on some condition. * * @return the Context */ protected String getValidationContext(ActionProxy proxy) { // This method created for WW-3753 return proxy.getActionName(); }
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 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; } }
/** * Is called to invoke the action invocation and time the execution time. * * @param invocation the action invocation. * @return the result of the action execution. * @throws Exception can be thrown from the action. */ protected String invokeUnderTiming(ActionInvocation invocation) throws Exception { long startTime = System.currentTimeMillis(); String result = invocation.invoke(); long executionTime = System.currentTimeMillis() - startTime; StringBuilder message = new StringBuilder(100); message.append("Executed action ["); String namespace = invocation.getProxy().getNamespace(); if ((namespace != null) && (namespace.trim().length() > 0)) { message.append(namespace).append("/"); } message.append(invocation.getProxy().getActionName()); message.append("!"); message.append(invocation.getProxy().getMethod()); message.append("] took ").append(executionTime).append(" ms."); doLog(getLoggerToUse(), message.toString()); return result; }
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); }
@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 void logger(long startTime, long middleTime) { if (logger && LOG.isInfoEnabled()) { long endTime = System.currentTimeMillis(); long executionTime = middleTime - startTime; long processResult = endTime - middleTime; long total = endTime - startTime; String message = "Executed action [/"; String namespace = getProxy().getNamespace(); if ((namespace != null) && (namespace.trim().length() > 1)) { message += namespace + "/"; } message += getProxy().getActionName() + "!" + getProxy().getMethod(); String extension = handlerSelector.findExtension( ServletActionContext.getRequest().getRequestURI()); if (extension != null) { message += "!" + extension; } if (httpHeaders != null) { message += "!" + httpHeaders.getStatus(); } message += "] took " + total + " ms (execution: " + executionTime + " ms, result: " + processResult + " ms)"; LOG.info(message); } }
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 + "())"; }
public void init(ActionProxy proxy) { this.proxy = proxy; Map<String, Object> contextMap = createContextMap(); // Setting this so that other classes, like object factories, can use the ActionProxy and other // contextual information to operate ActionContext actionContext = ActionContext.getContext(); if (actionContext != null) { actionContext.setActionInvocation(this); } createAction(contextMap); if (pushAction) { stack.push(action); contextMap.put("action", action); } invocationContext = new ActionContext(contextMap); invocationContext.setName(proxy.getActionName()); createInterceptors(proxy); }
/** * 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; }