details:   /erp/devel/pi/rev/eecd5dedc0dc
changeset: 6455:eecd5dedc0dc
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Thu Feb 18 12:36:08 2010 +0100
summary:   fixed bug 11113: Small fixes and improved comments

diffstat:

 src/org/openbravo/erpCommon/obps/ActivationKey.java   |  11 ++++++-----
 src/org/openbravo/erpCommon/utility/VerticalMenu.java |  11 ++++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)

diffs (68 lines):

diff -r 0e103bbcd82f -r eecd5dedc0dc 
src/org/openbravo/erpCommon/obps/ActivationKey.java
--- a/src/org/openbravo/erpCommon/obps/ActivationKey.java       Thu Feb 18 
11:12:09 2010 +0100
+++ b/src/org/openbravo/erpCommon/obps/ActivationKey.java       Thu Feb 18 
12:36:08 2010 +0100
@@ -343,8 +343,7 @@
 
       // maxUsers==0 is unlimited concurrent users
       if (maxUsers != 0) {
-        boolean adminMode = OBContext.getOBContext().isInAdministratorMode();
-        OBContext.getOBContext().setInAdministratorMode(true);
+        boolean adminMode = 
OBContext.getOBContext().setInAdministratorMode(true);
         int activeSessions = 0;
         try {
           activeSessions = getActiveSessions(currentSession);
@@ -380,8 +379,10 @@
   }
 
   /**
-   * Looks for all active sessions that haven't send a ping during last 
PING_TIMEOUT_SECS seconds
-   * and deactivates them.
+   * Looks for all active sessions that have not had activity during last
+   * {...@link ActivationKey#PING_TIMEOUT_SECS} seconds and deactivates them. 
Activity is tracked by
+   * the requests the browser sends to look for alerts (see
+   * {...@link org.openbravo.erpCommon.utility.VerticalMenu}).
    */
   private boolean deactivateTimeOutSessions() {
     // Last valid ping time is current time substract timeout seconds
@@ -418,7 +419,7 @@
     if (currentSession != null && !currentSession.equals("")) {
       obCriteria.add(Expression.ne(Session.PROPERTY_ID, currentSession));
     }
-    return obCriteria.list().size();
+    return obCriteria.count();
   }
 
   public String toString(ConnectionProvider conn, String lang) {
diff -r 0e103bbcd82f -r eecd5dedc0dc 
src/org/openbravo/erpCommon/utility/VerticalMenu.java
--- a/src/org/openbravo/erpCommon/utility/VerticalMenu.java     Thu Feb 18 
11:12:09 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/VerticalMenu.java     Thu Feb 18 
12:36:08 2010 +0100
@@ -61,7 +61,7 @@
     } else if (vars.commandIn("ALL")) {
       printPageDataSheet(response, vars, "0", true);
     } else if (vars.commandIn("ALERT")) {
-      pingSession(vars);
+      updateSessionLastActivity(vars);
       printPageAlert(response, vars);
     } else if (vars.commandIn("LOADING")) {
       printPageLoadingMenu(response, vars);
@@ -70,15 +70,16 @@
   }
 
   /**
-   * Updates the session's last ping value to keep trace of the last time the 
browser sent a ping
-   * for the current session.
+   * Updates last time the browser checked for alerts (ping) this info is 
later used (in
+   * {...@link org.openbravo.erpCommon.obps.ActivationKey}) to find no longer 
used sessions because the
+   * browser was closed without the user explicitly closing the session.
    */
-  private void pingSession(VariablesSecureApp vars) {
+  private void updateSessionLastActivity(VariablesSecureApp vars) {
     String sessionId = vars.getDBSession();
     Date now = new Date();
     log4j.debug("ping session:" + sessionId + " - time" + now);
     if (sessionId != null && !sessionId.isEmpty()) {
-      boolean adminMode = OBContext.getOBContext().isInAdministratorMode();
+      boolean adminMode = 
OBContext.getOBContext().setInAdministratorMode(true);
       try {
         Session session = OBDal.getInstance().get(Session.class, sessionId);
         session.setLastPing(now);

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to