Author: mbrohl
Date: Fri Dec 15 15:10:32 2017
New Revision: 1818291
URL: http://svn.apache.org/viewvc?rev=1818291&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.order.order.
(OFBIZ-10056)
Thanks Julian Leichert for reporting and providing the patch.
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java
Fri Dec 15 15:10:32 2017
@@ -208,7 +208,7 @@ public final class OrderChangeHelper {
Map<String, Object> digitalStatusFields =
UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId",
orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin);
Map<String, Object> digitalStatusChange =
dispatcher.runSync("changeOrderItemStatus", digitalStatusFields);
if
(ModelService.RESPOND_ERROR.equals(digitalStatusChange.get(ModelService.RESPONSE_MESSAGE)))
{
- Debug.logError("Problems with digital
product status change : " + product, module);
+ Debug.logError("Problems with digital
product status change : " + null, module);
}
}
}
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
Fri Dec 15 15:10:32 2017
@@ -108,13 +108,8 @@ public class OrderContentWrapper impleme
Writer outWriter = new StringWriter();
getOrderContentAsText(null, null, order, orderContentTypeId,
locale, mimeTypeId, delegator, dispatcher, outWriter, false);
String outString = outWriter.toString();
- if (UtilValidate.isEmpty(outString)) {
- outString = outString == null? "" : outString;
- }
outString = encoder.sanitize(outString, null);
- if (orderContentCache != null) {
- orderContentCache.put(cacheKey, outString);
- }
+ orderContentCache.put(cacheKey, outString);
return outString;
} catch (GeneralException e) {
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java
Fri Dec 15 15:10:32 2017
@@ -109,7 +109,7 @@ public class OrderEvents {
GenericValue userLogin = (GenericValue)
session.getAttribute("userLogin");
Locale locale = UtilHttp.getLocale(request);
- Map<String, Object> resultMap = new HashMap<String, Object>();
+ Map<String, Object> resultMap;
String orderId = request.getParameter("orderId");
String[] selectedItems = request.getParameterValues("selectedItem");
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java
Fri Dec 15 15:10:32 2017
@@ -124,7 +124,7 @@ public class OrderLookupServices {
for (String orderTypeId : orderTypeList) {
paramList.add("orderTypeId=" + orderTypeId);
- if (!"PURCHASE_ORDER".equals(orderTypeId) ||
("PURCHASE_ORDER".equals(orderTypeId) && canViewPo)) {
+ if (!("PURCHASE_ORDER".equals(orderTypeId)) ||
(("PURCHASE_ORDER".equals(orderTypeId) && canViewPo))) {
orExprs.add(EntityCondition.makeCondition("orderTypeId",
EntityOperator.EQUALS, orderTypeId));
}
}
@@ -274,8 +274,8 @@ public class OrderLookupServices {
// Shipment Method
String shipmentMethod = (String) context.get("shipmentMethod");
if (UtilValidate.isNotEmpty(shipmentMethod)) {
- String carrierPartyId = shipmentMethod.substring(0,
shipmentMethod.indexOf("@"));
- String ShippingMethodTypeId =
shipmentMethod.substring(shipmentMethod.indexOf("@")+1);
+ String carrierPartyId = shipmentMethod.substring(0,
shipmentMethod.indexOf('@'));
+ String ShippingMethodTypeId =
shipmentMethod.substring(shipmentMethod.indexOf('@') + 1);
dve.addMemberEntity("OISG", "OrderItemShipGroup");
dve.addAlias("OISG", "shipmentMethodTypeId");
dve.addAlias("OISG", "carrierPartyId");
@@ -398,12 +398,14 @@ public class OrderLookupServices {
orExprs.add(EntityCondition.makeCondition("productId",
EntityOperator.EQUALS, productId));
Map<String, Object> varLookup = null;
+ List<GenericValue> variants = null;
try {
varLookup =
dispatcher.runSync("getAllProductVariants", UtilMisc.toMap("productId",
productId));
+ variants =
UtilGenerics.checkList(varLookup.get("assocProducts"));
+
} catch (GenericServiceException e) {
Debug.logWarning(e.getMessage(), module);
}
- List<GenericValue> variants =
UtilGenerics.checkList(varLookup.get("assocProducts"));
if (variants != null) {
for (GenericValue v : variants) {
orExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS,
v.getString("productIdTo")));
@@ -603,7 +605,7 @@ public class OrderLookupServices {
highIndex = pagedOrderList.getEndIndex();
orderList = pagedOrderList.getData();
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e.getMessage(), module);
return ServiceUtil.returnError(e.getMessage());
}
}
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java
Fri Dec 15 15:10:32 2017
@@ -2416,7 +2416,6 @@ public class OrderReadHelper {
workOrderItemFulfillments =
orderItem.getDelegator().findByAnd("WorkOrderItemFulfillment",
UtilMisc.toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId",
orderItem.getString("orderItemSeqId")), null, true);
} catch (GenericEntityException e) {
Debug.logError(e, module);
- return result;
}
if (workOrderItemFulfillments != null) {
Iterator<GenericValue> iter =
workOrderItemFulfillments.iterator();
@@ -2425,7 +2424,9 @@ public class OrderReadHelper {
GenericValue workEffort = null;
try {
workEffort =
WorkOrderItemFulfillment.getRelatedOne("WorkEffort", true);
- } catch (GenericEntityException e) {}
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ }
result =
result.multiply(getWorkEffortRentalQuantity(workEffort));
}
}
@@ -2706,17 +2707,17 @@ public class OrderReadHelper {
public List<GenericValue> getAvailableOrderHeaderAdjustments() {
List<GenericValue> orderHeaderAdjustments =
this.getOrderHeaderAdjustments();
List<GenericValue> filteredAdjustments = new
LinkedList<GenericValue>();
- if (orderHeaderAdjustments != null) {
- for (GenericValue orderAdjustment : orderHeaderAdjustments) {
- long count = 0;
- try {
- count =
orderHeader.getDelegator().findCountByCondition("ReturnAdjustment",
EntityCondition.makeCondition("orderAdjustmentId", EntityOperator.EQUALS,
orderAdjustment.get("orderAdjustmentId")), null, null);
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
- }
- if (count == 0) {
- filteredAdjustments.add(orderAdjustment);
- }
+ for (GenericValue orderAdjustment : orderHeaderAdjustments) {
+ long count = 0;
+ try {
+ count =
orderHeader.getDelegator().findCountByCondition("ReturnAdjustment",
EntityCondition
+ .makeCondition("orderAdjustmentId",
EntityOperator.EQUALS, orderAdjustment.get(
+ "orderAdjustmentId")), null, null);
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ }
+ if (count == 0) {
+ filteredAdjustments.add(orderAdjustment);
}
}
return filteredAdjustments;
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
Fri Dec 15 15:10:32 2017
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.GeneralRuntimeException;
@@ -209,7 +210,7 @@ public class OrderReturnServices {
// get the return items
List<GenericValue> returnItems = null;
- List<GenericValue> returnAdjustments = new LinkedList<GenericValue>();
+ List<GenericValue> returnAdjustments;
try {
returnItems = returnHeader.getRelated("ReturnItem", null, null,
false);
returnAdjustments =
EntityQuery.use(delegator).from("ReturnAdjustment")
@@ -552,7 +553,7 @@ public class OrderReturnServices {
}
if (product != null) {
itemTypeKey = product.getString("productTypeId");
- } else if (item != null &&
item.getString("orderItemTypeId") != null) {
+ } else if (item.getString("orderItemTypeId") != null) {
itemTypeKey = item.getString("orderItemTypeId");
}
returnInfo.put("itemTypeKey", itemTypeKey);
@@ -683,7 +684,9 @@ public class OrderReturnServices {
}
Map<String, Object> result = ServiceUtil.returnSuccess();
- result.put("statusId", returnHeader.get("statusId"));
+ if (returnHeader != null) {
+ result.put("statusId", returnHeader.get("statusId"));
+ }
return result;
}
@@ -762,7 +765,7 @@ public class OrderReturnServices {
if (finAccountId == null && billingAccountId == null) {
// First find a Billing Account with negative balance, and if
found store credit to that
- List<GenericValue> billingAccounts = new
LinkedList<GenericValue>();
+ List<GenericValue> billingAccounts;
try {
billingAccounts =
EntityQuery.use(delegator).from("BillingAccountRoleAndAddress")
.where("partyId", fromPartyId, "roleTypeId",
"BILL_TO_CUSTOMER")
@@ -1086,7 +1089,7 @@ public class OrderReturnServices {
Map<String, Object> serviceResult = new HashMap<String, Object>();
GenericValue orderHeader = null;
- List<GenericValue> orderPayPrefs = new LinkedList<GenericValue>();
+ List<GenericValue> orderPayPrefs;
try {
orderHeader =
EntityQuery.use(delegator).from("OrderHeader").where("orderId",
orderId).queryOne();
orderPayPrefs = orderHeader.getRelated("OrderPaymentPreference",
null, UtilMisc.toList("-maxAmount"), false);
@@ -1098,7 +1101,7 @@ public class OrderReturnServices {
// Check for replacement order
if (UtilValidate.isEmpty(orderPayPrefs)) {
- List<GenericValue> returnItemResponses = new
LinkedList<GenericValue>();
+ List<GenericValue> returnItemResponses;
try {
returnItemResponses =
orderHeader.getRelated("ReplacementReturnItemResponse", null, null, false);
} catch (GenericEntityException e) {
@@ -1314,7 +1317,7 @@ public class OrderReturnServices {
orderedRefundPaymentMethodTypes.add("EFT_ACCOUNT");
// Add all the other paymentMethodTypes, in no particular order
- List<GenericValue> otherPaymentMethodTypes = new
LinkedList<GenericValue>();
+ List<GenericValue> otherPaymentMethodTypes;
try {
otherPaymentMethodTypes =
EntityQuery.use(delegator).from("PaymentMethodType")
.where(EntityCondition.makeCondition("paymentMethodTypeId",
EntityOperator.NOT_IN, orderedRefundPaymentMethodTypes))
@@ -1689,9 +1692,9 @@ public class OrderReturnServices {
return
ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
"OrderErrorGettingReturnHeaderItemInformation", locale));
}
- String returnHeaderTypeId =
returnHeader.getString("returnHeaderTypeId");
List<String> createdOrderIds = new LinkedList<String>();
if (returnHeader != null && UtilValidate.isNotEmpty(returnItems)) {
+ String returnHeaderTypeId =
returnHeader.getString("returnHeaderTypeId");
Map<String, List<GenericValue>> returnItemsByOrderId = new
HashMap<String, List<GenericValue>>();
Map<String, BigDecimal> totalByOrder = new HashMap<String,
BigDecimal>();
groupReturnItemsByOrder(returnItems, returnItemsByOrderId,
totalByOrder, delegator, returnId, returnTypeId);
@@ -1771,44 +1774,42 @@ public class OrderReturnServices {
Debug.logError(e, module);
continue;
}
- if (orderItem != null) {
- BigDecimal quantity =
returnItem.getBigDecimal("returnQuantity");
- BigDecimal unitPrice =
returnItem.getBigDecimal("returnPrice");
- if (quantity != null && unitPrice != null) {
- orderPriceTotal =
orderPriceTotal.add(quantity.multiply(unitPrice));
- // Check if the product being returned has a
Refurbished Equivalent and if so
- // (and there is inventory for the assoc
product) use that product instead
- GenericValue refurbItem = null;
- if
("CUSTOMER_RETURN".equals(returnHeaderTypeId)) {
- try {
- if (product != null) {
- GenericValue refurbItemAssoc =
EntityUtil.getFirst(EntityUtil.filterByDate(product.getRelated("MainProductAssoc",
UtilMisc.toMap("productAssocTypeId", "PRODUCT_REFURB"),
UtilMisc.toList("sequenceNum"), false)));
- if (refurbItemAssoc != null) {
- refurbItem =
refurbItemAssoc.getRelatedOne("AssocProduct", false);
- }
+ BigDecimal quantity =
returnItem.getBigDecimal("returnQuantity");
+ BigDecimal unitPrice =
returnItem.getBigDecimal("returnPrice");
+ if (quantity != null && unitPrice != null) {
+ orderPriceTotal =
orderPriceTotal.add(quantity.multiply(unitPrice));
+ // Check if the product being returned has a
Refurbished Equivalent and if so
+ // (and there is inventory for the assoc product)
use that product instead
+ GenericValue refurbItem = null;
+ if ("CUSTOMER_RETURN".equals(returnHeaderTypeId)) {
+ try {
+ if (product != null) {
+ GenericValue refurbItemAssoc =
EntityUtil.getFirst(EntityUtil.filterByDate(product.getRelated("MainProductAssoc",
UtilMisc.toMap("productAssocTypeId", "PRODUCT_REFURB"),
UtilMisc.toList("sequenceNum"), false)));
+ if (refurbItemAssoc != null) {
+ refurbItem =
refurbItemAssoc.getRelatedOne("AssocProduct", false);
}
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
}
- if (refurbItem != null) {
- boolean inventoryAvailable = false;
- try {
- Map<String, Object> invReqResult =
dispatcher.runSync("isStoreInventoryAvailable",
UtilMisc.toMap("productStoreId", orderHeader.get("productStoreId"),
-
"productId",
refurbItem.getString("productId"),
-
"product",
refurbItem, "quantity", quantity));
- if
(ServiceUtil.isError(invReqResult)) {
- Debug.logError("Error calling
isStoreInventoryAvailable service, result is: " + invReqResult, module);
- } else {
- inventoryAvailable =
"Y".equals(invReqResult.get("available"));
- }
- } catch (GenericServiceException e) {
- Debug.logError(e, "Fatal error
calling inventory checking services: " + e.toString(), module);
- }
- if (!inventoryAvailable) {
- // If the Refurbished Equivalent
is not available,
- // then use the original product.
- refurbItem = null;
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ }
+ if (refurbItem != null) {
+ boolean inventoryAvailable = false;
+ try {
+ Map<String, Object> invReqResult =
dispatcher.runSync("isStoreInventoryAvailable",
UtilMisc.toMap("productStoreId", orderHeader.get("productStoreId"),
+ "productId",
refurbItem.getString("productId"),
+ "product", refurbItem,
"quantity", quantity));
+ if (ServiceUtil.isError(invReqResult))
{
+ Debug.logError("Error calling
isStoreInventoryAvailable service, result is: " + invReqResult, module);
+ } else {
+ inventoryAvailable =
"Y".equals(invReqResult.get("available"));
}
+ } catch (GenericServiceException e) {
+ Debug.logError(e, "Fatal error calling
inventory checking services: " + e.toString(), module);
+ }
+ if (!inventoryAvailable) {
+ // If the Refurbished Equivalent is
not available,
+ // then use the original product.
+ refurbItem = null;
}
}
@@ -2241,14 +2242,14 @@ public class OrderReturnServices {
}
// We may also have some order-level adjustments, so we need to go
through each order again and add those as well
- if ((totalByOrder != null) && (totalByOrder.keySet() != null)) {
- for (String orderId : totalByOrder.keySet()) {
+ if ((totalByOrder != null) && (totalByOrder.entrySet() != null)) {
+ for (Entry<String, BigDecimal> orderId : totalByOrder.entrySet()) {
// find returnAdjustment for returnHeader
Map<String, Object> condition = UtilMisc.<String,
Object>toMap("returnId", returnId,
"returnItemSeqId",
org.apache.ofbiz.common.DataModelConstants.SEQ_ID_NA,
"returnTypeId", returnTypeId);
- BigDecimal existingTotal =
(totalByOrder.get(orderId)).add(getReturnAdjustmentTotal(delegator, condition));
- totalByOrder.put(orderId, existingTotal);
+ BigDecimal existingTotal =
(totalByOrder.get(orderId.getKey()).add(getReturnAdjustmentTotal(delegator,
condition)));
+ totalByOrder.put(orderId.getKey(), existingTotal);
}
}
}
@@ -2313,9 +2314,9 @@ public class OrderReturnServices {
returnAmountByOrder =
UtilGenerics.checkMap(serviceResult.get("orderReturnAmountMap"));
}
- if ((returnAmountByOrder != null) && (returnAmountByOrder.keySet() !=
null)) {
- for (String orderId : returnAmountByOrder.keySet()) {
- BigDecimal returnAmount = returnAmountByOrder.get(orderId);
+ if ((returnAmountByOrder != null) && (returnAmountByOrder.entrySet()
!= null)) {
+ for (Entry<String, BigDecimal> orderId :
returnAmountByOrder.entrySet()) {
+ BigDecimal returnAmount =
returnAmountByOrder.get(orderId.getKey());
if (returnAmount == null) {
return
ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
"OrderNoReturnAmountFound", UtilMisc.toMap("orderId", orderId), locale));
}
@@ -2324,7 +2325,7 @@ public class OrderReturnServices {
return
ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
"OrderReturnTotalCannotLessThanZero", locale));
}
- OrderReadHelper helper = new OrderReadHelper(delegator,
orderId);
+ OrderReadHelper helper = new OrderReadHelper(delegator,
orderId.getKey());
BigDecimal grandTotal = helper.getOrderGrandTotal();
if (returnAmount.subtract(grandTotal).compareTo(new
BigDecimal("0.01")) > 0) {
Debug.logError("Order [" + orderId + "] refund amount[ " +
returnAmount + "] exceeds order total [" + grandTotal + "]", module);
Modified:
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1818291&r1=1818290&r2=1818291&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
Fri Dec 15 15:10:32 2017
@@ -97,8 +97,8 @@ public class OrderServices {
public static final String resource_error = "OrderErrorUiLabels";
public static final String resourceProduct = "ProductUiLabels";
- public static Map<String, String> salesAttributeRoleMap = new
HashMap<String, String>();
- public static Map<String, String> purchaseAttributeRoleMap = new
HashMap<String, String>();
+ private static Map<String, String> salesAttributeRoleMap = new
HashMap<String, String>();
+ private static Map<String, String> purchaseAttributeRoleMap = new
HashMap<String, String>();
static {
salesAttributeRoleMap.put("placingCustomerPartyId",
"PLACING_CUSTOMER");
salesAttributeRoleMap.put("billToCustomerPartyId", "BILL_TO_CUSTOMER");
@@ -1261,9 +1261,7 @@ public class OrderServices {
if (ServiceUtil.isError(reserveResult)) {
String invErrMsg = "The product ";
- if (product != null) {
- invErrMsg +=
getProductName(product, orderItem);
- }
+ invErrMsg += getProductName(product,
orderItem);
invErrMsg += " with ID " +
orderItem.getString("productId") + " is no longer in stock. Please try reducing
the quantity or removing the product from this order.";
resErrorMessages.add(invErrMsg);
}
@@ -1336,9 +1334,7 @@ public class OrderServices {
if
(ServiceUtil.isError(reserveResult)) {
String invErrMsg = "The
product ";
- if (product != null) {
- invErrMsg +=
getProductName(product, orderItem);
- }
+ invErrMsg +=
getProductName(product, orderItem);
invErrMsg += " with ID " +
orderItem.getString("productId") + " is no longer in stock. Please try reducing
the quantity or removing the product from this order.";
resErrorMessages.add(invErrMsg);
}
@@ -1360,9 +1356,7 @@ public class OrderServices {
if
(ServiceUtil.isError(reserveResult)) {
String invErrMsg = "The product ";
- if (product != null) {
- invErrMsg +=
getProductName(product, orderItem);
- }
+ invErrMsg +=
getProductName(product, orderItem);
invErrMsg += " with ID " +
orderItem.getString("productId") + " is no longer in stock. Please try reducing
the quantity or removing the product from this order.";
resErrorMessages.add(invErrMsg);
}
@@ -2621,7 +2615,7 @@ public class OrderServices {
Locale locale = null;
GenericValue placingParty = orh.getPlacingParty();
GenericValue placingUserLogin = placingParty == null ? null :
PartyWorker.findPartyLatestUserLogin(placingParty.getString("partyId"),
delegator);
- if (locale == null && placingParty != null) {
+ if (placingParty != null) {
locale =
PartyWorker.findPartyLastLocale(placingParty.getString("partyId"), delegator);
}
@@ -2716,7 +2710,8 @@ public class OrderServices {
workEffort =
EntityQuery.use(delegator).from("WorkEffort").where("workEffortId",
workEffortId).queryOne();
String sourceReferenceId =
workEffort.getString("sourceReferenceId");
if (sourceReferenceId != null)
- orderHeader =
EntityQuery.use(delegator).from("OrderHeader").where("orderId",
sourceReferenceId).queryOne();
+ orderHeader =
EntityQuery.use(delegator).from("OrderHeader").where("orderId",
sourceReferenceId)
+ .queryOne();
} catch (GenericEntityException e) {
return
ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
"OrderProblemWithEntityLookup", locale));
@@ -2736,19 +2731,19 @@ public class OrderServices {
}
Map<String, Object> templateData = new HashMap<String,
Object>(context);
- templateData.putAll(orderHeader);
+ if (orderHeader != null) {
+ templateData.putAll(orderHeader);
+ }
templateData.putAll(workEffort);
templateData.put("omgStatusId",
workEffort.getString("currentStatusId"));
// get the assignments
List<GenericValue> assignments = null;
- if (workEffort != null) {
- try {
- assignments =
workEffort.getRelated("WorkEffortPartyAssignment", null, null, false);
- } catch (GenericEntityException e1) {
- Debug.logError(e1, "Problems getting assignements", module);
- }
+ try {
+ assignments = workEffort.getRelated("WorkEffortPartyAssignment",
null, null, false);
+ } catch (GenericEntityException e1) {
+ Debug.logError(e1, "Problems getting assignements", module);
}
templateData.put("assignments", assignments);
@@ -3483,7 +3478,6 @@ public class OrderServices {
String prodCatalogId = (String) context.get("prodCatalogId");
BigDecimal basePrice = (BigDecimal) context.get("basePrice");
BigDecimal quantity = (BigDecimal) context.get("quantity");
- BigDecimal amount = (BigDecimal) context.get("amount");
Timestamp itemDesiredDeliveryDate = (Timestamp)
context.get("itemDesiredDeliveryDate");
String overridePrice = (String) context.get("overridePrice");
String reasonEnumId = (String) context.get("reasonEnumId");
@@ -3496,9 +3490,6 @@ public class OrderServices {
calcTax = Boolean.TRUE;
}
- if (amount == null) {
- amount = BigDecimal.ZERO;
- }
int shipGroupIdx = -1;
try {
@@ -3523,10 +3514,6 @@ public class OrderServices {
} catch (GeneralException e) {
return ServiceUtil.returnError(e.getMessage());
}
- if (cart == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
- "OrderShoppingCartEmpty", locale));
- }
try {
//For quantity we should test if we allow to add decimal quantity
for this product an productStore :
@@ -3663,10 +3650,6 @@ public class OrderServices {
} catch (GeneralException e) {
return ServiceUtil.returnError(e.getMessage());
}
- if (cart == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
- "OrderShoppingCartEmpty", locale));
- }
// go through the item map and obtain the totals per item
Map<String, BigDecimal> itemTotals = new HashMap<String, BigDecimal>();
@@ -4986,7 +4969,7 @@ public class OrderServices {
sci.setAssociatedOrderId(orderId);
sci.setAssociatedOrderItemSeqId(item.getString("orderItemSeqId"));
sci.setOrderItemAssocTypeId("DROP_SHIPMENT");
- } catch (Exception e) {
+ } catch (CartItemModifyException |
ItemNotFoundException e) {
return
ServiceUtil.returnError(UtilProperties.getMessage(resource,
"OrderOrderCreatingDropShipmentsError",
UtilMisc.toMap("orderId", orderId,
"errorString", e.getMessage()),
@@ -5017,7 +5000,7 @@ public class OrderServices {
}
}
}
- } catch (Exception exc) {
+ } catch (GenericEntityException exc) {
// TODO: imporve error handling
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"OrderOrderCreatingDropShipmentsError",
@@ -5394,7 +5377,7 @@ public class OrderServices {
GenericValue orderHeader = null;
GenericValue orderItemToCheck = null;
- BigDecimal orderItemTotalValue = ZERO;
+ BigDecimal orderItemTotalValue;
BigDecimal invoicedQuantity = ZERO; // Quantity invoiced for the
target order item
try {
@@ -5592,7 +5575,7 @@ public class OrderServices {
Debug.logWarning("Don't know anything about
canclAutmExtTimeUomId [" + subscription.getString("canclAutmExtTimeUomId") +
"], defaulting to month", module);
}
- endDate.add(field,
Integer.valueOf(subscription.getString("canclAutmExtTime")).intValue());
+ endDate.add(field,
Integer.parseInt(subscription.getString("canclAutmExtTime")));
}
Calendar endDateSubscription = Calendar.getInstance();
@@ -5644,7 +5627,9 @@ public class OrderServices {
subscription.store();
// send notification
- dispatcher.runAsync("sendOrderPayRetryNotification",
UtilMisc.toMap("orderId", orderId));
+ if (orderId != null) {
+
dispatcher.runAsync("sendOrderPayRetryNotification", UtilMisc.toMap("orderId",
orderId));
+ }
count++;
}
}
@@ -5685,9 +5670,9 @@ public class OrderServices {
* @return
*/
public static Map<String, Object> addOrderItemShipGroup(DispatchContext
dctx, Map<String, Object> context) {
+ Map<String, Object> result;
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale" );
- Map<String, Object> result = ServiceUtil.returnSuccess();
String orderId = (String) context.get("orderId");
//main message error
@@ -5920,7 +5905,7 @@ public class OrderServices {
if (rowNumber == null) {
Long count =
EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId",
orderId, "orderItemSeqId", orderItemSeqId).queryCount();
if (count != null) {
- rowNumber = new Integer(count.intValue());
+ rowNumber = Integer.valueOf(count.intValue());
result.put("rowNumber", rowNumber);
}
}
@@ -5963,7 +5948,7 @@ public class OrderServices {
return ServiceUtil.returnError(e.toString());
}
//Only for multi service calling and the last row : test if
orderItem quantity equals OrderItemShipGroupAssocs quantitys
- if (rowCount != null && rowNumber != null ) {
+ if (rowCount != null) {
int rowCountInt = rowCount .intValue();
int rowNumberInt = rowNumber .intValue();
if (rowCountInt == rowNumberInt - 1) {
@@ -6106,9 +6091,6 @@ public class OrderServices {
}
//return warning message
- Map<String, Object> messageParameters = new HashMap<String,
Object>();
- messageParameters.put("shipByDate",
lastOISGAssoc.getRelatedOne("OrderItemShipGroup",
false).getString("shipByDate"));
- messageParameters.put("adjustementQuantity", adjustementQuantity);
return "Order OISG Assoc Quantity Auto Completed";
}
return result;
@@ -6351,10 +6333,7 @@ public class OrderServices {
BigDecimal shippableWeight =
orh.getShippableWeight(shipGroupSeqId);
List<BigDecimal> shippableItemSizes =
orh.getShippableSizes(shipGroupSeqId);
- GenericValue shippingAddress = null;
- if(UtilValidate.isEmpty(shippingAddress)) {
- shippingAddress = orh.getShippingAddress(shipGroupSeqId);
- }
+ GenericValue shippingAddress =
orh.getShippingAddress(shipGroupSeqId);
shippingMethods =
ProductStoreWorker.getAvailableStoreShippingMethods(delegator,
orh.getProductStoreId(),
shippingAddress, shippableItemSizes,
shippableItemFeatures, shippableWeight, shippableTotal);