From c72b29cb1ff264ce69b7d2e9e4d98cbd3f8920c9 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Mon, 23 Nov 2009 23:41:34 +0000 Subject: [PATCH] Use UtilValidate.isNotEmpty methods instead of (obj != null) || (obj.length > 0) and (obj != null) || (obj.size > 0) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@883549 13f79535-47bb-0310-9956-ffa450edef68 --- .../accounting/invoice/InvoiceServices.java | 4 +-- .../payment/PaymentGatewayServices.java | 2 +- .../payment/PaymentMethodServices.java | 10 +++--- .../authorizedotnet/AIMPaymentServices.java | 2 +- .../authorizedotnet/AuthorizeResponse.java | 4 ++- .../cybersource/IcsPaymentServices.java | 6 ++-- .../thirdparty/valuelink/ValueLinkApi.java | 3 +- .../valuelink/ValueLinkServices.java | 36 +++++++++---------- .../thirdparty/verisign/PayflowPro.java | 2 +- .../thirdparty/worldpay/WorldPayEvents.java | 8 ++--- applications/content/src/ControlApplet.java | 12 ++++--- .../content/ContentManagementWorker.java | 4 +-- .../content/content/ContentServices.java | 4 +-- .../ofbiz/content/content/ContentWorker.java | 4 +-- .../content/data/DataResourceWorker.java | 2 +- .../org/ofbiz/content/data/DataServices.java | 2 +- .../ftl/TraverseSubContentCacheTransform.java | 4 +-- .../ftl/TraverseSubContentTransform.java | 4 +-- .../jobshopmgt/ProductionRun.java | 2 +- .../jobshopmgt/ProductionRunHelper.java | 3 +- .../tracking/TrackingCodeEvents.java | 4 +-- .../GetContactListMarketingEmail.groovy | 4 ++- .../org/ofbiz/order/OrderManagerEvents.java | 4 +-- .../order/order/OrderReturnServices.java | 6 ++-- .../order/shoppingcart/CheckOutEvents.java | 4 +-- .../order/shoppingcart/CheckOutHelper.java | 12 +++---- .../shoppingcart/ShoppingCartEvents.java | 10 +++--- .../shoppingcart/ShoppingCartHelper.java | 12 +++---- .../product/ProductDisplayWorker.java | 2 +- .../shoppinglist/ShoppingListEvents.java | 2 +- .../thirdparty/zipsales/ZipSalesServices.java | 6 ++-- .../entry/catalog/CategoryDetail.groovy | 2 +- .../CommunicationEventServices.java | 4 +-- .../party/contact/ContactMechWorker.java | 4 +-- .../org/ofbiz/party/party/PartyServices.java | 36 +++++++++---------- .../ofbiz/product/catalog/CatalogWorker.java | 2 +- .../product/feature/ParametricSearch.java | 6 ++-- .../ofbiz/product/product/ProductSearch.java | 2 +- .../product/product/ProductSearchSession.java | 12 +++---- .../product/product/ProductUtilServices.java | 2 +- .../ofbiz/product/product/ProductWorker.java | 8 ++--- .../ImportProductServices.java | 3 +- .../product/store/ProductStoreWorker.java | 10 +++--- .../shipment/shipment/ShipmentServices.java | 2 +- .../workeffort/workeffort/ICalConverter.java | 2 +- .../workeffort/WorkEffortServices.java | 4 +-- .../workeffort/WorkEffortWorker.java | 4 +-- .../ofbiz/base/component/ComponentConfig.java | 4 +-- .../org/ofbiz/base/config/ResourceLoader.java | 7 ++-- .../base/src/org/ofbiz/base/util/Debug.java | 2 +- .../ofbiz/base/util/JNDIContextFactory.java | 6 ++-- .../org/ofbiz/base/util/MessageString.java | 8 ++--- .../ofbiz/base/util/OfbizBshBsfEngine.java | 2 +- .../src/org/ofbiz/base/util/UtilDateTime.java | 2 +- .../org/ofbiz/base/util/UtilFormatOut.java | 12 +++---- .../src/org/ofbiz/base/util/UtilHttp.java | 12 +++---- .../src/org/ofbiz/base/util/UtilMisc.java | 2 +- .../base/src/org/ofbiz/base/util/UtilXml.java | 12 +++---- .../util/collections/FlexibleMapAccessor.java | 2 +- .../src/org/ofbiz/common/CommonWorkers.java | 2 +- .../src/org/ofbiz/common/FindServices.java | 2 +- .../org/ofbiz/common/login/LoginServices.java | 4 +-- .../ofbiz/datafile/DataFile2EntityXml.java | 3 +- .../ofbiz/datafile/ModelDataFileReader.java | 20 +++++------ .../src/org/ofbiz/datafile/Record.java | 3 +- .../org/ofbiz/entity/GenericDelegator.java | 6 ++-- .../connection/DBCPConnectionFactory.java | 3 +- .../connection/MinervaConnectionFactory.java | 3 +- .../connection/TyrexConnectionFactory.java | 2 +- .../connection/XaPoolConnectionFactory.java | 4 +-- .../datasource/GenericHelperFactory.java | 3 +- .../org/ofbiz/entity/finder/ListFinder.java | 2 +- .../ofbiz/entity/jdbc/ConnectionFactory.java | 5 +-- .../org/ofbiz/entity/jdbc/DatabaseUtil.java | 30 ++++++++-------- .../org/ofbiz/entity/model/ModelEntity.java | 2 +- .../ofbiz/entity/transaction/JNDIFactory.java | 7 ++-- .../transaction/TransactionFactory.java | 3 +- .../ofbiz/entity/util/EntityDataLoader.java | 7 ++-- .../ofbiz/entity/util/EntitySaxReader.java | 4 +-- .../entityext/data/EntityDataServices.java | 2 +- .../ofbiz/entityext/eca/EntityEcaAction.java | 2 +- .../src/org/ofbiz/minilang/SimpleMethod.java | 8 ++--- .../minilang/method/callops/CallBsh.java | 4 +-- .../callops/CallSimpleMapProcessor.java | 3 +- .../method/callops/CallSimpleMethod.java | 2 +- .../method/callops/FlexibleMessage.java | 4 +-- .../conditional/HasPermissionCondition.java | 2 +- .../method/entityops/EntityCount.java | 2 +- .../minilang/method/entityops/EntityData.java | 2 +- .../minilang/method/entityops/FindByAnd.java | 3 +- .../method/entityops/FindByPrimaryKey.java | 2 +- .../minilang/method/envops/StringAppend.java | 2 +- .../minilang/method/envops/StringToField.java | 2 +- .../minilang/method/envops/StringToList.java | 2 +- .../method/ifops/CheckPermission.java | 2 +- .../method/ifops/IfHasPermission.java | 3 +- .../src/org/ofbiz/security/OFBizSecurity.java | 3 +- .../security/authz/AbstractAuthorization.java | 4 +-- .../security/authz/EntityAuthorization.java | 4 +-- .../src/org/ofbiz/service/ModelPermGroup.java | 4 ++- .../src/org/ofbiz/service/ModelService.java | 8 ++--- .../org/ofbiz/service/ModelServiceReader.java | 2 +- .../ofbiz/service/eca/ServiceEcaAction.java | 2 +- .../service/eca/ServiceEcaCondition.java | 4 +-- .../ofbiz/service/jms/JmsServiceEngine.java | 3 +- .../src/org/ofbiz/service/job/JobManager.java | 2 +- .../service/rmi/RmiServiceContainer.java | 4 +-- .../ofbiz/webapp/control/ContextFilter.java | 2 +- .../org/ofbiz/webapp/control/LoginWorker.java | 4 +-- .../org/ofbiz/webapp/event/CoreEvents.java | 12 +++---- .../webapp/event/ServiceEventHandler.java | 4 +-- .../event/ServiceMultiEventHandler.java | 4 +-- .../view/JasperReportsJXlsViewHandler.java | 2 +- .../view/JasperReportsPdfViewHandler.java | 2 +- .../view/JasperReportsPoiXlsViewHandler.java | 2 +- .../view/JasperReportsXmlViewHandler.java | 2 +- .../ofbiz/webapp/webdav/PropFindHelper.java | 3 +- .../org/ofbiz/webtools/GenericWebEvent.java | 5 +-- .../org/ofbiz/webtools/WebToolsServices.java | 8 ++--- .../WEB-INF/actions/entity/ViewGeneric.groovy | 3 +- .../src/org/ofbiz/widget/WidgetWorker.java | 2 +- .../ofbiz/widget/form/MacroFormRenderer.java | 2 +- .../src/org/ofbiz/widget/form/ModelForm.java | 4 +-- .../org/ofbiz/widget/form/ModelFormField.java | 18 +++++----- .../ofbiz/widget/html/HtmlFormRenderer.java | 2 +- .../ofbiz/widget/html/HtmlFormWrapper.java | 2 +- .../ofbiz/widget/menu/ModelMenuCondition.java | 2 +- .../org/ofbiz/widget/menu/ModelMenuItem.java | 2 +- .../widget/screen/ModelScreenCondition.java | 2 +- .../ofbiz/widget/tree/MacroTreeRenderer.java | 2 +- .../ofbiz/widget/tree/ModelTreeCondition.java | 3 +- .../src/org/ofbiz/ebay/EbayOrderServices.java | 8 ++--- .../org/ofbiz/ebay/ImportOrdersFromEbay.java | 2 +- .../googlebase/ProductsExportToGoogle.java | 2 +- .../googlecheckout/GoogleCheckoutHelper.java | 12 +++---- .../pos/jpos/service/KeyboardService.java | 2 +- .../ofbiz/shark/container/SharkContainer.java | 8 ++--- .../shark/repository/EntityRepositoryMgr.java | 4 +-- .../ofbiz/workflow/client/WorkflowClient.java | 2 +- .../ofbiz/workflow/definition/XpdlReader.java | 10 +++--- .../ofbiz/workflow/impl/WfProcessImpl.java | 2 +- 141 files changed, 367 insertions(+), 339 deletions(-) diff --git a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java index e9d99f443e..495f9581ba 100644 --- a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java @@ -845,7 +845,7 @@ public class InvoiceServices { String invoiceItemSeqId = invoiceItem.getString("invoiceItemSeqId"); String invoiceId = invoiceItem.getString("invoiceId"); // Determine commission parties for this invoiceItem - if (productId != null && productId.length() > 0) { + if (UtilValidate.isNotEmpty(productId)) { Map resultMap = null; try { resultMap = dispatcher.runSync("getCommissionForProduct", UtilMisc.toMap( @@ -1730,7 +1730,7 @@ public class InvoiceServices { billings = delegator.findByAnd("ReturnItemBilling", UtilMisc.toMap("returnId", returnId, "returnItemSeqId", returnItemSeqId)); } // if there are billings, we have already billed the item, so skip it - if (billings != null && billings.size() > 0) continue; + if (UtilValidate.isNotEmpty(billings)) continue; // get the List of items shipped to/from this returnId List billItems = itemsShippedGroupedByReturn.get(returnId); diff --git a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java index e6d4b947b3..dea7a2eb32 100644 --- a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -3159,7 +3159,7 @@ public class PaymentGatewayServices { } Debug.logInfo("Running credit card verification [" + paymentMethodId + "] (" + amount + ") : " + productStorePaymentProperties + " : " + mode, module); - if (amount != null && amount.length() > 0) { + if (UtilValidate.isNotEmpty(amount)) { BigDecimal authAmount = new BigDecimal(amount); if (authAmount.compareTo(BigDecimal.ZERO) > 0) { Map ccAuthContext = FastMap.newInstance(); diff --git a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java index 4030d863ef..38fa08b024 100644 --- a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java @@ -183,7 +183,7 @@ public class PaymentMethodServices { GenericValue newPartyContactMechPurpose = null; String contactMechId = (String) context.get("contactMechId"); - if (contactMechId != null && contactMechId.length() > 0 && !contactMechId.equals("_NEW_")) { + if (UtilValidate.isNotEmpty(contactMechId) && !contactMechId.equals("_NEW_")) { // set the contactMechId on the credit card newCc.set("contactMechId", context.get("contactMechId")); // add a PartyContactMechPurpose of BILLING_LOCATION if necessary @@ -334,7 +334,7 @@ public class PaymentMethodServices { GenericValue newPartyContactMechPurpose = null; String contactMechId = (String) context.get("contactMechId"); - if (contactMechId != null && contactMechId.length() > 0 && !contactMechId.equals("_NEW_")) { + if (UtilValidate.isNotEmpty(contactMechId) && !contactMechId.equals("_NEW_")) { // set the contactMechId on the credit card newCc.set("contactMechId", contactMechId); } @@ -347,7 +347,7 @@ public class PaymentMethodServices { isModified = true; } - if (contactMechId != null && contactMechId.length() > 0 && !contactMechId.equals("_NEW_")) { + if (UtilValidate.isNotEmpty(contactMechId) && !contactMechId.equals("_NEW_")) { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; @@ -671,7 +671,7 @@ public class PaymentMethodServices { GenericValue newPartyContactMechPurpose = null; String contactMechId = (String) context.get("contactMechId"); - if (contactMechId != null && contactMechId.length() > 0) { + if (UtilValidate.isNotEmpty(contactMechId)) { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; @@ -787,7 +787,7 @@ public class PaymentMethodServices { GenericValue newPartyContactMechPurpose = null; String contactMechId = (String) context.get("contactMechId"); - if (contactMechId != null && contactMechId.length() > 0) { + if (UtilValidate.isNotEmpty(contactMechId)) { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java index e8c99ded67..2a05daea61 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java @@ -399,7 +399,7 @@ public class AIMPaymentServices { private static void buildMerchantInfo(Map params, Properties props, Map AIMRequest) { AIMRequest.put("x_Login", props.getProperty("login")); String trankey = props.getProperty("trankey"); - if (trankey != null && trankey.length() > 0) { + if (UtilValidate.isNotEmpty(trankey)) { AIMRequest.put("x_Tran_Key", props.getProperty("trankey")); } AIMRequest.put("x_Password",props.getProperty("password")); diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java index 39c72626c6..a8c6468019 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java @@ -21,6 +21,8 @@ package org.ofbiz.accounting.thirdparty.authorizedotnet; import java.util.*; +import org.ofbiz.base.util.UtilValidate; + public class AuthorizeResponse { private String rawResp = null; @@ -114,7 +116,7 @@ public class AuthorizeResponse { public void setVersion(String version) { - if (version != null && version.length() > 0) + if (UtilValidate.isNotEmpty(version)) { if (version.equals("3.0") || version.equals("3.1")) this.version = version; diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java index 1eb81f4632..bcc88edefe 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java @@ -261,7 +261,7 @@ public class IcsPaymentServices { props.put("logDirectory", logDir); props.put("logFilename", logFile); props.put("logMaximumSize", logSize); - if (keysFile != null && keysFile.length() > 0) { + if (UtilValidate.isNotEmpty(keysFile)) { props.put("alternateKeyFilename", keysFile); } Debug.log("Created CyberSource Properties : " + props, module); @@ -383,12 +383,12 @@ public class IcsPaymentServices { } if (avsOverride != null && avsOverride.get("avsDeclineString") != null) { String overrideString = avsOverride.getString("avsDeclineString"); - if (overrideString != null && overrideString.length() > 0) { + if (UtilValidate.isNotEmpty(overrideString)) { avsCodes = overrideString; } } } - if (avsCodes != null && avsCodes.length() > 0) { + if (UtilValidate.isNotEmpty(avsCodes)) { request.put("businessRules_declineAVSFlags", avsCodes); } String avsIgnore = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "ignoreAvs", configString, "payment.cybersource.ignoreAvs", "false"); diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java index 59d4c63c6e..a62af44c63 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java @@ -64,6 +64,7 @@ import org.ofbiz.base.util.HttpClientException; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -706,7 +707,7 @@ public class ValueLinkApi { // mode settings String modes = (String) props.get("payment.valuelink.modes"); - if (modes != null && modes.length() > 0) { + if (UtilValidate.isNotEmpty(modes)) { request.put("Modes", modes); } diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java index 25bd28dc01..a958c5f74e 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java @@ -209,26 +209,26 @@ public class ValueLinkServices { ValueLinkApi vl = ValueLinkApi.getInstance(delegator, props); Map request = vl.getInitialRequestMap(context); request.put("Interface", iFace != null ? iFace : "Activate"); - if (vlPromoCode != null && vlPromoCode.length() > 0) { + if (UtilValidate.isNotEmpty(vlPromoCode)) { request.put("PromoCode", vlPromoCode); } request.put("Amount", vl.getAmount(amount)); request.put("LocalCurr", vl.getCurrency(currency)); - if (cardNumber != null && cardNumber.length() > 0) { + if (UtilValidate.isNotEmpty(cardNumber)) { request.put("CardNo", cardNumber); } - if (pin != null && pin.length() > 0) { + if (UtilValidate.isNotEmpty(pin)) { request.put("PIN", vl.encryptPin(pin)); } // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -287,7 +287,7 @@ public class ValueLinkServices { request.put("PPIN", vl.encryptPin(physicalPin)); // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -340,12 +340,12 @@ public class ValueLinkServices { request.put("Amount", vl.getAmount(amount)); // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -401,12 +401,12 @@ public class ValueLinkServices { request.put("LocalCurr", vl.getCurrency(currency)); // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -468,12 +468,12 @@ public class ValueLinkServices { request.put("LocalCurr", vl.getCurrency(currency)); // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -529,12 +529,12 @@ public class ValueLinkServices { request.put("LocalCurr", vl.getCurrency(currency)); // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -583,12 +583,12 @@ public class ValueLinkServices { request.put("PIN", vl.encryptPin(pin)); // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } @@ -645,12 +645,12 @@ public class ValueLinkServices { request.put("LocalCurr", vl.getCurrency(currency)); // user defined field #1 - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { request.put("User1", orderId); } // user defined field #2 - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { request.put("User2", partyId); } diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java index d997ebbed1..e41ad4f026 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java @@ -144,7 +144,7 @@ public class PayflowPro { // gather the address info if (ps != null) { - String street = ps.getString("address1") + (ps.get("address2") != null && ps.getString("address2").length() > 0 ? " " + ps.getString("address2") : ""); + String street = ps.getString(UtilValidate.isNotEmpty(ps.getString("address2")) ? " " + ps.getString("address2") : ""); data.put("STREET", street); data.put("ZIP", ps.getString("postalCode")); diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java index a12b0648de..b42b29e3d9 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java @@ -137,9 +137,9 @@ public class WorldPayEvents { // string of customer's name String name = ""; if (contactAddress != null) { - if (contactAddress.get("attnName") != null && contactAddress.getString("attnName").length() > 0) + if (UtilValidate.isNotEmpty(contactAddress.getString("attnName"))) name = contactAddress.getString("attnName"); - else if (contactAddress.get("toName") != null && contactAddress.getString("toName").length() > 0) + else if (UtilValidate.isNotEmpty(contactAddress.getString("toName"))) name = contactAddress.getString("toName"); } // build an address string @@ -191,9 +191,9 @@ public class WorldPayEvents { GenericValue contactMechShip = EntityUtil.getFirst(shippingAddresses); contactAddressShip = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", contactMechShip.getString("contactMechId")), false); if (UtilValidate.isNotEmpty(contactAddressShip)) { - if (contactAddressShip.get("attnName") != null && contactAddressShip.getString("attnName").length() > 0) { + if (UtilValidate.isNotEmpty(contactAddressShip.getString("attnName"))) { shipName = contactAddressShip.getString("attnName"); - } else if (contactAddressShip.get("toName") != null && contactAddressShip.getString("toName").length() > 0) { + } else if (UtilValidate.isNotEmpty(contactAddressShip.getString("toName"))) { shipName = contactAddressShip.getString("toName"); } if (contactAddressShip.get("address1") != null) { diff --git a/applications/content/src/ControlApplet.java b/applications/content/src/ControlApplet.java index d4e7f61111..7dfb2d8689 100644 --- a/applications/content/src/ControlApplet.java +++ b/applications/content/src/ControlApplet.java @@ -32,6 +32,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.ofbiz.base.util.UtilValidate; + /** * Control Applet - Client applet for page pushing and (future) chat */ @@ -86,11 +88,11 @@ public class ControlApplet extends Applet implements Runnable { boolean visitOkay = false; boolean pageOkay = false; - if (sessionId != null && sessionId.length() > 0) + if (UtilValidate.isNotEmpty(sessionId)) sessionOkay = true; - if (visitId != null && visitId.length() > 0) + if (UtilValidate.isNotEmpty(visitId)) visitOkay = true; - if (currentPage != null && currentPage.length() > 0) + if (UtilValidate.isNotEmpty(currentPage)) pageOkay = true; if (sessionOkay && visitOkay && pageOkay) { @@ -146,7 +148,7 @@ public class ControlApplet extends Applet implements Runnable { } } - if (pullResp != null && pullResp.length() > 0) { + if (UtilValidate.isNotEmpty(pullResp)) { URL docUrl = null; try { docUrl = new URL(pullResp); @@ -217,7 +219,7 @@ public class ControlApplet extends Applet implements Runnable { valueStr = value.toString(); } - if (valueStr != null && valueStr.length() > 0) { + if (UtilValidate.isNotEmpty(valueStr)) { if (buf.length() > 0) buf.append('&'); try { buf.append(URLEncoder.encode(name, "UTF-8")); diff --git a/applications/content/src/org/ofbiz/content/ContentManagementWorker.java b/applications/content/src/org/ofbiz/content/ContentManagementWorker.java index 313cb98f94..62fd4764fe 100644 --- a/applications/content/src/org/ofbiz/content/ContentManagementWorker.java +++ b/applications/content/src/org/ofbiz/content/ContentManagementWorker.java @@ -139,12 +139,12 @@ public class ContentManagementWorker { while (it.hasNext()) { String ky = (String)it.next(); String val = (String)pk.get(ky); - if (val != null && val.length() > 0) { + if (UtilValidate.isNotEmpty(val)) { if (sig.length() > 0) sig += "_"; sig += val; } } - if (suffix != null && suffix.length() > 0) { + if (UtilValidate.isNotEmpty(suffix)) { if (sig.length() > 0) sig += "_"; sig += suffix; } diff --git a/applications/content/src/org/ofbiz/content/content/ContentServices.java b/applications/content/src/org/ofbiz/content/content/ContentServices.java index e675271672..9b0d4dbcbe 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentServices.java +++ b/applications/content/src/org/ofbiz/content/content/ContentServices.java @@ -193,12 +193,12 @@ public class ContentServices { String fromDateStr = (String) context.get("fromDateStr"); String thruDateStr = (String) context.get("thruDateStr"); Timestamp fromDate = null; - if (fromDateStr != null && fromDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(fromDateStr)) { fromDate = UtilDateTime.toTimestamp(fromDateStr); } Timestamp thruDate = null; - if (thruDateStr != null && thruDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(thruDateStr)) { thruDate = UtilDateTime.toTimestamp(thruDateStr); } diff --git a/applications/content/src/org/ofbiz/content/content/ContentWorker.java b/applications/content/src/org/ofbiz/content/content/ContentWorker.java index efb5589383..95501abd64 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/org/ofbiz/content/content/ContentWorker.java @@ -702,7 +702,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { public static boolean checkWhen(Map context, String whenStr) { boolean isWhen = true; //opposite default from checkReturnWhen - if (whenStr != null && whenStr.length() > 0) { + if (UtilValidate.isNotEmpty(whenStr)) { FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr); String newWhen = fse.expandString(context); //if (Debug.infoOn()) Debug.logInfo("newWhen:" + newWhen,null); @@ -722,7 +722,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { public static boolean checkReturnWhen(Map context, String whenStr) { boolean isWhen = false; //opposite default from checkWhen - if (whenStr != null && whenStr.length() > 0) { + if (UtilValidate.isNotEmpty(whenStr)) { FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr); String newWhen = fse.expandString(context); try { diff --git a/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java index 69b4cc903e..c838a19219 100644 --- a/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java +++ b/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java @@ -306,7 +306,7 @@ public class DataResourceWorker implements org.ofbiz.widget.DataResourceWorkerI // It is possible that permission to work with DataResources will be controlled // by an external Content entity. String ownerContentId = (String) context.get("ownerContentId"); - if (ownerContentId != null && ownerContentId.length() > 0) { + if (UtilValidate.isNotEmpty(ownerContentId)) { try { GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", ownerContentId)); if (content != null) diff --git a/applications/content/src/org/ofbiz/content/data/DataServices.java b/applications/content/src/org/ofbiz/content/data/DataServices.java index 49df44652a..19d9cf0b6d 100644 --- a/applications/content/src/org/ofbiz/content/data/DataServices.java +++ b/applications/content/src/org/ofbiz/content/data/DataServices.java @@ -152,7 +152,7 @@ public class DataServices { Delegator delegator = dctx.getDelegator(); String dataResourceId = (String) context.get("dataResourceId"); String textData = (String) context.get("textData"); - if (textData != null && textData.length() > 0) { + if (UtilValidate.isNotEmpty(textData)) { GenericValue electronicText = delegator.makeValue("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId, "textData", textData)); try { electronicText.create(); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java index 9db253a33c..84c3eabaa3 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java @@ -116,12 +116,12 @@ public class TraverseSubContentCacheTransform implements TemplateTransformModel String fromDateStr = (String)templateRoot.get("fromDateStr"); String thruDateStr = (String)templateRoot.get("thruDateStr"); Timestamp fromDate = null; - if (fromDateStr != null && fromDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(fromDateStr)) { fromDate = UtilDateTime.toTimestamp(fromDateStr); } traverseContext.put("fromDate", fromDate); Timestamp thruDate = null; - if (thruDateStr != null && thruDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(thruDateStr)) { thruDate = UtilDateTime.toTimestamp(thruDateStr); } traverseContext.put("thruDate", thruDate); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java index b33f0f9cc8..4a3df32c91 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java @@ -134,12 +134,12 @@ public class TraverseSubContentTransform implements TemplateTransformModel { String fromDateStr = (String)templateCtx.get("fromDateStr"); String thruDateStr = (String)templateCtx.get("thruDateStr"); Timestamp fromDate = null; - if (fromDateStr != null && fromDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(fromDateStr)) { fromDate = UtilDateTime.toTimestamp(fromDateStr); } traverseContext.put("fromDate", fromDate); Timestamp thruDate = null; - if (thruDateStr != null && thruDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(thruDateStr)) { thruDate = UtilDateTime.toTimestamp(thruDateStr); } traverseContext.put("thruDate", thruDate); diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java index 1f51090fe4..1b5c03a930 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java @@ -373,7 +373,7 @@ public class ProductionRun { Debug.logWarning(e.getMessage(), module); } } - return (GenericValue)(productionRunRoutingTasks != null && productionRunRoutingTasks.size() > 0? productionRunRoutingTasks.get(productionRunRoutingTasks.size() - 1): null); + return (GenericValue) (UtilValidate.isNotEmpty(productionRunRoutingTasks) ? productionRunRoutingTasks.get(productionRunRoutingTasks.size() - 1): null); } return null; } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java index 3dbc4f075e..486754fc91 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java @@ -24,6 +24,7 @@ import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -76,7 +77,7 @@ public class ProductionRunHelper { List tasks = delegator.findByAnd("WorkEffort", UtilMisc.toMap("workEffortParentId", workEffortId, "workEffortTypeId", "PROD_ORDER_TASK", "workEffortName", taskName)); - return (tasks != null && tasks.size() > 0); + return (UtilValidate.isNotEmpty(tasks)); } public static void getLinkedProductionRuns(Delegator delegator, LocalDispatcher dispatcher, String productionRunId, List productionRuns) throws GenericEntityException { diff --git a/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java b/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java index a4b556c0a4..92128fcff5 100644 --- a/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java +++ b/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java @@ -246,7 +246,7 @@ public class TrackingCodeEvents { // if site id exist in cookies then it is not required to create it, if exist with different site then create it int siteIdCookieAge = (60 * 60 * 24 * 365); // should this be configurable? String siteId = request.getParameter("siteId"); - if (siteId != null && siteId.length() > 0) { + if (UtilValidate.isNotEmpty(siteId)) { String visitorSiteIdCookieName = "Ofbiz.TKCD.SiteId"; String visitorSiteId = null; // first try to get the current ID from the visitor cookie @@ -285,7 +285,7 @@ public class TrackingCodeEvents { if (overrideCss != null) session.setAttribute("overrideCss", overrideCss); String prodCatalogId = trackingCode.getString("prodCatalogId"); - if (prodCatalogId != null && prodCatalogId.length() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogId)) { session.setAttribute("CURRENT_CATALOG_ID", prodCatalogId); CategoryWorker.setTrail(request, FastList.newInstance()); } diff --git a/applications/marketing/webapp/marketing/WEB-INF/actions/contact/GetContactListMarketingEmail.groovy b/applications/marketing/webapp/marketing/WEB-INF/actions/contact/GetContactListMarketingEmail.groovy index 6173caccef..29da942abf 100644 --- a/applications/marketing/webapp/marketing/WEB-INF/actions/contact/GetContactListMarketingEmail.groovy +++ b/applications/marketing/webapp/marketing/WEB-INF/actions/contact/GetContactListMarketingEmail.groovy @@ -17,6 +17,8 @@ * under the License. */ +import org.ofbiz.base.util.UtilValidate; + // figure out the MARKETING_EMAIL of the ContactList owner, for setting in the send email link if (!contactList && contactListId) { contactList = delegator.findOne("ContactList", [contactListId : "contactListId"], true); @@ -29,7 +31,7 @@ if (contactList) { contactMechs = ownerParty.getRelatedByAnd("PartyContactMechPurpose", [contactMechPurposeTypeId : "PRIMARY_EMAIL"]); } - if (contactMechs != null && contactMechs.size() > 0) { + if (UtilValidate.isNotEmpty(contactMechs)) { context.marketingEmail = contactMechs.get(0); //context.contactMechIdFrom = context.marketingEmail.contactMechId; } diff --git a/applications/order/src/org/ofbiz/order/OrderManagerEvents.java b/applications/order/src/org/ofbiz/order/OrderManagerEvents.java index 6b2c0e5653..1cfb01cebe 100644 --- a/applications/order/src/org/ofbiz/order/OrderManagerEvents.java +++ b/applications/order/src/org/ofbiz/order/OrderManagerEvents.java @@ -75,7 +75,7 @@ public class OrderManagerEvents { try { paymentPrefs = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId)); List pRoles = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "PLACING_CUSTOMER")); - if (pRoles != null && pRoles.size() > 0) + if (UtilValidate.isNotEmpty(pRoles)) placingCustomer = EntityUtil.getFirst(pRoles); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up order payment preferences", module); @@ -171,7 +171,7 @@ public class OrderManagerEvents { GenericValue placingCustomer = null; try { List pRoles = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "PLACING_CUSTOMER")); - if (pRoles != null && pRoles.size() > 0) + if (UtilValidate.isNotEmpty(pRoles)) placingCustomer = EntityUtil.getFirst(pRoles); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up order payment preferences", module); diff --git a/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java b/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java index 2bf3ef3082..a7904bcee0 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java +++ b/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java @@ -237,7 +237,7 @@ public class OrderReturnServices { } // get the email setting and send the mail - if (productStoreId != null && productStoreId.length() > 0) { + if (UtilValidate.isNotEmpty(productStoreId)) { Map sendMap = FastMap.newInstance(); GenericValue productStoreEmail = null; @@ -695,7 +695,7 @@ public class OrderReturnServices { BigDecimal adjustments = getReturnAdjustmentTotal(delegator, UtilMisc.toMap("returnId", returnId, "returnTypeId", "RTN_CREDIT")); - if (returnHeader != null && ((returnItems != null && returnItems.size() > 0) || adjustments.compareTo(ZERO) > 0)) { + if (returnHeader != null && (UtilValidate.isNotEmpty(returnItems) || adjustments.compareTo(ZERO) > 0)) { String finAccountId = returnHeader.getString("finAccountId"); String billingAccountId = returnHeader.getString("billingAccountId"); String fromPartyId = returnHeader.getString("fromPartyId"); @@ -1162,7 +1162,7 @@ public class OrderReturnServices { BigDecimal adjustments = getReturnAdjustmentTotal(delegator, UtilMisc.toMap("returnId", returnId, "returnTypeId", returnTypeId)); - if (returnHeader != null && ((returnItems != null && returnItems.size() > 0) || adjustments.compareTo(ZERO) > 0)) { + if (returnHeader != null && (UtilValidate.isNotEmpty(returnItems) || adjustments.compareTo(ZERO) > 0)) { Map itemsByOrder = new HashMap(); Map totalByOrder = new HashMap(); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java index 3ab3658b87..41c775e856 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -62,7 +62,7 @@ public class CheckOutEvents { //Locale locale = UtilHttp.getLocale(request); String errMsg = null; - if (cart != null && cart.size() > 0) { + if (UtilValidate.isNotEmpty(cart)) { return "success"; } else { errMsg = UtilProperties.getMessage(resource_error, "checkevents.cart_empty", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -302,7 +302,7 @@ public class CheckOutEvents { } String amountStr = request.getParameter("amount_" + paymentMethods[i]); BigDecimal amount = null; - if (amountStr != null && amountStr.length() > 0 && !"REMAINING".equals(amountStr)) { + if (UtilValidate.isNotEmpty(amountStr) && !"REMAINING".equals(amountStr)) { try { amount = new BigDecimal(amountStr); } catch (NumberFormatException e) { diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java index d7d66a7f6b..c4ac80859b 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -197,7 +197,7 @@ public class CheckOutHelper { // interal code this.cart.setInternalCode(internalCode); - if (shipBeforeDate != null && shipBeforeDate.length() > 0) { + if (UtilValidate.isNotEmpty(shipBeforeDate)) { if (UtilValidate.isDate(shipBeforeDate)) { cart.setShipBeforeDate(UtilDateTime.toTimestamp(shipBeforeDate)); } else { @@ -206,7 +206,7 @@ public class CheckOutHelper { } } - if (shipAfterDate != null && shipAfterDate.length() > 0) { + if (UtilValidate.isNotEmpty(shipAfterDate)) { if (UtilValidate.isDate(shipAfterDate)) { cart.setShipAfterDate(UtilDateTime.toTimestamp(shipAfterDate)); } else { @@ -495,7 +495,7 @@ public class CheckOutHelper { gcFieldsOkay = false; } } - if (gcAmt != null && gcAmt.length() > 0) { + if (UtilValidate.isNotEmpty(gcAmt)) { try { gcAmount = new BigDecimal(gcAmt); } catch (NumberFormatException e) { @@ -603,7 +603,7 @@ public class CheckOutHelper { try { storeResult = dispatcher.runSync("storeOrder", context); orderId = (String) storeResult.get("orderId"); - if (orderId != null && orderId.length() > 0) { + if (UtilValidate.isNotEmpty(orderId)) { this.cart.setOrderId(orderId); if (this.cart.getFirstAttemptOrderId() == null) { this.cart.setFirstAttemptOrderId(orderId); @@ -1519,12 +1519,12 @@ public class CheckOutHelper { BigDecimal selectedPaymentTotal = cart.getPaymentTotal(); BigDecimal requiredAmount = reqAmtPreParse.setScale(scale, rounding); - if (paymentMethods != null && paymentMethods.size() > 0 && requiredAmount.compareTo(selectedPaymentTotal) > 0) { + 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())); return ServiceUtil.returnError(errMsg); } - if (paymentMethods != null && paymentMethods.size() > 0 && requiredAmount.compareTo(selectedPaymentTotal) < 0) { + 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); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java index 840cd60a42..16bbea5b33 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -430,7 +430,7 @@ public class ShoppingCartEvents { // get the ship before date (handles both yyyy-mm-dd input and full timestamp) shipBeforeDateStr = (String) paramMap.remove("shipBeforeDate"); - if (shipBeforeDateStr != null && shipBeforeDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(shipBeforeDateStr)) { if (shipBeforeDateStr.length() == 10) shipBeforeDateStr += " 00:00:00.000"; try { shipBeforeDate = java.sql.Timestamp.valueOf(shipBeforeDateStr); @@ -442,7 +442,7 @@ public class ShoppingCartEvents { // get the ship after date (handles both yyyy-mm-dd input and full timestamp) shipAfterDateStr = (String) paramMap.remove("shipAfterDate"); - if (shipAfterDateStr != null && shipAfterDateStr.length() > 0) { + if (UtilValidate.isNotEmpty(shipAfterDateStr)) { if (shipAfterDateStr.length() == 10) shipAfterDateStr += " 00:00:00.000"; try { shipAfterDate = java.sql.Timestamp.valueOf(shipAfterDateStr); @@ -656,7 +656,7 @@ public class ShoppingCartEvents { cart.setOrderPartyId(supplierPartyId); cart.setOrderId(orderId); String agreementId = request.getParameter("agreementId_o_0"); - if (agreementId != null && agreementId.length() > 0) { + if (UtilValidate.isNotEmpty(agreementId)) { ShoppingCartHelper sch = new ShoppingCartHelper(delegator, dispatcher, cart); sch.selectAgreement(agreementId); } @@ -1534,7 +1534,7 @@ public class ShoppingCartEvents { } String userLoginId = request.getParameter("userLoginId"); if (partyId != null || userLoginId != null) { - if (UtilValidate.isEmpty((partyId)) && userLoginId != null && userLoginId.length() > 0) { + if (UtilValidate.isEmpty((partyId)) && UtilValidate.isNotEmpty(userLoginId)) { GenericValue thisUserLogin = null; try { thisUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userLoginId)); @@ -1547,7 +1547,7 @@ public class ShoppingCartEvents { partyId = userLoginId; } } - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { GenericValue thisParty = null; try { thisParty = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId)); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java index db7eefe5c4..e6820ca296 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java @@ -404,7 +404,7 @@ public class ShoppingCartHelper { continue; } - if (quantStr != null && quantStr.length() > 0) { + if (UtilValidate.isNotEmpty(quantStr)) { BigDecimal quantity = BigDecimal.ZERO; try { @@ -480,7 +480,7 @@ public class ShoppingCartHelper { return ServiceUtil.returnError("Requirement with id [" + requirementId + "] doesn't exist."); } - if (quantStr != null && quantStr.length() > 0) { + if (UtilValidate.isNotEmpty(quantStr)) { BigDecimal quantity = BigDecimal.ZERO; try { quantity = new BigDecimal(nf.parse(quantStr).doubleValue()); @@ -697,21 +697,21 @@ public class ShoppingCartHelper { item.setReservPersons(reservPersons); } } else if (parameterName.startsWith("shipBeforeDate")) { - if (item != null && quantString.length() > 0) { + if (UtilValidate.isNotEmpty(quantString)) { // input is either yyyy-mm-dd or a full timestamp if (quantString.length() == 10) quantString += " 00:00:00.000"; item.setShipBeforeDate(Timestamp.valueOf(quantString)); } } else if (parameterName.startsWith("shipAfterDate")) { - if (item != null && quantString.length() > 0) { + if (UtilValidate.isNotEmpty(quantString)) { // input is either yyyy-mm-dd or a full timestamp if (quantString.length() == 10) quantString += " 00:00:00.000"; item.setShipAfterDate(Timestamp.valueOf(quantString)); } } else if (parameterName.startsWith("amount")) { - if (item != null && quantString.length() > 0) { + if (UtilValidate.isNotEmpty(quantString)) { BigDecimal amount = new BigDecimal(quantString); if (amount.compareTo(BigDecimal.ZERO) <= 0) { String errMsg = UtilProperties.getMessage(resource_error, "cart.amount_not_positive_number", this.cart.getLocale()); @@ -722,7 +722,7 @@ public class ShoppingCartHelper { item.setSelectedAmount(amount); } } else if (parameterName.startsWith("itemType")) { - if (item != null && quantString.length() > 0) { + if (UtilValidate.isNotEmpty(quantString)) { item.setItemType(quantString); } } else { diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java index 77df334202..9b1c602f37 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java @@ -233,7 +233,7 @@ public class ProductDisplayWorker { // remove all products that are already in the cart ShoppingCart cart = (ShoppingCart) httpRequest.getSession().getAttribute("shoppingCart"); - if (cart != null && cart.size() > 0) { + if (UtilValidate.isNotEmpty(cart)) { Iterator cartiter = cart.iterator(); while (cartiter.hasNext()) { ShoppingCartItem item = (ShoppingCartItem) cartiter.next(); diff --git a/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java b/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java index 3648b9a018..533f8ab78c 100644 --- a/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java @@ -191,7 +191,7 @@ public class ShoppingListEvents { return "error"; } - if (eventMessage != null && eventMessage.length() > 0) { + if (UtilValidate.isNotEmpty(eventMessage)) { request.setAttribute("_EVENT_MESSAGE_", eventMessage); } diff --git a/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java b/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java index 0fd4a7392d..b86ed27406 100644 --- a/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java +++ b/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java @@ -179,7 +179,7 @@ public class ZipSalesServices { } catch (DataFileException e) { Debug.logError(e, module); } - if (entry.get("stateCode") != null && entry.getString("stateCode").length() > 0) { + if (UtilValidate.isNotEmpty(entry.getString("stateCode"))) { GenericValue newValue = delegator.makeValue("ZipSalesRuleLookup"); // PK fields newValue.set("stateCode", entry.get("stateCode") != null ? entry.getString("stateCode").trim() : "_NA_"); @@ -229,7 +229,7 @@ public class ZipSalesServices { // check for a valid state/province geo String validStates = UtilProperties.getPropertyValue("zipsales.properties", "zipsales.valid.states"); - if (validStates != null && validStates.length() > 0) { + if (UtilValidate.isNotEmpty(validStates)) { List stateSplit = StringUtil.split(validStates, "|"); if (!stateSplit.contains(stateProvince)) { Map result = ServiceUtil.returnSuccess(); @@ -377,7 +377,7 @@ public class ZipSalesServices { } else { // except if conditions are met boolean qualify = false; - if (condition != null && condition.length() > 0) { + if (UtilValidate.isNotEmpty(condition)) { char[] conditions = condition.toCharArray(); for (int i = 0; i < conditions.length; i++) { switch (conditions[i]) { diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy index a3bd8bc1aa..182e748f18 100644 --- a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy +++ b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/CategoryDetail.groovy @@ -107,7 +107,7 @@ context.put("contentPathPrefix", contentPathPrefix); // little routine to see if any members have a quantity > 0 assigned members = context.get("productCategoryMembers"); -if (members != null && members.size() > 0) { +if (UtilValidate.isNotEmpty(members)) { for (i = 0; i < members.size(); i++) { productCategoryMember = (GenericValue) members.get(i); if (productCategoryMember.get("quantity") != null && productCategoryMember.getDouble("quantity").doubleValue() > 0.0) { diff --git a/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java b/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java index c1feb84117..2de37f302c 100644 --- a/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java +++ b/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java @@ -1173,7 +1173,7 @@ public class CommunicationEventServices { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } - if (values != null && values.size() > 0) { + if (UtilValidate.isNotEmpty(values)) { // there should be only one; unique key GenericValue value = values.get(0); @@ -1205,7 +1205,7 @@ public class CommunicationEventServices { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } - if (values != null && values.size() > 0) { + if (UtilValidate.isNotEmpty(values)) { // there should be only one; unique key GenericValue value = values.get(0); diff --git a/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java b/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java index efe0aa9481..4ab4f6ca79 100644 --- a/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java +++ b/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java @@ -348,7 +348,7 @@ public class ContactMechWorker { } catch (GenericEntityException e) { Debug.logWarning(e, module); } - if (partyContactMechPurposes != null && partyContactMechPurposes.size() > 0) + if (UtilValidate.isNotEmpty(partyContactMechPurposes)) target.put("partyContactMechPurposes", partyContactMechPurposes); } @@ -559,7 +559,7 @@ public class ContactMechWorker { } catch (GenericEntityException e) { Debug.logWarning(e, module); } - if (facilityContactMechPurposes != null && facilityContactMechPurposes.size() > 0) + if (UtilValidate.isNotEmpty(facilityContactMechPurposes)) target.put("facilityContactMechPurposes", facilityContactMechPurposes); } diff --git a/applications/party/src/org/ofbiz/party/party/PartyServices.java b/applications/party/src/org/ofbiz/party/party/PartyServices.java index af461605fe..b0132a24bb 100644 --- a/applications/party/src/org/ofbiz/party/party/PartyServices.java +++ b/applications/party/src/org/ofbiz/party/party/PartyServices.java @@ -112,7 +112,7 @@ public class PartyServices { String description = (String) context.get("description"); // if specified partyId starts with a number, return an error - if (partyId != null && partyId.length() > 0 && Character.isDigit(partyId.charAt(0))) { + if (UtilValidate.isNotEmpty(partyId) && Character.isDigit(partyId.charAt(0))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "party.id_is_digit", locale)); } @@ -986,7 +986,7 @@ public class PartyServices { String roleTypeId; try { roleTypeId = (String) context.get("roleTypeId"); - if (roleTypeId != null && roleTypeId.length() > 0) { + if (UtilValidate.isNotEmpty(roleTypeId)) { GenericValue currentRole = delegator.findByPrimaryKeyCache("RoleType", UtilMisc.toMap("roleTypeId", roleTypeId)); result.put("currentRole", currentRole); } @@ -1010,7 +1010,7 @@ public class PartyServices { String partyTypeId; try { partyTypeId = (String) context.get("partyTypeId"); - if (partyTypeId != null && partyTypeId.length() > 0) { + if (UtilValidate.isNotEmpty(partyTypeId)) { GenericValue currentPartyType = delegator.findByPrimaryKeyCache("PartyType", UtilMisc.toMap("partyTypeId", partyTypeId)); result.put("currentPartyType", currentPartyType); } @@ -1024,7 +1024,7 @@ public class PartyServices { String stateProvinceGeoId; try { stateProvinceGeoId = (String) context.get("stateProvinceGeoId"); - if (stateProvinceGeoId != null && stateProvinceGeoId.length() > 0) { + if (UtilValidate.isNotEmpty(stateProvinceGeoId)) { GenericValue currentStateGeo = delegator.findByPrimaryKeyCache("Geo", UtilMisc.toMap("geoId", stateProvinceGeoId)); result.put("currentStateGeo", currentStateGeo); } @@ -1123,7 +1123,7 @@ public class PartyServices { if (!"Y".equals(showAll)) { // check for a partyId - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { paramList = paramList + "&partyId=" + partyId; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+partyId+"%"))); } @@ -1149,7 +1149,7 @@ public class PartyServices { // ---- // filter on user login - if (userLoginId != null && userLoginId.length() > 0) { + if (UtilValidate.isNotEmpty(userLoginId)) { paramList = paramList + "&userLoginId=" + userLoginId; // modify the dynamic view @@ -1168,7 +1168,7 @@ public class PartyServices { // ---- // filter on groupName - if (groupName != null && groupName.length() > 0) { + if (UtilValidate.isNotEmpty(groupName)) { paramList = paramList + "&groupName=" + groupName; // modify the dynamic view @@ -1187,7 +1187,7 @@ public class PartyServices { // ---- // modify the dynamic view - if ((firstName != null && firstName.length() > 0) || (lastName != null && lastName.length() > 0)) { + if (UtilValidate.isNotEmpty(firstName) || UtilValidate.isNotEmpty(lastName)) { dynamicView.addMemberEntity("PE", "Person"); dynamicView.addAlias("PE", "firstName"); dynamicView.addAlias("PE", "lastName"); @@ -1200,13 +1200,13 @@ public class PartyServices { } // filter on firstName - if (firstName != null && firstName.length() > 0) { + if (UtilValidate.isNotEmpty(firstName)) { paramList = paramList + "&firstName=" + firstName; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+firstName+"%"))); } // filter on lastName - if (lastName != null && lastName.length() > 0) { + if (UtilValidate.isNotEmpty(lastName)) { paramList = paramList + "&lastName=" + lastName; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+lastName+"%"))); } @@ -1288,21 +1288,21 @@ public class PartyServices { // filter on address1 String address1 = (String) context.get("address1"); - if (address1 != null && address1.length() > 0) { + if (UtilValidate.isNotEmpty(address1)) { paramList = paramList + "&address1=" + address1; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address1"), EntityOperator.LIKE, EntityFunction.UPPER("%" + address1 + "%"))); } // filter on address2 String address2 = (String) context.get("address2"); - if (address2 != null && address2.length() > 0) { + if (UtilValidate.isNotEmpty(address2)) { paramList = paramList + "&address2=" + address2; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address2"), EntityOperator.LIKE, EntityFunction.UPPER("%" + address2 + "%"))); } // filter on city String city = (String) context.get("city"); - if (city != null && city.length() > 0) { + if (UtilValidate.isNotEmpty(city)) { paramList = paramList + "&city=" + city; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("city"), EntityOperator.LIKE, EntityFunction.UPPER("%" + city + "%"))); } @@ -1315,7 +1315,7 @@ public class PartyServices { // filter on postal code String postalCode = (String) context.get("postalCode"); - if (postalCode != null && postalCode.length() > 0) { + if (UtilValidate.isNotEmpty(postalCode)) { paramList = paramList + "&postalCode=" + postalCode; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("postalCode"), EntityOperator.LIKE, EntityFunction.UPPER("%" + postalCode + "%"))); } @@ -1339,7 +1339,7 @@ public class PartyServices { // filter on infoString String infoString = (String) context.get("infoString"); - if (infoString != null && infoString.length() > 0) { + if (UtilValidate.isNotEmpty(infoString)) { paramList = paramList + "&infoString=" + infoString; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER("%"+infoString+"%"))); fieldsToSelect.add("infoString"); @@ -1363,21 +1363,21 @@ public class PartyServices { // filter on countryCode String countryCode = (String) context.get("countryCode"); - if (countryCode != null && countryCode.length() > 0) { + if (UtilValidate.isNotEmpty(countryCode)) { paramList = paramList + "&countryCode=" + countryCode; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("countryCode"), EntityOperator.EQUALS, EntityFunction.UPPER(countryCode))); } // filter on areaCode String areaCode = (String) context.get("areaCode"); - if (areaCode != null && areaCode.length() > 0) { + if (UtilValidate.isNotEmpty(areaCode)) { paramList = paramList + "&areaCode=" + areaCode; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("areaCode"), EntityOperator.EQUALS, EntityFunction.UPPER(areaCode))); } // filter on contact number String contactNumber = (String) context.get("contactNumber"); - if (contactNumber != null && contactNumber.length() > 0) { + if (UtilValidate.isNotEmpty(contactNumber)) { paramList = paramList + "&contactNumber=" + contactNumber; andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactNumber"), EntityOperator.EQUALS, EntityFunction.UPPER(contactNumber))); } diff --git a/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java b/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java index 267d2b6bf0..4910ea380e 100644 --- a/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java +++ b/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java @@ -156,7 +156,7 @@ public class CatalogWorker { // get it from the database if (prodCatalogId == null) { List catalogIds = getCatalogIdsAvailable(request); - if (catalogIds != null && catalogIds.size() > 0) prodCatalogId = catalogIds.get(0); + if (UtilValidate.isNotEmpty(catalogIds)) prodCatalogId = catalogIds.get(0); } if (!fromSession) { diff --git a/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java b/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java index d18dafe865..79c0c2e45e 100644 --- a/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java +++ b/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java @@ -168,7 +168,7 @@ public class ParametricSearch { if (parameterName.startsWith("pft_")) { String productFeatureTypeId = parameterName.substring(4); String productFeatureId = (String) entry.getValue(); - if (productFeatureId != null && productFeatureId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureId)) { featureIdByType.put(productFeatureTypeId, productFeatureId); } } @@ -186,7 +186,7 @@ public class ParametricSearch { String parameterName = entry.getKey(); if (parameterName.startsWith("SEARCH_FEAT")) { String productFeatureId = (String) entry.getValue(); - if (productFeatureId != null && productFeatureId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureId)) { featureIdList.add(productFeatureId); } } @@ -228,7 +228,7 @@ public class ParametricSearch { String parameterName = entry.getKey(); if (parameterName.startsWith("SEARCH_PROD_FEAT_CAT")) { String productFeatureCategoryId = (String) entry.getValue(); - if (productFeatureCategoryId != null && productFeatureCategoryId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureCategoryId)) { prodFeatureCategoryIdList.add(productFeatureCategoryId); } } diff --git a/applications/product/src/org/ofbiz/product/product/ProductSearch.java b/applications/product/src/org/ofbiz/product/product/ProductSearch.java index 39d5290b56..f88e75ba7d 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductSearch.java +++ b/applications/product/src/org/ofbiz/product/product/ProductSearch.java @@ -2113,7 +2113,7 @@ public class ProductSearch { boolean productIdGroupBy = false; // Category - if (productCategoryId != null && productCategoryId.length() > 0) { + if (UtilValidate.isNotEmpty(productCategoryId)) { List productCategoryIdList = null; if (includeSubCategories) { // find all sub-categories recursively, make a Set of productCategoryId diff --git a/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java b/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java index 8f983fb05f..87bef7353c 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java +++ b/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java @@ -630,7 +630,7 @@ public class ProductSearchSession { for (String parameterName: parameters.keySet()) { if (parameterName.startsWith("SEARCH_FEAT") && !parameterName.startsWith("SEARCH_FEAT_EXC")) { String productFeatureId = (String) parameters.get(parameterName); - if (productFeatureId != null && productFeatureId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureId)) { String paramNameExt = parameterName.substring("SEARCH_FEAT".length()); String searchCategoryExc = (String) parameters.get("SEARCH_FEAT_EXC" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchCategoryExc) ? null : Boolean.valueOf(!"N".equals(searchCategoryExc)); @@ -642,7 +642,7 @@ public class ProductSearchSession { // a shorter feature variation if (parameterName.startsWith("S_PFI")) { String productFeatureId = (String) parameters.get(parameterName); - if (productFeatureId != null && productFeatureId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureId)) { String paramNameExt = parameterName.substring("S_PFI".length()); String searchCategoryExc = (String) parameters.get("S_PFX" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchCategoryExc) ? null : Boolean.valueOf(!"N".equals(searchCategoryExc)); @@ -655,7 +655,7 @@ public class ProductSearchSession { //if product features category were selected add a constraint for each if (parameterName.startsWith("SEARCH_PROD_FEAT_CAT") && !parameterName.startsWith("SEARCH_PROD_FEAT_CAT_EXC")) { String productFeatureCategoryId = (String) parameters.get(parameterName); - if (productFeatureCategoryId != null && productFeatureCategoryId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureCategoryId)) { String paramNameExt = parameterName.substring("SEARCH_PROD_FEAT_CAT".length()); String searchProdFeatureCategoryExc = (String) parameters.get("SEARCH_PROD_FEAT_CAT_EXC" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchProdFeatureCategoryExc) ? null : Boolean.valueOf(!"N".equals(searchProdFeatureCategoryExc)); @@ -666,7 +666,7 @@ public class ProductSearchSession { // a shorter variation for feature category if (parameterName.startsWith("S_FCI")) { String productFeatureCategoryId = (String) parameters.get(parameterName); - if (productFeatureCategoryId != null && productFeatureCategoryId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureCategoryId)) { String paramNameExt = parameterName.substring("S_FCI".length()); String searchProdFeatureCategoryExc = (String) parameters.get("S_FCX" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchProdFeatureCategoryExc) ? null : Boolean.valueOf(!"N".equals(searchProdFeatureCategoryExc)); @@ -678,7 +678,7 @@ public class ProductSearchSession { //if product features group were selected add a constraint for each if (parameterName.startsWith("SEARCH_PROD_FEAT_GRP") && !parameterName.startsWith("SEARCH_PROD_FEAT_GRP_EXC")) { String productFeatureGroupId = (String) parameters.get(parameterName); - if (productFeatureGroupId != null && productFeatureGroupId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureGroupId)) { String paramNameExt = parameterName.substring("SEARCH_PROD_FEAT_GRP".length()); String searchProdFeatureGroupExc = (String) parameters.get("SEARCH_PROD_FEAT_GRP_EXC" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchProdFeatureGroupExc) ? null : Boolean.valueOf(!"N".equals(searchProdFeatureGroupExc)); @@ -689,7 +689,7 @@ public class ProductSearchSession { // a shorter variation for feature group if (parameterName.startsWith("S_FGI")) { String productFeatureGroupId = (String) parameters.get(parameterName); - if (productFeatureGroupId != null && productFeatureGroupId.length() > 0) { + if (UtilValidate.isNotEmpty(productFeatureGroupId)) { String paramNameExt = parameterName.substring("S_FGI".length()); String searchProdFeatureGroupExc = (String) parameters.get("S_FGX" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchProdFeatureGroupExc) ? null : Boolean.valueOf(!"N".equals(searchProdFeatureGroupExc)); diff --git a/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java b/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java index 11a6b52a33..6df2528365 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java +++ b/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java @@ -671,7 +671,7 @@ while (allCatIter.hasNext()) { while ((productFeatureAndAppl = (GenericValue) productFeatureAndApplEli.next()) != null) { String productFeatureId = productFeatureAndAppl.getString("productFeatureId"); String productFeatureTypeId = productFeatureAndAppl.getString("productFeatureTypeId"); - if (productFeatureTypeIdsToInclude != null && productFeatureTypeIdsToInclude.size() > 0 && !productFeatureTypeIdsToInclude.contains(productFeatureTypeId)) { + if (UtilValidate.isNotEmpty(productFeatureTypeIdsToInclude) && !productFeatureTypeIdsToInclude.contains(productFeatureTypeId)) { continue; } if (productFeatureTypeIdsToExclude != null && productFeatureTypeIdsToExclude.contains(productFeatureTypeId)) { diff --git a/applications/product/src/org/ofbiz/product/product/ProductWorker.java b/applications/product/src/org/ofbiz/product/product/ProductWorker.java index 3b97212b85..c88b9342b9 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductWorker.java +++ b/applications/product/src/org/ofbiz/product/product/ProductWorker.java @@ -322,13 +322,13 @@ public class ProductWorker { obsolescenceProducts = EntityUtil.filterByDate(obsolescenceProducts); obsoleteByProducts = EntityUtil.filterByDate(obsoleteByProducts); - if (upgradeProducts != null && upgradeProducts.size() > 0) + if (UtilValidate.isNotEmpty(upgradeProducts)) pageContext.setAttribute(assocPrefix + "upgrade", upgradeProducts); - if (complementProducts != null && complementProducts.size() > 0) + if (UtilValidate.isNotEmpty(complementProducts)) pageContext.setAttribute(assocPrefix + "complement", complementProducts); - if (obsolescenceProducts != null && obsolescenceProducts.size() > 0) + if (UtilValidate.isNotEmpty(obsolescenceProducts)) pageContext.setAttribute(assocPrefix + "obsolescence", obsolescenceProducts); - if (obsoleteByProducts != null && obsoleteByProducts.size() > 0) + if (UtilValidate.isNotEmpty(obsoleteByProducts)) pageContext.setAttribute(assocPrefix + "obsoleteby", obsoleteByProducts); } catch (GenericEntityException e) { Debug.logWarning(e, module); diff --git a/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java b/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java index a80535cd44..9cd122b62f 100644 --- a/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java +++ b/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java @@ -35,6 +35,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -65,7 +66,7 @@ public class ImportProductServices { String path = System.getProperty("user.dir") + "/spreadsheet"; List fileItems = FastList.newInstance(); - if (path != null && path.length() > 0) { + if (UtilValidate.isNotEmpty(path)) { File importDir = new File(path); if (importDir.isDirectory() && importDir.canRead()) { File[] files = importDir.listFiles(); diff --git a/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java b/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java index 11a8b14f1d..0b768e3ca4 100644 --- a/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java +++ b/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java @@ -343,14 +343,14 @@ public class ProductStoreWorker { // check the geos String includeGeoId = method.getString("includeGeoId"); String excludeGeoId = method.getString("excludeGeoId"); - if ((includeGeoId != null && includeGeoId.length() > 0) || (excludeGeoId != null && excludeGeoId.length() > 0)) { + if (UtilValidate.isNotEmpty(includeGeoId) || UtilValidate.isNotEmpty(excludeGeoId)) { if (shippingAddress == null) { returnShippingMethods.remove(method); //Debug.logInfo("Removed shipping method due to empty shipping adresss (may not have been selected yet)", module); continue; } } - if (includeGeoId != null && includeGeoId.length() > 0) { + if (UtilValidate.isNotEmpty(includeGeoId)) { List includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator); if (!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) && !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) && @@ -361,7 +361,7 @@ public class ProductStoreWorker { continue; } } - if (excludeGeoId != null && excludeGeoId.length() > 0) { + if (UtilValidate.isNotEmpty(excludeGeoId)) { List excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator); if (GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) || GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) || @@ -376,7 +376,7 @@ public class ProductStoreWorker { // check the features String includeFeatures = method.getString("includeFeatureGroup"); String excludeFeatures = method.getString("excludeFeatureGroup"); - if (includeFeatures != null && includeFeatures.length() > 0) { + if (UtilValidate.isNotEmpty(includeFeatures)) { List includedFeatures = null; try { includedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", includeFeatures)); @@ -398,7 +398,7 @@ public class ProductStoreWorker { } } } - if (excludeFeatures != null && excludeFeatures.length() > 0) { + if (UtilValidate.isNotEmpty(excludeFeatures)) { List excludedFeatures = null; try { excludedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", excludeFeatures)); diff --git a/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java b/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java index 822e77945a..e288f34c41 100644 --- a/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java +++ b/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java @@ -527,7 +527,7 @@ public class ShipmentServices { featurePrice = BigDecimal.ZERO; } - if (featureGroupId != null && featureGroupId.length() > 0 && shippableFeatureMap != null) { + if (UtilValidate.isNotEmpty(featureGroupId) && shippableFeatureMap != null) { for (Map.Entry entry: shippableFeatureMap.entrySet()) { String featureId = entry.getKey(); BigDecimal quantity = entry.getValue(); diff --git a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java index 59dfb4f393..87cc544726 100644 --- a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java +++ b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/ICalConverter.java @@ -692,7 +692,7 @@ public class ICalConverter { } boolean hasCreatePermission = hasPermission(workEffortId, "CREATE", context); List workEfforts = getRelatedWorkEfforts(publishProperties, context); - if (workEfforts != null && workEfforts.size() > 0) { + if (UtilValidate.isNotEmpty(workEfforts)) { // Security issue: make sure only related work efforts get updated Set validWorkEfforts = FastSet.newInstance(); for (GenericValue workEffort : workEfforts) { diff --git a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java index 560383b40f..e79ee15c38 100644 --- a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java +++ b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java @@ -308,7 +308,7 @@ public class WorkEffortServices { String statusId = (String) context.get("currentStatusId"); - if (statusId != null && statusId.length() > 0) { + if (UtilValidate.isNotEmpty(statusId)) { try { currentStatus = delegator.findByPrimaryKeyCache("StatusItem", UtilMisc.toMap("statusId", statusId)); } catch (GenericEntityException e) { @@ -324,7 +324,7 @@ public class WorkEffortServices { Debug.logWarning(e, module); } } - canView = (workEffortPartyAssignments != null && workEffortPartyAssignments.size() > 0) ? Boolean.TRUE : Boolean.FALSE; + canView = (UtilValidate.isNotEmpty(workEffortPartyAssignments)) ? Boolean.TRUE : Boolean.FALSE; if (!canView.booleanValue() && security.hasEntityPermission("WORKEFFORTMGR", "_VIEW", userLogin)) { canView = Boolean.TRUE; } diff --git a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java index 0ea2292570..14337f694c 100644 --- a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java +++ b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortWorker.java @@ -82,7 +82,7 @@ public class WorkEffortWorker { String statusId = pageContext.getRequest().getParameter("currentStatusId"); - if (statusId != null && statusId.length() > 0) { + if (UtilValidate.isNotEmpty(statusId)) { try { currentStatus = delegator.findByPrimaryKeyCache("StatusItem", UtilMisc.toMap("statusId", statusId)); } catch (GenericEntityException e) { @@ -99,7 +99,7 @@ public class WorkEffortWorker { Debug.logWarning(e, module); } } - canView = (workEffortPartyAssignments != null && workEffortPartyAssignments.size() > 0) ? Boolean.TRUE : Boolean.FALSE; + canView = (UtilValidate.isNotEmpty(workEffortPartyAssignments)) ? Boolean.TRUE : Boolean.FALSE; if (!canView.booleanValue() && security.hasEntityPermission("WORKEFFORTMGR", "_VIEW", pageContext.getSession())) { canView = Boolean.TRUE; } diff --git a/framework/base/src/org/ofbiz/base/component/ComponentConfig.java b/framework/base/src/org/ofbiz/base/component/ComponentConfig.java index fd232620c9..0574136d5e 100644 --- a/framework/base/src/org/ofbiz/base/component/ComponentConfig.java +++ b/framework/base/src/org/ofbiz/base/component/ComponentConfig.java @@ -492,7 +492,7 @@ public class ComponentConfig { buf.append(rootLocation); } - if (resourceLoaderInfo.prependEnv != null && resourceLoaderInfo.prependEnv.length() > 0) { + if (UtilValidate.isNotEmpty(resourceLoaderInfo.prependEnv)) { String propValue = System.getProperty(resourceLoaderInfo.prependEnv); if (propValue == null) { String errMsg = "The Java environment (-Dxxx=yyy) variable with name " + resourceLoaderInfo.prependEnv + " is not set, cannot load resource."; @@ -501,7 +501,7 @@ public class ComponentConfig { } buf.append(propValue); } - if (resourceLoaderInfo.prefix != null && resourceLoaderInfo.prefix.length() > 0) { + if (UtilValidate.isNotEmpty(resourceLoaderInfo.prefix)) { buf.append(resourceLoaderInfo.prefix); } buf.append(location); diff --git a/framework/base/src/org/ofbiz/base/config/ResourceLoader.java b/framework/base/src/org/ofbiz/base/config/ResourceLoader.java index 19392fbaca..244cff83e5 100644 --- a/framework/base/src/org/ofbiz/base/config/ResourceLoader.java +++ b/framework/base/src/org/ofbiz/base/config/ResourceLoader.java @@ -23,6 +23,7 @@ import java.net.URL; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilURL; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.cache.UtilCache; import org.w3c.dom.Document; @@ -136,7 +137,7 @@ public abstract class ResourceLoader { try { Class lClass = null; - if (className != null && className.length() > 0) { + if (UtilValidate.isNotEmpty(className)) { try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); lClass = classLoader.loadClass(className); @@ -179,7 +180,7 @@ public abstract class ResourceLoader { public String fullLocation(String location) { StringBuilder buf = new StringBuilder(); - if (envName != null && envName.length() > 0) { + if (UtilValidate.isNotEmpty(envName)) { String propValue = System.getProperty(envName); if (propValue == null) { String errMsg = "The Java environment (-Dxxx=yyy) variable with name " + envName + " is not set, cannot load resource."; @@ -188,7 +189,7 @@ public abstract class ResourceLoader { } buf.append(propValue); } - if (prefix != null && prefix.length() > 0) { + if (UtilValidate.isNotEmpty(prefix)) { buf.append(prefix); } buf.append(location); diff --git a/framework/base/src/org/ofbiz/base/util/Debug.java b/framework/base/src/org/ofbiz/base/util/Debug.java index 4116924c4e..034f2b3941 100644 --- a/framework/base/src/org/ofbiz/base/util/Debug.java +++ b/framework/base/src/org/ofbiz/base/util/Debug.java @@ -122,7 +122,7 @@ public final class Debug { } public static Logger getLogger(String module) { - if (module != null && module.length() > 0) { + if (UtilValidate.isNotEmpty(module)) { return Logger.getLogger(module); } else { return root; diff --git a/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java b/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java index a8a85f4743..36f1771e99 100644 --- a/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java +++ b/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java @@ -62,12 +62,12 @@ public class JNDIContextFactory { h.put(Context.INITIAL_CONTEXT_FACTORY, jndiServerInfo.initialContextFactory); h.put(Context.PROVIDER_URL, jndiServerInfo.contextProviderUrl); - if (jndiServerInfo.urlPkgPrefixes != null && jndiServerInfo.urlPkgPrefixes.length() > 0) + if (UtilValidate.isNotEmpty(jndiServerInfo.urlPkgPrefixes)) h.put(Context.URL_PKG_PREFIXES, jndiServerInfo.urlPkgPrefixes); - if (jndiServerInfo.securityPrincipal != null && jndiServerInfo.securityPrincipal.length() > 0) + if (UtilValidate.isNotEmpty(jndiServerInfo.securityPrincipal)) h.put(Context.SECURITY_PRINCIPAL, jndiServerInfo.securityPrincipal); - if (jndiServerInfo.securityCredentials != null && jndiServerInfo.securityCredentials.length() > 0) + if (UtilValidate.isNotEmpty(jndiServerInfo.securityCredentials)) h.put(Context.SECURITY_CREDENTIALS, jndiServerInfo.securityCredentials); ic = new InitialContext(h); diff --git a/framework/base/src/org/ofbiz/base/util/MessageString.java b/framework/base/src/org/ofbiz/base/util/MessageString.java index 6a0fea2191..26eef1e6b0 100644 --- a/framework/base/src/org/ofbiz/base/util/MessageString.java +++ b/framework/base/src/org/ofbiz/base/util/MessageString.java @@ -54,10 +54,10 @@ public class MessageString implements Serializable { } public static List getMessagesForField(String fieldName1, String fieldName2, String fieldName3, String fieldName4, boolean convertToStrings, List messageStringList) { Set fieldSet = new TreeSet(); - if (fieldName1 != null && fieldName1.length() > 0) fieldSet.add(fieldName1); - if (fieldName2 != null && fieldName2.length() > 0) fieldSet.add(fieldName2); - if (fieldName3 != null && fieldName3.length() > 0) fieldSet.add(fieldName3); - if (fieldName4 != null && fieldName4.length() > 0) fieldSet.add(fieldName4); + if (UtilValidate.isNotEmpty(fieldName1)) fieldSet.add(fieldName1); + if (UtilValidate.isNotEmpty(fieldName2)) fieldSet.add(fieldName2); + if (UtilValidate.isNotEmpty(fieldName3)) fieldSet.add(fieldName3); + if (UtilValidate.isNotEmpty(fieldName4)) fieldSet.add(fieldName4); return getMessagesForField(fieldSet, convertToStrings, messageStringList); } public static List getMessagesForField(Set fieldNameSet, boolean convertToStrings, List messageStringList) { diff --git a/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java b/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java index 6d1e727de7..a794b7dcf8 100644 --- a/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java +++ b/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java @@ -174,7 +174,7 @@ public class OfbizBshBsfEngine extends BSFEngineImpl { Interpreter.ParsedScript script = null; - if (source != null && source.length() > 0) { + if (UtilValidate.isNotEmpty(source)) { script = parsedScripts.get(source); if (script == null) { synchronized (OfbizBshBsfEngine.class) { diff --git a/framework/base/src/org/ofbiz/base/util/UtilDateTime.java b/framework/base/src/org/ofbiz/base/util/UtilDateTime.java index 859ae49d5a..9c1ff309e8 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilDateTime.java +++ b/framework/base/src/org/ofbiz/base/util/UtilDateTime.java @@ -1055,7 +1055,7 @@ public class UtilDateTime { availableTimeZoneList = new LinkedList(); List idList = null; String tzString = UtilProperties.getPropertyValue("general", "timeZones.available"); - if (tzString != null && tzString.length() > 0) { + if (UtilValidate.isNotEmpty(tzString)) { idList = StringUtil.split(tzString, ","); } else { idList = Arrays.asList(TimeZone.getAvailableIDs()); diff --git a/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java b/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java index 6464bf0f2c..e51239226b 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java +++ b/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java @@ -383,7 +383,7 @@ public class UtilFormatOut { * @return pre + base + post if base String is not null or empty, otherwise an empty but non-null String. */ public static String ifNotEmpty(String base, String pre, String post) { - if (base != null && base.length() > 0) + if (UtilValidate.isNotEmpty(base)) return pre + base + post; else return ""; @@ -395,9 +395,9 @@ public class UtilFormatOut { * @return The first passed String if not empty, otherwise the second if not empty, otherwise an empty but non-null String */ public static String checkEmpty(String string1, String string2) { - if (string1 != null && string1.length() > 0) + if (UtilValidate.isNotEmpty(string1)) return string1; - else if (string2 != null && string2.length() > 0) + else if (UtilValidate.isNotEmpty(string2)) return string2; else return ""; @@ -410,11 +410,11 @@ public class UtilFormatOut { * @return The first passed String if not empty, otherwise the second if not empty, otherwise the third if not empty, otherwise an empty but non-null String */ public static String checkEmpty(String string1, String string2, String string3) { - if (string1 != null && string1.length() > 0) + if (UtilValidate.isNotEmpty(string1)) return string1; - else if (string2 != null && string2.length() > 0) + else if (UtilValidate.isNotEmpty(string2)) return string2; - else if (string3 != null && string3.length() > 0) + else if (UtilValidate.isNotEmpty(string3)) return string3; else return ""; diff --git a/framework/base/src/org/ofbiz/base/util/UtilHttp.java b/framework/base/src/org/ofbiz/base/util/UtilHttp.java index 172f6ce49a..85833b5af2 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilHttp.java +++ b/framework/base/src/org/ofbiz/base/util/UtilHttp.java @@ -183,7 +183,7 @@ public class UtilHttp { // note that if a parameter with a given name already exists it will be put into a list with all values String pathInfoStr = request.getPathInfo(); - if (pathInfoStr != null && pathInfoStr.length() > 0) { + if (UtilValidate.isNotEmpty(pathInfoStr)) { // make sure string ends with a trailing '/' so we get all values if (!pathInfoStr.endsWith("/")) pathInfoStr += "/"; @@ -393,7 +393,7 @@ public class UtilHttp { for (Map.Entry entry: context.entrySet()) { String parameterName = entry.getKey(); if (parameterName.startsWith(prefix)) { - if (suffix != null && suffix.length() > 0) { + if (UtilValidate.isNotEmpty(suffix)) { if (parameterName.endsWith(suffix)) { String key = parameterName.substring(prefix.length(), parameterName.length() - (suffix.length())); if (entry.getValue() instanceof ByteBuffer) { @@ -420,7 +420,7 @@ public class UtilHttp { for (Map.Entry entry: additionalFields.entrySet()) { String fieldName = entry.getKey(); if (fieldName.startsWith(prefix)) { - if (suffix != null && suffix.length() > 0) { + if (UtilValidate.isNotEmpty(suffix)) { if (fieldName.endsWith(suffix)) { String key = fieldName.substring(prefix.length(), fieldName.length() - (suffix.length() - 1)); Object value = entry.getValue(); @@ -489,7 +489,7 @@ public class UtilHttp { while (parameterNames.hasMoreElements()) { String parameterName = parameterNames.nextElement(); if (parameterName.endsWith(suffix)) { - if (prefix != null && prefix.length() > 0) { + if (UtilValidate.isNotEmpty(prefix)) { if (parameterName.startsWith(prefix)) { String value = request.getParameter(parameterName); paramList.add(value); @@ -504,7 +504,7 @@ public class UtilHttp { for (Map.Entry entry: additionalFields.entrySet()) { String fieldName = entry.getKey(); if (fieldName.endsWith(suffix)) { - if (prefix != null && prefix.length() > 0) { + if (UtilValidate.isNotEmpty(prefix)) { if (fieldName.startsWith(prefix)) { paramList.add(entry.getValue()); } @@ -753,7 +753,7 @@ public class UtilHttp { valueStr = value.toString(); } - if (valueStr != null && valueStr.length() > 0) { + if (UtilValidate.isNotEmpty(valueStr)) { if (buf.length() > 0) { if (useExpandedEntites) { buf.append("&"); diff --git a/framework/base/src/org/ofbiz/base/util/UtilMisc.java b/framework/base/src/org/ofbiz/base/util/UtilMisc.java index 36a43627e2..26c7b07654 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilMisc.java +++ b/framework/base/src/org/ofbiz/base/util/UtilMisc.java @@ -737,7 +737,7 @@ public class UtilMisc { if (availableLocaleList == null) { TreeMap localeMap = new TreeMap(); String localesString = UtilProperties.getPropertyValue("general", "locales.available"); - if (localesString != null && localesString.length() > 0) { // check if available locales need to be limited according general.properties file + if (UtilValidate.isNotEmpty(localesString)) { // check if available locales need to be limited according general.properties file int end = -1; int start = 0; for (int i=0; start < localesString.length(); i++) { diff --git a/framework/base/src/org/ofbiz/base/util/UtilXml.java b/framework/base/src/org/ofbiz/base/util/UtilXml.java index d740db722a..d3a7b7b08e 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilXml.java +++ b/framework/base/src/org/ofbiz/base/util/UtilXml.java @@ -865,27 +865,27 @@ public class UtilXml { } public static String checkEmpty(String string) { - if (string != null && string.length() > 0) + if (UtilValidate.isNotEmpty(string)) return string; else return ""; } public static String checkEmpty(String string1, String string2) { - if (string1 != null && string1.length() > 0) + if (UtilValidate.isNotEmpty(string1)) return string1; - else if (string2 != null && string2.length() > 0) + else if (UtilValidate.isNotEmpty(string2)) return string2; else return ""; } public static String checkEmpty(String string1, String string2, String string3) { - if (string1 != null && string1.length() > 0) + if (UtilValidate.isNotEmpty(string1)) return string1; - else if (string2 != null && string2.length() > 0) + else if (UtilValidate.isNotEmpty(string2)) return string2; - else if (string3 != null && string3.length() > 0) + else if (UtilValidate.isNotEmpty(string3)) return string3; else return ""; diff --git a/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java b/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java index 5dd90bbdb4..6cec4a3fde 100644 --- a/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java +++ b/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java @@ -51,7 +51,7 @@ public class FlexibleMapAccessor implements Serializable { this.original = name; FlexibleStringExpander fse = null; String bracketedOriginal = null; - if (name != null && name.length() > 0) { + if (UtilValidate.isNotEmpty(name)) { if (name.charAt(0) == '-') { this.isAscending = false; name = name.substring(1); diff --git a/framework/common/src/org/ofbiz/common/CommonWorkers.java b/framework/common/src/org/ofbiz/common/CommonWorkers.java index 065b86f2b7..98a0a025ab 100644 --- a/framework/common/src/org/ofbiz/common/CommonWorkers.java +++ b/framework/common/src/org/ofbiz/common/CommonWorkers.java @@ -46,7 +46,7 @@ public class CommonWorkers { List geoList = FastList.newInstance(); String defaultCountry = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default"); GenericValue defaultGeo = null; - if (defaultCountry != null && defaultCountry.length() > 0) { + if (UtilValidate.isNotEmpty(defaultCountry)) { try { defaultGeo = delegator.findOne("Geo", UtilMisc.toMap("geoId", defaultCountry), true); } catch (GenericEntityException e) { diff --git a/framework/common/src/org/ofbiz/common/FindServices.java b/framework/common/src/org/ofbiz/common/FindServices.java index c1fc4027f9..ac72e933f2 100644 --- a/framework/common/src/org/ofbiz/common/FindServices.java +++ b/framework/common/src/org/ofbiz/common/FindServices.java @@ -699,7 +699,7 @@ public class FindServices { try { EntityListIterator it = (EntityListIterator) result.get("listIt"); list = it.getPartialList(1, 1); // list starts at '1' - if (list != null && list.size() > 0) { + if (UtilValidate.isNotEmpty(list)) { item = list.get(0); } it.close(); diff --git a/framework/common/src/org/ofbiz/common/login/LoginServices.java b/framework/common/src/org/ofbiz/common/login/LoginServices.java index d2827aa9fd..e9f03e4858 100644 --- a/framework/common/src/org/ofbiz/common/login/LoginServices.java +++ b/framework/common/src/org/ofbiz/common/login/LoginServices.java @@ -497,7 +497,7 @@ public class LoginServices { // security: don't create a user login if the specified partyId (if not empty) already exists // unless the logged in user has permission to do so (same partyId or PARTYMGR_CREATE) - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { GenericValue party = null; try { @@ -724,7 +724,7 @@ public class LoginServices { // security: don't create a user login if the specified partyId (if not empty) already exists // unless the logged in user has permission to do so (same partyId or PARTYMGR_CREATE) - if (partyId != null && partyId.length() > 0) { + if (UtilValidate.isNotEmpty(partyId)) { //GenericValue party = null; //try { // party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId)); diff --git a/framework/datafile/src/org/ofbiz/datafile/DataFile2EntityXml.java b/framework/datafile/src/org/ofbiz/datafile/DataFile2EntityXml.java index 8120046d52..491fcfa336 100644 --- a/framework/datafile/src/org/ofbiz/datafile/DataFile2EntityXml.java +++ b/framework/datafile/src/org/ofbiz/datafile/DataFile2EntityXml.java @@ -29,6 +29,7 @@ import java.net.URL; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilURL; +import org.ofbiz.base.util.UtilValidate; public class DataFile2EntityXml { @@ -112,7 +113,7 @@ public class DataFile2EntityXml { //} DataFile dataFile = null; - if (dataFileUrl != null && definitionUrl != null && definitionName != null && definitionName.length() > 0) { + if (dataFileUrl != null && definitionUrl != null && UtilValidate.isNotEmpty(definitionName)) { try { dataFile = DataFile.readFile(dataFileUrl, definitionUrl, definitionName); } catch (Exception e) { diff --git a/framework/datafile/src/org/ofbiz/datafile/ModelDataFileReader.java b/framework/datafile/src/org/ofbiz/datafile/ModelDataFileReader.java index f4e7561255..c0790a5937 100644 --- a/framework/datafile/src/org/ofbiz/datafile/ModelDataFileReader.java +++ b/framework/datafile/src/org/ofbiz/datafile/ModelDataFileReader.java @@ -195,7 +195,7 @@ public class ModelDataFileReader { dataFile.receiver = UtilXml.checkEmpty(dataFileElement.getAttribute("receiver")); tempStr = UtilXml.checkEmpty(dataFileElement.getAttribute("record-length")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { dataFile.recordLength = Integer.parseInt(tempStr); } tempStr = UtilXml.checkEmpty(dataFileElement.getAttribute("delimiter")); @@ -204,7 +204,7 @@ public class ModelDataFileReader { } tempStr = UtilXml.checkEmpty(dataFileElement.getAttribute("text-delimiter")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { dataFile.textDelimiter = tempStr; } @@ -254,16 +254,16 @@ public class ModelDataFileReader { if (record.tcMax.length() > 0) record.tcMaxNum = Long.parseLong(record.tcMax); tempStr = UtilXml.checkEmpty(recordElement.getAttribute("tc-isnum")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { record.tcIsNum = Boolean.parseBoolean(tempStr); } tempStr = UtilXml.checkEmpty(recordElement.getAttribute("tc-position")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { record.tcPosition = Integer.parseInt(tempStr); } tempStr = UtilXml.checkEmpty(recordElement.getAttribute("tc-length")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { record.tcLength = Integer.parseInt(tempStr); } @@ -301,11 +301,11 @@ public class ModelDataFileReader { field.name = UtilXml.checkEmpty(fieldElement.getAttribute("name")); tempStr = UtilXml.checkEmpty(fieldElement.getAttribute("position")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { field.position = Integer.parseInt(tempStr); } tempStr = UtilXml.checkEmpty(fieldElement.getAttribute("length")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { field.length = Integer.parseInt(tempStr); } @@ -317,17 +317,17 @@ public class ModelDataFileReader { field.refField = UtilXml.checkEmpty(fieldElement.getAttribute("ref-field")); tempStr = UtilXml.checkEmpty(fieldElement.getAttribute("prim-key")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { field.isPk = Boolean.parseBoolean(tempStr); } tempStr = UtilXml.checkEmpty(fieldElement.getAttribute("ignored")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { field.ignored = Boolean.parseBoolean(tempStr); } tempStr = UtilXml.checkEmpty(fieldElement.getAttribute("expression")); - if (tempStr != null && tempStr.length() > 0) { + if (UtilValidate.isNotEmpty(tempStr)) { field.expression = Boolean.parseBoolean(tempStr); } diff --git a/framework/datafile/src/org/ofbiz/datafile/Record.java b/framework/datafile/src/org/ofbiz/datafile/Record.java index e835cde4ad..db31337073 100644 --- a/framework/datafile/src/org/ofbiz/datafile/Record.java +++ b/framework/datafile/src/org/ofbiz/datafile/Record.java @@ -31,6 +31,7 @@ import java.util.NoSuchElementException; import java.util.StringTokenizer; import org.ofbiz.base.crypto.HashCrypt; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.common.login.LoginServices; /** @@ -553,7 +554,7 @@ public class Record implements Serializable { String strVal = null; if (modelField.expression) { - if (modelField.refField != null && modelField.refField.length() > 0) { + if (UtilValidate.isNotEmpty(modelField.refField)) { strVal = record.getString(modelField.refField); } if (strVal == null) { diff --git a/framework/entity/src/org/ofbiz/entity/GenericDelegator.java b/framework/entity/src/org/ofbiz/entity/GenericDelegator.java index e03222cfa2..d696745c60 100644 --- a/framework/entity/src/org/ofbiz/entity/GenericDelegator.java +++ b/framework/entity/src/org/ofbiz/entity/GenericDelegator.java @@ -246,7 +246,7 @@ public class GenericDelegator implements Delegator { if (Debug.infoOn()) Debug.logInfo("Delegator \"" + delegatorName + "\" initializing helper \"" + helperName + "\" for entity group \"" + groupName + "\".", module); TreeSet helpersDone = new TreeSet(); - if (helperName != null && helperName.length() > 0) { + if (UtilValidate.isNotEmpty(helperName)) { // make sure each helper is only loaded once if (helpersDone.contains(helperName)) { if (Debug.infoOn()) Debug.logInfo("Helper \"" + helperName + "\" already initialized, not re-initializing.", module); @@ -461,7 +461,7 @@ public class GenericDelegator implements Delegator { public GenericHelper getEntityHelper(String entityName) throws GenericEntityException { String helperName = getEntityHelperName(entityName); - if (helperName != null && helperName.length() > 0) { + if (UtilValidate.isNotEmpty(helperName)) { return GenericHelperFactory.getHelper(helperName); } else { throw new GenericEntityException("There is no datasource (Helper) configured for the entity-group [" + this.getEntityGroupName(entityName) + "]; was trying to find datesource (helper) for entity [" + entityName + "]"); @@ -2762,7 +2762,7 @@ public class GenericDelegator implements Delegator { String name = modelField.getName(); String attr = element.getAttribute(name); - if (attr != null && attr.length() > 0) { + if (UtilValidate.isNotEmpty(attr)) { value.setString(name, attr); } else { // if no attribute try a subelement diff --git a/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java b/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java index 4213faf3bb..e5763def5a 100644 --- a/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java @@ -26,6 +26,7 @@ import org.apache.commons.dbcp.managed.ManagedDataSource; import org.apache.commons.dbcp.managed.XAConnectionFactory; import org.apache.commons.pool.impl.GenericObjectPool; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.transaction.TransactionFactory; import org.w3c.dom.Element; @@ -135,7 +136,7 @@ public class DBCPConnectionFactory implements ConnectionFactoryInterface { factory.setDefaultReadOnly(false); String transIso = jdbcElement.getAttribute("isolation-level"); - if (transIso != null && transIso.length() > 0) { + if (UtilValidate.isNotEmpty(transIso)) { if ("Serializable".equals(transIso)) { factory.setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } else if ("RepeatableRead".equals(transIso)) { diff --git a/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java b/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java index 423e8bac01..d7db023a0f 100644 --- a/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java @@ -28,6 +28,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.transaction.TransactionFactory; import org.ofbiz.minerva.pool.jdbc.xa.XAPoolDataSource; @@ -66,7 +67,7 @@ public class MinervaConnectionFactory implements ConnectionFactoryInterface { ds.setURL(jdbcElement.getAttribute("jdbc-uri")); String transIso = jdbcElement.getAttribute("isolation-level"); - if (transIso != null && transIso.length() > 0) { + if (UtilValidate.isNotEmpty(transIso)) { if ("Serializable".equals(transIso)) { pds.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } else if ("RepeatableRead".equals(transIso)) { diff --git a/framework/entity/src/org/ofbiz/entity/connection/TyrexConnectionFactory.java b/framework/entity/src/org/ofbiz/entity/connection/TyrexConnectionFactory.java index eaae306cbe..0dfec74e2d 100644 --- a/framework/entity/src/org/ofbiz/entity/connection/TyrexConnectionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/connection/TyrexConnectionFactory.java @@ -72,7 +72,7 @@ public class TyrexConnectionFactory { String transIso = inlineJdbcElement.getAttribute("isolation-level"); - if (transIso != null && transIso.length() > 0) + if (UtilValidate.isNotEmpty(transIso)) ds.setIsolationLevel(transIso); ds.setLogWriter(Debug.getPrintWriter()); diff --git a/framework/entity/src/org/ofbiz/entity/connection/XaPoolConnectionFactory.java b/framework/entity/src/org/ofbiz/entity/connection/XaPoolConnectionFactory.java index 29475304ac..0938a7c3e0 100644 --- a/framework/entity/src/org/ofbiz/entity/connection/XaPoolConnectionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/connection/XaPoolConnectionFactory.java @@ -84,7 +84,7 @@ public class XaPoolConnectionFactory { ds.setTransactionManager(TransactionFactory.getTransactionManager()); String transIso = jdbcElement.getAttribute("isolation-level"); - if (transIso != null && transIso.length() > 0) { + if (UtilValidate.isNotEmpty(transIso)) { if ("Serializable".equals(transIso)) { ((StandardXADataSource) ds).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } else if ("RepeatableRead".equals(transIso)) { @@ -119,7 +119,7 @@ public class XaPoolConnectionFactory { // set the test statement to test connections String testStmt = jdbcElement.getAttribute("pool-jdbc-test-stmt"); - if (testStmt != null && testStmt.length() > 0) { + if (UtilValidate.isNotEmpty(testStmt)) { pds.setJdbcTestStmt(testStmt); Debug.logInfo("Set JDBC Test Statement : " + testStmt, module); } diff --git a/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java b/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java index defc164c38..2683459f0f 100644 --- a/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java +++ b/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.config.DatasourceInfo; import org.ofbiz.entity.config.EntityConfigUtil; @@ -54,7 +55,7 @@ public class GenericHelperFactory { String helperClassName = datasourceInfo.helperClass; Class helperClass = null; - if (helperClassName != null && helperClassName.length() > 0) { + if (UtilValidate.isNotEmpty(helperClassName)) { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); helperClass = loader.loadClass(helperClassName); diff --git a/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java b/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java index 7cf387fc32..da0ba283d5 100644 --- a/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java +++ b/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java @@ -136,7 +136,7 @@ public abstract class ListFinder extends Finder { if ("forward".equals(resultSetTypeString)) resultSetType = ResultSet.TYPE_FORWARD_ONLY; - if (delegatorName != null && delegatorName.length() > 0) { + if (UtilValidate.isNotEmpty(delegatorName)) { delegator = DelegatorFactory.getDelegator(delegatorName); } diff --git a/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java b/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java index 41c681858d..88016b4c79 100644 --- a/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java @@ -19,6 +19,7 @@ package org.ofbiz.entity.jdbc; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.connection.ConnectionFactoryInterface; @@ -47,7 +48,7 @@ public class ConnectionFactory { } try { - if (userName != null && userName.length() > 0) + if (UtilValidate.isNotEmpty(userName)) return DriverManager.getConnection(connectionUrl, userName, password); else if (props != null) return DriverManager.getConnection(connectionUrl, props); @@ -95,7 +96,7 @@ public class ConnectionFactory { } Class cfClass = null; - if (className != null && className.length() > 0) { + if (UtilValidate.isNotEmpty(className)) { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); cfClass = loader.loadClass(className); diff --git a/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java b/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java index 34def5724e..c90f253c12 100644 --- a/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java +++ b/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java @@ -326,7 +326,7 @@ public class DatabaseUtil { // add the column String errMsg = addColumn(entity, field); - if (errMsg != null && errMsg.length() > 0) { + if (UtilValidate.isNotEmpty(errMsg)) { message = "Could not add column [" + field.getColName() + "] to table [" + entity.getTableName(datasourceInfo) + "]: " + errMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -346,7 +346,7 @@ public class DatabaseUtil { if (addMissing) { // create the table String errMsg = createTable(entity, modelEntities, false); - if (errMsg != null && errMsg.length() > 0) { + if (UtilValidate.isNotEmpty(errMsg)) { message = "Could not create table [" + entity.getTableName(datasourceInfo) + "]: " + errMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -463,7 +463,7 @@ public class DatabaseUtil { if (addMissing) { String errMsg = createForeignKey(entity, modelRelation, relModelEntity, datasourceInfo.constraintNameClipLength, datasourceInfo.fkStyle, datasourceInfo.useFkInitiallyDeferred); - if (errMsg != null && errMsg.length() > 0) { + if (UtilValidate.isNotEmpty(errMsg)) { String message = "Could not create foreign key " + relConstraintName + " for entity [" + entity.getEntityName() + "]: " + errMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -550,7 +550,7 @@ public class DatabaseUtil { if (addMissing) { String errMsg = createForeignKeyIndex(entity, modelRelation, datasourceInfo.constraintNameClipLength); - if (errMsg != null && errMsg.length() > 0) { + if (UtilValidate.isNotEmpty(errMsg)) { String message = "Could not create foreign key index " + relConstraintName + " for entity [" + entity.getEntityName() + "]: " + errMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -633,7 +633,7 @@ public class DatabaseUtil { if (addMissing) { String errMsg = createDeclaredIndex(entity, modelIndex); - if (errMsg != null && errMsg.length() > 0) { + if (UtilValidate.isNotEmpty(errMsg)) { String message = "Could not create index " + relIndexName + " for entity [" + entity.getEntityName() + "]: " + errMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -1220,7 +1220,7 @@ public class DatabaseUtil { String lookupSchemaName = null; try { if (dbData.supportsSchemasInTableDefinitions()) { - if (this.datasourceInfo.schemaName != null && this.datasourceInfo.schemaName.length() > 0) { + if (UtilValidate.isNotEmpty(this.datasourceInfo.schemaName)) { lookupSchemaName = this.datasourceInfo.schemaName; } else { lookupSchemaName = dbData.getUserName(); @@ -1456,7 +1456,7 @@ public class DatabaseUtil { // ResultSet rsCols = dbData.getCrossReference(null, null, null, null, null, null); String lookupSchemaName = null; if (dbData.supportsSchemasInTableDefinitions()) { - if (this.datasourceInfo.schemaName != null && this.datasourceInfo.schemaName.length() > 0) { + if (UtilValidate.isNotEmpty(this.datasourceInfo.schemaName)) { lookupSchemaName = this.datasourceInfo.schemaName; } else { lookupSchemaName = dbData.getUserName(); @@ -1609,7 +1609,7 @@ public class DatabaseUtil { for (String curTableName: tableNames) { String lookupSchemaName = null; if (dbData.supportsSchemasInTableDefinitions()) { - if (this.datasourceInfo.schemaName != null && this.datasourceInfo.schemaName.length() > 0) { + if (UtilValidate.isNotEmpty(this.datasourceInfo.schemaName)) { lookupSchemaName = this.datasourceInfo.schemaName; } else { lookupSchemaName = dbData.getUserName(); @@ -2295,7 +2295,7 @@ public class DatabaseUtil { } String retMsg = createForeignKey(entity, modelRelation, relModelEntity, constraintNameClipLength, fkStyle, useFkInitiallyDeferred); - if (retMsg != null && retMsg.length() > 0) { + if (UtilValidate.isNotEmpty(retMsg)) { Debug.logError(retMsg, module); if (messages != null) messages.add(retMsg); continue; @@ -2483,7 +2483,7 @@ public class DatabaseUtil { } String retMsg = deleteForeignKey(entity, modelRelation, relModelEntity, constraintNameClipLength); - if (retMsg != null && retMsg.length() > 0) { + if (UtilValidate.isNotEmpty(retMsg)) { if (messages != null) messages.add(retMsg); Debug.logError(retMsg, module); } @@ -2740,7 +2740,7 @@ public class DatabaseUtil { ModelIndex modelIndex = indexesIter.next(); String retMsg = createDeclaredIndex(entity, modelIndex); - if (retMsg != null && retMsg.length() > 0) { + if (UtilValidate.isNotEmpty(retMsg)) { String message = "Could not create declared indices for entity [" + entity.getEntityName() + "]: " + retMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -2850,7 +2850,7 @@ public class DatabaseUtil { while (indexesIter.hasNext()) { ModelIndex modelIndex = indexesIter.next(); String retMsg = deleteDeclaredIndex(entity, modelIndex); - if (retMsg != null && retMsg.length() > 0) { + if (UtilValidate.isNotEmpty(retMsg)) { if (retMsgsBuffer.length() > 0) { retMsgsBuffer.append("\n"); } @@ -2946,7 +2946,7 @@ public class DatabaseUtil { ModelRelation modelRelation = relationsIter.next(); if ("one".equals(modelRelation.getType())) { String retMsg = createForeignKeyIndex(entity, modelRelation, constraintNameClipLength); - if (retMsg != null && retMsg.length() > 0) { + if (UtilValidate.isNotEmpty(retMsg)) { String message = "Could not create foreign key indices for entity [" + entity.getEntityName() + "]: " + retMsg; Debug.logError(message, module); if (messages != null) messages.add(message); @@ -3070,7 +3070,7 @@ public class DatabaseUtil { if ("one".equals(modelRelation.getType())) { String retMsg = deleteForeignKeyIndex(entity, modelRelation, constraintNameClipLength); - if (retMsg != null && retMsg.length() > 0) { + if (UtilValidate.isNotEmpty(retMsg)) { if (retMsgsBuffer.length() > 0) { retMsgsBuffer.append("\n"); } @@ -3144,7 +3144,7 @@ public class DatabaseUtil { public String getSchemaName(DatabaseMetaData dbData) throws SQLException { if (!isLegacy && this.datasourceInfo.useSchemas && dbData.supportsSchemasInTableDefinitions()) { - if (this.datasourceInfo.schemaName != null && this.datasourceInfo.schemaName.length() > 0) { + if (UtilValidate.isNotEmpty(this.datasourceInfo.schemaName)) { return this.datasourceInfo.schemaName; } else { return dbData.getUserName(); diff --git a/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java b/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java index 65d213e103..e23449d886 100644 --- a/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java +++ b/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java @@ -328,7 +328,7 @@ public class ModelEntity extends ModelInfo implements Comparable, S /** The table-name of the Entity including a Schema name if specified in the datasource config */ public String getTableName(DatasourceInfo datasourceInfo) { - if (datasourceInfo != null && datasourceInfo.schemaName != null && datasourceInfo.schemaName.length() > 0) { + if (UtilValidate.isNotEmpty(datasourceInfo.schemaName)) { return datasourceInfo.schemaName + "." + this.tableName; } else { return this.tableName; diff --git a/framework/entity/src/org/ofbiz/entity/transaction/JNDIFactory.java b/framework/entity/src/org/ofbiz/entity/transaction/JNDIFactory.java index 4aca1451f6..4cecc26c6f 100644 --- a/framework/entity/src/org/ofbiz/entity/transaction/JNDIFactory.java +++ b/framework/entity/src/org/ofbiz/entity/transaction/JNDIFactory.java @@ -37,6 +37,7 @@ import org.ofbiz.base.config.GenericConfigException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.JNDIContextFactory; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.config.DatasourceInfo; import org.ofbiz.entity.config.EntityConfigUtil; @@ -66,7 +67,7 @@ public class JNDIFactory implements TransactionFactoryInterface { String jndiName = EntityConfigUtil.getTxFactoryTxMgrJndiName(); String jndiServerName = EntityConfigUtil.getTxFactoryTxMgrJndiServerName(); - if (jndiName != null && jndiName.length() > 0) { + if (UtilValidate.isNotEmpty(jndiName)) { // if (Debug.verboseOn()) Debug.logVerbose("[JNDIFactory.getTransactionManager] Trying JNDI name " + jndiName, module); try { @@ -102,7 +103,7 @@ public class JNDIFactory implements TransactionFactoryInterface { String jndiName = EntityConfigUtil.getTxFactoryUserTxJndiName(); String jndiServerName = EntityConfigUtil.getTxFactoryUserTxJndiServerName(); - if (jndiName != null && jndiName.length() > 0) { + if (UtilValidate.isNotEmpty(jndiName)) { // if (Debug.verboseOn()) Debug.logVerbose("[JNDIFactory.getTransactionManager] Trying JNDI name " + jndiName, module); try { @@ -213,7 +214,7 @@ public class JNDIFactory implements TransactionFactoryInterface { /* NOTE: This code causes problems because settting the transaction isolation level after a transaction has started is a no-no * The question is: how should we do this? String isolationLevel = jndiJdbcElement.getAttribute("isolation-level"); - if (con != null && isolationLevel != null && isolationLevel.length() > 0) { + if (UtilValidate.isNotEmpty(isolationLevel)) { if ("Serializable".equals(isolationLevel)) { con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } else if ("RepeatableRead".equals(isolationLevel)) { diff --git a/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java b/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java index 2e6e1c73aa..ddf577811e 100644 --- a/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java @@ -24,6 +24,7 @@ import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.config.DatasourceInfo; import org.ofbiz.entity.config.EntityConfigUtil; @@ -50,7 +51,7 @@ public class TransactionFactory { } Class tfClass = null; - if (className != null && className.length() > 0) { + if (UtilValidate.isNotEmpty(className)) { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); tfClass = loader.loadClass(className); diff --git a/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java b/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java index 771e8f0fba..288b094a87 100644 --- a/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java +++ b/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java @@ -30,6 +30,7 @@ import org.ofbiz.base.config.GenericConfigException; import org.ofbiz.base.config.MainResourceHandler; import org.ofbiz.base.config.ResourceHandler; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -51,12 +52,12 @@ public class EntityDataLoader { public static String getPathsString(String helperName) { StringBuilder pathBuffer = new StringBuilder(); - if (helperName != null && helperName.length() > 0) { + if (UtilValidate.isNotEmpty(helperName)) { DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperName); for (Element sqlLoadPathElement: datasourceInfo.sqlLoadPaths) { String prependEnv = sqlLoadPathElement.getAttribute("prepend-env"); pathBuffer.append(pathBuffer.length() == 0 ? "" : ";"); - if (prependEnv != null && prependEnv.length() > 0) { + if (UtilValidate.isNotEmpty(prependEnv)) { pathBuffer.append(System.getProperty(prependEnv)); pathBuffer.append("/"); } @@ -138,7 +139,7 @@ public class EntityDataLoader { } // get files from the paths string - if (paths != null && paths.length() > 0) { + if (UtilValidate.isNotEmpty(paths)) { StringTokenizer tokenizer = new StringTokenizer(paths, ";"); while (tokenizer.hasMoreTokens()) { String path = tokenizer.nextToken().toLowerCase(); diff --git a/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java b/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java index 0297d741a8..403ed9cc78 100644 --- a/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java +++ b/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java @@ -375,7 +375,7 @@ public class EntitySaxReader implements javolution.xml.sax.ContentHandler, Error if (currentValue != null) { if (currentFieldName != null) { - if (currentFieldValue != null && currentFieldValue.length() > 0) { + if (UtilValidate.isNotEmpty(currentFieldValue)) { if (currentValue.getModelEntity().isField(currentFieldName.toString())) { ModelEntity modelEntity = currentValue.getModelEntity(); ModelField modelField = modelEntity.getField(currentFieldName.toString()); @@ -553,7 +553,7 @@ public class EntitySaxReader implements javolution.xml.sax.ContentHandler, Error } try { // treat empty strings as nulls - if (value != null && value.length() > 0) { + if (UtilValidate.isNotEmpty(value)) { if (currentValue.getModelEntity().isField(name.toString())) { currentValue.setString(name.toString(), value.toString()); } else { diff --git a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java index 6324902cc1..5b270775a0 100644 --- a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java +++ b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java @@ -281,7 +281,7 @@ public class EntityDataServices { } // check for null values - if (value != null && value.length() > 0) { + if (UtilValidate.isNotEmpty(value)) { char first = value.charAt(0); if (first == 0x00) { value = null; diff --git a/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java b/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java index bc743d7138..af01a6c369 100644 --- a/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java +++ b/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java @@ -71,7 +71,7 @@ public class EntityEcaAction implements java.io.Serializable { // pull out context parameters needed for this service. Map actionContext = dctx.getModelService(serviceName).makeValid(context, ModelService.IN_PARAM); // if value-attr is specified, insert the value object in that attr name - if (valueAttr != null && valueAttr.length() > 0) { + if (UtilValidate.isNotEmpty(valueAttr)) { actionContext.put(valueAttr, newValue); } diff --git a/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java b/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java index b16989a929..26e6bc6318 100644 --- a/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java +++ b/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java @@ -715,7 +715,7 @@ public class SimpleMethod { boolean forceError = false; String tempErrorMsg = (String) methodContext.getEnv(eventErrorMessageName); - if (errorMsg.length() > 0 || (tempErrorMsg != null && tempErrorMsg.length() > 0)) { + if (errorMsg.length() > 0 || UtilValidate.isNotEmpty(tempErrorMsg)) { errorMsg += tempErrorMsg; methodContext.getRequest().setAttribute("_ERROR_MESSAGE_", errorMsg); forceError = true; @@ -732,7 +732,7 @@ public class SimpleMethod { } String eventMsg = (String) methodContext.getEnv(eventEventMessageName); - if (eventMsg != null && eventMsg.length() > 0) { + if (UtilValidate.isNotEmpty(eventMsg)) { methodContext.getRequest().setAttribute("_EVENT_MESSAGE_", eventMsg); } List eventMsgList = UtilGenerics.checkList(methodContext.getEnv(eventEventMessageListName)); @@ -758,7 +758,7 @@ public class SimpleMethod { boolean forceError = false; String tempErrorMsg = (String) methodContext.getEnv(serviceErrorMessageName); - if (errorMsg.length() > 0 || (tempErrorMsg != null && tempErrorMsg.length() > 0)) { + if (errorMsg.length() > 0 || UtilValidate.isNotEmpty(tempErrorMsg)) { errorMsg += tempErrorMsg; methodContext.putResult(ModelService.ERROR_MESSAGE, errorMsg); forceError = true; @@ -785,7 +785,7 @@ public class SimpleMethod { } String successMsg = (String) methodContext.getEnv(serviceSuccessMessageName); - if (successMsg != null && successMsg.length() > 0) { + if (UtilValidate.isNotEmpty(successMsg)) { methodContext.putResult(ModelService.SUCCESS_MESSAGE, successMsg); } diff --git a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java index 72a98fcd1b..87dd7750c3 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallBsh.java @@ -58,7 +58,7 @@ public class CallBsh extends MethodOperation { resource = element.getAttribute("resource"); errorListAcsr = new ContextAccessor>(element.getAttribute("error-list-name"), "error_list"); - if (inline != null && inline.length() > 0) {// pre-parse/compile inlined bsh, only accessed here + if (UtilValidate.isNotEmpty(inline)) {// pre-parse/compile inlined bsh, only accessed here } } @@ -81,7 +81,7 @@ public class CallBsh extends MethodOperation { } // run external, from resource, first if resource specified - if (resource != null && resource.length() > 0) { + if (UtilValidate.isNotEmpty(resource)) { String resource = methodContext.expandString(this.resource); InputStream is = methodContext.getLoader().getResourceAsStream(resource); diff --git a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMapProcessor.java b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMapProcessor.java index e3759bfda9..6854f0e8db 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMapProcessor.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMapProcessor.java @@ -86,8 +86,7 @@ public class CallSimpleMapProcessor extends MethodOperation { } // run external map processor first - if (this.xmlResource != null && this.xmlResource.length() > 0 && - this.processorName != null && this.processorName.length() > 0) { + if (UtilValidate.isNotEmpty(this.xmlResource) && UtilValidate.isNotEmpty(this.processorName)) { String xmlResource = methodContext.expandString(this.xmlResource); String processorName = methodContext.expandString(this.processorName); try { diff --git a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java index db8d03ae25..46be5cf9c3 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java @@ -63,7 +63,7 @@ public class CallSimpleMethod extends MethodOperation { @Override public boolean exec(MethodContext methodContext) { - if (this.methodName != null && this.methodName.length() > 0) { + if (UtilValidate.isNotEmpty(this.methodName)) { String methodName = methodContext.expandString(this.methodName); String xmlResource = methodContext.expandString(this.xmlResource); diff --git a/framework/minilang/src/org/ofbiz/minilang/method/callops/FlexibleMessage.java b/framework/minilang/src/org/ofbiz/minilang/method/callops/FlexibleMessage.java index abbff3985d..2853341559 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/callops/FlexibleMessage.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/callops/FlexibleMessage.java @@ -47,11 +47,11 @@ public class FlexibleMessage implements Serializable { elVal = UtilXml.elementValue(element); } - if (resAttr != null && resAttr.length() > 0) { + if (UtilValidate.isNotEmpty(resAttr)) { propertyResource = resAttr; message = propAttr; isProperty = true; - } else if (elVal != null && elVal.length() > 0) { + } else if (UtilValidate.isNotEmpty(elVal)) { message = elVal; isProperty = false; } else { diff --git a/framework/minilang/src/org/ofbiz/minilang/method/conditional/HasPermissionCondition.java b/framework/minilang/src/org/ofbiz/minilang/method/conditional/HasPermissionCondition.java index f5e3d4f8af..8c4de62b67 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/conditional/HasPermissionCondition.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/conditional/HasPermissionCondition.java @@ -67,7 +67,7 @@ public class HasPermissionCondition implements Conditional { Authorization authz = methodContext.getAuthz(); Security security = methodContext.getSecurity(); - if (action != null && action.length() > 0) { + if (UtilValidate.isNotEmpty(action)) { // run hasEntityPermission if (security.hasEntityPermission(permission, action, userLogin)) { runSubOps = true; diff --git a/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java b/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java index 2624a2cd73..fda4ddb010 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java @@ -101,7 +101,7 @@ public class EntityCount extends MethodOperation { String entityName = this.entityNameExdr.expandString(context); String delegatorName = this.delegatorNameExdr.expandString(context); - if (delegatorName != null && delegatorName.length() > 0) { + if (UtilValidate.isNotEmpty(delegatorName)) { delegator = DelegatorFactory.getDelegator(delegatorName); } diff --git a/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java b/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java index d778ae417a..4a1a979628 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java @@ -86,7 +86,7 @@ public class EntityData extends MethodOperation { String delegatorName = this.delegatorNameExdr.expandString(methodContext.getEnvMap()); Delegator delegator = methodContext.getDelegator(); - if (delegatorName != null && delegatorName.length() > 0) { + if (UtilValidate.isNotEmpty(delegatorName)) { delegator = DelegatorFactory.getDelegator(delegatorName); } diff --git a/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java b/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java index 0061425125..1a048edf0d 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericEntityException; @@ -84,7 +85,7 @@ public class FindByAnd extends MethodOperation { } Delegator delegator = methodContext.getDelegator(); - if (delegatorName != null && delegatorName.length() > 0) { + if (UtilValidate.isNotEmpty(delegatorName)) { delegator = DelegatorFactory.getDelegator(delegatorName); } diff --git a/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java b/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java index 1adead51cb..38274a62c6 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java @@ -77,7 +77,7 @@ public class FindByPrimaryKey extends MethodOperation { boolean useCache = "true".equals(useCacheStr); Delegator delegator = methodContext.getDelegator(); - if (delegatorName != null && delegatorName.length() > 0) { + if (UtilValidate.isNotEmpty(delegatorName)) { delegator = DelegatorFactory.getDelegator(delegatorName); } diff --git a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java index 62c7f286d3..7aba6cb06f 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java @@ -99,7 +99,7 @@ public class StringAppend extends MethodOperation { } StringBuilder newValue = new StringBuilder(); - if (value != null && value.length() > 0) { + if (UtilValidate.isNotEmpty(value)) { if (UtilValidate.isEmpty(oldValue)) { newValue.append(value); } else { diff --git a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java index af17c8c0ee..4c4f486969 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java @@ -74,7 +74,7 @@ public class StringToField extends MethodOperation { } Object value; - if (this.messageFieldName != null && this.messageFieldName.length() > 0) { + if (UtilValidate.isNotEmpty(this.messageFieldName)) { value = new MessageString(valueStr, this.messageFieldName, true); } else { value = valueStr; diff --git a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java index 5f89af9ea7..35df73c307 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java @@ -69,7 +69,7 @@ public class StringToList extends MethodOperation { } Object value; - if (this.messageFieldName != null && this.messageFieldName.length() > 0) { + if (UtilValidate.isNotEmpty(this.messageFieldName)) { value = new MessageString(valueStr, this.messageFieldName, true); } else { value = valueStr; diff --git a/framework/minilang/src/org/ofbiz/minilang/method/ifops/CheckPermission.java b/framework/minilang/src/org/ofbiz/minilang/method/ifops/CheckPermission.java index ac715e0b0f..c8498a355e 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/ifops/CheckPermission.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/ifops/CheckPermission.java @@ -178,7 +178,7 @@ public class CheckPermission extends MethodOperation { String permission = methodContext.expandString(this.permission); String action = methodContext.expandString(this.action); - if (action != null && action.length() > 0) { + if (UtilValidate.isNotEmpty(action)) { // run hasEntityPermission return security.hasEntityPermission(permission, action, userLogin); } else { diff --git a/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java b/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java index 1dc638f7d9..42ab73410f 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java @@ -22,6 +22,7 @@ import java.util.List; import javolution.util.FastList; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.GenericValue; @@ -84,7 +85,7 @@ public class IfHasPermission extends MethodOperation { Authorization authz = methodContext.getAuthz(); Security security = methodContext.getSecurity(); - if (action != null && action.length() > 0) { + if (UtilValidate.isNotEmpty(action)) { // run hasEntityPermission if (security.hasEntityPermission(permission, action, userLogin)) { runSubOps = true; diff --git a/framework/security/src/org/ofbiz/security/OFBizSecurity.java b/framework/security/src/org/ofbiz/security/OFBizSecurity.java index 577b39931c..b714362e5f 100644 --- a/framework/security/src/org/ofbiz/security/OFBizSecurity.java +++ b/framework/security/src/org/ofbiz/security/OFBizSecurity.java @@ -29,6 +29,7 @@ import javolution.util.FastList; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -262,7 +263,7 @@ public class OFBizSecurity implements Security { // if we pass all tests //Debug.logInfo("Found (" + (roleTest == null ? 0 : roleTest.size()) + ") matches :: " + roleTest, module); - if (roleTest != null && roleTest.size() > 0) return true; + if (UtilValidate.isNotEmpty(roleTest)) return true; } return false; diff --git a/framework/security/src/org/ofbiz/security/authz/AbstractAuthorization.java b/framework/security/src/org/ofbiz/security/authz/AbstractAuthorization.java index 1d9a88ecc1..61ff90460f 100644 --- a/framework/security/src/org/ofbiz/security/authz/AbstractAuthorization.java +++ b/framework/security/src/org/ofbiz/security/authz/AbstractAuthorization.java @@ -149,7 +149,7 @@ public abstract class AbstractAuthorization implements Authorization { // first check auto-granted permissions List grantedPerms = autoGrant.get(); - if (grantedPerms != null && grantedPerms.size() > 0) { + if (UtilValidate.isNotEmpty(grantedPerms)) { Debug.logVerbose("Auto-Grant permissions found; looking for a match", module); for (String granted : grantedPerms) { if (Debug.verboseOn()) Debug.logVerbose("Testing - " + granted + " - with - " + joined.toString(), module); @@ -192,7 +192,7 @@ public abstract class AbstractAuthorization implements Authorization { protected void handleAutoGrantPermissions(String userId, String expandedPermission, Map context) { List granted = getAutoGrantPermissions(userId, expandedPermission, context); - if (granted != null && granted.size() > 0) { + if (UtilValidate.isNotEmpty(granted)) { List alreadyGranted = autoGrant.get(); if (alreadyGranted == null) { alreadyGranted = FastList.newInstance(); diff --git a/framework/security/src/org/ofbiz/security/authz/EntityAuthorization.java b/framework/security/src/org/ofbiz/security/authz/EntityAuthorization.java index bac72baef5..de4dd3da60 100644 --- a/framework/security/src/org/ofbiz/security/authz/EntityAuthorization.java +++ b/framework/security/src/org/ofbiz/security/authz/EntityAuthorization.java @@ -53,7 +53,7 @@ public class EntityAuthorization extends AbstractAuthorization { while (checking) { if (Debug.verboseOn()) Debug.logVerbose("Looking for auto-grant permissions for : " + checkString, module); List autoGrant = getPermissionAutoGrant(checkString); - if (autoGrant != null && autoGrant.size() > 0) { + if (UtilValidate.isNotEmpty(autoGrant)) { return autoGrant; } if (checkString.indexOf(":") > -1) { @@ -183,7 +183,7 @@ public class EntityAuthorization extends AbstractAuthorization { Debug.logWarning(e, module); } - if (values != null && values.size() > 0) { + if (UtilValidate.isNotEmpty(values)) { for (GenericValue v : values) { autoGrants.add(v.getString("grantPermission")); } diff --git a/framework/service/src/org/ofbiz/service/ModelPermGroup.java b/framework/service/src/org/ofbiz/service/ModelPermGroup.java index 669704c33e..be3dd33c09 100644 --- a/framework/service/src/org/ofbiz/service/ModelPermGroup.java +++ b/framework/service/src/org/ofbiz/service/ModelPermGroup.java @@ -23,6 +23,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.ofbiz.base.util.UtilValidate; + /** * Service Permission Group Model Class */ @@ -37,7 +39,7 @@ public class ModelPermGroup implements Serializable { public String joinType; public boolean evalPermissions(DispatchContext dctx, Map context) { - if (permissions != null && permissions.size() > 0) { + if (UtilValidate.isNotEmpty(permissions)) { boolean foundOne = false; for (ModelPermission perm: permissions) { if (perm.evalPermission(dctx, context)) { diff --git a/framework/service/src/org/ofbiz/service/ModelService.java b/framework/service/src/org/ofbiz/service/ModelService.java index d7d71fa301..d4f1f5ee46 100644 --- a/framework/service/src/org/ofbiz/service/ModelService.java +++ b/framework/service/src/org/ofbiz/service/ModelService.java @@ -869,13 +869,13 @@ public class ModelService extends AbstractMap implements Seriali String key = param.name; // internal map of strings - if (param.stringMapPrefix != null && param.stringMapPrefix.length() > 0 && !source.containsKey(key)) { + if (UtilValidate.isNotEmpty(param.stringMapPrefix) && !source.containsKey(key)) { Map paramMap = this.makePrefixMap(source, param); if (UtilValidate.isNotEmpty(paramMap)) { target.put(key, paramMap); } // internal list of strings - } else if (param.stringListSuffix != null && param.stringListSuffix.length() > 0 && !source.containsKey(key)) { + } else if (UtilValidate.isNotEmpty(param.stringListSuffix) && !source.containsKey(key)) { List paramList = this.makeSuffixList(source, param); if (UtilValidate.isNotEmpty(paramList)) { target.put(key, paramList); @@ -928,7 +928,7 @@ public class ModelService extends AbstractMap implements Seriali } public boolean containsPermissions() { - return (this.permissionGroups != null && this.permissionGroups.size() > 0); + return (UtilValidate.isNotEmpty(this.permissionGroups)); } /** @@ -1097,7 +1097,7 @@ public class ModelService extends AbstractMap implements Seriali } // handle interfaces - if (implServices != null && implServices.size() > 0 && dctx != null) { + if (UtilValidate.isNotEmpty(implServices) && dctx != null) { for (ModelServiceIface iface: implServices) { String serviceName = iface.getService(); boolean optional = iface.isOptional(); diff --git a/framework/service/src/org/ofbiz/service/ModelServiceReader.java b/framework/service/src/org/ofbiz/service/ModelServiceReader.java index f7ff7b2825..716fb4dc6c 100644 --- a/framework/service/src/org/ofbiz/service/ModelServiceReader.java +++ b/framework/service/src/org/ofbiz/service/ModelServiceReader.java @@ -430,7 +430,7 @@ public class ModelServiceReader implements Serializable { ModelPermission perm = new ModelPermission(); perm.nameOrRole = element.getAttribute("permission").intern(); perm.action = element.getAttribute("action").intern(); - if (perm.action != null && perm.action.length() > 0) { + if (UtilValidate.isNotEmpty(perm.action)) { perm.permissionType = ModelPermission.ENTITY_PERMISSION; } else { perm.permissionType = ModelPermission.PERMISSION; diff --git a/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java b/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java index 345a128af3..6640fcc952 100644 --- a/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java +++ b/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java @@ -142,7 +142,7 @@ public class ServiceEcaAction implements java.io.Serializable { } // put the results in to the defined map - if (resultMapName != null && resultMapName.length() > 0) { + if (UtilValidate.isNotEmpty(resultMapName)) { Map resultMap = UtilGenerics.checkMap(context.get(resultMapName)); if (resultMap == null) { resultMap = FastMap.newInstance(); diff --git a/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java b/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java index 0dac06c3ae..f986d37d6c 100644 --- a/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java +++ b/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java @@ -137,7 +137,7 @@ public class ServiceEcaCondition implements java.io.Serializable { Object lhsValue = null; Object rhsValue = null; - if (lhsMapName != null && lhsMapName.length() > 0) { + if (UtilValidate.isNotEmpty(lhsMapName)) { try { if (context.containsKey(lhsMapName)) { Map envMap = UtilGenerics.checkMap(context.get(lhsMapName)); @@ -158,7 +158,7 @@ public class ServiceEcaCondition implements java.io.Serializable { if (isConstant) { rhsValue = rhsValueName; - } else if (rhsMapName != null && rhsMapName.length() > 0) { + } else if (UtilValidate.isNotEmpty(rhsMapName)) { try { if (context.containsKey(rhsMapName)) { Map envMap = UtilGenerics.checkMap(context.get(rhsMapName)); diff --git a/framework/service/src/org/ofbiz/service/jms/JmsServiceEngine.java b/framework/service/src/org/ofbiz/service/jms/JmsServiceEngine.java index 78c0725f6d..6ce9a3c755 100644 --- a/framework/service/src/org/ofbiz/service/jms/JmsServiceEngine.java +++ b/framework/service/src/org/ofbiz/service/jms/JmsServiceEngine.java @@ -49,6 +49,7 @@ import org.ofbiz.base.config.GenericConfigException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.JNDIContextFactory; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.serialize.XmlSerializer; import org.ofbiz.entity.transaction.GenericTransactionException; @@ -96,7 +97,7 @@ public class JmsServiceEngine extends AbstractEngine { throws GenericServiceException, JMSException { List outParams = modelService.getParameterNames(ModelService.OUT_PARAM, false); - if (outParams != null && outParams.size() > 0) + if (UtilValidate.isNotEmpty(outParams)) throw new GenericServiceException("JMS service cannot have required OUT parameters; no parameters will be returned."); String xmlContext = null; diff --git a/framework/service/src/org/ofbiz/service/job/JobManager.java b/framework/service/src/org/ofbiz/service/job/JobManager.java index ffbf61c3cc..41f306cefd 100644 --- a/framework/service/src/org/ofbiz/service/job/JobManager.java +++ b/framework/service/src/org/ofbiz/service/job/JobManager.java @@ -411,7 +411,7 @@ public class JobManager { "serviceName", serviceName, "statusId", "SERVICE_PENDING", "recurrenceInfoId", infoId, "runtimeDataId", dataId); // set the pool ID - if (poolName != null && poolName.length() > 0) { + if (UtilValidate.isNotEmpty(poolName)) { jFields.put("poolId", poolName); } else { jFields.put("poolId", ServiceConfigUtil.getSendPool()); diff --git a/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java b/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java index 9c12fcaf0a..f9735d8b5a 100644 --- a/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java +++ b/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java @@ -95,7 +95,7 @@ public class RmiServiceContainer implements Container { ClassLoader loader = Thread.currentThread().getContextClassLoader(); // load the factories - if (clientProp != null && clientProp.value != null && clientProp.value.length() > 0) { + if (clientProp != null && UtilValidate.isNotEmpty(clientProp.value)) { try { Class c = loader.loadClass(clientProp.value); csf = (RMIClientSocketFactory) c.newInstance(); @@ -103,7 +103,7 @@ public class RmiServiceContainer implements Container { throw new ContainerException(e); } } - if (serverProp != null && serverProp.value != null && serverProp.value.length() > 0) { + if (serverProp != null && UtilValidate.isNotEmpty(serverProp.value)) { try { Class c = loader.loadClass(serverProp.value); ssf = (RMIServerSocketFactory) c.newInstance(); diff --git a/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java b/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java index b14000c6a7..3d43b7422f 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java @@ -168,7 +168,7 @@ public class ContextFilter implements Filter { // check if we are told to redirect everthing String redirectAllTo = config.getInitParameter("forceRedirectAll"); - if (redirectAllTo != null && redirectAllTo.length() > 0) { + if (UtilValidate.isNotEmpty(redirectAllTo)) { // little trick here so we don't loop on ourself if (httpRequest.getSession().getAttribute("_FORCE_REDIRECT_") == null) { httpRequest.getSession().setAttribute("_FORCE_REDIRECT_", "true"); diff --git a/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java b/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java index eba95f80cb..ba5176e127 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java @@ -264,11 +264,11 @@ public class LoginWorker { // NOTE: not using the old _PREVIOUS_PARAMS_ attribute at all because it was a security hole as it was used to put data in the URL (never encrypted) that was originally in a form field that may have been encrypted // keep 2 maps: one for URL parameters and one for form parameters Map urlParams = UtilHttp.getUrlOnlyParameterMap(request); - if (urlParams != null && urlParams.size() > 0) { + if (UtilValidate.isNotEmpty(urlParams)) { session.setAttribute("_PREVIOUS_PARAM_MAP_URL_", urlParams); } Map formParams = UtilHttp.getParameterMap(request, urlParams.keySet(), false); - if (formParams != null && formParams.size() > 0) { + if (UtilValidate.isNotEmpty(formParams)) { session.setAttribute("_PREVIOUS_PARAM_MAP_FORM_", formParams); } diff --git a/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java b/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java index c4667d3e94..a789eb7bec 100644 --- a/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java +++ b/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java @@ -313,7 +313,7 @@ public class CoreEvents { } // some conversions - if (serviceTime != null && serviceTime.length() > 0) { + if (UtilValidate.isNotEmpty(serviceTime)) { try { Timestamp ts1 = Timestamp.valueOf(serviceTime); startTime = ts1.getTime(); @@ -330,7 +330,7 @@ public class CoreEvents { errorBuf.append("
  • " + errMsg); } } - if (serviceEndTime != null && serviceEndTime.length() > 0) { + if (UtilValidate.isNotEmpty(serviceEndTime)) { try { Timestamp ts1 = Timestamp.valueOf(serviceEndTime); endTime = ts1.getTime(); @@ -347,7 +347,7 @@ public class CoreEvents { errorBuf.append("
  • " + errMsg); } } - if (serviceIntr != null && serviceIntr.length() > 0) { + if (UtilValidate.isNotEmpty(serviceIntr)) { try { interval = Integer.parseInt(serviceIntr); } catch (NumberFormatException nfe) { @@ -355,7 +355,7 @@ public class CoreEvents { errorBuf.append("
  • " + errMsg); } } - if (serviceCnt != null && serviceCnt.length() > 0) { + if (UtilValidate.isNotEmpty(serviceCnt)) { try { count = Integer.parseInt(serviceCnt); } catch (NumberFormatException nfe) { @@ -363,7 +363,7 @@ public class CoreEvents { errorBuf.append("
  • " + errMsg); } } - if (serviceFreq != null && serviceFreq.length() > 0) { + if (UtilValidate.isNotEmpty(serviceFreq)) { int parsedValue = 0; try { @@ -382,7 +382,7 @@ public class CoreEvents { } } } - if (retryCnt != null && retryCnt.length() > 0) { + if (UtilValidate.isNotEmpty(retryCnt)) { int parsedValue = -2; try { diff --git a/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java b/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java index dc849f7cb8..47361516c2 100644 --- a/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java @@ -242,11 +242,11 @@ public class ServiceEventHandler implements EventHandler { if ("timeZone".equals(name)) continue; Object value = null; - if (modelParam.stringMapPrefix != null && modelParam.stringMapPrefix.length() > 0) { + if (UtilValidate.isNotEmpty(modelParam.stringMapPrefix)) { Map paramMap = UtilHttp.makeParamMapWithPrefix(request, multiPartMap, modelParam.stringMapPrefix, null); value = paramMap; if (Debug.verboseOn()) Debug.log("Set [" + modelParam.name + "]: " + paramMap, module); - } else if (modelParam.stringListSuffix != null && modelParam.stringListSuffix.length() > 0) { + } else if (UtilValidate.isNotEmpty(modelParam.stringListSuffix)) { List paramList = UtilHttp.makeParamListWithSuffix(request, multiPartMap, modelParam.stringListSuffix, null); value = paramList; } else { diff --git a/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java b/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java index 87892cd0b2..66b34c5e72 100644 --- a/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java @@ -210,10 +210,10 @@ public class ServiceMultiEventHandler implements EventHandler { if ("timeZone".equals(paramName)) continue; Object value = null; - if (modelParam.stringMapPrefix != null && modelParam.stringMapPrefix.length() > 0) { + if (UtilValidate.isNotEmpty(modelParam.stringMapPrefix)) { Map paramMap = UtilHttp.makeParamMapWithPrefix(request, modelParam.stringMapPrefix, curSuffix); value = paramMap; - } else if (modelParam.stringListSuffix != null && modelParam.stringListSuffix.length() > 0) { + } else if (UtilValidate.isNotEmpty(modelParam.stringListSuffix)) { List paramList = UtilHttp.makeParamListWithSuffix(request, modelParam.stringListSuffix, null); value = paramList; } else { diff --git a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java index fac707e177..6ed03aec29 100644 --- a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java @@ -103,7 +103,7 @@ public class JasperReportsJXlsViewHandler extends AbstractViewHandler { JasperPrint jp = null; if (jrDataSource == null) { String datasourceName = delegator.getEntityHelperName(info); - if (datasourceName != null && datasourceName.length() > 0) { + if (UtilValidate.isNotEmpty(datasourceName)) { Debug.logInfo("Filling report with connection from datasource: " + datasourceName, module); jp = JasperFillManager.fillReport(report, parameters, ConnectionFactory.getConnection(datasourceName)); } else { diff --git a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java index 39cabbe841..c07e674308 100644 --- a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java @@ -101,7 +101,7 @@ public class JasperReportsPdfViewHandler extends AbstractViewHandler { JasperPrint jp = null; if (jrDataSource == null) { String datasourceName = delegator.getEntityHelperName(info); - if (datasourceName != null && datasourceName.length() > 0) { + if (UtilValidate.isNotEmpty(datasourceName)) { Debug.logInfo("Filling report with connection from datasource: " + datasourceName, module); jp = JasperFillManager.fillReport(report, parameters, ConnectionFactory.getConnection(datasourceName)); } else { diff --git a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java index 56358e3d45..fb31a4e2f7 100644 --- a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java @@ -103,7 +103,7 @@ public class JasperReportsPoiXlsViewHandler extends AbstractViewHandler { JasperPrint jp = null; if (jrDataSource == null) { String datasourceName = delegator.getEntityHelperName(info); - if (datasourceName != null && datasourceName.length() > 0) { + if (UtilValidate.isNotEmpty(datasourceName)) { Debug.logInfo("Filling report with connection from datasource: " + datasourceName, module); jp = JasperFillManager.fillReport(report, parameters, ConnectionFactory.getConnection(datasourceName)); } else { diff --git a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java index beacb51f64..a3b23face5 100644 --- a/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java @@ -89,7 +89,7 @@ public class JasperReportsXmlViewHandler extends AbstractViewHandler { PipedOutputStream fillToPrintOutputStream = new PipedOutputStream(); PipedInputStream fillToPrintInputStream = new PipedInputStream(fillToPrintOutputStream); - if (datasourceName != null && datasourceName.length() > 0) { + if (UtilValidate.isNotEmpty(datasourceName)) { JasperFillManager.fillReportToStream(report, fillToPrintOutputStream, parameters, ConnectionFactory.getConnection(datasourceName)); } else { JasperFillManager.fillReportToStream(report, fillToPrintOutputStream, parameters, new JREmptyDataSource()); diff --git a/framework/webapp/src/org/ofbiz/webapp/webdav/PropFindHelper.java b/framework/webapp/src/org/ofbiz/webapp/webdav/PropFindHelper.java index 30a7c15e8c..a0504909b0 100644 --- a/framework/webapp/src/org/ofbiz/webapp/webdav/PropFindHelper.java +++ b/framework/webapp/src/org/ofbiz/webapp/webdav/PropFindHelper.java @@ -22,6 +22,7 @@ import java.util.List; import javolution.util.FastList; +import org.ofbiz.base.util.UtilValidate; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -39,7 +40,7 @@ public class PropFindHelper extends ResponseHelper { public Element createPropElement(List propList) { Element element = this.responseDocument.createElementNS(DAV_NAMESPACE_URI, "D:prop"); - if (propList != null && propList.size() > 0) { + if (UtilValidate.isNotEmpty(propList)) { for (Element propElement : propList) { element.appendChild(propElement); } diff --git a/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java b/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java index 47d5314f58..1b8af6a097 100644 --- a/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java +++ b/framework/webtools/src/org/ofbiz/webtools/GenericWebEvent.java @@ -31,6 +31,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -132,7 +133,7 @@ public class GenericWebEvent { } String fval = request.getParameter(field.getName()); - if (fval != null && fval.length() > 0) { + if (UtilValidate.isNotEmpty(fval)) { try { findByEntity.setString(field.getName(), fval); } catch (Exception e) { @@ -180,7 +181,7 @@ public class GenericWebEvent { } String fval = request.getParameter(field.getName()); - if (fval != null && fval.length() > 0) { + if (UtilValidate.isNotEmpty(fval)) { try { findByEntity.setString(field.getName(), fval); } catch (Exception e) { diff --git a/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java index 285f0588e0..e1fba06e97 100644 --- a/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java @@ -126,7 +126,7 @@ public class WebToolsServices { // ############################# // The filename to parse is prepared // ############################# - if (filename != null && filename.length() > 0) { + if (UtilValidate.isNotEmpty(filename)) { try { url = isUrl?FlexibleLocation.resolveLocation(filename):UtilURL.fromFilename(filename); InputStream is = url.openStream(); @@ -143,7 +143,7 @@ public class WebToolsServices { // ############################# // The text to parse is prepared // ############################# - if (fulltext != null && fulltext.length() > 0) { + if (UtilValidate.isNotEmpty(fulltext)) { StringReader sr = new StringReader(fulltext); ins = new InputSource(sr); } @@ -243,7 +243,7 @@ public class WebToolsServices { filePause = Long.valueOf(0); } - if (path != null && path.length() > 0) { + if (UtilValidate.isNotEmpty(path)) { long pauseLong = filePause != null ? filePause.longValue() : 0; File baseDir = new File(path); @@ -481,7 +481,7 @@ public class WebToolsServices { List results = FastList.newInstance(); - if (outpath != null && outpath.length() > 0) { + if (UtilValidate.isNotEmpty(outpath)) { File outdir = new File(outpath); if (!outdir.exists()) { outdir.mkdir(); diff --git a/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.groovy b/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.groovy index ce2a2d9dbb..481d4fe624 100644 --- a/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.groovy +++ b/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.groovy @@ -28,6 +28,7 @@ import org.ofbiz.entity.model.ModelRelation; import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import java.sql.Timestamp; import java.sql.Date; import java.sql.Time; @@ -68,7 +69,7 @@ for(int fnum = 0; fnum < entity.getPksSize(); fnum++) { ModelField field = entity.getPk(fnum); ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); String fval = parameters.get(field.getName()); - if (fval != null && fval.length() > 0) { + if (UtilValidate.isNotEmpty(fval)) { curFindString = curFindString + "&" + field.getName() + "=" + fval; findByPK.setString(field.getName(), fval); } diff --git a/framework/widget/src/org/ofbiz/widget/WidgetWorker.java b/framework/widget/src/org/ofbiz/widget/WidgetWorker.java index 1f7a33a6ee..af21b37111 100644 --- a/framework/widget/src/org/ofbiz/widget/WidgetWorker.java +++ b/framework/widget/src/org/ofbiz/widget/WidgetWorker.java @@ -83,7 +83,7 @@ public class WidgetWorker { localWriter.append(localRequestName); } - if (parameterList != null && parameterList.size() > 0) { + if (UtilValidate.isNotEmpty(parameterList)) { String localUrl = localWriter.toString(); externalWriter.append(localUrl); boolean needsAmp = true; diff --git a/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java b/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java index 58d9edaec4..82965efb08 100644 --- a/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java @@ -1147,7 +1147,7 @@ public class MacroFormRenderer implements FormStringRenderer { String targetType = modelForm.getTargetType(); String targ = modelForm.getTarget(context, targetType); StringBuilder linkUrl = new StringBuilder(); - if (targ != null && targ.length() > 0) { + if (UtilValidate.isNotEmpty(targ)) { //this.appendOfbizUrl(writer, "/" + targ); WidgetWorker.buildHyperlinkUrl(linkUrl, targ, targetType, null, null, false, false, true, request, response, context); } diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java index 62ac689954..598bf55294 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java @@ -2682,7 +2682,7 @@ public class ModelForm extends ModelWidget { String positionStr = element.getAttribute("default-position"); int position = 1; try { - if (positionStr != null && positionStr.length() > 0) { + if (UtilValidate.isNotEmpty(positionStr)) { position = Integer.valueOf(positionStr); } } catch (Exception e) { @@ -2706,7 +2706,7 @@ public class ModelForm extends ModelWidget { String positionStr = element.getAttribute("default-position"); int position = 1; try { - if (positionStr != null && positionStr.length() > 0) { + if (UtilValidate.isNotEmpty(positionStr)) { position = Integer.valueOf(positionStr); } } catch (Exception e) { diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java index c5935dd165..7321ffac04 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java @@ -160,7 +160,7 @@ public class ModelFormField { String positionStr = fieldElement.getAttribute("position"); try { - if (positionStr != null && positionStr.length() > 0) { + if (UtilValidate.isNotEmpty(positionStr)) { position = Integer.valueOf(positionStr); } } catch (Exception e) { @@ -2665,7 +2665,7 @@ public class ModelFormField { try { size = Integer.parseInt(sizeStr); } catch (Exception e) { - if (sizeStr != null && sizeStr.length() > 0) { + if (UtilValidate.isNotEmpty(sizeStr)) { Debug.logError("Could not parse the size value of the text element: [" + sizeStr + "], setting to the default of " + size, module); } } @@ -2675,7 +2675,7 @@ public class ModelFormField { maxlength = Integer.valueOf(maxlengthStr); } catch (Exception e) { maxlength = null; - if (maxlengthStr != null && maxlengthStr.length() > 0) { + if (UtilValidate.isNotEmpty(maxlengthStr)) { Debug.logError("Could not parse the max-length value of the text element: [" + maxlengthStr + "], setting to null; default of no maxlength will be used", module); } } @@ -2788,7 +2788,7 @@ public class ModelFormField { try { cols = Integer.parseInt(colsStr); } catch (Exception e) { - if (colsStr != null && colsStr.length() > 0) { + if (UtilValidate.isNotEmpty(colsStr)) { Debug.logError("Could not parse the size value of the text element: [" + colsStr + "], setting to default of " + cols, module); } } @@ -2797,7 +2797,7 @@ public class ModelFormField { try { rows = Integer.parseInt(rowsStr); } catch (Exception e) { - if (rowsStr != null && rowsStr.length() > 0) { + if (UtilValidate.isNotEmpty(rowsStr)) { Debug.logError("Could not parse the size value of the text element: [" + rowsStr + "], setting to default of " + rows, module); } } @@ -3013,7 +3013,7 @@ public class ModelFormField { try { this.otherFieldSize = Integer.parseInt(sizeStr); } catch (Exception e) { - if (sizeStr != null && sizeStr.length() > 0) { + if (UtilValidate.isNotEmpty(sizeStr)) { Debug.logError("Could not parse the size value of the text element: [" + sizeStr + "], setting to the default of " + this.otherFieldSize, module); } } @@ -3577,7 +3577,7 @@ public class ModelFormField { try { border = Integer.parseInt(borderStr); } catch (Exception e) { - if (borderStr != null && borderStr.length() > 0) { + if (UtilValidate.isNotEmpty(borderStr)) { Debug.logError("Could not parse the border value of the text element: [" + borderStr + "], setting to the default of " + border, module); } } @@ -3587,7 +3587,7 @@ public class ModelFormField { width = Integer.valueOf(widthStr); } catch (Exception e) { width = null; - if (widthStr != null && widthStr.length() > 0) { + if (UtilValidate.isNotEmpty(widthStr)) { Debug.logError( "Could not parse the size value of the text element: [" + widthStr + "], setting to null; default of no width will be used", module); @@ -3599,7 +3599,7 @@ public class ModelFormField { height = Integer.valueOf(heightStr); } catch (Exception e) { height = null; - if (heightStr != null && heightStr.length() > 0) { + if (UtilValidate.isNotEmpty(heightStr)) { Debug.logError( "Could not parse the size value of the text element: [" + heightStr + "], setting to null; default of no height will be used", module); diff --git a/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java b/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java index a722a2625c..5a5b785d23 100644 --- a/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java @@ -1293,7 +1293,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe // The 'action' attribute is mandatory in a form definition, // even if it is empty. writer.append(" action=\""); - if (targ != null && targ.length() > 0) { + if (UtilValidate.isNotEmpty(targ)) { //this.appendOfbizUrl(writer, "/" + targ); WidgetWorker.buildHyperlinkUrl(writer, targ, targetType, null, null, false, false, true, request, response, context); } diff --git a/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java b/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java index 833eb8c21e..9782d1d8b4 100644 --- a/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java +++ b/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java @@ -97,7 +97,7 @@ public class HtmlFormWrapper { } Map uiLabelMap = UtilGenerics.cast(request.getAttribute("uiLabelMap")); - if (uiLabelMap != null && uiLabelMap.size() > 0 && context.get("uiLabelMap") == null) { + if (UtilValidate.isNotEmpty(uiLabelMap) && context.get("uiLabelMap") == null) { Debug.logInfo("Got uiLabelMap: " + uiLabelMap, module); context.put("uiLabelMap", uiLabelMap); } diff --git a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java index 316817df88..26c56a9ec9 100644 --- a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java +++ b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java @@ -317,7 +317,7 @@ public class ModelMenuCondition { Authorization authz = (Authorization) context.get("authz"); Security security = (Security) context.get("security"); - if (action != null && action.length() > 0) { + if (UtilValidate.isNotEmpty(action)) { //Debug.logWarning("Deprecated method hasEntityPermission() was called; the action field should no longer be used", module); // run hasEntityPermission if (security.hasEntityPermission(permission, action, userLogin)) { diff --git a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java index 7aa607b274..b65c090fd2 100644 --- a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java +++ b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java @@ -127,7 +127,7 @@ public class ModelMenuItem { String positionStr = fieldElement.getAttribute("position"); try { - if (positionStr != null && positionStr.length() > 0) { + if (UtilValidate.isNotEmpty(positionStr)) { position = Integer.valueOf(positionStr); } } catch (Exception e) { diff --git a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java index 959905b6be..8846046a05 100644 --- a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java +++ b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java @@ -313,7 +313,7 @@ public class ModelScreenCondition implements Serializable { Authorization authz = (Authorization) context.get("authz"); Security security = (Security) context.get("security"); - if (action != null && action.length() > 0) { + if (UtilValidate.isNotEmpty(action)) { //Debug.logWarning("Deprecated method hasEntityPermission() was called; the action field should no longer be used", module); // run hasEntityPermission if (security.hasEntityPermission(permission, action, userLogin)) { diff --git a/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java b/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java index ebc12e57c2..a493073197 100644 --- a/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java @@ -269,7 +269,7 @@ public class MacroTreeRenderer implements TreeStringRenderer { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); - if (target != null && target.length() > 0) { + if (UtilValidate.isNotEmpty(target)) { WidgetWorker.buildHyperlinkUrl(linkUrl, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context), link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context); } diff --git a/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java b/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java index 8035946bb3..91ed5f519e 100644 --- a/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java +++ b/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java @@ -35,6 +35,7 @@ import org.apache.oro.text.regex.Perl5Matcher; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; @@ -217,7 +218,7 @@ public class ModelTreeCondition { Authorization authz = (Authorization) context.get("authorization"); Security security = (Security) context.get("security"); - if (action != null && action.length() > 0) { + if (UtilValidate.isNotEmpty(action)) { //Debug.logWarning("Deprecated method hasEntityPermission() was called; the action field should no longer be used", module); // run hasEntityPermission if (security.hasEntityPermission(permission, action, userLogin)) { diff --git a/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java b/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java index 0c6986a5f9..b95277ef88 100644 --- a/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java +++ b/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java @@ -431,7 +431,7 @@ public class EbayOrderServices { if (ack != null && "Success".equals(ack)) { List orderArrays = UtilXml.childElementList(elemResponse, "OrderArray"); - if (orderArrays != null && orderArrays.size() > 0) { + if (UtilValidate.isNotEmpty(orderArrays)) { totalOrders = orderArrays.size(); } if (totalOrders > 0) { @@ -680,7 +680,7 @@ public class EbayOrderServices { getSellerTransactionsContainingOrderList.add(orderId); } } - if (containingOrders != null && containingOrders.size() > 0) { + if (UtilValidate.isNotEmpty(containingOrders)) { continue; } @@ -1109,7 +1109,7 @@ public class EbayOrderServices { List shipInfo = PartyWorker.findMatchingPartyAndPostalAddress(delegator, shippingAddressCtx.get("shippingAddressStreet1").toString(), (UtilValidate.isEmpty(shippingAddressCtx.get("shippingAddressStreet2")) ? null : shippingAddressCtx.get("shippingAddressStreet2").toString()), shippingAddressCtx.get("city").toString(), shippingAddressCtx.get("stateProvinceGeoId").toString(), shippingAddressCtx.get("shippingAddressPostalCode").toString(), null, shippingAddressCtx.get("countryGeoId").toString(), firstName, null, lastName); - if (shipInfo != null && shipInfo.size() > 0) { + if (UtilValidate.isNotEmpty(shipInfo)) { GenericValue first = EntityUtil.getFirst(shipInfo); partyId = first.getString("partyId"); Debug.logInfo("Existing shipping address found for : (party: " + partyId + ")", module); @@ -1223,7 +1223,7 @@ public class EbayOrderServices { Debug.logInfo("Checking for existing externalId: " + externalId, module); GenericValue orderHeader = null; List orderHeaderList = delegator.findByAnd("OrderHeader", UtilMisc.toMap("externalId", externalId)); - if (orderHeaderList != null && orderHeaderList.size() > 0) { + if (UtilValidate.isNotEmpty(orderHeaderList)) { orderHeader = EntityUtil.getFirst(orderHeaderList); } return orderHeader; diff --git a/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java b/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java index a9fb200102..997c7f1585 100755 --- a/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java +++ b/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java @@ -358,7 +358,7 @@ public class ImportOrdersFromEbay { Element transactionElement = (Element) transactionElemIter.next(); List containingOrders = UtilXml.childElementList(transactionElement, "ContainingOrder"); - if (containingOrders != null && containingOrders.size() > 0) { + if (UtilValidate.isNotEmpty(containingOrders)) { continue; } order.put("amountPaid", UtilXml.childElementValue(transactionElement, "AmountPaid", "0")); diff --git a/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java b/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java index b27ce7159f..5dac72b593 100644 --- a/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java +++ b/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java @@ -275,7 +275,7 @@ public class ProductsExportToGoogle { if (responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK) { inputStream = connection.getInputStream(); response = toString(inputStream); - if (response != null && response.length() > 0) { + if (UtilValidate.isNotEmpty(response)) { result = readResponseFromGoogle(response, newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator, locale); //String msg = ServiceUtil.getErrorMessage(result); if (ServiceUtil.isError(result)) { diff --git a/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java b/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java index 62a84eba79..7bd1420a6f 100644 --- a/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java +++ b/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java @@ -237,7 +237,7 @@ public class GoogleCheckoutHelper { // check and make sure this order doesn't already exist List existingOrder = delegator.findByAnd("OrderHeader", UtilMisc.toMap("externalId", externalId)); - if (existingOrder != null && existingOrder.size() > 0) { + if (UtilValidate.isNotEmpty(existingOrder)) { //throw new GeneralException("Google order #" + externalId + " already exists."); Debug.logWarning("Google order #" + externalId + " already exists.", module); return; @@ -439,7 +439,7 @@ public class GoogleCheckoutHelper { shipAddr.getPostalCode(), null, getCountryGeoId(shipAddr.getCountryCode()), shipAddr.getStructuredName().getFirstName(), null, shipAddr.getStructuredName().getLastName()); - if (shipInfo != null && shipInfo.size() > 0) { + if (UtilValidate.isNotEmpty(shipInfo)) { GenericValue first = EntityUtil.getFirst(shipInfo); shipCmId = first.getString("contactMechId"); partyId = first.getString("partyId"); @@ -452,7 +452,7 @@ public class GoogleCheckoutHelper { billAddr.getPostalCode(), null, getCountryGeoId(billAddr.getCountryCode()), billAddr.getStructuredName().getFirstName(), null, billAddr.getStructuredName().getLastName()); - if (billInfo != null && billInfo.size() > 0) { + if (UtilValidate.isNotEmpty(billInfo)) { GenericValue first = EntityUtil.getFirst(billInfo); billCmId = first.getString("contactMechId"); if (partyId == null) { @@ -486,7 +486,7 @@ public class GoogleCheckoutHelper { billAddr.getPostalCode(), null, getCountryGeoId(billAddr.getCountryCode()), billAddr.getStructuredName().getFirstName(), null, billAddr.getStructuredName().getLastName()); - if (billInfo != null && billInfo.size() > 0) { + if (UtilValidate.isNotEmpty(billInfo)) { GenericValue first = EntityUtil.getFirst(billInfo); billCmId = first.getString("contactMechId"); } else { @@ -611,7 +611,7 @@ public class GoogleCheckoutHelper { throw e; } - if (cmLookup != null && cmLookup.size() > 0) { + if (UtilValidate.isNotEmpty(cmLookup)) { GenericValue v = EntityUtil.getFirst(cmLookup); if (v != null) { cmId = v.getString("contactMechId"); @@ -661,7 +661,7 @@ public class GoogleCheckoutHelper { } catch (GenericEntityException e) { Debug.logError(e, module); } - if (geos != null && geos.size() > 0) { + if (UtilValidate.isNotEmpty(geos)) { return EntityUtil.getFirst(geos).getString("geoId"); } else { return "_NA_"; diff --git a/specialpurpose/pos/src/org/ofbiz/pos/jpos/service/KeyboardService.java b/specialpurpose/pos/src/org/ofbiz/pos/jpos/service/KeyboardService.java index ee70bebbbb..6686448b0c 100644 --- a/specialpurpose/pos/src/org/ofbiz/pos/jpos/service/KeyboardService.java +++ b/specialpurpose/pos/src/org/ofbiz/pos/jpos/service/KeyboardService.java @@ -220,7 +220,7 @@ public class KeyboardService extends BaseService implements jpos.services.POSKey // set the key modifiers String[] modifiers = null; - if (keyMod != null && keyMod.length() > 0) { + if (UtilValidate.isNotEmpty(keyMod)) { if (keyMod.indexOf("+") != -1) { modifiers = keyMod.split("\\+"); } else { diff --git a/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java b/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java index 2360fe5bd0..ed7cd529ef 100644 --- a/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java +++ b/specialpurpose/shark/src/org/ofbiz/shark/container/SharkContainer.java @@ -138,8 +138,8 @@ public class SharkContainer implements Container, Runnable { Debug.logError("OUT :Java home variable is undefined", module); } else - if (iiopHost != null && iiopHost.value != null && iiopHost.value.length() > 0) { - if (iiopPort != null && iiopPort.value != null && iiopPort.value.length() > 0) { + if (iiopHost != null && UtilValidate.isNotEmpty(iiopHost.value)) { + if (iiopPort != null && UtilValidate.isNotEmpty(iiopPort.value)) { try { p = Runtime.getRuntime().exec(java_home + "\\" + "bin\\tnameserv" + " -ORBInitialPort " @@ -162,8 +162,8 @@ public class SharkContainer implements Container, Runnable Debug.logInfo("Started Shark workflow service", module); // create the CORBA server and bind to iiop - if (iiopHost != null && iiopHost.value != null && iiopHost.value.length() > 0) { - if (iiopPort != null && iiopPort.value != null && iiopPort.value.length() > 0) { + if (iiopHost != null && UtilValidate.isNotEmpty(iiopHost.value)) { + if (iiopPort != null && UtilValidate.isNotEmpty(iiopPort.value)) { try { corbaServer = new SharkCORBAServer(engineName.value, iiopHost.value, iiopPort.value, shark); orbThread = new Thread(this); diff --git a/specialpurpose/shark/src/org/ofbiz/shark/repository/EntityRepositoryMgr.java b/specialpurpose/shark/src/org/ofbiz/shark/repository/EntityRepositoryMgr.java index 93d4dfc202..cb7e9fc812 100644 --- a/specialpurpose/shark/src/org/ofbiz/shark/repository/EntityRepositoryMgr.java +++ b/specialpurpose/shark/src/org/ofbiz/shark/repository/EntityRepositoryMgr.java @@ -177,8 +177,8 @@ public class EntityRepositoryMgr implements RepositoryPersistenceManager { public boolean doesXPDLExist(RepositoryTransaction t, String xpdlId) throws RepositoryException { List xpdls = this.getXpdlValues(xpdlId, null, false); - Debug.log("Does XPDL [" + xpdlId + "] Exist - " + xpdls + "(" + (xpdls != null && xpdls.size() > 0 ? true : false) + ")", module); - return (xpdls != null && xpdls.size() > 0 ? true : false); + Debug.log(UtilValidate.isNotEmpty(xpdls) ? true : false) + ")", module); + return (UtilValidate.isNotEmpty(xpdls) ? true : false); } public boolean doesXPDLExist(RepositoryTransaction t, String xpdlId, String xpdlVersion) throws RepositoryException { diff --git a/specialpurpose/workflow/src/org/ofbiz/workflow/client/WorkflowClient.java b/specialpurpose/workflow/src/org/ofbiz/workflow/client/WorkflowClient.java index 1ef575b37f..3497ccc9c8 100644 --- a/specialpurpose/workflow/src/org/ofbiz/workflow/client/WorkflowClient.java +++ b/specialpurpose/workflow/src/org/ofbiz/workflow/client/WorkflowClient.java @@ -251,7 +251,7 @@ public class WorkflowClient { */ public void complete(String workEffortId, String partyId, String roleTypeId, Timestamp fromDate, Map result) throws WfException { WfAssignment assign = WfFactory.getWfAssignment(delegator, workEffortId, partyId, roleTypeId, fromDate); - if (result != null && result.size() > 0) + if (UtilValidate.isNotEmpty(result)) assign.setResult(result); assign.complete(); } diff --git a/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java b/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java index 576d8518f6..f03865ae54 100644 --- a/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java +++ b/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java @@ -885,7 +885,7 @@ public class XpdlReader { transitionValue.set("fromActivityId", transitionElement.getAttribute("From")); transitionValue.set("toActivityId", transitionElement.getAttribute("To")); - if (transitionElement.getAttribute("Loop") != null && transitionElement.getAttribute("Loop").length() > 0) + if (UtilValidate.isNotEmpty(transitionElement.getAttribute("Loop"))) transitionValue.set("loopTypeEnumId", "WTL_" + transitionElement.getAttribute("Loop")); else transitionValue.set("loopTypeEnumId", "WTL_NOLOOP"); @@ -962,7 +962,7 @@ public class XpdlReader { if (joinElement != null) { String joinType = joinElement.getAttribute("Type"); - if (joinType != null && joinType.length() > 0) { + if (UtilValidate.isNotEmpty(joinType)) { activityValue.set("joinTypeEnumId", "WJT_" + joinType); } } @@ -973,7 +973,7 @@ public class XpdlReader { if (splitElement != null) { String splitType = splitElement.getAttribute("Type"); - if (splitType != null && splitType.length() > 0) { + if (UtilValidate.isNotEmpty(splitType)) { activityValue.set("splitTypeEnumId", "WST_" + splitType); } @@ -1183,7 +1183,7 @@ public class XpdlReader { // Length? String lengthStr = UtilXml.childElementValue(dataFieldElement, "Length"); - if (lengthStr != null && lengthStr.length() > 0) { + if (UtilValidate.isNotEmpty(lengthStr)) { try { dataFieldValue.set("lengthBytes", Long.valueOf(lengthStr)); } catch (NumberFormatException e) { @@ -1221,7 +1221,7 @@ public class XpdlReader { String indexStr = formalParameterElement.getAttribute("Index"); - if (indexStr != null && indexStr.length() > 0) { + if (UtilValidate.isNotEmpty(indexStr)) { try { formalParameterValue.set("indexNumber", Long.valueOf(indexStr)); } catch (NumberFormatException e) { diff --git a/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java b/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java index b3d6d183a0..88bf34de40 100644 --- a/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java +++ b/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java @@ -79,7 +79,7 @@ public class WfProcessImpl extends WfExecutionObjectImpl implements WfProcess { */ public WfProcessImpl(Delegator delegator, String workEffortId) throws WfException { super(delegator, workEffortId); - if (activityId != null && activityId.length() > 0) + if (UtilValidate.isNotEmpty(activityId)) throw new WfException("Execution object is not of type WfProcess."); this.manager = WfFactory.getWfProcessMgr(delegator, packageId, packageVersion, processId, processVersion); this.requester = null;