Salome HOME
Fix:
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / SimanRedirectOnEndOfSessionInterceptor.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   10.01.2013
6  * @author         $Author$
7  * @version        $Revision$
8  * @copyright      OPEN CASCADE 2012
9  *****************************************************************************/
10
11 package org.splat.simer;
12
13 import org.apache.struts2.ServletActionContext;
14
15 import com.opensymphony.xwork2.ActionInvocation;
16
17 /**
18  * Redirect to a globalResult if the session has been invalidated.
19  * 
20  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
21  * 
22  */
23 public class SimanRedirectOnEndOfSessionInterceptor extends
24                 AbstractRedirectAfterLoginInterceptor {
25
26         /**
27          * Serial version UID.
28          */
29         private static final long serialVersionUID = -2669940721820416684L;
30
31         /**
32          * serialVersionUID.
33          */
34
35         /**
36          * globalResultActionName.
37          */
38         private String _globalResultActionName;
39
40         /**
41          * Get the globalResultActionName.
42          * 
43          * @return the globalResultActionName
44          */
45         public String getGlobalResultActionName() {
46                 return _globalResultActionName;
47         }
48
49         /**
50          * Set the globalResultActionName.
51          * 
52          * @param globalResultActionName
53          *            the globalResultActionName to set
54          */
55         public void setGlobalResultActionName(final String globalResultActionName) {
56                 _globalResultActionName = globalResultActionName;
57         }
58
59         /**
60          * {@inheritDoc}
61          * 
62          * @see org.splat.simer.AbstractRedirectAfterLoginInterceptor#redirectCondition(com.opensymphony.xwork2.ActionInvocation)
63          */
64         @Override
65         protected boolean redirectCondition(final ActionInvocation invocation)
66                         throws Exception { // NOPMD: RKV: because of struts invoke() method
67                 String action = invocation.getInvocationContext().getName();
68                 boolean doRedirect = (!"index".equals(action));
69                 if (LOG.isDebugEnabled()) {
70                         LOG.debug("Entering redirectCondition Test: " + action);
71                         LOG
72                                         .debug("Do redirection: "
73                                                         + (doRedirect && (ServletActionContext.getRequest()
74                                                                         .getSession().getAttribute(
75                                                                                         Action.USER_RIGHTS) == null)));
76                 }
77                 return (doRedirect && (ServletActionContext.getRequest().getSession()
78                                 .getAttribute(Action.USER_RIGHTS) == null));
79         }
80
81 }