details:   https://code.openbravo.com/erp/devel/pi/rev/65f08702a333
changeset: 30320:65f08702a333
user:      Inigo Sanchez <inigo.sanchez <at> openbravo.com>
date:      Tue Sep 27 16:26:36 2016 +0200
summary:   Fixes issue 34067: No UOM Conversion Rate between UOMs found warning 
shown.

This problem is related with Improve performance callouts project. The problem
was related with how to manage null and "null" values.

Previously it was necessary to send the "null" value as part of the callout
execution result because StringBuilder in CalloutInfo class couldn't accept
null Objects values. Then, this way the parseCalloutResponse() of the FIC
was able to retrieve the null values properly. This now is not necessary in
SimpleCallouts due to its new internal implementation.

It have been resolved this problem by sending null Object as part of the
callout execution result in both cases: When a "null" String or null
Object is recieved. Now the problem it has fixed and the null and "null"
values are managing properly.

diffstat:

 src/org/openbravo/erpCommon/ad_callouts/SimpleCallout.java                    
|  18 ++++++---
 src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java 
|   4 +-
 2 files changed, 15 insertions(+), 7 deletions(-)

diffs (45 lines):

diff -r 098fa4ba0316 -r 65f08702a333 
src/org/openbravo/erpCommon/ad_callouts/SimpleCallout.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SimpleCallout.java        Mon Sep 
26 20:02:41 2016 +0000
+++ b/src/org/openbravo/erpCommon/ad_callouts/SimpleCallout.java        Tue Sep 
27 16:26:36 2016 +0200
@@ -324,15 +324,21 @@
      */
     public void addResult(String param, Object value) {
       JSONObject columnValue = new JSONObject();
-      Object strValue = value == null ? "null" : value;
 
-      // handle case when callouts are sending us "\"\"" string.
-      if ("\"\"".equals(strValue)) {
-        strValue = "";
+      Object resultValue = value;
+      if (resultValue != null) {
+        // handle case when SimpleCallouts are sending us "\"\"" string.
+        if ("\"\"".equals(resultValue)) {
+          resultValue = "";
+        }
+        // handle case when SimpleCallouts are sending us "null" string. Force 
to be null object in
+        // order to ensure backwards compatibility.
+        resultValue = JsonConstants.NULL.equals(resultValue) ? null : 
resultValue;
       }
+
       try {
-        columnValue.put(CalloutConstants.VALUE, strValue);
-        columnValue.put(CalloutConstants.CLASSIC_VALUE, strValue);
+        columnValue.put(CalloutConstants.VALUE, resultValue);
+        columnValue.put(CalloutConstants.CLASSIC_VALUE, resultValue);
         result.put(param, columnValue);
       } catch (JSONException e) {
         log.error("Error parsing JSON Object.", e);
diff -r 098fa4ba0316 -r 65f08702a333 
src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java
--- 
a/src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java 
    Mon Sep 26 20:02:41 2016 +0000
+++ 
b/src/org/openbravo/erpCommon/ad_callouts/SimpleCalloutInformationProvider.java 
    Tue Sep 27 16:26:36 2016 +0200
@@ -64,7 +64,9 @@
     JSONObject json = (JSONObject) element;
     String value = null;
     try {
-      value = json.getString(CalloutConstants.CLASSIC_VALUE);
+      if (json.has(CalloutConstants.CLASSIC_VALUE)) {
+        value = json.getString(CalloutConstants.CLASSIC_VALUE);
+      }
     } catch (JSONException e) {
       log.error("Error retrieving value from json {}", json);
     }

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to