Author: mbrohl
Date: Fri Dec 8 21:34:14 2017
New Revision: 1817576
URL: http://svn.apache.org/viewvc?rev=1817576&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.order.shoppinglist.
(OFBIZ-9731)
Thanks Julian Leichert for reporting and providing the patch.
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java?rev=1817576&r1=1817575&r2=1817576&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
Fri Dec 8 21:34:14 2017
@@ -183,7 +183,6 @@ public class ShoppingListEvents {
String includeChild = request.getParameter("includeChild");
String prodCatalogId = CatalogWorker.getCurrentCatalogId(request);
- String eventMessage = null;
try {
addListToCart(delegator, dispatcher, cart, prodCatalogId,
shoppingListId, (includeChild != null), true, true);
} catch (IllegalArgumentException e) {
@@ -191,9 +190,6 @@ public class ShoppingListEvents {
return "error";
}
- if (UtilValidate.isNotEmpty(eventMessage)) {
- request.setAttribute("_EVENT_MESSAGE_", eventMessage);
- }
return "success";
}
@@ -325,7 +321,7 @@ public class ShoppingListEvents {
BigDecimal quantity = null;
try {
quantity = new BigDecimal(quantityStr);
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
// do nothing, just won't pass to service if it is null
}
@@ -410,9 +406,9 @@ public class ShoppingListEvents {
try {
String[] itemsArray = makeCartItemsArray(cart);
- if (itemsArray != null && itemsArray.length != 0) {
+ if (itemsArray.length != 0) {
addBulkFromCart(delegator, dispatcher, cart, userLogin,
autoSaveListId, null, itemsArray, false, false);
- }else if(itemsArray.length == 0 && currentListSize != 0){
+ } else if (currentListSize != 0) {
clearListInfo(delegator, autoSaveListId);
}
} catch (IllegalArgumentException e) {
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=1817576&r1=1817575&r2=1817576&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
Fri Dec 8 21:34:14 2017
@@ -141,19 +141,18 @@ public class ShoppingListServices {
GenericValue shoppingList;
while (((shoppingList = eli.next()) != null)) {
Timestamp lastOrder =
shoppingList.getTimestamp("lastOrderedDate");
- GenericValue recurrenceInfo = null;
- recurrenceInfo =
shoppingList.getRelatedOne("RecurrenceInfo", false);
+ RecurrenceInfo recurrence = null;
+ GenericValue recurrenceInfo =
shoppingList.getRelatedOne("RecurrenceInfo", false);
Timestamp startDateTime =
recurrenceInfo.getTimestamp("startDateTime");
- RecurrenceInfo recurrence = null;
- if (recurrenceInfo != null) {
- try {
- recurrence = new RecurrenceInfo(recurrenceInfo);
- } catch (RecurrenceInfoException e) {
- Debug.logError(e, module);
- }
+
+ try {
+ recurrence = new RecurrenceInfo(recurrenceInfo);
+ } catch (RecurrenceInfoException e) {
+ Debug.logError(e, module);
}
+
// check the next recurrence
if (recurrence != null) {
long next = lastOrder == null ?
recurrence.next(startDateTime.getTime()) : recurrence.next(lastOrder.getTime());
@@ -172,9 +171,10 @@ public class ShoppingListServices {
// store the order
Map<String, Object> createResp =
helper.createOrder(userLogin);
- if (createResp != null && ServiceUtil.isError(createResp))
{
+ if (createResp == null || (createResp != null &&
ServiceUtil.isError(createResp))) {
Debug.logError("Cannot create order for shopping list
- " + shoppingList, module);
} else {
+
String orderId = (String) createResp.get("orderId");
// authorize the payments