Fixes issue 16622 : ReadOnlyDataSourceService doesn't honour the prevent count parameter
authorPandeeswari Ramakrishnan <pandeeswari.ramakrishnan@openbravo.com>
Fri, 07 Sep 2012 17:05:42 +0530
changeset 17887 d719d893fa76
parent 17886 1a4b754c7bb7
child 17888 c60e1cf42d3b
Fixes issue 16622 : ReadOnlyDataSourceService doesn't honour the prevent count parameter
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java	Fri Sep 07 14:28:34 2012 +0200
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java	Fri Sep 07 17:05:42 2012 +0530
@@ -63,6 +63,9 @@
     if (endRowStr != null) {
       doCount = true;
     }
+    boolean preventCountOperation = !parameters.containsKey(JsonConstants.NOCOUNT_PARAMETER)
+        || "true".equals(parameters.get(JsonConstants.NOCOUNT_PARAMETER));
+
     final List<JSONObject> jsonObjects = fetchJSONObject(parameters);
 
     // now jsonfy the data
@@ -72,7 +75,7 @@
       jsonResponse.put(JsonConstants.RESPONSE_STATUS, JsonConstants.RPCREQUEST_STATUS_SUCCESS);
       jsonResponse.put(JsonConstants.RESPONSE_STARTROW, startRow);
       jsonResponse.put(JsonConstants.RESPONSE_ENDROW, jsonObjects.size() + startRow - 1);
-      if (doCount) {
+      if (doCount && !preventCountOperation) {
         int num = getCount(parameters);
         if (num == -1) {
           int endRow = Integer.parseInt(endRowStr);