From 569a4afeea6929225eb15effe1596c0c8ab33167 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sat, 28 Nov 2009 14:08:16 +0000 Subject: [PATCH] Some cleaning related to isEmpty * remove duplicate () * remove casts no longer needed I'm doing these last tasks around isEmpty and isNotEmpty mostly to be sure that nothing has slipped in. Despite I have been very careful, I prefer double check. + one typo in ofbizSelenium help (not sure this file is used yet though, seems to be missing some parts which are commented out, for now I guess) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@885093 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/order/shoppingcart/ShoppingCartEvents.java | 2 +- .../org/ofbiz/order/shoppingcart/ShoppingCartHelper.java | 4 ++-- .../order/shoppingcart/product/ProductPromoWorker.java | 4 ++-- .../src/org/ofbiz/product/store/ProductStoreWorker.java | 2 +- framework/base/src/org/ofbiz/base/util/UtilHttp.java | 2 +- framework/entity/src/org/ofbiz/entity/GenericDelegator.java | 4 ++-- .../ofbiz/entityext/synchronization/EntitySyncServices.java | 6 +++--- framework/testtools/documents/OfbizSeleniumSetupHTTPS.xml | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java index 16bbea5b33..3417c7b82a 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -1534,7 +1534,7 @@ public class ShoppingCartEvents { } String userLoginId = request.getParameter("userLoginId"); if (partyId != null || userLoginId != null) { - if (UtilValidate.isEmpty((partyId)) && UtilValidate.isNotEmpty(userLoginId)) { + if (UtilValidate.isEmpty(partyId) && UtilValidate.isNotEmpty(userLoginId)) { GenericValue thisUserLogin = null; try { thisUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userLoginId)); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java index e6820ca296..e5a4c5045d 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java @@ -162,7 +162,7 @@ public class ShoppingCartHelper { } // stores the default desired delivery date in the cart if need - if (!UtilValidate.isEmpty((String) context.get("useAsDefaultDesiredDeliveryDate"))) { + if (!UtilValidate.isEmpty(context.get("useAsDefaultDesiredDeliveryDate"))) { cart.setDefaultItemDeliveryDate((String) context.get("itemDesiredDeliveryDate")); } else { // do we really want to clear this if it isn't checked? @@ -170,7 +170,7 @@ public class ShoppingCartHelper { } // stores the default comment in session if need - if (!UtilValidate.isEmpty((String) context.get("useAsDefaultComment"))) { + if (!UtilValidate.isEmpty(context.get("useAsDefaultComment"))) { cart.setDefaultItemComment((String) context.get("itemComment")); } else { // do we really want to clear this if it isn't checked? diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java index f10af796c1..ae0d1b272a 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java @@ -640,8 +640,8 @@ public class ProductPromoWorker { Map messageContext = UtilMisc.toMap("quantity", productPromoAction.get("quantity"), "amount", productPromoAction.get("amount"), "productId", productId, "partyId", productPromoAction.get("partyId")); - if (UtilValidate.isEmpty((String) messageContext.get("productId"))) messageContext.put("productId", "any"); - if (UtilValidate.isEmpty((String) messageContext.get("partyId"))) messageContext.put("partyId", "any"); + if (UtilValidate.isEmpty(messageContext.get("productId"))) messageContext.put("productId", "any"); + if (UtilValidate.isEmpty(messageContext.get("partyId"))) messageContext.put("partyId", "any"); GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId)); if (product != null) { messageContext.put("productName", ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", locale, null)); diff --git a/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java b/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java index 0b768e3ca4..4246ab691e 100644 --- a/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java +++ b/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java @@ -333,7 +333,7 @@ public class ProductStoreWorker { // check the items excluded from shipping String includeFreeShipping = method.getString("includeNoChargeItems"); if (includeFreeShipping != null && "N".equalsIgnoreCase(includeFreeShipping)) { - if (UtilValidate.isEmpty((itemSizes)) && orderTotal.compareTo(BigDecimal.ZERO) == 0) { + if (UtilValidate.isEmpty(itemSizes) && orderTotal.compareTo(BigDecimal.ZERO) == 0) { returnShippingMethods.remove(method); //Debug.logInfo("Removed shipping method due to all items being exempt from shipping", module); continue; diff --git a/framework/base/src/org/ofbiz/base/util/UtilHttp.java b/framework/base/src/org/ofbiz/base/util/UtilHttp.java index 85833b5af2..70ee86ea97 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilHttp.java +++ b/framework/base/src/org/ofbiz/base/util/UtilHttp.java @@ -1203,7 +1203,7 @@ public class UtilHttp { if (date == null || date.length() < 10) return null; if (UtilValidate.isEmpty(hour)) return null; if (UtilValidate.isEmpty(minutes)) return null; - boolean isTwelveHour = (UtilValidate.isEmpty((ampm)) ? false : true); + boolean isTwelveHour = UtilValidate.isEmpty(ampm); // create the timestamp from the data try { diff --git a/framework/entity/src/org/ofbiz/entity/GenericDelegator.java b/framework/entity/src/org/ofbiz/entity/GenericDelegator.java index d696745c60..042e9144e3 100644 --- a/framework/entity/src/org/ofbiz/entity/GenericDelegator.java +++ b/framework/entity/src/org/ofbiz/entity/GenericDelegator.java @@ -2997,7 +2997,7 @@ public class GenericDelegator implements Delegator { if (field.getEncrypt()) { Object obj = entity.get(field.getName()); if (obj != null) { - if (obj instanceof String && UtilValidate.isEmpty((String) obj)) { + if (obj instanceof String && UtilValidate.isEmpty(obj)) { continue; } entity.dangerousSetNoCheckButFast(field, this.encryptFieldValue(entityName, obj)); @@ -3011,7 +3011,7 @@ public class GenericDelegator implements Delegator { */ public Object encryptFieldValue(String entityName, Object fieldValue) throws EntityCryptoException { if (fieldValue != null) { - if (fieldValue instanceof String && UtilValidate.isEmpty((String) fieldValue)) { + if (fieldValue instanceof String && UtilValidate.isEmpty(fieldValue)) { return fieldValue; } return this.crypto.encrypt(entityName, fieldValue); diff --git a/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java b/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java index b5ab82e3b9..5ea40a1363 100644 --- a/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java +++ b/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java @@ -311,9 +311,9 @@ public class EntitySyncServices { // store data returned, get results (just call storeEntitySyncData locally, get the numbers back and boom shakalaka) // anything to store locally? - if (startDate != null && (!UtilValidate.isEmpty((Collection) result.get("valuesToCreate")) || - !UtilValidate.isEmpty((Collection) result.get("valuesToStore")) || - !UtilValidate.isEmpty((Collection) result.get("keysToRemove")))) { + if (startDate != null && (!UtilValidate.isEmpty(result.get("valuesToCreate")) || + !UtilValidate.isEmpty(result.get("valuesToStore")) || + !UtilValidate.isEmpty(result.get("keysToRemove")))) { // yep, we got more data gotMoreData = true; diff --git a/framework/testtools/documents/OfbizSeleniumSetupHTTPS.xml b/framework/testtools/documents/OfbizSeleniumSetupHTTPS.xml index 8d3702b5e7..51977c0017 100644 --- a/framework/testtools/documents/OfbizSeleniumSetupHTTPS.xml +++ b/framework/testtools/documents/OfbizSeleniumSetupHTTPS.xml @@ -122,7 +122,7 @@ Uncheck “autoscrolling” option from “General” tab - uncheck “warn me …” and “Ssearch Engines”option from “Update” tab + uncheck “warn me …” and “Search Engines”option from “Update” tab