svn commit: r476251 - in /incubator/ofbiz/trunk/applications/order: servicedef/secas.xml src/org/ofbiz/order/order/OrderServices.java

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

svn commit: r476251 - in /incubator/ofbiz/trunk/applications/order: servicedef/secas.xml src/org/ofbiz/order/order/OrderServices.java

jacopoc
Author: jacopoc
Date: Fri Nov 17 10:57:16 2006
New Revision: 476251

URL: http://svn.apache.org/viewvc?view=rev&rev=476251
Log:
The "processOrderPaymets" service now internally gets a ShoppingCart instance by calling the "loadCartFromOrder" service instead of the "loadCartForUpdate" method.
The latter is a dangerous method, since it removes all the order reservations (I've added a comment to explain how it should be used).
With this change, I've reactivated the seca that calls the "processOrderPaymets" service when items are cancelled (that has been disabled to avoid the loss of reservations).
This should completely close issue OFBIZ-380.

Modified:
    incubator/ofbiz/trunk/applications/order/servicedef/secas.xml
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: incubator/ofbiz/trunk/applications/order/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/servicedef/secas.xml?view=diff&rev=476251&r1=476250&r2=476251
==============================================================================
--- incubator/ofbiz/trunk/applications/order/servicedef/secas.xml (original)
+++ incubator/ofbiz/trunk/applications/order/servicedef/secas.xml Fri Nov 17 10:57:16 2006
@@ -103,13 +103,9 @@
         <action service="recreateOrderAdjustments" mode="sync"/>
         <action service="resetGrandTotal" mode="sync"/>
     </eca>
-    <!--
-        as a temp fix, it is now disabled since, due to the way processOrderPayments works,
-        the end result is that all the order's inventory reservations were lost
     <eca service="cancelOrderItem" event="return">
         <action service="processOrderPayments" mode="sync"/>
     </eca>
-    -->
 
     <!-- order confirmation/notification email ECAs -->
     <eca service="sendOrderConfirmation" event="commit">

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=476251&r1=476250&r2=476251
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Fri Nov 17 10:57:16 2006
@@ -3056,7 +3056,12 @@
         result.put("orderId", orderId);
         return result;
     }
-
+    
+    /*
+     *  Warning: this method will remove all the existing reservations of the order
+     *           before returning the ShoppingCart object; for this reason, the cart
+     *           must be stored back using the method saveUpdatedCartToOrder(...).
+     */
     private static ShoppingCart loadCartForUpdate(LocalDispatcher dispatcher, GenericDelegator delegator, GenericValue userLogin, String orderId) throws GeneralException {
         // find ship group associations
         List shipGroupAssocs = null;
@@ -3325,14 +3330,20 @@
         String productStoreId = orh.getProductStoreId();
 
         if (cart == null) {
+            // load the order into a shopping cart
+            Map loadCartResp = null;
             try {
-                cart = loadCartForUpdate(dispatcher, delegator, userLogin, orderId);
-            } catch (GeneralException e) {
+                loadCartResp = dispatcher.runSync("loadCartFromOrder", UtilMisc.toMap("orderId", orderId, "userLogin", userLogin));
+            } catch (GenericServiceException e) {
                 return ServiceUtil.returnError(e.getMessage());
             }
+            cart = (ShoppingCart) loadCartResp.get("shoppingCart");
+
             if (cart == null) {
                 return ServiceUtil.returnError("ERROR: Null shopping cart object returned!");
             }
+            
+            cart.setOrderId(orderId);
         }
         CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
         // process the payments