# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1557990197 -19800
#      Thu May 16 12:33:17 2019 +0530
# Node ID e0a2a0fa64010a846434a2e060940f6b4e22b91d
# Parent  28fd9db6a14be949e317bd73fc4c52d4034d627c
Related to issue 40588 : MobileServerRequestExecutor.executeRequest is not using bind-parameters

diff -r 28fd9db6a14b -r e0a2a0fa6401 src/org/openbravo/mobile/core/servercontroller/MobileServerRequestExecutor.java
--- a/src/org/openbravo/mobile/core/servercontroller/MobileServerRequestExecutor.java	Thu May 16 12:32:41 2019 +0530
+++ b/src/org/openbravo/mobile/core/servercontroller/MobileServerRequestExecutor.java	Thu May 16 12:33:17 2019 +0530
@@ -194,8 +194,8 @@
       }
       hc.setRequestProperty("Cookie", sb.toString());
 
-      log.info("Session cookie set " + sb + " for "
-          + RequestContext.get().getRequest().getRequestURL());
+      log.info(
+          "Session cookie set " + sb + " for " + RequestContext.get().getRequest().getRequestURL());
     } else {
       log.info("No session cookie to set for " + RequestContext.get().getRequest().getRequestURL());
     }
@@ -467,13 +467,12 @@
 
       // Find a server which can execute the service
       OBQuery<MobileServerDefinition> servers = OBDal.getInstance()
-          .createQuery(MobileServerDefinition.class,
-              "(" + MobileServerDefinition.PROPERTY_ALLORGS + "=true or :org in elements("
-                  + MobileServerDefinition.PROPERTY_OBMOBCSERVERORGSLIST
-                  + "))  and client.id=:clientId and " + MobileServerDefinition.PROPERTY_ACTIVE
-                  + "=true and " + MobileServerDefinition.PROPERTY_MOBILESERVERKEY + "!='"
-                  + MobileServerController.getInstance().getMobileServerKey() + "' order by "
-                  + MobileServerDefinition.PROPERTY_PRIORITY);
+          .createQuery(MobileServerDefinition.class, " client.id=:clientId and " //
+              + MobileServerDefinition.PROPERTY_ACTIVE + "=true and "//
+              + MobileServerDefinition.PROPERTY_MOBILESERVERKEY + "!=:mobileServerKey and "//
+              + "(" + MobileServerDefinition.PROPERTY_ALLORGS + "=true or :org in elements("
+              + MobileServerDefinition.PROPERTY_OBMOBCSERVERORGSLIST + "))" //
+              + "order by " + MobileServerDefinition.PROPERTY_PRIORITY);
       servers.setFilterOnReadableClients(false);
       servers.setFilterOnReadableOrganization(false);
       servers.setNamedParameter("org",
@@ -485,6 +484,8 @@
         parameters.put("client", org.getClient().getId());
       }
       servers.setNamedParameter("clientId", parameters.getString("client"));
+      servers.setNamedParameter("mobileServerKey",
+          MobileServerController.getInstance().getMobileServerKey());
 
       for (MobileServerDefinition srv : servers.list()) {
         // only call online servers
