[Alerting] Platform Code Review
authorAnder Iraceburu <ander.iraceburu@openbravo.com>
Tue, 10 Jul 2018 10:09:20 +0200
changeset 34001 9795ccaab86a
parent 34000 7df31b728967
child 34002 6b5d30a882f9
[Alerting] Platform Code Review
src-db/database/model/tables/AD_SESSION.xml
src-db/database/sourcedata/AD_COLUMN.xml
src/org/openbravo/dal/core/DalThreadHandler.java
src/org/openbravo/erpCommon/security/SessionLogin.java
--- a/src-db/database/model/tables/AD_SESSION.xml	Wed Jun 13 13:17:59 2018 +0200
+++ b/src-db/database/model/tables/AD_SESSION.xml	Tue Jul 10 10:09:20 2018 +0200
@@ -69,19 +69,12 @@
         <default/>
         <onCreateDefault/>
       </column>
-      <column name="AD_USER_ID" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
-        <default/>
-        <onCreateDefault/>
-      </column>
       <foreign-key foreignTable="AD_CLIENT" name="AD_SESSION_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
       <foreign-key foreignTable="AD_ORG" name="AD_SESSION_AD_ORG">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
-      <foreign-key foreignTable="AD_USER" name="AD_SESSION_AD_USER">
-        <reference local="AD_USER_ID" foreign="AD_USER_ID"/>
-      </foreign-key>
       <index name="AD_SESSION_ACTIVE_IDX" unique="false">
         <index-column name="SESSION_ACTIVE"/>
       </index>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Wed Jun 13 13:17:59 2018 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Jul 10 10:09:20 2018 +0200
@@ -373199,44 +373199,6 @@
 <!--DF97786558E348AD807C77F1917B1C30-->  <ALLOWED_CROSS_ORG_LINK><![CDATA[N]]></ALLOWED_CROSS_ORG_LINK>
 <!--DF97786558E348AD807C77F1917B1C30--></AD_COLUMN>
 
-<!--DFCD2EC5687F413F8D0F4E10EF00435D--><AD_COLUMN>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_COLUMN_ID><![CDATA[DFCD2EC5687F413F8D0F4E10EF00435D]]></AD_COLUMN_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <NAME><![CDATA[User]]></NAME>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <DESCRIPTION><![CDATA[The User identifies a unique user in the system.]]></DESCRIPTION>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <HELP><![CDATA[The User identifies a unique user in the system.]]></HELP>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <COLUMNNAME><![CDATA[AD_User_ID]]></COLUMNNAME>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_TABLE_ID><![CDATA[566]]></AD_TABLE_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISKEY><![CDATA[N]]></ISKEY>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISPARENT><![CDATA[N]]></ISPARENT>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <SEQNO><![CDATA[91]]></SEQNO>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_ELEMENT_ID><![CDATA[0C050A4090E5411EB1514BDD0E19DAAA]]></AD_ELEMENT_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <POSITION><![CDATA[21]]></POSITION>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D-->  <ALLOWED_CROSS_ORG_LINK><![CDATA[N]]></ALLOWED_CROSS_ORG_LINK>
-<!--DFCD2EC5687F413F8D0F4E10EF00435D--></AD_COLUMN>
-
 <!--DFD312AEF4DC4E5A8145A487ECD0C280--><AD_COLUMN>
 <!--DFD312AEF4DC4E5A8145A487ECD0C280-->  <AD_COLUMN_ID><![CDATA[DFD312AEF4DC4E5A8145A487ECD0C280]]></AD_COLUMN_ID>
 <!--DFD312AEF4DC4E5A8145A487ECD0C280-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/dal/core/DalThreadHandler.java	Wed Jun 13 13:17:59 2018 +0200
+++ b/src/org/openbravo/dal/core/DalThreadHandler.java	Tue Jul 10 10:09:20 2018 +0200
@@ -39,29 +39,6 @@
   /** @see ThreadHandler#doFinal */
   @Override
   public void doFinal(boolean errorOccured) {
-    closeSessions(errorOccured);
-  }
-
-  private static void closeDefaultPoolSession(boolean errorOccured) {
-    SessionHandler sessionHandler = SessionHandler.isSessionHandlerPresent() ? SessionHandler
-        .getInstance() : null;
-    if (sessionHandler != null && sessionHandler.doSessionInViewPatter()) {
-      // application software can force a rollback
-      if (sessionHandler.getDoRollback() || errorOccured) {
-        sessionHandler.rollback();
-      } else if (sessionHandler.getSession().getTransaction().isActive()) {
-        sessionHandler.commitAndClose();
-      }
-    }
-  }
-
-  private static void closeOtherSessions() {
-    if (SessionHandler.existsOpenedSessions()) {
-      SessionHandler.getInstance().cleanUpSessions();
-    }
-  }
-
-  public static void closeSessions(boolean errorOccured) {
     try {
       closeDefaultPoolSession(errorOccured);
     } finally {
@@ -79,4 +56,23 @@
       }
     }
   }
+
+  private void closeDefaultPoolSession(boolean errorOccured) {
+    SessionHandler sessionHandler = SessionHandler.isSessionHandlerPresent() ? SessionHandler
+        .getInstance() : null;
+    if (sessionHandler != null && sessionHandler.doSessionInViewPatter()) {
+      // application software can force a rollback
+      if (sessionHandler.getDoRollback() || errorOccured) {
+        sessionHandler.rollback();
+      } else if (sessionHandler.getSession().getTransaction().isActive()) {
+        sessionHandler.commitAndClose();
+      }
+    }
+  }
+
+  private void closeOtherSessions() {
+    if (SessionHandler.existsOpenedSessions()) {
+      SessionHandler.getInstance().cleanUpSessions();
+    }
+  }
 }
\ No newline at end of file
--- a/src/org/openbravo/erpCommon/security/SessionLogin.java	Wed Jun 13 13:17:59 2018 +0200
+++ b/src/org/openbravo/erpCommon/security/SessionLogin.java	Tue Jul 10 10:09:20 2018 +0200
@@ -137,7 +137,6 @@
       User user1 = OBDal.getInstance().getProxy(User.class, getUser());
       session.setCreatedBy(user1);
       session.setUpdatedBy(user1);
-      session.setUser(user1);
       session.setWebSession(getWebSession());
       session.setRemoteAddress(getRemoteAddr());
       session.setRemoteHost(getRemoteHost());