svn commit: r821705 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r821705 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

lektran
Author: lektran
Date: Mon Oct  5 07:19:42 2009
New Revision: 821705

URL: http://svn.apache.org/viewvc?rev=821705&view=rev
Log:
Fix bug reported by Abdullah Shaikh - OFBIZ-2978

It appears the PaymentGatewayServices method savePgr and its associated service savePaymentGatewayResponse was originally intended to support saving either PaymentGatewayResponse OR PaymentGatewayRespMsg values but at some point this has been reduced to supporting only PaymentGatewayResponse values.
Fixed by checking the entity name before running some PaymentGatewayResponse spcific code.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=821705&r1=821704&r2=821705&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Mon Oct  5 07:19:42 2009
@@ -2806,7 +2806,14 @@
         return true;
     }
 
-    // safe payment gateway store
+    // safe payment gateway response store
+    
+    /**
+     * Saves either a PaymentGatewayResponse or PaymentGatewayRespMsg value and ensures that the value
+     * is persisted even in the event of a rollback.
+     * @param dctx
+     * @param pgr Either a PaymentGatewayResponse or PaymentGatewayRespMsg GenericValue
+     */
     private static void savePgr(DispatchContext dctx, GenericValue pgr) {
         Map<String, GenericValue> context = UtilMisc.<String, GenericValue>toMap("paymentGatewayResponse", pgr);
         LocalDispatcher dispatcher = dctx.getDispatcher();
@@ -2823,9 +2830,11 @@
     public static Map<String, Object> savePaymentGatewayResponse(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
         GenericValue pgr = (GenericValue) context.get("paymentGatewayResponse");
-        String message = pgr.getString("gatewayMessage");
-        if (message.length() > 255) {
-            pgr.set("gatewayMessage", message.substring(0, 255));
+        if ("PaymentGatewayResponse".equals(pgr.getEntityName())) {
+            String message = pgr.getString("gatewayMessage");
+            if (message.length() > 255) {
+                pgr.set("gatewayMessage", message.substring(0, 255));
+            }
         }
 
         try {