Author: jleroux
Date: Wed Dec 23 23:26:33 2009
New Revision: 893656

URL: http://svn.apache.org/viewvc?rev=893656&view=rev
Log:
Fix a possible NPE (in POS but I guess not only) when a Product have been 
created without a ProductType associated (from import data).
The reason of this informative log is to facilitate the search then...
Can't hurt anyway

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

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=893656&r1=893655&r2=893656&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
 Wed Dec 23 23:26:33 2009
@@ -716,10 +716,16 @@
         if (parentProduct != null)
             this.parentProductId = _parentProduct.getString("productId");
         if (UtilValidate.isEmpty(itemType)) {
-            if (_product.getString("productTypeId").equals("ASSET_USAGE")) {
-                this.itemType = "RENTAL_ORDER_ITEM";  // will create 
additional workeffort/asset usage records
+            if (UtilValidate.isNotEmpty(_product)) {
+                if (_product.getString("productTypeId").equals("ASSET_USAGE")) 
{
+                    this.itemType = "RENTAL_ORDER_ITEM";  // will create 
additional workeffort/asset usage records
+                } else {
+                    this.itemType = "PRODUCT_ORDER_ITEM";
+                }
             } else {
-                this.itemType = "PRODUCT_ORDER_ITEM";
+               Debug.logError("Error calling ShoppingCartItem (trying to 
creates new ShoppingCartItem object)." +
+                               " Check that there is a type for this product 
", module);
+               return;
             }
         } else {
             this.itemType = itemType;


Reply via email to