Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.product.inventory.
Thanks Julian Leichert for reporting and providing the patch.
@@ -234,7 +234,7 @@ public class InventoryServices {
UtilMisc.toMap("errorString", e.getMessage()), locale));
}
- if (inventoryTransfer == null || inventoryItem == null) {
+ if (inventoryItem == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ProductInventoryItemLookupProblem",
UtilMisc.toMap("errorString", ""), locale));
@@ -350,7 +350,7 @@ public class InventoryServices {
UtilMisc.toMap("errorString", e.getMessage()), locale));
}
- if (inventoryTransfer == null || inventoryItem == null) {
+ if (inventoryItem == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ProductInventoryItemLookupProblem",
UtilMisc.toMap("errorString", ""), locale));
@@ -603,7 +603,7 @@ public class InventoryServices {
/* Check the split preference. */
boolean maySplit = false;
- if (orderItemShipGroup != null && orderItemShipGroup.get("maySplit") != null) {
+ if (orderItemShipGroup.get("maySplit") != null) {
maySplit = orderItemShipGroup.getBoolean("maySplit").booleanValue();
}
@@ -619,7 +619,6 @@ public class InventoryServices {
cancelItems = new HashMap<String, Timestamp>();
}
- if (orderItems != null) {
List<GenericValue> toBeStored = new LinkedList<GenericValue>();
for (GenericValue orderItem: orderItems) {
String orderItemSeqId = orderItem.getString("orderItemSeqId");
@@ -646,7 +645,6 @@ public class InventoryServices {
}
toBeStored.add(orderItem);
}
- }
if (toBeStored.size() > 0) {
try {
delegator.storeAll(toBeStored);
@@ -860,7 +858,9 @@ public class InventoryServices {
} catch (GenericEntityException e) {
e.printStackTrace();
}
- if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG")) {
+ if (product != null) {
+ if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString(
+ "productTypeId"), "parentTypeId", "MARKETING_PKG")) {
try {
resultOutput = dispatcher.runSync("getMktgPackagesAvailable", contextInput);
} catch (GenericServiceException e) {
@@ -894,7 +894,7 @@ public class InventoryServices {
result.put("quantityUomId", product.getString("quantityUomId"));
result.put("offsetQOHQtyAvailable", offsetQOHQtyAvailable);
result.put("offsetATPQtyAvailable", offsetATPQtyAvailable);
-
+ }
List<GenericValue> productPrices = null;
try {
productPrices = EntityQuery.use(delegator).from("ProductPrice").where("productId",productId).orderBy("-fromDate").cache(true).queryList();
@@ -902,6 +902,7 @@ public class InventoryServices {
e.printStackTrace();
}
//change this for product price
+ if(productPrices != null) {
for (GenericValue onePrice: productPrices) {
if ("DEFAULT_PRICE".equals(onePrice.getString("productPriceTypeId"))) { //defaultPrice
result.put("defaultPrice", onePrice.getBigDecimal("price"));
@@ -915,6 +916,7 @@ public class InventoryServices {
result.put("wholeSalePrice", onePrice.getBigDecimal("price"));
}
}
+ }
DynamicViewEntity salesUsageViewEntity = new DynamicViewEntity();
DynamicViewEntity productionUsageViewEntity = new DynamicViewEntity();
