details:   https://code.openbravo.com/erp/devel/pi/rev/c101c7b3b408
changeset: 13782:c101c7b3b408
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Sep 17 16:48:11 2011 +0200
summary:   Set newUI when generating static resource component

details:   https://code.openbravo.com/erp/devel/pi/rev/103957c0f0ad
changeset: 13783:103957c0f0ad
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Sep 17 16:48:32 2011 +0200
summary:   Prevent setting OBContext in session when it already was set

details:   https://code.openbravo.com/erp/devel/pi/rev/b76178797a94
changeset: 13784:b76178797a94
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Sep 17 16:48:59 2011 +0200
summary:   Prevent re-initializing session and OBContext many times for each 
request

details:   https://code.openbravo.com/erp/devel/pi/rev/d239a25a825d
changeset: 13785:d239a25a825d
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Sep 17 16:55:54 2011 +0200
summary:   Added comments in the code, to prevent later mistake with logging 
in/re-inits for each request

diffstat:

 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
 |  5 +++--
 src/org/openbravo/base/secureApp/HttpSecureAppServlet.java                     
                  |  8 +++++++-
 src/org/openbravo/base/secureApp/LoginUtils.java                               
                  |  3 +++
 src/org/openbravo/dal/core/OBContext.java                                      
                  |  5 +++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diffs (85 lines):

diff -r b1fde682e407 -r d239a25a825d 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
  Sat Sep 17 11:07:37 2011 +0200
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
  Sat Sep 17 16:55:54 2011 +0200
@@ -100,11 +100,12 @@
               KernelConstants.MODE_PARAMETER_300);
 
       if (!classicMode) {
+        // set in the session that we are looking at the new ui
         // note injecting the HttpSession through Weld does not work
         // as it will instantiate one of the subclasses of HttpSession
         // defined in the RequestContext
-        ((HttpSession) 
getParameters().get(KernelConstants.HTTP_SESSION)).setAttribute(
-            "#Hide_BackButton".toUpperCase(), "true");
+        final HttpSession session = (HttpSession) 
getParameters().get(KernelConstants.HTTP_SESSION);
+        session.setAttribute("#Hide_BackButton".toUpperCase(), "true");
         OBContext.getOBContext().setNewUI(true);
       }
 
diff -r b1fde682e407 -r d239a25a825d 
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Sat Sep 
17 11:07:37 2011 +0200
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Sat Sep 
17 16:55:54 2011 +0200
@@ -121,6 +121,8 @@
       setSessionValue("reqHistory.command" + sufix, strCommand);
     }
 
+    // Note, see LoginUtils.fillSessionArguments which sets the loggingIn
+    // session var to N explicitly
     public boolean isLoggingIn() {
       return loggingIn == null || loggingIn.equals("") || 
loggingIn.equals("Y");
     }
@@ -235,6 +237,8 @@
 
       boolean loggedOK = false;
 
+      // NOTE !isLoggingIn assumes that the value of LoggingIn is N, this
+      // is done by the fillSessionArguments below
       if (!variables.isLoggingIn()) {
         // log in process is completed, check whether the session in db is 
still active
         loggedOK = SeguridadData.loggedOK(this, variables.getDBSession());
@@ -302,6 +306,9 @@
           }
 
           final VariablesSecureApp vars = new VariablesSecureApp(request, 
false);
+
+          // note fill session arguments will set the LOGGINGIN session var
+          // to N
           if (LoginUtils.fillSessionArguments(this, vars, strUserAuth, 
strLanguage, strIsRTL,
               strRole, strClient, strOrg, strWarehouse)) {
             readProperties(vars, 
globalParameters.getOpenbravoPropertiesPath());
@@ -313,7 +320,6 @@
             logout(request, response);
             return;
           }
-          variables.removeSessionValue("#LOGGINGIN");
         } else {
           variables.updateHistory(request);
         }
diff -r b1fde682e407 -r d239a25a825d 
src/org/openbravo/base/secureApp/LoginUtils.java
--- a/src/org/openbravo/base/secureApp/LoginUtils.java  Sat Sep 17 11:07:37 
2011 +0200
+++ b/src/org/openbravo/base/secureApp/LoginUtils.java  Sat Sep 17 16:55:54 
2011 +0200
@@ -309,6 +309,9 @@
     }
 
     // Login process if finished, set the flag as not logging in
+    // this flag may not be removed from the session, it must be set
+    // to N to prevent re-initializing the session continuously
+    // See the HttpSecureAppServlet
     vars.setSessionValue("#loggingIn", "N");
     return true;
   }
diff -r b1fde682e407 -r d239a25a825d src/org/openbravo/dal/core/OBContext.java
--- a/src/org/openbravo/dal/core/OBContext.java Sat Sep 17 11:07:37 2011 +0200
+++ b/src/org/openbravo/dal/core/OBContext.java Sat Sep 17 16:55:54 2011 +0200
@@ -339,6 +339,11 @@
       return;
     }
 
+    // already set, go away
+    if (session.getAttribute(CONTEXT_PARAM) == context) {
+      return;
+    }
+
     // Determine whether using new ui by #Hide_BackButton session attribute 
set in Menu class
     if (context != null) {
       String newUIValue = (String) 
session.getAttribute("#Hide_BackButton".toUpperCase());

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to