1 /*****************************************************************************
5 * Creation date 10.01.2013
8 * @copyright OPEN CASCADE 2012
9 *****************************************************************************/
11 package org.splat.simer;
13 import org.apache.struts2.ServletActionContext;
15 import com.opensymphony.xwork2.ActionInvocation;
18 * Redirect to a globalResult if the session has been invalidated.
20 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
23 public class SimanRedirectOnEndOfSessionInterceptor extends
24 AbstractRedirectAfterLoginInterceptor {
29 private static final long serialVersionUID = -2669940721820416684L;
36 * globalResultActionName.
38 private String _globalResultActionName;
41 * Get the globalResultActionName.
43 * @return the globalResultActionName
45 public String getGlobalResultActionName() {
46 return _globalResultActionName;
50 * Set the globalResultActionName.
52 * @param globalResultActionName
53 * the globalResultActionName to set
55 public void setGlobalResultActionName(final String globalResultActionName) {
56 _globalResultActionName = globalResultActionName;
62 * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
64 public String intercept(final ActionInvocation invocation) throws Exception { //NOPMD: RKV: because of struts invoke() method
65 String result = super.intercept(invocation);
66 if (result.equals(getGlobalResult())) { //Redirect happened
67 ((Action)invocation.getAction()).setMessage("");
75 * @see org.splat.simer.AbstractRedirectAfterLoginInterceptor#redirectCondition(com.opensymphony.xwork2.ActionInvocation)
78 protected boolean redirectCondition(final ActionInvocation invocation)
79 throws Exception { // NOPMD: RKV: because of struts invoke() method
80 String action = invocation.getInvocationContext().getName();
81 boolean doRedirect = (!"index".equals(action));
82 if (LOG.isDebugEnabled()) {
83 LOG.debug("Entering redirectCondition Test: " + action);
85 .debug("Do redirection: "
86 + (doRedirect && (ServletActionContext.getRequest()
87 .getSession().getAttribute(
88 Action.USER_RIGHTS) == null)));
90 return (doRedirect && (ServletActionContext.getRequest().getSession()
91 .getAttribute(Action.USER_RIGHTS) == null));