svn commit: r810921 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java framework/service/src/org/ofbiz/service/ServiceUtil.java

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

svn commit: r810921 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java framework/service/src/org/ofbiz/service/ServiceUtil.java

jleroux@apache.org
Author: jleroux
Date: Thu Sep  3 12:54:16 2009
New Revision: 810921

URL: http://svn.apache.org/viewvc?rev=810921&view=rev
Log:
A patch from Bob Morley "loadCartFromOrder assumes service call is successful" (https://issues.apache.org/jira/browse/OFBIZ-2782) - OFBIZ-2782

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=810921&r1=810920&r2=810921&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Thu Sep  3 12:54:16 2009
@@ -1310,12 +1310,17 @@
 
         ShoppingCart cart = null;
         try {
-            Map outMap = dispatcher.runSync("loadCartFromOrder",
+            Map<String, Object> outMap = dispatcher.runSync("loadCartFromOrder",
                                                 UtilMisc.<String, Object>toMap("orderId", orderId,
                                                         "skipProductChecks", Boolean.TRUE, // the products have already been checked in the order, no need to check their validity again
                                                         "userLogin", userLogin));
+            if (!ServiceUtil.isSuccess(outMap)) {
+                request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(outMap));
+                return "error";
+             }
 
             cart = (ShoppingCart) outMap.get("shoppingCart");
+            
         } catch (GenericServiceException exc) {
             request.setAttribute("_ERROR_MESSAGE_", exc.getMessage());
             return "error";

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java?rev=810921&r1=810920&r2=810921&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java Thu Sep  3 12:54:16 2009
@@ -73,6 +73,14 @@
         return ModelService.RESPOND_FAIL.equals(results.get(ModelService.RESPONSE_MESSAGE));
     }
 
+    /** A little short-cut method to check to see if a service was successful (neither error or failed) */
+    public static boolean isSuccess(Map<String, ? extends Object> results) {
+        if (ServiceUtil.isError(results) || ServiceUtil.isFailure(results)) {
+         return false;
+        }
+        return true;
+    }
+    
     /** A small routine used all over to improve code efficiency, make a result map with the message and the error response code */
     public static Map<String, Object> returnError(String errorMessage) {
         return returnProblem(ModelService.RESPOND_ERROR, errorMessage, null, null, null);