fixed bug 40897: broken system if tying to create a ws row with unlimited WS
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 17 May 2019 11:14:19 +0200
changeset 36309 1596542c21af
parent 36306 59e2bd0cc7fa
child 36310 bbe0c764ef47
child 36312 9d8fe95b6904
child 36313 3a3d3ff9f157
child 36314 0271c70e1c1d
child 36315 8d8aa0e2d423
child 36317 bdf8cb07b73b
child 36318 8a483b102112
child 36320 bffbad15c449
child 36323 ec509bcc31cc
child 36326 8d004aaabef9
child 36333 4401e5eb48cf
child 36342 03a370b59dee
child 36343 1df829310ef3
fixed bug 40897: broken system if tying to create a ws row with unlimited WS

System became unreacheable after trtying to create/update a record through WS
as first action after Tomcat restart having unlimited WS access license.

This occurred because TreeTablesEventHandler initialization assumed to be in
admin mode. As unlimited access license does not do any DB modification on login,
which is what occurs in standard login and with limited acess licenses, first
flush with dirty entities causes TreeTablesEventHandler init to fail in a
unrecoverable manner.

Now TreeTablesEventHandler is initialized in admin mode to prevent this case.
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/TreeTablesEventHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/TreeTablesEventHandler.java	Fri May 17 09:49:39 2019 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/TreeTablesEventHandler.java	Fri May 17 11:14:19 2019 +0200
@@ -164,13 +164,18 @@
   }
 
   private static Entity[] getTreeTables() {
-    OBCriteria<Table> treeTablesCriteria = OBDal.getInstance().createCriteria(Table.class);
-    treeTablesCriteria.add(Restrictions.eq(Table.PROPERTY_ISTREE, true));
-    List<Table> treeTableList = treeTablesCriteria.list();
-    ArrayList<Entity> entityArray = new ArrayList<>();
-    for (Table treeTable : treeTableList) {
-      entityArray.add(ModelProvider.getInstance().getEntityByTableId(treeTable.getId()));
+    OBContext.setAdminMode(true);
+    try {
+      OBCriteria<Table> treeTablesCriteria = OBDal.getInstance().createCriteria(Table.class);
+      treeTablesCriteria.add(Restrictions.eq(Table.PROPERTY_ISTREE, true));
+      List<Table> treeTableList = treeTablesCriteria.list();
+      ArrayList<Entity> entityArray = new ArrayList<>();
+      for (Table treeTable : treeTableList) {
+        entityArray.add(ModelProvider.getInstance().getEntityByTableId(treeTable.getId()));
+      }
+      return entityArray.toArray(new Entity[entityArray.size()]);
+    } finally {
+      OBContext.restorePreviousMode();
     }
-    return entityArray.toArray(new Entity[entityArray.size()]);
   }
 }