svn commit: r653787 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

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

svn commit: r653787 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

bibryam
Author: bibryam
Date: Tue May  6 07:15:24 2008
New Revision: 653787

URL: http://svn.apache.org/viewvc?rev=653787&view=rev
Log:
Fix NPE.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=653787&r1=653786&r2=653787&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Tue May  6 07:15:24 2008
@@ -950,18 +950,20 @@
             // set the agreement id in the cart
             cart.setAgreementId(agreementId);
             try {
-                 // set the currency based on the pricing agreement
-                 List agreementItems = agreement.getRelated("AgreementItem", UtilMisc.toMap("agreementItemTypeId", "AGREEMENT_PRICING_PR"), null);
-                 if (agreementItems.size() > 0) {
-                       GenericValue agreementItem = (GenericValue) agreementItems.get(0);
-                       String currencyUomId = (String) agreementItem.get("currencyUomId");
-                       try {
+                // set the currency based on the pricing agreement
+                List agreementItems = agreement.getRelated("AgreementItem", UtilMisc.toMap("agreementItemTypeId", "AGREEMENT_PRICING_PR"), null);
+                if (agreementItems.size() > 0) {
+                    GenericValue agreementItem = (GenericValue) agreementItems.get(0);
+                    String currencyUomId = (String) agreementItem.get("currencyUomId");
+                    if (UtilValidate.isNotEmpty(currencyUomId)) {
+                        try {
                             cart.setCurrency(dispatcher,currencyUomId);
-                       } catch (CartItemModifyException ex) {
-                           result = ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderSetCurrencyError",this.cart.getLocale()) + ex.getMessage());
+                        } catch (CartItemModifyException ex) {
+                            result = ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderSetCurrencyError",this.cart.getLocale()) + ex.getMessage());
                             return result;
-                       }
-                 }
+                        }
+                    }
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.toString(), module);
                 result = ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderCouldNotGetAgreementItemsThrough",UtilMisc.toMap("agreementId",agreementId),this.cart.getLocale()) + UtilProperties.getMessage(resource_error,"OrderError",this.cart.getLocale()) + e.getMessage());