Author: mbrohl
Date: Sat Dec 9 17:52:33 2017 New Revision: 1817641 URL: http://svn.apache.org/viewvc?rev=1817641&view=rev Log: Improved: Fixing defects reported by FindBugs, package org.apache.ofbiz.order.shoppingcart. (OFBIZ-9783) Thanks Dennis Balkir for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CartEventListener.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CartEventListener.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CartEventListener.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CartEventListener.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CartEventListener.java Sat Dec 9 17:52:33 2017 @@ -78,7 +78,7 @@ public class CartEventListener implement GenericValue cartAbandonedLine = delegator.makeValue("CartAbandonedLine"); cartAbandonedLine.set("visitId", visit.get("visitId")); - cartAbandonedLine.set("cartAbandonedLineSeqId", (Integer.valueOf(seqId)).toString()); + cartAbandonedLine.set("cartAbandonedLineSeqId", Integer.toString(seqId)); cartAbandonedLine.set("productId", cartItem.getProductId()); cartAbandonedLine.set("prodCatalogId", cartItem.getProdCatalogId()); cartAbandonedLine.set("quantity", cartItem.getQuantity()); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java Sat Dec 9 17:52:33 2017 @@ -64,10 +64,10 @@ public class CheckOutEvents { public static String cartNotEmpty(HttpServletRequest request, HttpServletResponse response) { ShoppingCart cart = ShoppingCartEvents.getCartObject(request); - if (cart != null && UtilValidate.isNotEmpty(cart.items())) { + if (UtilValidate.isNotEmpty(cart.items())) { return "success"; } else { - String errMsg = UtilProperties.getMessage(resource_error, "checkevents.cart_empty", (cart != null ? cart.getLocale() : UtilHttp.getLocale(request))); + String errMsg = UtilProperties.getMessage(resource_error, "checkevents.cart_empty", cart.getLocale()); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -481,14 +481,14 @@ public class CheckOutEvents { request.setAttribute("orderAdditionalEmails", cart.getOrderAdditionalEmails()); } } - + String issuerId = request.getParameter("issuerId"); if (UtilValidate.isNotEmpty(issuerId)) { request.setAttribute("issuerId", issuerId); } - - return cart.getOrderType().toLowerCase(); + + return cart.getOrderType().toLowerCase(Locale.getDefault()); } // Event wrapper for the tax calc. Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java Sat Dec 9 17:52:33 2017 @@ -98,7 +98,7 @@ public class CheckOutHelper { errorMessages.add(errMsg); } if (errorMessages.size() == 1) { - result = ServiceUtil.returnError(errorMessages.get(0).toString()); + result = ServiceUtil.returnError(errorMessages.get(0)); } else if (errorMessages.size() > 0) { result = ServiceUtil.returnError(errorMessages); } else { @@ -117,7 +117,7 @@ public class CheckOutHelper { this.cart.setAllShippingContactMechId(shippingContactMechId); } else if (cart.shippingApplies()) { // only return an error if shipping is required for this purchase - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_shipping_destination", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_shipping_destination", cart.getLocale()); errorMessages.add(errMsg); } @@ -139,7 +139,7 @@ public class CheckOutHelper { } if (errorMessages.size() == 1) { - result = ServiceUtil.returnError(errorMessages.get(0).toString()); + result = ServiceUtil.returnError(errorMessages.get(0)); } else if (errorMessages.size() > 0) { result = ServiceUtil.returnError(errorMessages); } else { @@ -169,7 +169,7 @@ public class CheckOutHelper { this.cart.setAllCarrierPartyId(carrierPartyId); } else if (cart.shippingApplies()) { // only return an error if shipping is required for this purchase - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_shipping_method", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_shipping_method", cart.getLocale()); errorMessages.add(errMsg); } @@ -179,7 +179,7 @@ public class CheckOutHelper { if (UtilValidate.isNotEmpty(maySplit)) { cart.setAllMaySplit(Boolean.valueOf(maySplit)); } else { - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_splitting_preference", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_splitting_preference", cart.getLocale()); errorMessages.add(errMsg); } @@ -189,7 +189,7 @@ public class CheckOutHelper { if (UtilValidate.isNotEmpty(isGift)) { cart.setAllIsGift(Boolean.valueOf(isGift)); } else { - errMsg = UtilProperties.getMessage(resource_error, "checkhelper.specify_if_order_is_gift", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkhelper.specify_if_order_is_gift", cart.getLocale()); errorMessages.add(errMsg); } @@ -200,7 +200,7 @@ public class CheckOutHelper { if (UtilValidate.isDate(shipBeforeDate)) { cart.setShipBeforeDate(UtilDateTime.toTimestamp(shipBeforeDate)); } else { - errMsg = UtilProperties.getMessage(resource_error, "checkhelper.specify_if_shipBeforeDate_is_date", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkhelper.specify_if_shipBeforeDate_is_date", cart.getLocale()); errorMessages.add(errMsg); } } @@ -209,7 +209,7 @@ public class CheckOutHelper { if (UtilValidate.isDate(shipAfterDate)) { cart.setShipAfterDate(UtilDateTime.toTimestamp(shipAfterDate)); } else { - errMsg = UtilProperties.getMessage(resource_error, "checkhelper.specify_if_shipAfterDate_is_date", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkhelper.specify_if_shipAfterDate_is_date", cart.getLocale()); errorMessages.add(errMsg); } } @@ -233,7 +233,7 @@ public class CheckOutHelper { } if (errorMessages.size() == 1) { - result = ServiceUtil.returnError(errorMessages.get(0).toString()); + result = ServiceUtil.returnError(errorMessages.get(0)); } else if (errorMessages.size() > 0) { result = ServiceUtil.returnError(errorMessages); } else { @@ -288,7 +288,7 @@ public class CheckOutHelper { // if an amount was entered, check that it doesn't exceed available amount if (amountToUse.compareTo(BigDecimal.ZERO) > 0 && amountToUse.compareTo(accountCredit) > 0) { errMsg = UtilProperties.getMessage(resource_error,"checkhelper.insufficient_credit_available_on_account", - (cart != null ? cart.getLocale() : Locale.getDefault())); + cart.getLocale()); errorMessages.add(errMsg); } else { // otherwise use the available account credit (The user might enter 10.00 for an order worth 20.00 from an account with 30.00. This makes sure that the 30.00 is used) @@ -300,7 +300,7 @@ public class CheckOutHelper { if (grandTotal.compareTo(amountToUse) > 0) { cart.setBillingAccount(null, BigDecimal.ZERO); // erase existing billing account data errMsg = UtilProperties.getMessage(resource_error,"checkhelper.insufficient_credit_available_on_account", - (cart != null ? cart.getLocale() : Locale.getDefault())); + cart.getLocale()); errorMessages.add(errMsg); } else { // since this is the only selected payment method, let's make this amount the grand total for convenience @@ -318,7 +318,7 @@ public class CheckOutHelper { for (String checkOutPaymentId : selectedPaymentMethods.keySet()) { String finAccountId = null; - if (checkOutPaymentId.indexOf("|") > -1) { + if (checkOutPaymentId.indexOf('|') > -1) { // split type -- ID|Actual String[] splitStr = checkOutPaymentId.split("\\|"); checkOutPaymentId = splitStr[0]; @@ -349,7 +349,7 @@ public class CheckOutHelper { } else if (cart.getGrandTotal().compareTo(BigDecimal.ZERO) != 0) { // only return an error if the order total is not 0.00 errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_method_of_payment", - (cart != null ? cart.getLocale() : Locale.getDefault())); + cart.getLocale()); errorMessages.add(errMsg); } @@ -371,7 +371,7 @@ public class CheckOutHelper { } if (errorMessages.size() == 1) { - result = ServiceUtil.returnError(errorMessages.get(0).toString()); + result = ServiceUtil.returnError(errorMessages.get(0)); } else if (errorMessages.size() > 0) { result = ServiceUtil.returnError(errorMessages); } else { @@ -421,7 +421,7 @@ public class CheckOutHelper { } if (errorMessages.size() == 1) { - result = ServiceUtil.returnError(errorMessages.get(0).toString()); + result = ServiceUtil.returnError(errorMessages.get(0)); } else if (errorMessages.size() > 0) { result = ServiceUtil.returnError(errorMessages); } else { @@ -452,7 +452,7 @@ public class CheckOutHelper { if (cart.isPinRequiredForGC(delegator)) { // if a PIN is required, make sure the PIN is valid if (UtilValidate.isEmpty(gcPin)) { - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.enter_gift_card_pin_number", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.enter_gift_card_pin_number", cart.getLocale()); errorMessages.add(errMsg); gcFieldsOkay = false; } @@ -464,13 +464,13 @@ public class CheckOutHelper { if (!cart.isPinRequiredForGC(delegator)) { GenericValue finAccount = FinAccountHelper.getFinAccountFromCode(gcNum, delegator); if (finAccount == null) { - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.gift_card_does_not_exist", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.gift_card_does_not_exist", cart.getLocale()); errorMessages.add(errMsg); gcFieldsOkay = false; } else if ((finAccount.getBigDecimal("availableBalance") == null) || !((finAccount.getBigDecimal("availableBalance")).compareTo(FinAccountHelper.ZERO) > 0)) { // if account's available balance (including authorizations) is not greater than zero, then return an error - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.gift_card_has_no_value", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.gift_card_has_no_value", cart.getLocale()); errorMessages.add(errMsg); gcFieldsOkay = false; } @@ -484,7 +484,7 @@ public class CheckOutHelper { if (UtilValidate.isNotEmpty(selectedPaymentMethods)) { if (UtilValidate.isEmpty(gcAmt)) { - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.enter_amount_to_place_on_gift_card", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.enter_amount_to_place_on_gift_card", cart.getLocale()); errorMessages.add(errMsg); gcFieldsOkay = false; } @@ -494,7 +494,7 @@ public class CheckOutHelper { gcAmount = new BigDecimal(gcAmt); } catch (NumberFormatException e) { Debug.logError(e, module); - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.invalid_amount_for_gift_card", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.invalid_amount_for_gift_card", cart.getLocale()); errorMessages.add(errMsg); gcFieldsOkay = false; } @@ -531,7 +531,7 @@ public class CheckOutHelper { result.put("amount", giftCardAmount); } } else { - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.problem_with_gift_card_information", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.problem_with_gift_card_information", cart.getLocale()); errorMessages.add(errMsg); } } @@ -609,14 +609,14 @@ public class CheckOutHelper { } catch (GenericServiceException e) { String service = e.getMessage(); Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("service", service); - String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, cart.getLocale()); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } // check for error message(s) if (ServiceUtil.isError(storeResult)) { - String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.did_not_complete_order_following_occurred", (cart != null ? cart.getLocale() : Locale.getDefault())); + String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.did_not_complete_order_following_occurred", cart.getLocale()); List<String> resErrorMessages = new LinkedList<String>(); resErrorMessages.add(errMsg); resErrorMessages.add(ServiceUtil.getErrorMessage(storeResult)); @@ -656,19 +656,19 @@ public class CheckOutHelper { String service = e.getMessage(); Map<String, String> messageMap = UtilMisc.toMap("service", service); String errMsg = "Problem accessing the Product entity"; - errMsg = errMsg + UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = errMsg + UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, cart.getLocale()); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (GenericServiceException e) { String service = e.getMessage(); Map<String, String> messageMap = UtilMisc.toMap("service", service); - String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, cart.getLocale()); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (Exception e) { String service = e.getMessage(); Map<String, String> messageMap = UtilMisc.toMap("service", service); - String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, cart.getLocale()); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } @@ -690,13 +690,13 @@ public class CheckOutHelper { } catch (GenericServiceException e) { String service = e.getMessage(); Map<String, String> messageMap = UtilMisc.toMap("service", service); - String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, cart.getLocale()); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (Exception e) { String service = e.getMessage(); Map<String, String> messageMap = UtilMisc.toMap("service", service); - String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + String errMsg = UtilProperties.getMessage(resource_error, "checkhelper.could_not_create_order_invoking_service", messageMap, cart.getLocale()); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } @@ -1204,7 +1204,7 @@ public class CheckOutHelper { if (shippingAddressObj == null) { return ServiceUtil.returnSuccess("success"); } - String shippingAddress = UtilFormatOut.checkNull(shippingAddressObj.getString("address1")).toUpperCase(); + String shippingAddress = UtilFormatOut.checkNull(shippingAddressObj.getString("address1")).toUpperCase(Locale.getDefault()); shippingAddress = UtilFormatOut.makeSqlSafe(shippingAddress); List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition( EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("blacklistString"), EntityOperator.EQUALS, EntityFunction.UPPER(shippingAddress)), @@ -1223,7 +1223,7 @@ public class CheckOutHelper { billingAddress = creditCard.getRelatedOne("PostalAddress", false); } catch (GenericEntityException e) { Debug.logError(e, "Problems getting credit card from payment method", module); - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.problems_reading_database", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.problems_reading_database", cart.getLocale()); return ServiceUtil.returnError(errMsg); } if (creditCard != null) { @@ -1233,7 +1233,7 @@ public class CheckOutHelper { EntityCondition.makeCondition("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_CREDITCARD"))); } if (billingAddress != null) { - String address = UtilFormatOut.checkNull(billingAddress.getString("address1").toUpperCase()); + String address = UtilFormatOut.checkNull(billingAddress.getString("address1").toUpperCase(Locale.getDefault())); address = UtilFormatOut.makeSqlSafe(address); exprs.add(EntityCondition.makeCondition( EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("blacklistString"), EntityOperator.EQUALS, EntityFunction.UPPER(address)), @@ -1249,13 +1249,13 @@ public class CheckOutHelper { blacklistFound = EntityQuery.use(this.delegator).from("OrderBlacklist").where(exprs).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Problems with OrderBlacklist lookup.", module); - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.problems_reading_database", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.problems_reading_database", cart.getLocale()); return ServiceUtil.returnError(errMsg); } } if (UtilValidate.isNotEmpty(blacklistFound)) { - return ServiceUtil.returnFailure(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault()))); + return ServiceUtil.returnFailure(UtilProperties.getMessage(resource_error,"OrderFailed", cart.getLocale())); } else { return ServiceUtil.returnSuccess("success"); } @@ -1282,7 +1282,7 @@ public class CheckOutHelper { } } catch (GenericEntityException e) { Debug.logError(e, module); - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.database_error", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.database_error", cart.getLocale()); result = ServiceUtil.returnError(errMsg); return result; } @@ -1332,7 +1332,7 @@ public class CheckOutHelper { if (!("EXT_PAYPAL".equals(paymentMethodTypeId) && UtilValidate.isNotEmpty(paymentPreference.getString("paymentMethodId")))) { String type = paymentMethodTypeId.substring(4); result = ServiceUtil.returnSuccess(); - result.put("type", type.toLowerCase()); + result.put("type", type.toLowerCase(Locale.getDefault())); return result; } } @@ -1418,7 +1418,7 @@ public class CheckOutHelper { this.cart.setShipmentMethodTypeId(shipGroupIndex, shipmentMethodTypeId); this.cart.setCarrierPartyId(shipGroupIndex, carrierPartyId); } else { - errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_shipping_method", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error,"checkhelper.select_shipping_method", cart.getLocale()); result = ServiceUtil.returnError(errMsg); } @@ -1528,7 +1528,7 @@ public class CheckOutHelper { if (billingAccountAmt.compareTo(availableAmount) > 0) { Debug.logError("Billing account " + billingAccountId + " has [" + availableAmount + "] available but needs [" + billingAccountAmt + "] for this order", module); Map<String, String> messageMap = UtilMisc.toMap("billingAccountId", billingAccountId); - errMsg = UtilProperties.getMessage(resource_error, "checkevents.not_enough_available_on_account", messageMap, (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkevents.not_enough_available_on_account", messageMap, cart.getLocale()); return ServiceUtil.returnError(errMsg); } @@ -1537,7 +1537,7 @@ public class CheckOutHelper { List<String> paymentTypes = cart.getPaymentMethodTypeIds(); if (paymentTypes.contains("EXT_BILLACT") && paymentTypes.size() == 1 && paymentMethods.size() == 0) { if (cart.getGrandTotal().compareTo(availableAmount) > 0) { - errMsg = UtilProperties.getMessage(resource_error, "checkevents.insufficient_credit_available_on_account", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkevents.insufficient_credit_available_on_account", cart.getLocale()); return ServiceUtil.returnError(errMsg); } } @@ -1572,7 +1572,7 @@ public class CheckOutHelper { if (Debug.verboseOn()) Debug.logVerbose("Set null paymentMethodId - " + info.paymentMethodId + " / " + info.amount, module); } if (!setOverflow) { - info.overflow = setOverflow = true; + info.overflow = true; if (Debug.verboseOn()) Debug.logVerbose("Set overflow flag on payment - " + info.paymentMethodId, module); } } @@ -1587,14 +1587,14 @@ public class CheckOutHelper { if (UtilValidate.isNotEmpty(paymentMethods) && requiredAmount.compareTo(selectedPaymentTotal) > 0) { Debug.logError("Required Amount : " + requiredAmount + " / Selected Amount : " + selectedPaymentTotal, module); - errMsg = UtilProperties.getMessage(resource_error, "checkevents.payment_not_cover_this_order", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkevents.payment_not_cover_this_order", cart.getLocale()); return ServiceUtil.returnError(errMsg); } if (UtilValidate.isNotEmpty(paymentMethods) && requiredAmount.compareTo(selectedPaymentTotal) < 0) { BigDecimal changeAmount = selectedPaymentTotal.subtract(requiredAmount); if (!paymentTypes.contains("CASH")) { Debug.logError("Change Amount : " + changeAmount + " / No cash.", module); - errMsg = UtilProperties.getMessage(resource_error, "checkhelper.change_returned_cannot_be_greater_than_cash", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkhelper.change_returned_cannot_be_greater_than_cash", cart.getLocale()); return ServiceUtil.returnError(errMsg); } else { int cashIndex = paymentTypes.indexOf("CASH"); @@ -1602,7 +1602,7 @@ public class CheckOutHelper { BigDecimal cashAmount = cart.getPaymentAmount(cashId); if (cashAmount.compareTo(changeAmount) < 0) { Debug.logError("Change Amount : " + changeAmount + " / Cash Amount : " + cashAmount, module); - errMsg = UtilProperties.getMessage(resource_error, "checkhelper.change_returned_cannot_be_greater_than_cash", (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(resource_error, "checkhelper.change_returned_cannot_be_greater_than_cash", cart.getLocale()); return ServiceUtil.returnError(errMsg); } } Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Sat Dec 9 17:52:33 2017 @@ -24,6 +24,7 @@ import java.math.MathContext; import java.math.RoundingMode; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -134,7 +135,7 @@ public class ShoppingCart implements Ite private List<ShoppingCartItem> cartLines = new LinkedList<ShoppingCartItem>(); private Map<String, ShoppingCartItemGroup> itemGroupByNumberMap = new HashMap<String, ShoppingCartItemGroup>(); protected long nextGroupNumber = 1; - private List<CartPaymentInfo> paymentInfo = new LinkedList<ShoppingCart.CartPaymentInfo>(); + protected List<CartPaymentInfo> paymentInfo = new LinkedList<ShoppingCart.CartPaymentInfo>(); private List<CartShipInfo> shipInfo = new LinkedList<ShoppingCart.CartShipInfo>(); private Map<String, String> contactMechIdsMap = new HashMap<String, String>(); private Map<String, String> orderAttributes = new HashMap<String, String>(); @@ -432,11 +433,11 @@ public class ShoppingCart implements Ite } public void setOrderDate(Timestamp t) { - this.orderDate = t; + this.orderDate = t != null ? (Timestamp) t.clone() : null; } public Timestamp getOrderDate() { - return this.orderDate; + return this.orderDate != null ? (Timestamp) this.orderDate.clone() : null; } /** Sets the currency for the cart. */ @@ -464,7 +465,7 @@ public class ShoppingCart implements Ite } public Timestamp getCartCreatedTime() { - return this.cartCreatedTs; + return this.cartCreatedTs != null ? (Timestamp) this.cartCreatedTs.clone() : null; } public GenericValue getSupplierProduct(String productId, BigDecimal quantity, LocalDispatcher dispatcher) { @@ -1200,27 +1201,27 @@ public class ShoppingCart implements Ite } public void setDefaultShipBeforeDate(Timestamp defaultShipBeforeDate) { - this.defaultShipBeforeDate = defaultShipBeforeDate; + this.defaultShipBeforeDate = defaultShipBeforeDate != null ? (Timestamp) defaultShipBeforeDate.clone() : null; } public Timestamp getDefaultShipBeforeDate() { - return this.defaultShipBeforeDate; + return this.defaultShipBeforeDate != null ? (Timestamp) this.defaultShipBeforeDate.clone() : null; } public void setDefaultShipAfterDate(Timestamp defaultShipAfterDate) { - this.defaultShipAfterDate = defaultShipAfterDate; + this.defaultShipAfterDate = defaultShipAfterDate != null ? (Timestamp) defaultShipAfterDate.clone() : null; } public void setCancelBackOrderDate(Timestamp cancelBackOrderDate) { - this.cancelBackOrderDate = cancelBackOrderDate; + this.cancelBackOrderDate = cancelBackOrderDate != null ? (Timestamp) cancelBackOrderDate.clone() : null; } public Timestamp getCancelBackOrderDate() { - return this.cancelBackOrderDate; + return this.cancelBackOrderDate != null ? (Timestamp) this.cancelBackOrderDate.clone() : null; } public Timestamp getDefaultShipAfterDate() { - return this.defaultShipAfterDate; + return this.defaultShipAfterDate != null ? (Timestamp) this.defaultShipAfterDate.clone() : null; } public String getOrderPartyId() { @@ -1320,11 +1321,11 @@ public class ShoppingCart implements Ite } public void setLastListRestore(Timestamp time) { - this.lastListRestore = time; + this.lastListRestore = time != null ? (Timestamp) time.clone() : null; } public Timestamp getLastListRestore() { - return this.lastListRestore; + return this.lastListRestore != null ? (Timestamp) this.lastListRestore.clone() : null; } public BigDecimal getPartyDaysSinceCreated(Timestamp nowTimestamp) { @@ -1832,15 +1833,13 @@ public class ShoppingCart implements Ite public List<GenericValue> getCreditCards() { List<GenericValue> paymentMethods = this.getPaymentMethods(); List<GenericValue> creditCards = new LinkedList<GenericValue>(); - if (paymentMethods != null) { - for (GenericValue pm : paymentMethods) { - if ("CREDIT_CARD".equals(pm.getString("paymentMethodTypeId"))) { - try { - GenericValue cc = pm.getRelatedOne("CreditCard", false); - creditCards.add(cc); - } catch (GenericEntityException e) { - Debug.logError(e, "Unable to get credit card record from payment method : " + pm, module); - } + for (GenericValue pm : paymentMethods) { + if ("CREDIT_CARD".equals(pm.getString("paymentMethodTypeId"))) { + try { + GenericValue cc = pm.getRelatedOne("CreditCard", false); + creditCards.add(cc); + } catch (GenericEntityException e) { + Debug.logError(e, "Unable to get credit card record from payment method : " + pm, module); } } } @@ -1851,15 +1850,13 @@ public class ShoppingCart implements Ite public List<GenericValue> getGiftCards() { List<GenericValue> paymentMethods = this.getPaymentMethods(); List<GenericValue> giftCards = new LinkedList<GenericValue>(); - if (paymentMethods != null) { - for (GenericValue pm : paymentMethods) { - if ("GIFT_CARD".equals(pm.getString("paymentMethodTypeId"))) { - try { - GenericValue gc = pm.getRelatedOne("GiftCard", false); - giftCards.add(gc); - } catch (GenericEntityException e) { - Debug.logError(e, "Unable to get gift card record from payment method : " + pm, module); - } + for (GenericValue pm : paymentMethods) { + if ("GIFT_CARD".equals(pm.getString("paymentMethodTypeId"))) { + try { + GenericValue gc = pm.getRelatedOne("GiftCard", false); + giftCards.add(gc); + } catch (GenericEntityException e) { + Debug.logError(e, "Unable to get gift card record from payment method : " + pm, module); } } } @@ -2068,7 +2065,7 @@ public class ShoppingCart implements Ite public void setShipGroupShipDatesFromItem(ShoppingCartItem item) { Map<Integer, BigDecimal> shipGroups = this.getShipGroups(item); - if ((shipGroups != null) && (shipGroups.keySet() != null)) { + if (shipGroups.keySet() != null) { for (Integer shipGroup : shipGroups.keySet()) { CartShipInfo cartShipInfo = this.getShipInfo(shipGroup.intValue()); @@ -3321,7 +3318,7 @@ public class ShoppingCart implements Ite Iterator<ShoppingCartItem> cartItemIter = this.iterator(); while (cartItemIter.hasNext()) { ShoppingCartItem checkItem = cartItemIter.next(); - if (checkItem != null && checkItem.getIsPromo()) { + if (checkItem.getIsPromo()) { this.clearItemShipInfo(checkItem); cartItemIter.remove(); } else { @@ -3486,7 +3483,7 @@ public class ShoppingCart implements Ite else { serviceContext.put("productTypeId", "AGGREGATED_CONF"); } - + serviceContext.put("configId", configId); if (UtilValidate.isNotEmpty(product.getString("requirementMethodEnumId"))) { serviceContext.put("requirementMethodEnumId", product.getString("requirementMethodEnumId")); @@ -3957,12 +3954,13 @@ public class ShoppingCart implements Ite for (ShoppingCartItem item : cartLines) { Map<String, String> orderItemAttributes = item.getOrderItemAttributes(); - for (String key : orderItemAttributes.keySet()) { - String value = orderItemAttributes.get(key); + for (Entry<String, String> entry : orderItemAttributes.entrySet()) { + String value = entry.getValue(); + String key = entry.getKey(); if (ALL == mode || (FILLED_ONLY == mode && UtilValidate.isNotEmpty(value)) || (EMPTY_ONLY == mode && UtilValidate.isEmpty(value)) - || (mode != ALL && mode != FILLED_ONLY && mode != EMPTY_ONLY)) { - + || (mode != FILLED_ONLY && mode != EMPTY_ONLY)) { + GenericValue orderItemAttribute = getDelegator().makeValue("OrderItemAttribute"); if (UtilValidate.isNotEmpty(orderId)) { orderItemAttribute.set("orderId", orderId); @@ -4000,9 +3998,6 @@ public class ShoppingCart implements Ite orderAtt.put("attrValue", value); switch (mode) { - case ALL: - allOrderAttributes.add(orderAtt); - break; case FILLED_ONLY: if (UtilValidate.isNotEmpty(value)) { allOrderAttributes.add(orderAtt); @@ -4013,6 +4008,7 @@ public class ShoppingCart implements Ite allOrderAttributes.add(orderAtt); } break; + case ALL: default: allOrderAttributes.add(orderAtt); break; @@ -4259,7 +4255,8 @@ public class ShoppingCart implements Ite } // Reassign the drop-shippable item quantities to new or existing drop-ship groups - for (String supplierPartyId : dropShipItems.keySet()) { + for (Entry<String, Map<ShoppingCartItem, Map<Integer, BigDecimal>>> supplierPartyEntry : dropShipItems.entrySet()) { + String supplierPartyId = supplierPartyEntry.getKey(); CartShipInfo shipInfo = null; int newShipGroupIndex = -1 ; @@ -4275,12 +4272,14 @@ public class ShoppingCart implements Ite } shipInfo.supplierPartyId = supplierPartyId; - Map<ShoppingCartItem, Map<Integer, BigDecimal>> supplierCartItems = UtilGenerics.checkMap(dropShipItems.get(supplierPartyId)); - for (ShoppingCartItem cartItem : supplierCartItems.keySet()) { - Map<Integer, BigDecimal> cartItemGroupQuantities = UtilGenerics.checkMap(supplierCartItems.get(cartItem)); - for (Integer previousShipGroupIndex : cartItemGroupQuantities.keySet()) { - BigDecimal dropShipQuantity = cartItemGroupQuantities.get(previousShipGroupIndex); - positionItemToGroup(cartItem, dropShipQuantity, previousShipGroupIndex.intValue(), newShipGroupIndex, true); + Map<ShoppingCartItem, Map<Integer, BigDecimal>> supplierCartItems = UtilGenerics.checkMap(supplierPartyEntry.getValue()); + for (Entry<ShoppingCartItem, Map<Integer, BigDecimal>> cartItemEntry : supplierCartItems.entrySet()) { + ShoppingCartItem cartItem = cartItemEntry.getKey(); + Map<Integer, BigDecimal> cartItemGroupQuantities = UtilGenerics.checkMap(cartItemEntry.getValue()); + for (Entry<Integer, BigDecimal> previousShipGroupIndexEntry : cartItemGroupQuantities.entrySet()) { + Integer previousShipGroupIndex = previousShipGroupIndexEntry.getKey(); + BigDecimal dropShipQuantity = previousShipGroupIndexEntry.getValue(); + positionItemToGroup(cartItem, dropShipQuantity, previousShipGroupIndex, newShipGroupIndex, true); } } } @@ -4298,15 +4297,19 @@ public class ShoppingCart implements Ite ShoppingCartItem cartItem = (ShoppingCartItem) obj; ShoppingCartItem cartItem1 = (ShoppingCartItem) obj1; - int compareValue = cartItem.getBasePrice().compareTo(cartItem1.getBasePrice()); - if (this.ascending) { - return compareValue; - } else { - return -compareValue; - } + return this.ascending + ? cartItem.getBasePrice().compareTo(cartItem1.getBasePrice()) + : cartItem1.getBasePrice().compareTo(cartItem.getBasePrice()); } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (ascending ? 1231 : 1237); + return result; + } + public boolean equals(java.lang.Object obj) { if (obj instanceof BasePriceOrderComparator) { return this.ascending == ((BasePriceOrderComparator) obj).ascending; @@ -4379,11 +4382,22 @@ public class ShoppingCart implements Ite } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((groupName == null) ? 0 : groupName.hashCode()); + result = prime * result + ((groupNumber == null) ? 0 : groupNumber.hashCode()); + result = prime * result + ((parentGroup == null) ? 0 : parentGroup.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { - if (obj == null) return false; - ShoppingCartItemGroup that = (ShoppingCartItemGroup) obj; - if (that.groupNumber.equals(this.groupNumber)) { - return true; + if (obj instanceof ShoppingCartItemGroup) { + ShoppingCartItemGroup that = (ShoppingCartItemGroup) obj; + if (that.groupNumber.equals(this.groupNumber)) { + return true; + } } return false; } @@ -4410,10 +4424,10 @@ public class ShoppingCart implements Ite public BigDecimal getQuantityLeftInActions() { return this.quantityLeftInActions; } public Map<ShoppingCartItem,BigDecimal> getUsageInfoMap() { return this.usageInfoMap; } public BigDecimal getUsageWeight() { - Iterator<ShoppingCartItem> lineItems = this.usageInfoMap.keySet().iterator(); + Iterator<Entry<ShoppingCartItem, BigDecimal>> lineItems = this.usageInfoMap.entrySet().iterator(); BigDecimal totalAmount = BigDecimal.ZERO; while (lineItems.hasNext()) { - ShoppingCartItem lineItem = lineItems.next(); + ShoppingCartItem lineItem = lineItems.next().getKey(); totalAmount = totalAmount.add(lineItem.getBasePrice().multiply(usageInfoMap.get(lineItem))); } if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { @@ -4425,7 +4439,56 @@ public class ShoppingCart implements Ite @Override public int compareTo(ProductPromoUseInfo other) { - return other.getUsageWeight().compareTo(getUsageWeight()); + return other.getUsageWeight().compareTo(getUsageWeight()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((productPromoCodeId == null) ? 0 : productPromoCodeId.hashCode()); + result = prime * result + ((productPromoId == null) ? 0 : productPromoId.hashCode()); + result = prime * result + ((quantityLeftInActions == null) ? 0 : quantityLeftInActions.hashCode()); + result = prime * result + ((totalDiscountAmount == null) ? 0 : totalDiscountAmount.hashCode()); + result = prime * result + ((usageInfoMap == null) ? 0 : usageInfoMap.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ProductPromoUseInfo other = (ProductPromoUseInfo) obj; + if (productPromoCodeId == null) { + if (other.productPromoCodeId != null) + return false; + } else if (!productPromoCodeId.equals(other.productPromoCodeId)) + return false; + if (productPromoId == null) { + if (other.productPromoId != null) + return false; + } else if (!productPromoId.equals(other.productPromoId)) + return false; + if (quantityLeftInActions == null) { + if (other.quantityLeftInActions != null) + return false; + } else if (!quantityLeftInActions.equals(other.quantityLeftInActions)) + return false; + if (totalDiscountAmount == null) { + if (other.totalDiscountAmount != null) + return false; + } else if (!totalDiscountAmount.equals(other.totalDiscountAmount)) + return false; + if (usageInfoMap == null) { + if (other.usageInfoMap != null) + return false; + } else if (!usageInfoMap.equals(other.usageInfoMap)) + return false; + return true; } } @@ -4601,8 +4664,9 @@ public class ShoppingCart implements Ite } // create the ship group item associations - for (ShoppingCartItem item : shipItemInfo.keySet()) { - CartShipItemInfo itemInfo = shipItemInfo.get(item); + for (Entry<ShoppingCartItem, CartShipItemInfo> entry : shipItemInfo.entrySet()) { + ShoppingCartItem item = entry.getKey(); + CartShipItemInfo itemInfo = entry.getValue(); GenericValue assoc = delegator.makeValue("OrderItemShipGroupAssoc"); assoc.set("orderItemSeqId", item.getOrderItemSeqId()); @@ -4684,7 +4748,7 @@ public class ShoppingCart implements Ite public void resetShipBeforeDateIfAfter(Timestamp newShipBeforeDate) { if (newShipBeforeDate != null) { if ((this.shipBeforeDate == null) || (!this.shipBeforeDate.before(newShipBeforeDate))) { - this.shipBeforeDate = newShipBeforeDate; + this.shipBeforeDate = (Timestamp) newShipBeforeDate.clone(); } } } @@ -4696,7 +4760,7 @@ public class ShoppingCart implements Ite public void resetShipAfterDateIfBefore(Timestamp newShipAfterDate) { if (newShipAfterDate != null) { if ((this.shipAfterDate == null) || (!this.shipAfterDate.after(newShipAfterDate))) { - this.shipAfterDate = newShipAfterDate; + this.shipAfterDate = (Timestamp) newShipAfterDate.clone(); } } } @@ -5007,17 +5071,87 @@ public class ShoppingCart implements Ite } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((amount == null) ? 0 : amount.hashCode()); + result = prime * result + ((finAccountId == null) ? 0 : finAccountId.hashCode()); + result = prime * result + (isPresent ? 1231 : 1237); + result = prime * result + (isSwiped ? 1231 : 1237); + result = prime * result + (overflow ? 1231 : 1237); + result = prime * result + ((paymentMethodId == null) ? 0 : paymentMethodId.hashCode()); + result = prime * result + ((paymentMethodTypeId == null) ? 0 : paymentMethodTypeId.hashCode()); + result = prime * result + ((postalCode == null) ? 0 : postalCode.hashCode()); + result = prime * result + Arrays.hashCode(refNum); + result = prime * result + ((securityCode == null) ? 0 : securityCode.hashCode()); + result = prime * result + (singleUse ? 1231 : 1237); + result = prime * result + ((track2 == null) ? 0 : track2.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CartPaymentInfo other = (CartPaymentInfo) obj; + if (amount == null) { + if (other.amount != null) + return false; + } else if (!amount.equals(other.amount)) + return false; + if (finAccountId == null) { + if (other.finAccountId != null) + return false; + } else if (!finAccountId.equals(other.finAccountId)) + return false; + if (isPresent != other.isPresent) + return false; + if (isSwiped != other.isSwiped) + return false; + if (overflow != other.overflow) + return false; + if (paymentMethodId == null) { + if (other.paymentMethodId != null) + return false; + } else if (!paymentMethodId.equals(other.paymentMethodId)) + return false; + if (paymentMethodTypeId == null) { + if (other.paymentMethodTypeId != null) + return false; + } else if (!paymentMethodTypeId.equals(other.paymentMethodTypeId)) + return false; + if (postalCode == null) { + if (other.postalCode != null) + return false; + } else if (!postalCode.equals(other.postalCode)) + return false; + if (!Arrays.equals(refNum, other.refNum)) + return false; + if (securityCode == null) { + if (other.securityCode != null) + return false; + } else if (!securityCode.equals(other.securityCode)) + return false; + if (singleUse != other.singleUse) + return false; + if (track2 == null) { + if (other.track2 != null) + return false; + } else if (!track2.equals(other.track2)) + return false; + return true; + } + + @Override public String toString() { return "Pm: " + paymentMethodId + " / PmType: " + paymentMethodTypeId + " / Amt: " + amount + " / Ref: " + refNum[0] + "!" + refNum[1]; } } - @Override - protected void finalize() throws Throwable { - // DEJ20050518 we should not call clear because it kills the auto-save shopping list and is unnecessary given that when this object is GC'ed it will cause everything it points to that isn't referenced anywhere else to be GC'ed too: this.clear(); - super.finalize(); - } - public Map<String, String> getOrderAttributes() { return orderAttributes; } Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java Sat Dec 9 17:52:33 2017 @@ -71,7 +71,7 @@ import org.apache.ofbiz.webapp.control.R */ public class ShoppingCartEvents { - public static String module = ShoppingCartEvents.class.getName(); + public static final String module = ShoppingCartEvents.class.getName(); public static final String resource = "OrderUiLabels"; public static final String resource_error = "OrderErrorUiLabels"; @@ -358,7 +358,7 @@ public class ShoppingCartEvents { if (paramMap.containsKey("numberOfDay")) { numberOfDay = (String) paramMap.remove("numberOfDay"); reservStart = UtilDateTime.addDaysToTimestamp(UtilDateTime.nowTimestamp(), 1); - reservEnd = UtilDateTime.addDaysToTimestamp(reservStart, Integer.valueOf(numberOfDay)); + reservEnd = UtilDateTime.addDaysToTimestamp(reservStart, Integer.parseInt(numberOfDay)); } } @@ -409,7 +409,6 @@ public class ShoppingCartEvents { } catch (Exception e) { Debug.logWarning(e, "Problems parsing reservation length string: " + reservLengthStr, module); - reservLength = BigDecimal.ONE; request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderReservationLengthShouldBeAPositiveNumber", locale)); return "error"; } @@ -422,7 +421,6 @@ public class ShoppingCartEvents { reservPersons = (BigDecimal) ObjectType.simpleTypeConvert(reservPersonsStr, "BigDecimal", null, locale); } catch (Exception e) { Debug.logWarning(e, "Problems parsing reservation number of persons string: " + reservPersonsStr, module); - reservPersons = BigDecimal.ONE; request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderNumberOfPersonsShouldBeOneOrLarger", locale)); return "error"; } @@ -605,7 +603,7 @@ public class ShoppingCartEvents { productList = EntityQuery.use(delegator).select("productId").from("ProductAssoc").where("productIdTo", productId, "productAssocTypeId", "PRODUCT_UPGRADE").queryList(); if (productList != null) { for (ShoppingCartItem sci : cart) { - if (productList.contains(sci.getProductId())) { + if (productList.parallelStream().anyMatch(p -> sci.getProductId().equals(p.getString("productId")))) { try { cart.removeCartItem(sci, dispatcher); } catch (CartItemModifyException e) { @@ -1465,8 +1463,7 @@ public class ShoppingCartEvents { String shipGroupSeqId = null; long groupIndex = cart.getShipInfoSize(); List<GenericValue> orderAdjustmentList = new ArrayList<GenericValue>(); - List<GenericValue> orderAdjustments = new ArrayList<GenericValue>(); - orderAdjustments = cart.getAdjustments(); + List<GenericValue> orderAdjustments = cart.getAdjustments(); try { orderAdjustmentList = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId).queryList(); } catch (GenericEntityException e) { @@ -1769,7 +1766,6 @@ public class ShoppingCartEvents { String controlDirective = null; Map<String, Object> result = null; String productId = null; - String productCategoryId = null; String quantityStr = null; String itemDesiredDeliveryDateStr = null; BigDecimal quantity = BigDecimal.ZERO; @@ -1868,10 +1864,10 @@ public class ShoppingCartEvents { Map<String, Object> itemAttributes = UtilMisc.<String, Object>toMap("itemDesiredDeliveryDate", itemDesiredDeliveryDateStr); if (quantity.compareTo(BigDecimal.ZERO) > 0) { - Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + productCategoryId + + Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + null + ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, module); result = cartHelper.addToCart(catalogId, shoppingListId, shoppingListItemSeqId, productId, - productCategoryId, itemType, itemDescription, null, + null, itemType, itemDescription, null, amount, quantity, null, null, null, null, null, null, itemGroupNumber, itemAttributes,null); // no values for price and paramMap (a context for adding attributes) @@ -1989,10 +1985,9 @@ public class ShoppingCartEvents { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); Locale locale = UtilHttp.getLocale(request); String productId = null; - String productCategoryId = null; String quantityStr = null; String itemDesiredDeliveryDateStr = null; - BigDecimal quantity = BigDecimal.ZERO; + BigDecimal quantity; String itemType = null; String itemDescription = ""; String orderId = null; @@ -2061,7 +2056,7 @@ public class ShoppingCartEvents { shipGroupSeqId = (String) paramMap.remove("shipGroupSeqId" + thisSuffix); } if (quantity.compareTo(BigDecimal.ZERO) > 0) { - Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + productCategoryId + + Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + null + ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, module); HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java Sat Dec 9 17:52:33 2017 @@ -65,7 +65,7 @@ import org.apache.ofbiz.service.ServiceU public class ShoppingCartHelper { public static final String resource = "OrderUiLabels"; - public static String module = ShoppingCartHelper.class.getName(); + public static final String module = ShoppingCartHelper.class.getName(); public static final String resource_error = "OrderErrorUiLabels"; // The shopping cart to manipulate @@ -206,8 +206,9 @@ public class ShoppingCartHelper { // Get the additional features selected for the product (if any) Map<String, Object> selectedFeatures = UtilHttp.makeParamMapWithPrefix(context, null, "FT", null); Map<String, GenericValue> additionalFeaturesMap = new HashMap<String, GenericValue>(); - for (String selectedFeatureType : selectedFeatures.keySet()) { - String selectedFeatureValue = (String)selectedFeatures.get(selectedFeatureType); + for (Entry<String, Object> entry : selectedFeatures.entrySet()) { + String selectedFeatureType = entry.getKey(); + String selectedFeatureValue = (String) entry.getValue(); if (UtilValidate.isNotEmpty(selectedFeatureValue)) { GenericValue productFeatureAndAppl = null; try { @@ -229,7 +230,7 @@ public class ShoppingCartHelper { Map<String, String> orderItemAttributes = new HashMap<String, String>(); String orderItemAttributePrefix = EntityUtilProperties.getPropertyValue("order", "order.item.attr.prefix", delegator); for (Entry<String, ? extends Object> entry : context.entrySet()) { - if (entry.getKey().toString().contains(orderItemAttributePrefix) && UtilValidate.isNotEmpty(entry.getValue())) { + if (entry.getKey().contains(orderItemAttributePrefix) && UtilValidate.isNotEmpty(entry.getValue())) { orderItemAttributes.put(entry.getKey().replaceAll(orderItemAttributePrefix, ""), entry.getValue().toString()); } } @@ -269,7 +270,7 @@ public class ShoppingCartHelper { // Indicate there were no critical errors result = ServiceUtil.returnSuccess(); if (itemId != -1) { - result.put("itemId", new Integer(itemId)); + result.put("itemId", Integer.valueOf(itemId)); } return result; } @@ -432,9 +433,8 @@ public class ShoppingCartHelper { } catch (GenericEntityException e) { Debug.logError(e, "Error getting parent product", module); } - BigDecimal piecesIncluded = BigDecimal.ZERO; if(originalProduct != null){ - piecesIncluded = new BigDecimal(originalProduct.getLong("piecesIncluded")); + BigDecimal piecesIncluded = new BigDecimal(originalProduct.getLong("piecesIncluded")); quantity = quantity.multiply(piecesIncluded); } } @@ -525,7 +525,7 @@ public class ShoppingCartHelper { } if (UtilValidate.isNotEmpty(quantStr)) { - BigDecimal quantity = BigDecimal.ZERO; + BigDecimal quantity; try { quantity = (BigDecimal) ObjectType.simpleTypeConvert(quantStr, "BigDecimal", null, cart.getLocale()); } catch (GeneralException ge) { @@ -633,7 +633,7 @@ public class ShoppingCartHelper { Map<String, Object> result = null; List<String> errorMsgs = new ArrayList<String>(); for (String o : context.keySet()) { - if (o.toUpperCase().startsWith("DELETE")) { + if (o.toUpperCase(Locale.getDefault()).startsWith("DELETE")) { try { String indexStr = o.substring(o.lastIndexOf('_') + 1); int index = Integer.parseInt(indexStr); @@ -667,7 +667,7 @@ public class ShoppingCartHelper { List<ShoppingCartItem> deleteList = new ArrayList<ShoppingCartItem>(); List<String> errorMsgs = new ArrayList<String>(); - BigDecimal oldQuantity = BigDecimal.ONE.negate(); + BigDecimal oldQuantity; String oldDescription = ""; String oldItemComment = ""; BigDecimal oldPrice = BigDecimal.ONE.negate(); @@ -680,7 +680,8 @@ public class ShoppingCartHelper { } // TODO: This should be refactored to use UtilHttp.parseMultiFormData(parameters) - for (String parameterName : context.keySet()) { + for (Entry<String, ? extends Object> entry : context.entrySet()) { + String parameterName = entry.getKey(); int underscorePos = parameterName.lastIndexOf('_'); // ignore localized date input elements, just use their counterpart without the _i18n suffix @@ -688,7 +689,7 @@ public class ShoppingCartHelper { try { String indexStr = parameterName.substring(underscorePos + 1); int index = Integer.parseInt(indexStr); - String quantString = (String) context.get(parameterName); + String quantString = parameterName; BigDecimal quantity = BigDecimal.ONE.negate(); String itemDescription = ""; String itemComment = ""; @@ -696,8 +697,8 @@ public class ShoppingCartHelper { // get the cart item ShoppingCartItem item = this.cart.findCartItem(index); - if (parameterName.toUpperCase().startsWith("OPTION")) { - if (quantString.toUpperCase().startsWith("NO^")) { + if (parameterName.toUpperCase(Locale.getDefault()).startsWith("OPTION")) { + if (quantString.toUpperCase(Locale.getDefault()).startsWith("NO^")) { if (quantString.length() > 2) { // the length of the prefix String featureTypeId = this.getRemoveFeatureTypeId(parameterName); if (featureTypeId != null) { @@ -710,9 +711,9 @@ public class ShoppingCartHelper { item.putAdditionalProductFeatureAndAppl(featureAppl); } } - } else if (parameterName.toUpperCase().startsWith("DESCRIPTION")) { + } else if (parameterName.toUpperCase(Locale.getDefault()).startsWith("DESCRIPTION")) { itemDescription = quantString; // the quantString is actually the description if the field name starts with DESCRIPTION - } else if (parameterName.toUpperCase().startsWith("COMMENT")) { + } else if (parameterName.toUpperCase(Locale.getDefault()).startsWith("COMMENT")) { itemComment= quantString; // the quantString is actually the comment if the field name starts with COMMENT } else if (parameterName.startsWith("reservStart")) { if (quantString.length() ==0) { @@ -792,7 +793,7 @@ public class ShoppingCartHelper { this.cart.setShipGroupShipDatesFromItem(item); } - if (parameterName.toUpperCase().startsWith("UPDATE")) { + if (parameterName.toUpperCase(Locale.getDefault()).startsWith("UPDATE")) { if (quantity.compareTo(BigDecimal.ZERO) == 0) { deleteList.add(item); } else { @@ -850,7 +851,7 @@ public class ShoppingCartHelper { } } - if (parameterName.toUpperCase().startsWith("DESCRIPTION")) { + if (parameterName.toUpperCase(Locale.getDefault()).startsWith("DESCRIPTION")) { if (!oldDescription.equals(itemDescription)) { if (security.hasEntityPermission("ORDERMGR", "_CREATE", userLogin)) { if (item != null) { @@ -859,8 +860,8 @@ public class ShoppingCartHelper { } } } - - if (parameterName.toUpperCase().startsWith("COMMENT")) { + + if (parameterName.toUpperCase(Locale.getDefault()).startsWith("COMMENT")) { if (!oldItemComment.equals(itemComment)) { if (security.hasEntityPermission("ORDERMGR", "_CREATE", userLogin)) { if (item != null) { @@ -870,7 +871,7 @@ public class ShoppingCartHelper { } } - if (parameterName.toUpperCase().startsWith("PRICE")) { + if (parameterName.toUpperCase(Locale.getDefault()).startsWith("PRICE")) { NumberFormat pf = NumberFormat.getCurrencyInstance(locale); String tmpQuantity = pf.format(quantity); String tmpOldPrice = pf.format(oldPrice); @@ -884,7 +885,7 @@ public class ShoppingCartHelper { } } - if (parameterName.toUpperCase().startsWith("DELETE")) { + if (parameterName.toUpperCase(Locale.getDefault()).startsWith("DELETE")) { deleteList.add(this.cart.findCartItem(index)); } } catch (NumberFormatException nfe) { Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java Sat Dec 9 17:52:33 2017 @@ -75,10 +75,10 @@ import org.apache.ofbiz.service.ServiceU @SuppressWarnings("serial") public class ShoppingCartItem implements java.io.Serializable { - public static String module = ShoppingCartItem.class.getName(); + public static final String module = ShoppingCartItem.class.getName(); public static final String resource = "OrderUiLabels"; public static final String resource_error = "OrderErrorUiLabels"; - public static String[] attributeNames = { "shoppingListId", "shoppingListItemSeqId", "surveyResponses", + protected static final String[] attributeNames = { "shoppingListId", "shoppingListItemSeqId", "surveyResponses", "itemDesiredDeliveryDate", "itemComment", "fromInventoryItemId"}; public static final MathContext generalRounding = new MathContext(10); @@ -703,21 +703,19 @@ public class ShoppingCartItem implements protected ShoppingCartItem(GenericValue product, Map<String, GenericValue> additionalProductFeatureAndAppls, Map<String, Object> attributes, String prodCatalogId, Locale locale, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher) { this(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, locale, itemType, itemGroup, null); - if (product != null) { - String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale, dispatcher, "html"); - // if the productName is null or empty, see if there is an associated virtual product and get the productName of that product - if (UtilValidate.isEmpty(productName)) { - GenericValue parentProduct = this.getParentProduct(); - if (parentProduct != null) { - productName = ProductContentWrapper.getProductContentAsText(parentProduct, "PRODUCT_NAME", this.locale, dispatcher, "html"); - } + String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale, dispatcher, "html"); + // if the productName is null or empty, see if there is an associated virtual product and get the productName of that product + if (UtilValidate.isEmpty(productName)) { + GenericValue parentProduct = this.getParentProduct(); + if (parentProduct != null) { + productName = ProductContentWrapper.getProductContentAsText(parentProduct, "PRODUCT_NAME", this.locale, dispatcher, "html"); } + } - if (productName == null) { - this.itemDescription= ""; - } else { - this.itemDescription= productName; - } + if (productName == null) { + this.itemDescription = ""; + } else { + this.itemDescription = productName; } } @@ -832,7 +830,7 @@ public class ShoppingCartItem implements } /** Sets the reservation start date */ public void setReservStart(Timestamp reservStart) { - this.reservStart = reservStart; + this.reservStart = reservStart != null ? (Timestamp) reservStart.clone() : null; } /** Sets the reservation length */ public void setReservLength(BigDecimal reservLength) { @@ -1233,7 +1231,7 @@ public class ShoppingCartItem implements /** Returns the reservation start date with a number of days added. */ public Timestamp getReservStart(BigDecimal addDays) { if (addDays.compareTo(BigDecimal.ZERO) == 0) - return this.reservStart; + return this.reservStart != null ? (Timestamp) this.reservStart.clone() : null; else { if (this.reservStart != null) return new Timestamp((long)(this.reservStart.getTime() + (addDays.doubleValue() * 86400000.0))); @@ -1259,7 +1257,7 @@ public class ShoppingCartItem implements return this.accommodationSpotId; } - public BigDecimal getPromoQuantityUsed() { + public synchronized BigDecimal getPromoQuantityUsed() { if (this.getIsPromo()) { return this.quantity; } else { @@ -1267,7 +1265,7 @@ public class ShoppingCartItem implements } } - public BigDecimal getPromoQuantityAvailable() { + public synchronized BigDecimal getPromoQuantityAvailable() { if (this.getIsPromo()) { return BigDecimal.ZERO; } else { @@ -1430,43 +1428,43 @@ public class ShoppingCartItem implements /** Sets the date to ship before */ public void setShipBeforeDate(Timestamp date) { - this.shipBeforeDate = date; + this.shipBeforeDate = date != null ? (Timestamp) date.clone() : null; } /** Returns the date to ship before */ public Timestamp getShipBeforeDate() { - return this.shipBeforeDate; + return this.shipBeforeDate != null ? (Timestamp) this.shipBeforeDate.clone() : null; } /** Sets the date to ship after */ public void setShipAfterDate(Timestamp date) { - this.shipAfterDate = date; + this.shipAfterDate = date != null ? (Timestamp) date.clone() : null; } /** Returns the date to ship after */ public Timestamp getShipAfterDate() { - return this.shipAfterDate; + return this.shipAfterDate != null ? (Timestamp) this.shipAfterDate.clone() : null; } /** Sets the cancel back order date */ public void setCancelBackOrderDate(Timestamp date) { - this.cancelBackOrderDate = date; + this.cancelBackOrderDate = date != null ? (Timestamp) date.clone() : null; } /** Returns the cancel back order date */ public Timestamp getCancelBackOrderDate() { - return this.cancelBackOrderDate; + return this.cancelBackOrderDate != null ? (Timestamp) this.cancelBackOrderDate.clone() : null; } /** Sets the date to EstimatedShipDate */ public void setEstimatedShipDate(Timestamp date) { - this.estimatedShipDate = date; + this.estimatedShipDate = date != null ? (Timestamp) date.clone() : null; } /** Returns the date to EstimatedShipDate */ public Timestamp getEstimatedShipDate() { - return this.estimatedShipDate; + return this.estimatedShipDate != null ? (Timestamp) this.estimatedShipDate.clone() : null; } /** Sets the item type. */ @@ -2261,12 +2259,19 @@ public class ShoppingCartItem implements this.alternativeOptionProductIds = alternativeOptionProductIds; } - /** Compares the specified object with this cart item. */ public boolean equals(ShoppingCartItem item) { if (item == null) return false; return this.equals(item.getProductId(), item.additionalProductFeatureAndAppls, item.attributes, item.prodCatalogId, item.selectedAmount, item.getItemType(), item.getItemGroup(), item.getIsPromo()); } + public boolean equals(Object obj) { + return super.equals(obj); + } + + public int hashCode() { + return super.hashCode(); + } + /** Compares the specified object with this cart item. Defaults isPromo to false. Default to no itemGroup. */ public boolean equals(String productId, Map<String, GenericValue> additionalProductFeatureAndAppls, Map<String, Object> attributes, String prodCatalogId, BigDecimal selectedAmount) { return equals(productId, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, null, false); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1817641&r1=1817640&r2=1817641&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java Sat Dec 9 17:52:33 2017 @@ -27,6 +27,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.GeneralException; @@ -351,10 +353,12 @@ public class ShoppingCartServices { List<GenericValue> orderItems = orh.getOrderItems(); long nextItemSeq = 0; if (UtilValidate.isNotEmpty(orderItems)) { + Pattern pattern = Pattern.compile("\\P{Digit}"); for (GenericValue item : orderItems) { // get the next item sequence id String orderItemSeqId = item.getString("orderItemSeqId"); - orderItemSeqId = orderItemSeqId.replaceAll("\\P{Digit}", ""); + Matcher pmatcher = pattern.matcher(orderItemSeqId); + orderItemSeqId = pmatcher.replaceAll(""); // get product Id String productId = item.getString("productId"); GenericValue product = null; @@ -808,10 +812,12 @@ public class ShoppingCartServices { long nextItemSeq = 0; if (UtilValidate.isNotEmpty(quoteItems)) { + Pattern pattern = Pattern.compile("\\P{Digit}"); for (GenericValue quoteItem : quoteItems) { // get the next item sequence id String orderItemSeqId = quoteItem.getString("quoteItemSeqId"); - orderItemSeqId = orderItemSeqId.replaceAll("\\P{Digit}", ""); + Matcher pmatcher = pattern.matcher(orderItemSeqId); + orderItemSeqId = pmatcher.replaceAll(""); try { long seq = Long.parseLong(orderItemSeqId); if (seq > nextItemSeq) { @@ -870,7 +876,7 @@ public class ShoppingCartServices { configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, quoteItem.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin); } try { - itemIndex = cart.addItemToEnd(productId, amount, quantity, quoteUnitPrice, reservStart, reservLength, reservPersons,null,null, null, null, null, configWrapper, null, dispatcher, new Boolean(!applyQuoteAdjustments), new Boolean(quoteUnitPrice.compareTo(BigDecimal.ZERO) == 0), Boolean.FALSE, Boolean.FALSE); + itemIndex = cart.addItemToEnd(productId, amount, quantity, quoteUnitPrice, reservStart, reservLength, reservPersons,null,null, null, null, null, configWrapper, null, dispatcher, Boolean.valueOf(!applyQuoteAdjustments), Boolean.valueOf(quoteUnitPrice.compareTo(BigDecimal.ZERO) == 0), Boolean.FALSE, Boolean.FALSE); } catch (ItemNotFoundException e) { Debug.logError(e, module); @@ -1024,10 +1030,12 @@ public class ShoppingCartServices { long nextItemSeq = 0; if (UtilValidate.isNotEmpty(shoppingListItems)) { + Pattern pattern = Pattern.compile("\\P{Digit}"); for (GenericValue shoppingListItem : shoppingListItems) { // get the next item sequence id String orderItemSeqId = shoppingListItem.getString("shoppingListItemSeqId"); - orderItemSeqId = orderItemSeqId.replaceAll("\\P{Digit}", ""); + Matcher pmatcher = pattern.matcher(orderItemSeqId); + orderItemSeqId = pmatcher.replaceAll(""); try { long seq = Long.parseLong(orderItemSeqId); if (seq > nextItemSeq) { |
Free forum by Nabble | Edit this page |