details:   https://code.openbravo.com/erp/devel/pi/rev/3711ee90ab5f
changeset: 19645:3711ee90ab5f
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Tue Feb 12 11:03:34 2013 +0530
summary:   Fixes Issue 0022838: DAL should not be used to update session last 
ping

Changed DAL update code to xsql.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
      |  10 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler_data.xsql
 |  42 ++++++++++
 2 files changed, 45 insertions(+), 7 deletions(-)

diffs (83 lines):

diff -r fda0bc8e8d80 -r 3711ee90ab5f 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
     Tue Feb 12 00:19:58 2013 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
     Tue Feb 12 11:03:34 2013 +0530
@@ -20,7 +20,6 @@
 
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.util.Date;
 import java.util.Map;
 
 import javax.enterprise.context.ApplicationScoped;
@@ -37,8 +36,8 @@
 import org.openbravo.client.kernel.StaticResourceComponent;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.UsedByLink;
-import org.openbravo.model.ad.access.Session;
 import org.openbravo.model.ad.alert.AlertRecipient;
 import org.openbravo.model.ad.alert.AlertRule;
 import org.openbravo.service.db.DalConnectionProvider;
@@ -75,13 +74,10 @@
       if (session != null) {
         final String dbSessionId = (String) 
session.getAttribute("#AD_Session_ID".toUpperCase());
         if (dbSessionId != null) {
-          final Session dbSession = OBDal.getInstance().get(Session.class, 
dbSessionId);
-          dbSession.setLastPing(new Date());
-          // flush to force commit in admin mode
-          OBDal.getInstance().flush();
+          ConnectionProvider conn = new DalConnectionProvider(false);
+          AlertActionHandlerData.setLastPing(conn, dbSessionId);
         }
       }
-
       final VariablesSecureApp vars = new VariablesSecureApp(request);
       // Do not execute the alerts if the system if being rebuilt
       Long total = 0L;
diff -r fda0bc8e8d80 -r 3711ee90ab5f 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler_data.xsql
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler_data.xsql
        Tue Feb 12 11:03:34 2013 +0530
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+
+<SqlClass name="AlertActionHandlerData" 
package="org.openbravo.client.application">
+   <SqlClassComment></SqlClassComment>
+
+   <SqlMethod name="activeSessions" type="preparedStatement" return="multiple">
+    <Sql><![CDATA[
+        SELECT AD_SESSION_ID, SERVER_URL
+          FROM AD_SESSION
+         WHERE SESSION_ACTIVE = 'Y'
+    ]]></Sql>
+      <Field name="supportContact" value=""/>
+    </SqlMethod>
+
+   <SqlMethod name="setLastPing" type="preparedStatement" return="rowCount">
+    <Sql><![CDATA[
+        UPDATE AD_Session
+        SET last_session_ping = NOW()
+        WHERE AD_Session.AD_Session_ID = ?
+    ]]></Sql>
+    <Parameter name="adSessionId"/>
+  </SqlMethod>
+
+</SqlClass>

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to