svn commit: r604343 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping: ShippingEstimateWrapper.java ShippingEvents.java

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

svn commit: r604343 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping: ShippingEstimateWrapper.java ShippingEvents.java

sichen
Author: sichen
Date: Fri Dec 14 16:14:16 2007
New Revision: 604343

URL: http://svn.apache.org/viewvc?rev=604343&view=rev
Log:
better error handling when there are problems getting shipping estimates

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java?rev=604343&r1=604342&r2=604343&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java Fri Dec 14 16:14:16 2007
@@ -29,6 +29,7 @@
 import org.ofbiz.order.shoppingcart.ShoppingCart;
 import org.ofbiz.product.store.ProductStoreWorker;
 import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
 
 public class ShippingEstimateWrapper {
 
@@ -94,8 +95,10 @@
                         shippingMethodTypeId, carrierPartyId, carrierRoleTypeId, shippingCmId, productStoreId,
                         shippableItemInfo, shippableWeight, shippableQuantity, shippableTotal);
 
-                Double shippingTotal = (Double) estimateMap.get("shippingTotal");
-                shippingEstimates.put(shipMethod, shippingTotal);
+                if (!ServiceUtil.isError(estimateMap)) {
+                    Double shippingTotal = (Double) estimateMap.get("shippingTotal");
+                    shippingEstimates.put(shipMethod, shippingTotal);
+                }
             }
         }
     }

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=604343&r1=604342&r2=604343&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java Fri Dec 14 16:14:16 2007
@@ -181,7 +181,7 @@
                 shippingTotal += externalAmt.doubleValue();
             }
         } catch (GeneralException e) {
-            return ServiceUtil.returnSuccess(standardMessage);
+            return ServiceUtil.returnError(standardMessage);
         }
 
         // update the initial amount
@@ -194,7 +194,7 @@
                 shippingTotal += genericAmt.doubleValue();
             }
         } catch (GeneralException e) {
-            return ServiceUtil.returnSuccess(standardMessage);
+            return ServiceUtil.returnError(standardMessage);
         }
 
         // return the totals
@@ -213,7 +213,7 @@
             Debug.logError(e, "Shipment Service Error", module);
             throw new GeneralException();
         }
-        if (ServiceUtil.isError(genericEstimate)) {
+        if (ServiceUtil.isError(genericEstimate) || ServiceUtil.isFailure(genericEstimate)) {
             Debug.logError(ServiceUtil.getErrorMessage(genericEstimate), module);
             throw new GeneralException();
         } else if (ServiceUtil.isFailure(genericEstimate)) {
@@ -256,12 +256,16 @@
                     Debug.logError(e, "Shipment Service Error", module);
                     throw new GeneralException(e);
                 }
-                if (!ServiceUtil.isError(serviceResp)) {
-                    externalShipAmt = (Double) serviceResp.get("shippingEstimateAmount");
-                } else {
+                if (ServiceUtil.isError(serviceResp)) {
                     String errMsg = "Error getting external shipment cost estimate: " + ServiceUtil.getErrorMessage(serviceResp);
                     Debug.logError(errMsg, module);
                     throw new GeneralException(errMsg);
+                } else if (ServiceUtil.isFailure(serviceResp)) {
+                    String errMsg = "Failure getting external shipment cost estimate: " + ServiceUtil.getErrorMessage(serviceResp);
+                    Debug.logError(errMsg, module);
+                    throw new GeneralException(errMsg);
+                } else {
+                    externalShipAmt = (Double) serviceResp.get("shippingEstimateAmount");
                 }
             }
         }