From e7905f2c8ceeb8181ecde3225f1b2b39aff726e4 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sun, 17 Aug 2008 07:47:18 +0000 Subject: [PATCH] Fix the anti-pattern if (* != null && *.size() > 0) { where * is a variable name (String or Collection). Rewritten to if (UtilValidate.isNotEmpty(*)) { Done with Eclipse regex replace feature with search = if \((\w+) *!= *null *&& *(\w+)\.size\(\) *> *0\) *\{ replace = if (UtilValidate.isNotEmpty($1)) { And of course some hand-work for imports and cleaning. I compiled and tested with ant run-tests git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@686591 13f79535-47bb-0310-9956-ffa450edef68 --- .../accounting/invoice/InvoiceServices.java | 4 +- .../accounting/invoice/InvoiceWorker.java | 11 ++-- .../payment/PaymentGatewayServices.java | 12 ++--- .../accounting/payment/PaymentWorker.java | 4 +- .../worldpay/SelectRespServlet.java | 2 +- .../src/org/ofbiz/content/cms/CmsEvents.java | 2 +- .../content/ContentServicesComplex.java | 8 +-- .../ofbiz/content/content/ContentWorker.java | 12 ++--- .../content/data/DataResourceWorker.java | 2 +- .../ofbiz/content/survey/SurveyWrapper.java | 6 +-- .../ftl/InjectNodeTrailCsvTransform.java | 2 +- .../ofbiz/manufacturing/bom/BOMHelper.java | 3 +- .../org/ofbiz/manufacturing/bom/BOMNode.java | 2 +- .../ofbiz/manufacturing/bom/BOMServices.java | 2 +- .../jobshopmgt/ProductionRunServices.java | 2 +- .../ofbiz/manufacturing/mrp/MrpServices.java | 6 +-- .../org/ofbiz/order/OrderManagerEvents.java | 2 +- .../ofbiz/order/order/OrderChangeHelper.java | 4 +- .../ofbiz/order/order/OrderReadHelper.java | 18 +++---- .../order/order/OrderReturnServices.java | 8 +-- .../org/ofbiz/order/order/OrderServices.java | 54 +++++++++---------- .../requirement/RequirementServices.java | 2 +- .../order/shoppingcart/CheckOutEvents.java | 4 +- .../order/shoppingcart/CheckOutHelper.java | 22 ++++---- .../order/shoppingcart/ShoppingCart.java | 6 +-- .../shoppingcart/ShoppingCartEvents.java | 4 +- .../order/shoppingcart/ShoppingCartItem.java | 10 ++-- .../shoppingcart/ShoppingCartServices.java | 2 +- .../product/ProductDisplayWorker.java | 6 +-- .../product/ProductPromoWorker.java | 8 +-- .../shoppinglist/ShoppingListEvents.java | 6 +-- .../thirdparty/zipsales/ZipSalesServices.java | 9 ++-- .../party/contact/ContactMechWorker.java | 2 +- .../org/ofbiz/party/party/PartyWorker.java | 2 +- .../ofbiz/product/catalog/CatalogWorker.java | 14 ++--- .../product/category/CategoryServices.java | 4 +- .../product/category/CategoryWorker.java | 6 +-- .../product/config/ProductConfigWrapper.java | 2 +- .../product/inventory/InventoryServices.java | 2 +- .../ofbiz/product/price/PriceServices.java | 38 ++++++------- .../ofbiz/product/product/ProductSearch.java | 4 +- .../product/product/ProductSearchEvents.java | 2 +- .../product/product/ProductSearchSession.java | 4 +- .../product/product/ProductServices.java | 6 +-- .../ofbiz/product/product/ProductWorker.java | 6 +-- .../product/store/ProductStoreWorker.java | 2 +- .../supplier/SupplierProductServices.java | 3 +- .../shipment/packing/PackingSession.java | 2 +- .../shipment/shipment/ShipmentServices.java | 2 +- .../shipment/thirdparty/dhl/DhlServices.java | 2 +- .../workeffort/WorkEffortSearchEvents.java | 3 +- .../workeffort/WorkEffortServices.java | 4 +- .../ofbiz/base/component/ComponentConfig.java | 4 +- .../base/component/ComponentLoaderConfig.java | 4 +- .../ofbiz/base/container/ContainerConfig.java | 4 +- .../src/org/ofbiz/base/util/HttpClient.java | 4 +- .../src/org/ofbiz/base/util/UtilHttp.java | 2 +- .../org/ofbiz/base/util/UtilProperties.java | 4 +- .../ofbiz/base/util/cache/CacheLineTable.java | 4 +- .../catalina/container/CatalinaContainer.java | 8 +-- .../src/org/ofbiz/common/CommonServices.java | 4 +- .../src/org/ofbiz/common/FindServices.java | 2 +- .../src/org/ofbiz/common/geo/GeoWorker.java | 18 +++---- .../src/org/ofbiz/datafile/DataFile.java | 3 +- .../entity/condition/EntityJoinOperator.java | 7 +-- .../ofbiz/entity/datasource/GenericDAO.java | 2 +- .../ofbiz/entity/finder/EntityFinderUtil.java | 4 +- .../org/ofbiz/entity/jdbc/SqlJdbcUtil.java | 4 +- .../org/ofbiz/entity/model/ModelEntity.java | 2 +- .../ofbiz/entity/model/ModelViewEntity.java | 2 +- .../entity/transaction/TransactionUtil.java | 16 +++--- .../src/org/ofbiz/entity/util/EntityUtil.java | 6 +-- .../data/EntityDataLoadContainer.java | 4 +- .../entityext/data/EntityDataServices.java | 5 +- .../src/org/ofbiz/minilang/SimpleMethod.java | 12 ++--- .../minilang/method/callops/CallService.java | 10 ++-- .../minilang/method/callops/CheckErrors.java | 3 +- .../minilang/method/conditional/MasterIf.java | 4 +- .../minilang/method/envops/StringAppend.java | 2 +- .../minilang/method/envops/StringToField.java | 2 +- .../minilang/method/envops/StringToList.java | 2 +- .../method/otherops/PropertyToField.java | 2 +- .../minilang/operation/MakeInString.java | 2 +- .../minilang/operation/MapProcessor.java | 4 +- .../minilang/operation/SimpleMapProcess.java | 2 +- .../org/ofbiz/service/ModelNotification.java | 7 +-- .../src/org/ofbiz/service/ModelParam.java | 3 +- .../org/ofbiz/service/ModelPermission.java | 14 ++--- .../src/org/ofbiz/service/ModelService.java | 8 +-- .../org/ofbiz/service/ModelServiceReader.java | 4 +- .../org/ofbiz/service/ServiceDispatcher.java | 2 +- .../src/org/ofbiz/service/ServiceUtil.java | 4 +- .../service/ServiceValidationException.java | 5 +- .../service/calendar/RecurrenceInfo.java | 3 +- .../service/calendar/RecurrenceRule.java | 17 +++--- .../ofbiz/service/eca/ServiceEcaAction.java | 4 +- .../src/org/ofbiz/service/job/JobManager.java | 4 +- .../ofbiz/service/mail/JavaMailContainer.java | 4 +- .../ofbiz/webapp/control/ConfigXMLReader.java | 4 +- .../webapp/control/ControlEventListener.java | 5 +- .../ofbiz/webapp/control/RequestHandler.java | 4 +- .../ofbiz/webapp/taglib/I18nMessageTag.java | 3 +- .../org/ofbiz/webtools/WebToolsServices.java | 2 +- .../webtools/print/FoPrintServerEvents.java | 4 +- .../ofbiz/widget/form/ModelFormAction.java | 2 +- .../org/ofbiz/widget/form/ModelFormField.java | 6 +-- .../ofbiz/widget/menu/ModelMenuAction.java | 2 +- .../widget/screen/IterateSectionWidget.java | 10 ++-- .../widget/screen/ModelScreenAction.java | 2 +- .../org/ofbiz/ebay/ImportOrdersFromEbay.java | 4 +- .../ofbiz/hhfacility/FacilityServices.java | 2 +- .../pos/src/org/ofbiz/pos/PosTransaction.java | 4 +- .../org/ofbiz/pos/device/impl/Keyboard.java | 3 +- .../org/ofbiz/shark/audit/EntityAuditMgr.java | 12 ++--- .../shark/instance/EntityPersistentMgr.java | 24 ++++----- .../mapping/EntityParticipantMappingMgr.java | 2 +- .../ofbiz/shark/user/GenericUserGroupMgr.java | 12 ++--- .../ofbiz/workflow/definition/XpdlReader.java | 4 +- .../ofbiz/workflow/impl/WfActivityImpl.java | 4 +- 119 files changed, 362 insertions(+), 345 deletions(-) diff --git a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java index 7c57e7d97e..1d1026a0b2 100644 --- a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java @@ -898,7 +898,7 @@ public class InvoiceServices { // build a Map of partyIds (both to and from) in a commission and the amounts // Note that getCommissionForProduct returns a List of Maps with a lot values. See services.xml definition for reference. List itemComms = (List) outMap.get("commissions"); - if (itemComms != null && itemComms.size() > 0) { + if (UtilValidate.isNotEmpty(itemComms)) { Iterator it = itemComms.iterator(); while (it.hasNext()) { Map commMap = (Map)it.next(); @@ -2828,7 +2828,7 @@ public class InvoiceServices { BigDecimal tobeApplied = ZERO; // item total amount - already applied (if any) BigDecimal alreadyApplied = ZERO; - if (paymentApplications != null && paymentApplications.size() > 0) { + if (UtilValidate.isNotEmpty(paymentApplications)) { // application(s) found, add them all together Iterator p = paymentApplications.iterator(); while (p.hasNext()) { diff --git a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java index 00cc2f1708..11bb2bb855 100644 --- a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java +++ b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java @@ -29,6 +29,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilNumber; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -108,7 +109,7 @@ public class InvoiceWorker { } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting InvoiceItem list", module); } - if (invoiceTaxItems != null && invoiceTaxItems.size() > 0) { + if (UtilValidate.isNotEmpty(invoiceTaxItems)) { Iterator invoiceItemsIter = invoiceTaxItems.iterator(); while (invoiceItemsIter.hasNext()) { GenericValue invoiceItem = (GenericValue) invoiceItemsIter.next(); @@ -150,7 +151,7 @@ public class InvoiceWorker { } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting InvoiceItem list", module); } - if (invoiceItems != null && invoiceItems.size() > 0) { + if (UtilValidate.isNotEmpty(invoiceItems)) { Iterator invoiceItemsIter = invoiceItems.iterator(); while (invoiceItemsIter.hasNext()) { GenericValue invoiceItem = (GenericValue) invoiceItemsIter.next(); @@ -307,7 +308,7 @@ public class InvoiceWorker { // now return the first PostalAddress from the locations GenericValue postalAddress = null; GenericValue contactMech = null; - if (locations != null && locations.size() > 0) { + if (UtilValidate.isNotEmpty(locations)) { try { contactMech = ((GenericValue) locations.get(0)).getRelatedOne("ContactMech"); } catch (GenericEntityException e) { @@ -425,7 +426,7 @@ public class InvoiceWorker { } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting paymentApplicationlist", module); } - if (paymentApplications != null && paymentApplications.size() > 0) { + if (UtilValidate.isNotEmpty(paymentApplications)) { Iterator p = paymentApplications.iterator(); while (p.hasNext()) { GenericValue paymentApplication = (GenericValue) p.next(); @@ -509,7 +510,7 @@ public class InvoiceWorker { } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting paymentApplicationlist", module); } - if (paymentApplications != null && paymentApplications.size() > 0) { + if (UtilValidate.isNotEmpty(paymentApplications)) { Iterator p = paymentApplications.iterator(); while (p.hasNext()) { GenericValue paymentApplication = (GenericValue) p.next(); diff --git a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java index 050a05ce34..e34a5aac06 100644 --- a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -210,7 +210,7 @@ public class PaymentGatewayServices { otherPaymentMethodAndCreditCardList = EntityUtil.filterByDate(otherPaymentMethodAndCreditCardList, true); } - if (otherPaymentMethodAndCreditCardList != null && otherPaymentMethodAndCreditCardList.size() > 0) { + if (UtilValidate.isNotEmpty(otherPaymentMethodAndCreditCardList)) { Iterator otherPaymentMethodAndCreditCardIter = otherPaymentMethodAndCreditCardList.iterator(); while (otherPaymentMethodAndCreditCardIter.hasNext()) { GenericValue otherPaymentMethodAndCreditCard = (GenericValue) otherPaymentMethodAndCreditCardIter.next(); @@ -885,7 +885,7 @@ public class PaymentGatewayServices { // create the internal messages List messages = (List) context.get("internalRespMsgs"); - if (messages != null && messages.size() > 0) { + if (UtilValidate.isNotEmpty(messages)) { Iterator i = messages.iterator(); while (i.hasNext()) { GenericValue respMsg = delegator.makeValue("PaymentGatewayRespMsg"); @@ -1751,7 +1751,7 @@ public class PaymentGatewayServices { // create the internal messages List messages = (List) context.get("internalRespMsgs"); - if (messages != null && messages.size() > 0) { + if (UtilValidate.isNotEmpty(messages)) { Iterator i = messages.iterator(); while (i.hasNext()) { GenericValue respMsg = delegator.makeValue("PaymentGatewayRespMsg"); @@ -2061,7 +2061,7 @@ public class PaymentGatewayServices { // create the internal messages List messages = (List) context.get("internalRespMsgs"); - if (messages != null && messages.size() > 0) { + if (UtilValidate.isNotEmpty(messages)) { Iterator i = messages.iterator(); while (i.hasNext()) { GenericValue respMsg = delegator.makeValue("PaymentGatewayRespMsg"); @@ -2102,7 +2102,7 @@ public class PaymentGatewayServices { } catch (GenericEntityException e) { Debug.logError(e, module); } - if (orl != null && orl.size() > 0) { + if (UtilValidate.isNotEmpty(orl)) { GenericValue orderRole = EntityUtil.getFirst(orl); partyIdFrom = orderRole.getString("partyId"); } @@ -2312,7 +2312,7 @@ public class PaymentGatewayServices { // create the internal messages List messages = (List) context.get("internalRespMsgs"); - if (messages != null && messages.size() > 0) { + if (UtilValidate.isNotEmpty(messages)) { Iterator i = messages.iterator(); while (i.hasNext()) { GenericValue respMsg = delegator.makeValue("PaymentGatewayRespMsg"); diff --git a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java index 920e297cc8..c23817b6aa 100644 --- a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java +++ b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java @@ -268,7 +268,7 @@ public class PaymentWorker { } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting paymentApplicationlist", module); } - if (paymentApplications != null && paymentApplications.size() > 0) { + if (UtilValidate.isNotEmpty(paymentApplications)) { Iterator p = paymentApplications.iterator(); while (p.hasNext()) { GenericValue paymentApplication = (GenericValue) p.next(); @@ -282,7 +282,7 @@ public class PaymentWorker { } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting the 'to' paymentApplicationlist", module); } - if (paymentApplications != null && paymentApplications.size() > 0) { + if (UtilValidate.isNotEmpty(paymentApplications)) { Iterator p = paymentApplications.iterator(); while (p.hasNext()) { GenericValue paymentApplication = (GenericValue) p.next(); diff --git a/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java b/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java index 8b6ae88f9f..5f63f5fec7 100644 --- a/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java +++ b/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java @@ -222,7 +222,7 @@ public class SelectRespServlet extends SelectServlet implements SelectDefs { } catch (GenericEntityException e) { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); } - if (paymentPrefs != null && paymentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(paymentPrefs)) { Iterator i = paymentPrefs.iterator(); while (okay && i.hasNext()) { GenericValue pref = (GenericValue) i.next(); diff --git a/applications/content/src/org/ofbiz/content/cms/CmsEvents.java b/applications/content/src/org/ofbiz/content/cms/CmsEvents.java index 07b6f9bd42..935d5c8adf 100644 --- a/applications/content/src/org/ofbiz/content/cms/CmsEvents.java +++ b/applications/content/src/org/ofbiz/content/cms/CmsEvents.java @@ -254,7 +254,7 @@ public class CmsEvents { } publishPoints = EntityUtil.filterByDate(publishPoints); - if (publishPoints != null && publishPoints.size() > 0) { + if (UtilValidate.isNotEmpty(publishPoints)) { if (Debug.verboseOn()) Debug.logVerbose("Found publish points: " + publishPoints, module); return true; } else { diff --git a/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java b/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java index e13a298d65..c1f7759647 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java +++ b/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java @@ -99,10 +99,10 @@ public class ContentServicesComplex { viewName = "ContentAssocDataResourceViewTo"; } exprList.add(joinExpr); - if (assocTypes != null && assocTypes.size() > 0) { + if (UtilValidate.isNotEmpty(assocTypes)) { exprList.add(EntityCondition.makeCondition("caContentAssocTypeId", EntityOperator.IN, assocTypes)); } - if (contentTypes != null && contentTypes.size() > 0) { + if (UtilValidate.isNotEmpty(contentTypes)) { exprList.add(EntityCondition.makeCondition("contentTypeId", EntityOperator.IN, contentTypes)); } @@ -300,7 +300,7 @@ public class ContentServicesComplex { while (it.hasNext()) { contentAssoc = (GenericValue)it.next(); content = contentAssoc.getRelatedOneCache(assocRelationName); - if (contentTypes != null && contentTypes.size() > 0) { + if (UtilValidate.isNotEmpty(contentTypes)) { String contentTypeId = (String)content.get("contentTypeId"); if (contentTypes.contains(contentTypeId)) { contentAssocDataResourceView = delegator.makeValue(viewName); @@ -333,7 +333,7 @@ public class ContentServicesComplex { } Map results = FastMap.newInstance(); results.put("entityList", contentAssocDataResourceList); - if (contentAssocDataResourceList != null && contentAssocDataResourceList.size() > 0) { + if (UtilValidate.isNotEmpty(contentAssocDataResourceList)) { results.put("view", contentAssocDataResourceList.get(0)); } return results; diff --git a/applications/content/src/org/ofbiz/content/content/ContentWorker.java b/applications/content/src/org/ofbiz/content/content/ContentWorker.java index 5678fd9ab8..895ab83175 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/org/ofbiz/content/content/ContentWorker.java @@ -140,7 +140,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { "caContentAssocTypeId", "PUBLISH_LINK"), UtilMisc.toList("caFromDate")); relContentIds = EntityUtil.filterByDate(relContentIds, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); - if (relContentIds != null && relContentIds.size() > 0) { + if (UtilValidate.isNotEmpty(relContentIds)) { content = EntityUtil.getFirst(relContentIds); } @@ -488,7 +488,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } List kids = (List)currentNode.get("kids"); - if (kids != null && kids.size() > 0) { + if (UtilValidate.isNotEmpty(kids)) { int idx = 0; while (idx < kids.size()) { currentNode = (Map)kids.get(idx); @@ -722,7 +722,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { String contentId = (String) assoc.get(contentIdName); if (Debug.infoOn()) Debug.logInfo("contentId:" + contentId, ""); content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); - if (contentTypes != null && contentTypes.size() > 0) { + if (UtilValidate.isNotEmpty(contentTypes)) { contentTypeId = (String) content.get("contentTypeId"); if (contentTypes.contains(contentTypeId)) { contentList.add(content); @@ -801,7 +801,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { joinExpr = EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId); } exprList.add(joinExpr); - if (assocTypes != null && assocTypes.size() > 0) { + if (UtilValidate.isNotEmpty(assocTypes)) { List exprListOr = FastList.newInstance(); Iterator it = assocTypes.iterator(); while (it.hasNext()) { @@ -1101,7 +1101,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { GenericValue view = null; List lst = delegator.findByAndCache("ContentDataResourceView", UtilMisc.toMap("contentId", contentId)); //if (Debug.infoOn()) Debug.logInfo("getContentCache, lst(2):" + lst, ""); - if (lst != null && lst.size() > 0) { + if (UtilValidate.isNotEmpty(lst)) { view = (GenericValue) lst.get(0); } return view; @@ -1117,7 +1117,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { List passedGlobalNodeTrail = null; GenericValue currentContent = null; String viewContentId = null; - if (trail != null && trail.size() > 0) { + if (UtilValidate.isNotEmpty(trail)) { passedGlobalNodeTrail = UtilMisc.makeListWritable(trail); } else { passedGlobalNodeTrail = FastList.newInstance(); diff --git a/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java index 88f466c946..b969e420a6 100644 --- a/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java +++ b/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java @@ -534,7 +534,7 @@ public class DataResourceWorker implements org.ofbiz.widget.DataResourceWorkerI // first item in map is the most current directory File latestDir = null; - if (dirMap != null && dirMap.size() > 0) { + if (UtilValidate.isNotEmpty(dirMap)) { latestDir = (File) dirMap.values().iterator().next(); if (latestDir != null) { File[] dirList = latestDir.listFiles(); diff --git a/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java b/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java index 1528d6f070..4b0914e0ea 100644 --- a/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java +++ b/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java @@ -311,7 +311,7 @@ public class SurveyWrapper { Debug.logError(e, module); } - if (responses != null && responses.size() > 0) { + if (UtilValidate.isNotEmpty(responses)) { GenericValue response = EntityUtil.getFirst(responses); responseId = response.getString("surveyResponseId"); if (responses.size() > 1) { @@ -359,7 +359,7 @@ public class SurveyWrapper { Debug.logError(e, module); } - if (answers != null && answers.size() > 0) { + if (UtilValidate.isNotEmpty(answers)) { Iterator i = answers.iterator(); while (i.hasNext()) { GenericValue answer = (GenericValue) i.next(); @@ -369,7 +369,7 @@ public class SurveyWrapper { } // get the pass-thru (posted form data) - if (passThru != null && passThru.size() > 0) { + if (UtilValidate.isNotEmpty(passThru)) { Iterator i = passThru.keySet().iterator(); while (i.hasNext()) { String key = (String) i.next(); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java index e0aa67adf6..e7ff9d8398 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java @@ -138,7 +138,7 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel { } if (UtilValidate.isNotEmpty(lastPassedContentId)) { - if (trail != null && trail.size() > 0) { + if (UtilValidate.isNotEmpty(trail)) { Map nd = (Map)trail.get(0); String firstTrailContentId = (String)nd.get("contentId"); if (UtilValidate.isNotEmpty(firstTrailContentId) diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java index ef8435a86e..d4aaeb6284 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java @@ -30,6 +30,7 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.base.util.Debug; @@ -149,7 +150,7 @@ public class BOMHelper { GenericValue orderItem = shipmentPlan.getRelatedOne("OrderItem"); List productionRuns = delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"))); - if (productionRuns != null && productionRuns.size() > 0) { + if (UtilValidate.isNotEmpty(productionRuns)) { Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", module); continue; } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java index ee73426676..de368c8a32 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java @@ -261,7 +261,7 @@ public class BOMNode { if (newNode == oneChildNode) { // If no substitution has been done (no valid rule applied), // we try to set the default (first) node-substitution - if (genericNodeRules != null && genericNodeRules.size() > 0) { + if (UtilValidate.isNotEmpty(genericNodeRules)) { // FIXME //... } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java index 0b6c8df15c..9e8a50cd42 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java @@ -557,7 +557,7 @@ public class BOMServices { if (productsInPackages != null && productsInPackages.size() == 0) { productsInPackages = null; } - if (productsInPackages != null && productsInPackages.size() > 0) { + if (UtilValidate.isNotEmpty(productsInPackages)) { orderShipmentReadMap.put("productsInPackages", productsInPackages); } } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java index 0b0d2f6074..0c328c0c13 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java @@ -2398,7 +2398,7 @@ public class ProductionRunServices { } try { List existingProductionRuns = delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId"))); - if (existingProductionRuns != null && existingProductionRuns.size() > 0) { + if (UtilValidate.isNotEmpty(existingProductionRuns)) { Debug.logWarning("Production Run for order item [" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + "] already exists.", module); continue; } diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java index 6518a80424..5af9e7913b 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java @@ -555,7 +555,7 @@ public class MrpServices { // TODO : change the return type to boolean to be able to test if all is ok or if it have had a exception GenericDelegator delegator = product.getDelegator(); - if (listComponent != null && listComponent.size() >0) { + if (UtilValidate.isNotEmpty(listComponent)) { Iterator listComponentIter = listComponent.iterator(); while (listComponentIter.hasNext()) { BOMNode node = (BOMNode) listComponentIter.next(); @@ -744,7 +744,7 @@ public class MrpServices { return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]"); } components = (List)serviceResponse.get("components"); - if (components != null && components.size() > 0) { + if (UtilValidate.isNotEmpty(components)) { BOMNode node = ((BOMNode)components.get(0)).getParentNode(); isBuilt = node.isManufactured(); } else { @@ -786,7 +786,7 @@ public class MrpServices { } else { routing = null; } - if (components != null && components.size() > 0) { + if (UtilValidate.isNotEmpty(components)) { BOMNode node = ((BOMNode)components.get(0)).getParentNode(); isBuilt = node.isManufactured(); } else { diff --git a/applications/order/src/org/ofbiz/order/OrderManagerEvents.java b/applications/order/src/org/ofbiz/order/OrderManagerEvents.java index 7ab1035e74..3ecaba4b29 100644 --- a/applications/order/src/org/ofbiz/order/OrderManagerEvents.java +++ b/applications/order/src/org/ofbiz/order/OrderManagerEvents.java @@ -246,7 +246,7 @@ public class OrderManagerEvents { } catch (GenericEntityException e) { Debug.logError(e, "ERROR: Unable to get existing payment preferences from order", module); } - if (currentPrefs != null && currentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(currentPrefs)) { Iterator cpi = currentPrefs.iterator(); while (cpi.hasNext()) { GenericValue cp = (GenericValue) cpi.next(); diff --git a/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java b/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java index 763e5788e3..a92a619845 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java +++ b/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java @@ -25,10 +25,10 @@ import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; @@ -184,7 +184,7 @@ public class OrderChangeHelper { } catch (GenericEntityException e) { Debug.logError(e, "ERROR: Unable to get OrderItem records for OrderHeader : " + orderId, module); } - if (orderItems != null && orderItems.size() > 0) { + if (UtilValidate.isNotEmpty(orderItems)) { Iterator oii = orderItems.iterator(); while (oii.hasNext()) { GenericValue orderItem = (GenericValue) oii.next(); diff --git a/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java b/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java index 483f214cd8..61f6cca598 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java +++ b/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java @@ -1430,7 +1430,7 @@ public class OrderReadHelper { } catch (GenericEntityException e) { Debug.logWarning(e, module); } - if (receipts != null && receipts.size() > 0) { + if (UtilValidate.isNotEmpty(receipts)) { Iterator recIter = receipts.iterator(); while (recIter.hasNext()) { GenericValue rec = (GenericValue) recIter.next(); @@ -1468,7 +1468,7 @@ public class OrderReadHelper { } catch (GenericEntityException e) { Debug.logWarning(e, module); } - if (receipts != null && receipts.size() > 0) { + if (UtilValidate.isNotEmpty(receipts)) { Iterator recIter = receipts.iterator(); while (recIter.hasNext()) { GenericValue rec = (GenericValue) recIter.next(); @@ -1534,7 +1534,7 @@ public class OrderReadHelper { Debug.logError(e, "Unable to get OrderItemBilling from OrderItem"); } - if (orderItemBillings != null && orderItemBillings.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemBillings)) { // get the ProductContent records List productContents = null; try { @@ -1550,7 +1550,7 @@ public class OrderReadHelper { productContents = EntityUtil.filterByDate(productContents); productContents = EntityUtil.filterByOr(productContents, cExprs); - if (productContents != null && productContents.size() > 0) { + if (UtilValidate.isNotEmpty(productContents)) { // make sure we are still within the allowed timeframe and use limits Iterator pci = productContents.iterator(); while (pci.hasNext()) { @@ -2356,7 +2356,7 @@ public class OrderReadHelper { public static BigDecimal calcOrderAdjustments(List orderHeaderAdjustments, BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) { BigDecimal adjTotal = ZERO; - if (orderHeaderAdjustments != null && orderHeaderAdjustments.size() > 0) { + if (UtilValidate.isNotEmpty(orderHeaderAdjustments)) { List filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false); Iterator adjIt = filteredAdjs.iterator(); @@ -2577,7 +2577,7 @@ public class OrderReadHelper { public static BigDecimal calcItemAdjustments(BigDecimal quantity, BigDecimal unitPrice, List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) { BigDecimal adjTotal = ZERO; - if (adjustments != null && adjustments.size() > 0) { + if (UtilValidate.isNotEmpty(adjustments)) { List filteredAdjs = filterOrderAdjustments(adjustments, includeOther, includeTax, includeShipping, forTax, forShipping); Iterator adjIt = filteredAdjs.iterator(); @@ -2593,7 +2593,7 @@ public class OrderReadHelper { public static BigDecimal calcItemAdjustmentsRecurringBd(BigDecimal quantity, BigDecimal unitPrice, List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) { BigDecimal adjTotal = ZERO; - if (adjustments != null && adjustments.size() > 0) { + if (UtilValidate.isNotEmpty(adjustments)) { List filteredAdjs = filterOrderAdjustments(adjustments, includeOther, includeTax, includeShipping, forTax, forShipping); Iterator adjIt = filteredAdjs.iterator(); @@ -2634,7 +2634,7 @@ public class OrderReadHelper { public static List filterOrderAdjustments(List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) { List newOrderAdjustmentsList = FastList.newInstance(); - if (adjustments != null && adjustments.size() > 0) { + if (UtilValidate.isNotEmpty(adjustments)) { Iterator adjIt = adjustments.iterator(); while (adjIt.hasNext()) { @@ -2685,7 +2685,7 @@ public class OrderReadHelper { Debug.logError(e, module); } - if (openOrders != null && openOrders.size() > 0) { + if (UtilValidate.isNotEmpty(openOrders)) { Iterator i = openOrders.iterator(); while (i.hasNext()) { GenericValue order = (GenericValue) i.next(); diff --git a/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java b/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java index bd429d4304..4b2a134139 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java +++ b/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java @@ -158,7 +158,7 @@ public class OrderReturnServices { Debug.logError(e, module); throw new GeneralRuntimeException(e.getMessage()); } - if (itemIssue != null && itemIssue.size() > 0) { + if (UtilValidate.isNotEmpty(itemIssue)) { Debug.log("Found item issuance reference", module); // just use the first one for now; maybe later we can find a better way to determine which was the // actual item being returned; maybe by serial number @@ -215,7 +215,7 @@ public class OrderReturnServices { // get the order header -- the first item will determine which product store to use from the order String productStoreId = null; String emailAddress = null; - if (returnItems != null && returnItems.size() > 0) { + if (UtilValidate.isNotEmpty(returnItems)) { GenericValue firstItem = EntityUtil.getFirst(returnItems); GenericValue orderHeader = null; try { @@ -549,7 +549,7 @@ public class OrderReturnServices { Timestamp now = UtilDateTime.nowTimestamp(); List completedItems = new ArrayList(); - if (returnHeader != null && returnItems != null && returnItems.size() > 0) { + if (returnHeader != null && UtilValidate.isNotEmpty(returnItems)) { Iterator itemsIter = returnItems.iterator(); while (itemsIter.hasNext()) { GenericValue item = (GenericValue) itemsIter.next(); @@ -1350,7 +1350,7 @@ public class OrderReturnServices { } String returnHeaderTypeId = returnHeader.getString("returnHeaderTypeId"); List createdOrderIds = new ArrayList(); - if (returnHeader != null && returnItems != null && returnItems.size() > 0) { + if (returnHeader != null && UtilValidate.isNotEmpty(returnItems)) { Map returnItemsByOrderId = new HashMap(); Map totalByOrder = new HashMap(); groupReturnItemsByOrder(returnItems, returnItemsByOrderId, totalByOrder, delegator, returnId, returnTypeId); diff --git a/applications/order/src/org/ofbiz/order/order/OrderServices.java b/applications/order/src/org/ofbiz/order/order/OrderServices.java index 81778baf07..b1cd14dd7f 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/org/ofbiz/order/order/OrderServices.java @@ -372,7 +372,7 @@ public class OrderServices { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderCouldNotFindRelatedFixedAssetForTheProduct",UtilMisc.toMap("productId",orderItem.getString("productId")), locale )); } - if (selFixedAssetProduct != null && selFixedAssetProduct.size() > 0) { + if (UtilValidate.isNotEmpty(selFixedAssetProduct)) { Iterator firstOne = selFixedAssetProduct.iterator(); if(firstOne.hasNext()) { GenericValue fixedAssetProduct = delegator.makeValue("FixedAssetProduct"); @@ -532,7 +532,7 @@ public class OrderServices { // before processing orderItems process orderItemGroups so that they'll be in place for the foreign keys and what not List orderItemGroups = (List) context.get("orderItemGroups"); - if (orderItemGroups != null && orderItemGroups.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemGroups)) { Iterator orderItemGroupIter = orderItemGroups.iterator(); while (orderItemGroupIter.hasNext()) { GenericValue orderItemGroup = (GenericValue) orderItemGroupIter.next(); @@ -561,7 +561,7 @@ public class OrderServices { // set the order attributes List orderAttributes = (List) context.get("orderAttributes"); - if (orderAttributes != null && orderAttributes.size() > 0) { + if (UtilValidate.isNotEmpty(orderAttributes)) { Iterator oattr = orderAttributes.iterator(); while (oattr.hasNext()) { GenericValue oatt = (GenericValue) oattr.next(); @@ -572,7 +572,7 @@ public class OrderServices { // set the order item attributes List orderItemAttributes = (List) context.get("orderItemAttributes"); - if (orderItemAttributes != null && orderItemAttributes.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemAttributes)) { Iterator oiattr = orderItemAttributes.iterator(); while (oiattr.hasNext()) { GenericValue oiatt = (GenericValue) oiattr.next(); @@ -583,7 +583,7 @@ public class OrderServices { // create the order internal notes List orderInternalNotes = (List) context.get("orderInternalNotes"); - if (orderInternalNotes != null && orderInternalNotes.size() > 0) { + if (UtilValidate.isNotEmpty(orderInternalNotes)) { Iterator orderInternalNotesIt = orderInternalNotes.iterator(); while (orderInternalNotesIt.hasNext()) { String orderInternalNote = (String) orderInternalNotesIt.next(); @@ -605,7 +605,7 @@ public class OrderServices { // create the order public notes List orderNotes = (List) context.get("orderNotes"); - if (orderNotes != null && orderNotes.size() > 0) { + if (UtilValidate.isNotEmpty(orderNotes)) { Iterator orderNotesIt = orderNotes.iterator(); while (orderNotesIt.hasNext()) { String orderNote = (String) orderNotesIt.next(); @@ -628,7 +628,7 @@ public class OrderServices { // create the workeffort records // and connect them with the orderitem over the WorkOrderItemFulfillment // create also the techData calendars to keep track of availability of the fixed asset. - if (workEfforts != null && workEfforts.size() > 0) { + if (UtilValidate.isNotEmpty(workEfforts)) { List tempList = new LinkedList(); Iterator we = workEfforts.iterator(); while (we.hasNext()) { @@ -764,7 +764,7 @@ public class OrderServices { // set the orderId on all adjustments; this list will include order and // item adjustments... - if (orderAdjustments != null && orderAdjustments.size() > 0) { + if (UtilValidate.isNotEmpty(orderAdjustments)) { Iterator iter = orderAdjustments.iterator(); while (iter.hasNext()) { @@ -791,7 +791,7 @@ public class OrderServices { // set the order contact mechs List orderContactMechs = (List) context.get("orderContactMechs"); - if (orderContactMechs != null && orderContactMechs.size() > 0) { + if (UtilValidate.isNotEmpty(orderContactMechs)) { Iterator ocmi = orderContactMechs.iterator(); while (ocmi.hasNext()) { @@ -803,7 +803,7 @@ public class OrderServices { // set the order item contact mechs List orderItemContactMechs = (List) context.get("orderItemContactMechs"); - if (orderItemContactMechs != null && orderItemContactMechs.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemContactMechs)) { Iterator oicmi = orderItemContactMechs.iterator(); while (oicmi.hasNext()) { @@ -815,7 +815,7 @@ public class OrderServices { // set the order item ship groups List dropShipGroupIds = FastList.newInstance(); // this list will contain the ids of all the ship groups for drop shipments (no reservations) - if (orderItemShipGroupInfo != null && orderItemShipGroupInfo.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemShipGroupInfo)) { Iterator osiInfos = orderItemShipGroupInfo.iterator(); while (osiInfos.hasNext()) { GenericValue valueObj = (GenericValue) osiInfos.next(); @@ -862,7 +862,7 @@ public class OrderServices { // set the item survey responses List surveyResponses = (List) context.get("orderItemSurveyResponses"); - if (surveyResponses != null && surveyResponses.size() > 0) { + if (UtilValidate.isNotEmpty(surveyResponses)) { Iterator oisr = surveyResponses.iterator(); while (oisr.hasNext()) { GenericValue surveyResponse = (GenericValue) oisr.next(); @@ -872,7 +872,7 @@ public class OrderServices { } // set the item price info; NOTE: this must be after the orderItems are stored for referential integrity - if (orderItemPriceInfo != null && orderItemPriceInfo.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemPriceInfo)) { Iterator oipii = orderItemPriceInfo.iterator(); while (oipii.hasNext()) { @@ -890,7 +890,7 @@ public class OrderServices { // set the item associations List orderItemAssociations = (List) context.get("orderItemAssociations"); - if (orderItemAssociations != null && orderItemAssociations.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemAssociations)) { Iterator oia = orderItemAssociations.iterator(); while (oia.hasNext()) { GenericValue orderItemAssociation = (GenericValue) oia.next(); @@ -905,7 +905,7 @@ public class OrderServices { // store the orderProductPromoUseInfos List orderProductPromoUses = (List) context.get("orderProductPromoUses"); - if (orderProductPromoUses != null && orderProductPromoUses.size() > 0) { + if (UtilValidate.isNotEmpty(orderProductPromoUses)) { Iterator orderProductPromoUseIter = orderProductPromoUses.iterator(); while (orderProductPromoUseIter.hasNext()) { GenericValue productPromoUse = (GenericValue) orderProductPromoUseIter.next(); @@ -1004,7 +1004,7 @@ public class OrderServices { // set the order payment info List orderPaymentInfos = (List) context.get("orderPaymentInfo"); - if (orderPaymentInfos != null && orderPaymentInfos.size() > 0) { + if (UtilValidate.isNotEmpty(orderPaymentInfos)) { Iterator oppIter = orderPaymentInfos.iterator(); while (oppIter.hasNext()) { GenericValue valueObj = (GenericValue) oppIter.next(); @@ -1025,7 +1025,7 @@ public class OrderServices { // store the trackingCodeOrder entities List trackingCodeOrders = (List) context.get("trackingCodeOrders"); - if (trackingCodeOrders != null && trackingCodeOrders.size() > 0) { + if (UtilValidate.isNotEmpty(trackingCodeOrders)) { Iterator tkcdordIter = trackingCodeOrders.iterator(); while (tkcdordIter.hasNext()) { GenericValue trackingCodeOrder = (GenericValue) tkcdordIter.next(); @@ -1037,7 +1037,7 @@ public class OrderServices { // store the OrderTerm entities List orderTerms = (List) context.get("orderTerms"); - if (orderTerms != null && orderTerms.size() > 0) { + if (UtilValidate.isNotEmpty(orderTerms)) { Iterator orderTermIter = orderTerms.iterator(); while (orderTermIter.hasNext()) { GenericValue orderTerm = (GenericValue) orderTermIter.next(); @@ -1105,7 +1105,7 @@ public class OrderServices { // START inventory reservation // decrement inventory available for each OrderItemShipGroupAssoc, within the same transaction - if (orderItemShipGroupInfo != null && orderItemShipGroupInfo.size() > 0) { + if (UtilValidate.isNotEmpty(orderItemShipGroupInfo)) { Iterator osiInfos = orderItemShipGroupInfo.iterator(); while (osiInfos.hasNext()) { GenericValue orderItemShipGroupAssoc = (GenericValue) osiInfos.next(); @@ -1494,7 +1494,7 @@ public class OrderServices { List itemAdj = (List) serviceResult.get("itemAdjustments"); // Accumulate the new tax total from the recalculated header adjustments - if (orderAdj != null && orderAdj.size() > 0) { + if (UtilValidate.isNotEmpty(orderAdj)) { Iterator oai = orderAdj.iterator(); while (oai.hasNext()) { GenericValue oa = (GenericValue) oai.next(); @@ -1507,7 +1507,7 @@ public class OrderServices { } // Accumulate the new tax total from the recalculated item adjustments - if (itemAdj != null && itemAdj.size() > 0) { + if (UtilValidate.isNotEmpty(itemAdj)) { for (int i = 0; i < itemAdj.size(); i++) { List itemAdjustments = (List) itemAdj.get(i); Iterator ida = itemAdjustments.iterator(); @@ -1962,7 +1962,7 @@ public class OrderServices { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorCannotGetOrderItemEntity ",locale) + e.getMessage()); } - if (orderItems != null && orderItems.size() > 0) { + if (UtilValidate.isNotEmpty(orderItems)) { List toBeStored = new ArrayList(); Iterator itemsIterator = orderItems.iterator(); while (itemsIterator.hasNext()) { @@ -2812,7 +2812,7 @@ public class OrderServices { } catch (GenericEntityException e) { Debug.logError(e, "Problem getting order item records", module); } - if (orderItems != null && orderItems.size() > 0) { + if (UtilValidate.isNotEmpty(orderItems)) { Iterator oii = orderItems.iterator(); while (oii.hasNext()) { GenericValue orderItem = (GenericValue) oii.next(); @@ -2870,7 +2870,7 @@ public class OrderServices { List digitalItems = new ArrayList(); Map digitalProducts = new HashMap(); - if (orderItems != null && orderItems.size() > 0) { + if (UtilValidate.isNotEmpty(orderItems)) { Iterator i = orderItems.iterator(); while (i.hasNext()) { GenericValue item = (GenericValue) i.next(); @@ -3021,7 +3021,7 @@ public class OrderServices { GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); - if (orderItems != null && orderItems.size() > 0) { + if (UtilValidate.isNotEmpty(orderItems)) { // loop through the digital items to fulfill Iterator itemsIterator = orderItems.iterator(); while (itemsIterator.hasNext()) { @@ -3054,7 +3054,7 @@ public class OrderServices { } } - if (allProductContent != null && allProductContent.size() > 0) { + if (UtilValidate.isNotEmpty(allProductContent)) { // only keep ones with valid dates productContent = EntityUtil.filterByDate(allProductContent, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); Debug.logInfo("Product has " + allProductContent.size() + " associations, " + @@ -3065,7 +3065,7 @@ public class OrderServices { } // now use the ProductContent to fulfill the item - if (productContent != null && productContent.size() > 0) { + if (UtilValidate.isNotEmpty(productContent)) { Iterator prodcontentIterator = productContent.iterator(); while (prodcontentIterator.hasNext()) { GenericValue productContentItem = (GenericValue) prodcontentIterator.next(); diff --git a/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java b/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java index 6da51c7a32..ec7faaab7e 100644 --- a/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java +++ b/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java @@ -60,7 +60,7 @@ public class RequirementServices { EntityCondition.makeCondition("requirementTypeId", EntityOperator.EQUALS, "PRODUCT_REQUIREMENT"), EntityUtil.getFilterByDateExpr() ); - if (statusIds != null && statusIds.size() > 0) { + if (UtilValidate.isNotEmpty(statusIds)) { conditions.add( EntityCondition.makeCondition("statusId", EntityOperator.IN, statusIds) ); } else { conditions.add( EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "REQ_APPROVED") ); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java index 4c05d55d7a..66be1c4b24 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -60,7 +60,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, "checkevents.cart_empty", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -557,7 +557,7 @@ public class CheckOutEvents { // check for customer message(s) List messages = (List) callResult.get("authResultMsgs"); - if (messages != null && messages.size() > 0) { + if (UtilValidate.isNotEmpty(messages)) { request.setAttribute("_EVENT_MESSAGE_LIST_", messages); } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java index a6234997ed..c4c9a1fbc9 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -85,7 +85,7 @@ public class CheckOutHelper { Map result; String errMsg = null; - if (this.cart != null && this.cart.size() > 0) { + if (UtilValidate.isNotEmpty(this.cart)) { errorMessages.addAll(setCheckOutShippingAddressInternal(shippingContactMechId)); } else { errMsg = UtilProperties.getMessage(resource,"checkhelper.no_items_in_cart", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -124,7 +124,7 @@ public class CheckOutHelper { Map result; String errMsg = null; - if (this.cart != null && this.cart.size() > 0) { + if (UtilValidate.isNotEmpty(this.cart)) { errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions, orderAdditionalEmails, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate)); } else { @@ -219,7 +219,7 @@ public class CheckOutHelper { Map result; String errMsg = null; - if (this.cart != null && this.cart.size() > 0) { + if (UtilValidate.isNotEmpty(this.cart)) { errorMessages.addAll(setCheckOutPaymentInternal(selectedPaymentMethods, singleUsePayments, billingAccountId)); } else { errMsg = UtilProperties.getMessage(resource,"checkhelper.no_items_in_cart", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -246,7 +246,7 @@ public class CheckOutHelper { } // set the payment method option - if (selectedPaymentMethods != null && selectedPaymentMethods.size() > 0) { + if (UtilValidate.isNotEmpty(selectedPaymentMethods)) { // clear out the old payments cart.clearPayments(); @@ -360,7 +360,7 @@ public class CheckOutHelper { Map result = null; String errMsg = null; - if (this.cart != null && this.cart.size() > 0) { + if (UtilValidate.isNotEmpty(this.cart)) { this.cart.setShipBeforeDate(shipBefore); this.cart.setShipAfterDate(shipAfter); } else { @@ -388,7 +388,7 @@ public class CheckOutHelper { String errMsg = null; - if (this.cart != null && this.cart.size() > 0) { + if (UtilValidate.isNotEmpty(this.cart)) { // set the general shipping options and method errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions, orderAdditionalEmails, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate)); @@ -480,7 +480,7 @@ public class CheckOutHelper { } } - if (selectedPaymentMethods != null && selectedPaymentMethods.size() > 0) { + if (UtilValidate.isNotEmpty(selectedPaymentMethods)) { if (gcAmt == null || gcAmt.length() == 0) { errMsg = UtilProperties.getMessage(resource,"checkhelper.enter_amount_to_place_on_gift_card", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); @@ -905,7 +905,7 @@ public class CheckOutHelper { // check for online payment methods or in-hand payment types with verbal or external refs List exprs = UtilMisc.toList(EntityCondition.makeCondition("manualRefNum", EntityOperator.NOT_EQUAL, null)); List manualRefPaymentPrefs = EntityUtil.filterByAnd(allPaymentPreferences, exprs); - if (manualRefPaymentPrefs != null && manualRefPaymentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(manualRefPaymentPrefs)) { Iterator i = manualRefPaymentPrefs.iterator(); while (i.hasNext()) { GenericValue opp = (GenericValue) i.next(); @@ -955,7 +955,7 @@ public class CheckOutHelper { // Check the payment preferences; if we have ANY w/ status PAYMENT_NOT_AUTH invoke payment service. // Invoke payment processing. - if (onlinePaymentPrefs != null && onlinePaymentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(onlinePaymentPrefs)) { boolean autoApproveOrder = UtilValidate.isEmpty(productStore.get("autoApproveOrder")) || "Y".equalsIgnoreCase(productStore.getString("autoApproveOrder")); if (orderTotal == 0 && autoApproveOrder) { // if there is nothing to authorize; don't bother @@ -1210,7 +1210,7 @@ public class CheckOutHelper { } } - if (blacklistFound != null && blacklistFound.size() > 0) { + if (UtilValidate.isNotEmpty(blacklistFound)) { return ServiceUtil.returnFailure(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault()))); } else { return ServiceUtil.returnSuccess("success"); @@ -1272,7 +1272,7 @@ public class CheckOutHelper { result = ServiceUtil.returnError(errMsg); return result; } - if (paymentPrefs != null && paymentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(paymentPrefs)) { if (paymentPrefs.size() > 1) { Debug.logError("Too many payment preferences, you cannot have more then one when using external gateways", module); } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java index 5830760aa7..0659e717ac 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java @@ -1708,7 +1708,7 @@ public class ShoppingCart implements Serializable { /** Returns a list of PaymentMethod value objects selected in the cart */ public List getPaymentMethods() { List methods = FastList.newInstance(); - if (paymentInfo != null && paymentInfo.size() > 0) { + if (UtilValidate.isNotEmpty(paymentInfo)) { Iterator paymentMethodIdIter = getPaymentMethodIds().iterator(); while (paymentMethodIdIter.hasNext()) { String paymentMethodId = (String) paymentMethodIdIter.next(); @@ -1731,7 +1731,7 @@ public class ShoppingCart implements Serializable { /** Returns a list of PaymentMethodType value objects selected in the cart */ public List getPaymentMethodTypes() { List types = new LinkedList(); - if (paymentInfo != null && paymentInfo.size() > 0) { + if (UtilValidate.isNotEmpty(paymentInfo)) { Iterator i = getPaymentMethodTypeIds().iterator(); while (i.hasNext()) { String id = (String) i.next(); @@ -2373,7 +2373,7 @@ public class ShoppingCart implements Serializable { try { GenericValue orderParty = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", this.getPartyId())); Collection shippingContactMechList = ContactHelper.getContactMech(orderParty, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false); - if (shippingContactMechList != null && shippingContactMechList.size() > 0) { + if (UtilValidate.isNotEmpty(shippingContactMechList)) { GenericValue shippingContactMech = (GenericValue)(shippingContactMechList.iterator()).next(); this.setShippingContactMechId(shippingContactMech.getString("contactMechId")); } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java index 58a15bfe71..c5e350780c 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -441,7 +441,7 @@ public class ShoppingCartEvents { if (productId != null) { String productStoreId = ProductStoreWorker.getProductStoreId(request); List productSurvey = ProductStoreWorker.getProductSurveys(delegator, productStoreId, productId, "CART_ADD", parentProductId); - if (productSurvey != null && productSurvey.size() > 0) { + if (UtilValidate.isNotEmpty(productSurvey)) { // TODO: implement multiple survey per product GenericValue survey = EntityUtil.getFirst(productSurvey); String surveyResponseId = (String) request.getAttribute("surveyResponseId"); @@ -1401,7 +1401,7 @@ public class ShoppingCartEvents { // } storeReps = EntityUtil.filterByDate(storeReps); - if (storeReps != null && storeReps.size() > 0) { + if (UtilValidate.isNotEmpty(storeReps)) { hasPermission = true; } } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java index afae17a40d..d07b44c727 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java @@ -854,7 +854,7 @@ public class ShoppingCartItem implements java.io.Serializable { String msg = UtilProperties.getMessage(resource, "item.cannot_find_Fixed_Asset", messageMap , cart.getLocale()); return msg; } - if (selFixedAssetProduct != null && selFixedAssetProduct.size() > 0) { + if (UtilValidate.isNotEmpty(selFixedAssetProduct)) { Iterator firstOne = selFixedAssetProduct.iterator(); fixedAssetProduct = (GenericValue) firstOne.next(); } else { @@ -1139,7 +1139,7 @@ public class ShoppingCartItem implements java.io.Serializable { // check if a survey is associated with the item and add to the price calculation List surveyResponses = (List) getAttribute("surveyResponses"); - if (surveyResponses != null && surveyResponses.size() > 0) { + if (UtilValidate.isNotEmpty(surveyResponses)) { priceContext.put("surveyResponseId", surveyResponses.get(0)); } @@ -1772,7 +1772,7 @@ public class ShoppingCartItem implements java.io.Serializable { /** Returns a List of the item's features for supplier*/ public List getFeaturesForSupplier(LocalDispatcher dispatcher,String partyId) { List featureAppls = getStandardFeatureList(); - if (featureAppls != null && featureAppls.size() > 0) { + if (UtilValidate.isNotEmpty(featureAppls)) { try { Map result = dispatcher.runSync("convertFeaturesForSupplier", UtilMisc.toMap("partyId", partyId, "productFeatures", featureAppls)); featuresForSupplier = (List) result.get("convertedProductFeatures"); @@ -2391,7 +2391,7 @@ public class ShoppingCartItem implements java.io.Serializable { // now copy/calc the adjustments Debug.logInfo("Clone's adj: " + item.getAdjustments(), module); - if (item.getAdjustments() != null && item.getAdjustments().size() > 0) { + if (UtilValidate.isNotEmpty(item.getAdjustments())) { List adjustments = new LinkedList(item.getAdjustments()); Iterator adjIterator = adjustments.iterator(); @@ -2423,7 +2423,7 @@ public class ShoppingCartItem implements java.io.Serializable { Debug.logInfo("Item's Adj: " + this.getAdjustments(), module); // re-calc this item's adjustments - if (this.getAdjustments() != null && this.getAdjustments().size() > 0) { + if (UtilValidate.isNotEmpty(this.getAdjustments())) { List adjustments = new LinkedList(this.getAdjustments()); Iterator adjIterator = adjustments.iterator(); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java index b0afa325a8..7cf2212827 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java @@ -238,7 +238,7 @@ public class ShoppingCartServices { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } - if (orderPaymentPrefs != null && orderPaymentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(orderPaymentPrefs)) { Iterator oppi = orderPaymentPrefs.iterator(); while (oppi.hasNext()) { GenericValue opp = (GenericValue) oppi.next(); 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 684d9c9991..af927a83f9 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java @@ -95,7 +95,7 @@ public class ProductDisplayWorker { } } - if (complementProducts != null && complementProducts.size() > 0) { + if (UtilValidate.isNotEmpty(complementProducts)) { Iterator complIter = complementProducts.iterator(); while (complIter.hasNext()) { GenericValue productAssoc = (GenericValue) complIter.next(); @@ -138,7 +138,7 @@ public class ProductDisplayWorker { Debug.logWarning(e, module); } - if (cartAssocs != null && cartAssocs.size() > 0) { + if (UtilValidate.isNotEmpty(cartAssocs)) { return cartAssocs; } else { return null; @@ -231,7 +231,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/shoppingcart/product/ProductPromoWorker.java b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java index 4a0aa19ebf..8585c40ef1 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java @@ -366,7 +366,7 @@ public class ProductPromoWorker { String productPromoId = productPromo.getString("productPromoId"); List productPromoRules = productPromo.getRelatedCache("ProductPromoRule", null, null); - if (productPromoRules != null && productPromoRules.size() > 0) { + if (UtilValidate.isNotEmpty(productPromoRules)) { // always have a useLimit to avoid unlimited looping, default to 1 if no other is specified Long candidateUseLimit = getProductPromoUseLimit(productPromo, partyId, delegator); Long useLimit = candidateUseLimit; @@ -935,7 +935,7 @@ public class ProductPromoWorker { List productCategoryMembers = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", productId, "productCategoryId", productCategoryId)); // and from/thru date within range productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp); - if (productCategoryMembers != null && productCategoryMembers.size() > 0) { + if (UtilValidate.isNotEmpty(productCategoryMembers)) { // if any product is in category, set true and break // then 0 (equals), otherwise 1 (not equals) compareBase = new Integer(0); @@ -969,7 +969,7 @@ public class ProductPromoWorker { // and from/thru date within range partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, true); // then 0 (equals), otherwise 1 (not equals) - if (partyRelationshipList != null && partyRelationshipList.size() > 0) { + if (UtilValidate.isNotEmpty(partyRelationshipList)) { compareBase = new Integer(0); } else { compareBase = new Integer(1); @@ -986,7 +986,7 @@ public class ProductPromoWorker { // and from/thru date within range partyClassificationList = EntityUtil.filterByDate(partyClassificationList, true); // then 0 (equals), otherwise 1 (not equals) - if (partyClassificationList != null && partyClassificationList.size() > 0) { + if (UtilValidate.isNotEmpty(partyClassificationList)) { compareBase = new Integer(0); } else { compareBase = new Integer(1); diff --git a/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java b/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java index f8316d4624..94f58d9299 100644 --- a/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java @@ -522,7 +522,7 @@ public class ShoppingListEvents { * Creates records for survey responses on survey items */ public static int makeListItemSurveyResp(GenericDelegator delegator, GenericValue item, List surveyResps) throws GenericEntityException { - if (surveyResps != null && surveyResps.size() > 0) { + if (UtilValidate.isNotEmpty(surveyResps)) { Iterator i = surveyResps.iterator(); int count = 0; while (i.hasNext()) { @@ -544,7 +544,7 @@ public class ShoppingListEvents { */ public static Map getItemSurveyInfos(List items) { Map surveyInfos = new HashMap(); - if (items != null && items.size() > 0) { + if (UtilValidate.isNotEmpty(items)) { Iterator itemIt = items.iterator(); while (itemIt.hasNext()) { GenericValue item = (GenericValue) itemIt.next(); @@ -569,7 +569,7 @@ public class ShoppingListEvents { Debug.logError(e, module); } - if (surveyResp != null && surveyResp.size() > 0) { + if (UtilValidate.isNotEmpty(surveyResp)) { Iterator respIt = surveyResp.iterator(); while (respIt.hasNext()) { GenericValue resp = (GenericValue) respIt.next(); 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 0d37fcc551..77a318d3e5 100644 --- a/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java +++ b/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java @@ -35,6 +35,7 @@ import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilURL; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.datafile.DataFile; import org.ofbiz.datafile.DataFileException; import org.ofbiz.datafile.Record; @@ -285,11 +286,11 @@ public class ZipSalesServices { if (zipLookup != null && zipLookup.size() > 1) { // first filter by city List cityLookup = EntityUtil.filterByAnd(zipLookup, UtilMisc.toMap("city", city.toUpperCase())); - if (cityLookup != null && cityLookup.size() > 0) { + if (UtilValidate.isNotEmpty(cityLookup)) { if (cityLookup.size() > 1) { // filter by county List countyLookup = EntityUtil.filterByAnd(taxLookup, UtilMisc.toMap("countyDefault", "Y")); - if (countyLookup != null && countyLookup.size() > 0) { + if (UtilValidate.isNotEmpty(countyLookup)) { // use the county default taxLookup = countyLookup; } else { @@ -303,7 +304,7 @@ public class ZipSalesServices { } else { // no city found; lookup default city List defaultLookup = EntityUtil.filterByAnd(zipLookup, UtilMisc.toMap("generalDefault", "Y")); - if (defaultLookup != null && defaultLookup.size() > 0) { + if (UtilValidate.isNotEmpty(defaultLookup)) { // use the default city lookup taxLookup = defaultLookup; } else { @@ -318,7 +319,7 @@ public class ZipSalesServices { // get the first one GenericValue taxEntry = null; - if (taxLookup != null && taxLookup.size() > 0) { + if (UtilValidate.isNotEmpty(taxLookup)) { taxEntry = (GenericValue) taxLookup.iterator().next(); } diff --git a/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java b/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java index 5bfb7c4b30..7a75f72844 100644 --- a/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java +++ b/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java @@ -208,7 +208,7 @@ public class ContactMechWorker { public static void getOrderContactMechValueMaps(PageContext pageContext, String orderId, String orderContactMechValueMapsAttr) { GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); List> maps = getOrderContactMechValueMaps(delegator, orderId); - if (maps != null && maps.size() > 0) { + if (UtilValidate.isNotEmpty(maps)) { pageContext.setAttribute(orderContactMechValueMapsAttr, maps); } } diff --git a/applications/party/src/org/ofbiz/party/party/PartyWorker.java b/applications/party/src/org/ofbiz/party/party/PartyWorker.java index de87efe708..47c67ae229 100644 --- a/applications/party/src/org/ofbiz/party/party/PartyWorker.java +++ b/applications/party/src/org/ofbiz/party/party/PartyWorker.java @@ -302,7 +302,7 @@ public class PartyWorker { } } - if (validFound != null && validFound.size() > 0) { + if (UtilValidate.isNotEmpty(validFound)) { for (GenericValue partyAndAddr: validFound) { String partyId = partyAndAddr.getString("partyId"); String cmId = partyAndAddr.getString("contactMechId"); diff --git a/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java b/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java index 658ae2c781..cc51dfce88 100644 --- a/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java +++ b/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java @@ -262,7 +262,7 @@ public class CatalogWorker { List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_BROWSE_ROOT"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); @@ -282,7 +282,7 @@ public class CatalogWorker { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_SEARCH"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); } else { @@ -294,7 +294,7 @@ public class CatalogWorker { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_VIEW_ALLW"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); } else { @@ -306,7 +306,7 @@ public class CatalogWorker { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_PURCH_ALLW"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); } else { @@ -323,7 +323,7 @@ public class CatalogWorker { List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_PROMOTIONS"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); @@ -361,7 +361,7 @@ public class CatalogWorker { List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); @@ -381,7 +381,7 @@ public class CatalogWorker { Collection prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD"); - if (prodCatalogCategories != null && prodCatalogCategories.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogCategories)) { Iterator pccIter = prodCatalogCategories.iterator(); while (pccIter.hasNext()) { diff --git a/applications/product/src/org/ofbiz/product/category/CategoryServices.java b/applications/product/src/org/ofbiz/product/category/CategoryServices.java index 6f24ca5430..3460194485 100644 --- a/applications/product/src/org/ofbiz/product/category/CategoryServices.java +++ b/applications/product/src/org/ofbiz/product/category/CategoryServices.java @@ -262,7 +262,7 @@ public class CategoryServices { } // filter out the view allow before getting the sublist - if (viewProductCategoryId != null && productCategoryMembers.size() > 0) { + if (UtilValidate.isNotEmpty(viewProductCategoryId)) { productCategoryMembers = CategoryWorker.filterProductsInCategory(delegator, productCategoryMembers, viewProductCategoryId); listSize = productCategoryMembers.size(); } @@ -321,7 +321,7 @@ public class CategoryServices { } } else { productCategoryMembers = pli.getCompleteList(); - if (viewProductCategoryId != null && productCategoryMembers.size() > 0) { + if (UtilValidate.isNotEmpty(viewProductCategoryId)) { // fiter out the view allow productCategoryMembers = CategoryWorker.filterProductsInCategory(delegator, productCategoryMembers, viewProductCategoryId); } diff --git a/applications/product/src/org/ofbiz/product/category/CategoryWorker.java b/applications/product/src/org/ofbiz/product/category/CategoryWorker.java index e921bf2b5e..b78fae2fd8 100644 --- a/applications/product/src/org/ofbiz/product/category/CategoryWorker.java +++ b/applications/product/src/org/ofbiz/product/category/CategoryWorker.java @@ -176,7 +176,7 @@ public class CategoryWorker { Debug.logWarning(e.getMessage(), module); rollups = null; } - if (rollups != null && rollups.size() > 0) { + if (UtilValidate.isNotEmpty(rollups)) { // Debug.log("Rollup size: " + rollups.size(), module); Iterator ri = rollups.iterator(); @@ -387,7 +387,7 @@ public class CategoryWorker { public static String lastTrailItem(ServletRequest request) { List crumb = getTrail(request); - if (crumb != null && crumb.size() > 0) { + if (UtilValidate.isNotEmpty(crumb)) { return (String) crumb.get(crumb.size() - 1); } else { return null; @@ -405,7 +405,7 @@ public class CategoryWorker { GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId)); List productAssocs = ProductWorker.getVariantVirtualAssocs(product); //this does take into account that a product could be a variant of multiple products, but this shouldn't ever really happen... - if (productAssocs != null && productAssocs.size() > 0) { + if (UtilValidate.isNotEmpty(productAssocs)) { Iterator pasIter = productAssocs.iterator(); while (pasIter.hasNext()) { GenericValue productAssoc = (GenericValue) pasIter.next(); diff --git a/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java b/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java index 8d02add122..65dbc51241 100644 --- a/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java +++ b/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java @@ -138,7 +138,7 @@ public class ProductConfigWrapper implements Serializable { if (UtilValidate.isNotEmpty(configId)) { this.configId = configId; List productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId)); - if (productConfigConfig != null && productConfigConfig.size() > 0) { + if (UtilValidate.isNotEmpty(productConfigConfig)) { Iterator pccIt = productConfigConfig.iterator(); while (pccIt.hasNext()) { GenericValue pcc =(GenericValue) pccIt.next(); diff --git a/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java b/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java index ef8d47afe2..7fa9114ad0 100644 --- a/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java +++ b/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java @@ -653,7 +653,7 @@ public class InventoryServices { Double availableToPromiseTotal = new Double(0); Double quantityOnHandTotal = new Double(0); - if (productAssocList != null && productAssocList.size() > 0) { + if (UtilValidate.isNotEmpty(productAssocList)) { // minimum QOH and ATP encountered double minQuantityOnHandTotal = Double.MAX_VALUE; double minAvailableToPromiseTotal = Double.MAX_VALUE; diff --git a/applications/product/src/org/ofbiz/product/price/PriceServices.java b/applications/product/src/org/ofbiz/product/price/PriceServices.java index ca86a0b24e..c5d4c0411e 100644 --- a/applications/product/src/org/ofbiz/product/price/PriceServices.java +++ b/applications/product/src/org/ofbiz/product/price/PriceServices.java @@ -300,7 +300,7 @@ public class PriceServices { } // if any of these prices is missing and this product is a variant, default to the corresponding price on the virtual product - if (virtualProductPrices != null && virtualProductPrices.size() > 0) { + if (UtilValidate.isNotEmpty(virtualProductPrices)) { if (listPriceValue == null) { List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE")); listPriceValue = EntityUtil.getFirst(virtualTempPrices); @@ -741,7 +741,7 @@ public class PriceServices { // for we will always include any rules that go by category, shouldn't be too many to iterate through each time and will save on cache entries // note that we always want to put the category, quantity, etc ones that find all rules with these conditions in separate cache lists so that they can be easily cleared Collection productCategoryIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CAT_ID")); - if (productCategoryIdConds != null && productCategoryIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(productCategoryIdConds)) { Iterator productCategoryIdCondsIter = productCategoryIdConds.iterator(); while (productCategoryIdCondsIter.hasNext()) { GenericValue productCategoryIdCond = (GenericValue) productCategoryIdCondsIter.next(); @@ -751,7 +751,7 @@ public class PriceServices { // by productFeatureId Collection productFeatureIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_FEAT_ID")); - if (productFeatureIdConds != null && productFeatureIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(productFeatureIdConds)) { Iterator productFeatureIdCondsIter = productFeatureIdConds.iterator(); while (productFeatureIdCondsIter.hasNext()) { GenericValue productFeatureIdCond = (GenericValue) productFeatureIdCondsIter.next(); @@ -763,7 +763,7 @@ public class PriceServices { // we could say that all rules with quantity on them must have one of these other values // but, no we'll do it the other way, any that have a quantity will always get compared Collection quantityConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_QUANTITY")); - if (quantityConds != null && quantityConds.size() > 0) { + if (UtilValidate.isNotEmpty(quantityConds)) { Iterator quantityCondsIter = quantityConds.iterator(); while (quantityCondsIter.hasNext()) { GenericValue quantityCond = (GenericValue) quantityCondsIter.next(); @@ -773,7 +773,7 @@ public class PriceServices { // by roleTypeId Collection roleTypeIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_ROLE_TYPE")); - if (roleTypeIdConds != null && roleTypeIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(roleTypeIdConds)) { Iterator roleTypeIdCondsIter = roleTypeIdConds.iterator(); while (roleTypeIdCondsIter.hasNext()) { GenericValue roleTypeIdCond = (GenericValue) roleTypeIdCondsIter.next(); @@ -787,7 +787,7 @@ public class PriceServices { // by listPrice Collection listPriceConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_LIST_PRICE")); - if (listPriceConds != null && listPriceConds.size() > 0) { + if (UtilValidate.isNotEmpty(listPriceConds)) { Iterator listPriceCondsIter = listPriceConds.iterator(); while (listPriceCondsIter.hasNext()) { GenericValue listPriceCond = (GenericValue) listPriceCondsIter.next(); @@ -799,7 +799,7 @@ public class PriceServices { // by productId Collection productIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", productId)); - if (productIdConds != null && productIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(productIdConds)) { Iterator productIdCondsIter = productIdConds.iterator(); while (productIdCondsIter.hasNext()) { GenericValue productIdCond = (GenericValue) productIdCondsIter.next(); @@ -810,7 +810,7 @@ public class PriceServices { // by virtualProductId, if not null if (virtualProductId != null) { Collection virtualProductIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", virtualProductId)); - if (virtualProductIdConds != null && virtualProductIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(virtualProductIdConds)) { Iterator virtualProductIdCondsIter = virtualProductIdConds.iterator(); while (virtualProductIdCondsIter.hasNext()) { GenericValue virtualProductIdCond = (GenericValue) virtualProductIdCondsIter.next(); @@ -822,7 +822,7 @@ public class PriceServices { // by prodCatalogId - which is optional in certain cases if (UtilValidate.isNotEmpty(prodCatalogId)) { Collection prodCatalogIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CLG_ID", "condValue", prodCatalogId)); - if (prodCatalogIdConds != null && prodCatalogIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(prodCatalogIdConds)) { Iterator prodCatalogIdCondsIter = prodCatalogIdConds.iterator(); while (prodCatalogIdCondsIter.hasNext()) { GenericValue prodCatalogIdCond = (GenericValue) prodCatalogIdCondsIter.next(); @@ -834,7 +834,7 @@ public class PriceServices { // by productStoreGroupId if (UtilValidate.isNotEmpty(productStoreGroupId)) { Collection storeGroupConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_SGRP_ID", "condValue", productStoreGroupId)); - if (storeGroupConds != null && storeGroupConds.size() > 0) { + if (UtilValidate.isNotEmpty(storeGroupConds)) { Iterator storeGroupCondsIter = storeGroupConds.iterator(); while (storeGroupCondsIter.hasNext()) { GenericValue storeGroupCond = (GenericValue) storeGroupCondsIter.next(); @@ -846,7 +846,7 @@ public class PriceServices { // by webSiteId if (UtilValidate.isNotEmpty(webSiteId)) { Collection webSiteIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_WEBSITE_ID", "condValue", webSiteId)); - if (webSiteIdConds != null && webSiteIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(webSiteIdConds)) { Iterator webSiteIdCondsIter = webSiteIdConds.iterator(); while (webSiteIdCondsIter.hasNext()) { GenericValue webSiteIdCond = (GenericValue) webSiteIdCondsIter.next(); @@ -858,7 +858,7 @@ public class PriceServices { // by partyId if (UtilValidate.isNotEmpty(partyId)) { Collection partyIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PARTY_ID", "condValue", partyId)); - if (partyIdConds != null && partyIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(partyIdConds)) { Iterator partyIdCondsIter = partyIdConds.iterator(); while (partyIdCondsIter.hasNext()) { GenericValue partyIdCond = (GenericValue) partyIdCondsIter.next(); @@ -869,7 +869,7 @@ public class PriceServices { // by currencyUomId Collection currencyUomIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_CURRENCY_UOMID", "condValue", currencyUomId)); - if (currencyUomIdConds != null && currencyUomIdConds.size() > 0) { + if (UtilValidate.isNotEmpty(currencyUomIdConds)) { Iterator currencyUomIdCondsIter = currencyUomIdConds.iterator(); while (currencyUomIdCondsIter.hasNext()) { GenericValue currencyUomIdCond = (GenericValue) currencyUomIdCondsIter.next(); @@ -1171,7 +1171,7 @@ public class PriceServices { // and from/thru date within range productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) - if (productCategoryMembers != null && productCategoryMembers.size() > 0) { + if (UtilValidate.isNotEmpty(productCategoryMembers)) { compare = 0; } else { compare = 1; @@ -1185,7 +1185,7 @@ public class PriceServices { UtilMisc.toMap("productId", virtualProductId, "productCategoryId", productCategoryId)); // and from/thru date within range virtualProductCategoryMembers = EntityUtil.filterByDate(virtualProductCategoryMembers, nowTimestamp, null, null, true); - if (virtualProductCategoryMembers != null && virtualProductCategoryMembers.size() > 0) { + if (UtilValidate.isNotEmpty(virtualProductCategoryMembers)) { // we found a member record? great, then this condition is satisfied compare = 0; } @@ -1200,7 +1200,7 @@ public class PriceServices { // and from/thru date within range productFeatureAppls = EntityUtil.filterByDate(productFeatureAppls, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) - if (productFeatureAppls != null && productFeatureAppls.size() > 0) { + if (UtilValidate.isNotEmpty(productFeatureAppls)) { compare = 0; } else { compare = 1; @@ -1251,14 +1251,14 @@ public class PriceServices { // and from/thru date within range partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) - if (partyRelationshipList != null && partyRelationshipList.size() > 0) { + if (UtilValidate.isNotEmpty(partyRelationshipList)) { compare = 0; } else { // before setting 1 try one more query: look for a 2 hop relationship List partyRelationshipTwoHopList = delegator.findByAndCache("PartyRelationshipToFrom", UtilMisc.toMap("onePartyIdFrom", groupPartyId, "twoPartyIdTo", partyId, "onePartyRelationshipTypeId", "GROUP_ROLLUP", "twoPartyRelationshipTypeId", "GROUP_ROLLUP")); partyRelationshipTwoHopList = EntityUtil.filterByDate(partyRelationshipTwoHopList, nowTimestamp, "oneFromDate", "oneThruDate", true); partyRelationshipTwoHopList = EntityUtil.filterByDate(partyRelationshipTwoHopList, nowTimestamp, "twoFromDate", "twoThruDate", true); - if (partyRelationshipTwoHopList != null && partyRelationshipTwoHopList.size() > 0) { + if (UtilValidate.isNotEmpty(partyRelationshipTwoHopList)) { compare = 0; } else { compare = 1; @@ -1276,7 +1276,7 @@ public class PriceServices { // and from/thru date within range partyClassificationList = EntityUtil.filterByDate(partyClassificationList, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) - if (partyClassificationList != null && partyClassificationList.size() > 0) { + if (UtilValidate.isNotEmpty(partyClassificationList)) { compare = 0; } else { compare = 1; diff --git a/applications/product/src/org/ofbiz/product/product/ProductSearch.java b/applications/product/src/org/ofbiz/product/product/ProductSearch.java index 3e7bea36a8..3a241f2769 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductSearch.java +++ b/applications/product/src/org/ofbiz/product/product/ProductSearch.java @@ -91,7 +91,7 @@ public class ProductSearch { productSearchConstraintList.add(new KeywordConstraint(keywordsString, anyPrefix, anySuffix, null, isAnd)); } - if (featureIdSet != null && featureIdSet.size() > 0) { + if (UtilValidate.isNotEmpty(featureIdSet)) { Iterator featureIdIter = featureIdSet.iterator(); while (featureIdIter.hasNext()) { String productFeatureId = (String) featureIdIter.next(); @@ -2141,7 +2141,7 @@ public class ProductSearch { } // Features - if (featureIdSet != null && featureIdSet.size() > 0) { + if (UtilValidate.isNotEmpty(featureIdSet)) { Iterator featureIdIter = featureIdSet.iterator(); while (featureIdIter.hasNext()) { String productFeatureId = (String) featureIdIter.next(); diff --git a/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java b/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java index f6efec9140..ca8e0bed4b 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java +++ b/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java @@ -462,7 +462,7 @@ public class ProductSearchEvents { List productSearchConstraintList = ProductSearchSession.ProductSearchOptions.getConstraintList(session); // if no constraints, don't do a search... - if (productSearchConstraintList != null && productSearchConstraintList.size() > 0) { + if (UtilValidate.isNotEmpty(productSearchConstraintList)) { ResultSortOrder resultSortOrder = ProductSearchSession.ProductSearchOptions.getResultSortOrder(request); ProductSearchSession.checkSaveSearchOptionsHistory(session); ProductSearchContext productSearchContext = new ProductSearchContext(delegator, visitId); diff --git a/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java b/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java index c4d43ac453..723aedb7b5 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java +++ b/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java @@ -393,7 +393,7 @@ public class ProductSearchSession { Debug.logError(e, "Error reading ProductStoreKeywordOvrd list, not doing keyword override", module); } - if (productStoreKeywordOvrdList != null && productStoreKeywordOvrdList.size() > 0) { + if (UtilValidate.isNotEmpty(productStoreKeywordOvrdList)) { Iterator productStoreKeywordOvrdIter = productStoreKeywordOvrdList.iterator(); while (productStoreKeywordOvrdIter.hasNext()) { GenericValue productStoreKeywordOvrd = (GenericValue) productStoreKeywordOvrdIter.next(); @@ -872,7 +872,7 @@ public class ProductSearchSession { String visitId = VisitHandler.getVisitId(session); List productSearchConstraintList = ProductSearchOptions.getConstraintList(session); // if no constraints, don't do a search... - if (productSearchConstraintList != null && productSearchConstraintList.size() > 0) { + if (UtilValidate.isNotEmpty(productSearchConstraintList)) { // if the search options have changed since the last search, put at the beginning of the options history list checkSaveSearchOptionsHistory(session); diff --git a/applications/product/src/org/ofbiz/product/product/ProductServices.java b/applications/product/src/org/ofbiz/product/product/ProductServices.java index f5c74e607e..18f4de2ebe 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductServices.java +++ b/applications/product/src/org/ofbiz/product/product/ProductServices.java @@ -462,8 +462,8 @@ public class ProductServices { } // filter the list by date productAssocs = EntityUtil.filterByDate(productAssocs); - // first check to see if there is a view allow category and if these producta are in it... - if (checkViewAllow && prodCatalogId != null && productAssocs != null && productAssocs.size() > 0) { + // first check to see if there is a view allow category and if these products are in it... + if (checkViewAllow && prodCatalogId != null && UtilValidate.isNotEmpty(productAssocs)) { String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, prodCatalogId); if (viewProductCategoryId != null) { if (productIdTo == null) { @@ -587,7 +587,7 @@ public class ProductServices { Object key = groupIterator.next(); List itemList = (List) group.get(key); - if (itemList != null && itemList.size() > 0) { + if (UtilValidate.isNotEmpty(itemList)) { Map subGroup = makeGroup(delegator, featureList, itemList, order, index + 1); group.put(key, subGroup); } else { diff --git a/applications/product/src/org/ofbiz/product/product/ProductWorker.java b/applications/product/src/org/ofbiz/product/product/ProductWorker.java index 6138e2ddf2..41e703a257 100644 --- a/applications/product/src/org/ofbiz/product/product/ProductWorker.java +++ b/applications/product/src/org/ofbiz/product/product/ProductWorker.java @@ -399,7 +399,7 @@ public class ProductWorker { if (alternativeOptionProduct != null) { if ("Y".equals(alternativeOptionProduct.getString("isVariant"))) { Set distFeatures = getVariantDistinguishingFeatures(alternativeOptionProduct); - if (distFeatures != null && distFeatures.size() > 0) { + if (UtilValidate.isNotEmpty(distFeatures)) { // Debug.logInfo("Found distinguishing features: " + distFeatures, module); StringBuffer nameBuf = new StringBuffer(); @@ -590,7 +590,7 @@ public class ProductWorker { public static double calcOrderAdjustments(List orderHeaderAdjustments, double subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) { double adjTotal = 0.0; - if (orderHeaderAdjustments != null && orderHeaderAdjustments.size() > 0) { + if (UtilValidate.isNotEmpty(orderHeaderAdjustments)) { List filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false); Iterator adjIt = filteredAdjs.iterator(); @@ -618,7 +618,7 @@ public class ProductWorker { public static List filterOrderAdjustments(List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) { List newOrderAdjustmentsList = new LinkedList(); - if (adjustments != null && adjustments.size() > 0) { + if (UtilValidate.isNotEmpty(adjustments)) { Iterator adjIt = adjustments.iterator(); while (adjIt.hasNext()) { diff --git a/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java b/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java index c94f4f99f6..a59f8253fe 100644 --- a/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java +++ b/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java @@ -700,7 +700,7 @@ public class ProductStoreWorker { return false; } - if (productFacilities != null && productFacilities.size() > 0) { + if (UtilValidate.isNotEmpty(productFacilities)) { Iterator pfIter = productFacilities.iterator(); while (pfIter.hasNext()) { diff --git a/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java b/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java index 6d906ed69a..3d33b92621 100644 --- a/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java +++ b/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java @@ -28,6 +28,7 @@ import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -129,7 +130,7 @@ public class SupplierProductServices { Collection features = (Collection) context.get("productFeatures"); try { - if (partyId != null && features != null && features.size() > 0) { + if (partyId != null && UtilValidate.isNotEmpty(features)) { // loop through all the features, find the related SupplierProductFeature for the given partyId, and // substitue description and idCode for (Iterator fI = features.iterator(); fI.hasNext(); ) { diff --git a/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java b/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java index 64a400318a..7bac142bfd 100644 --- a/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java +++ b/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java @@ -803,7 +803,7 @@ public class PackingSession implements java.io.Serializable { currentRoles = EntityUtil.filterByDate(currentRoles); // if not; create the role - if (currentRoles != null && currentRoles.size() > 0) { + if (UtilValidate.isNotEmpty(currentRoles)) { ctx.put("userLogin", userLogin); Map addRole = this.getDispatcher().runSync("createPicklistRole", ctx); if (ServiceUtil.isError(addRole)) { diff --git a/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java b/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java index ecbac82b89..3ec493a866 100644 --- a/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java +++ b/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java @@ -397,7 +397,7 @@ public class ShipmentServices { // add the feature quantities Double quantity = (Double) itemMap.get("quantity"); Set featureSet = (Set) itemMap.get("featureSet"); - if (featureSet != null && featureSet.size() > 0) { + if (UtilValidate.isNotEmpty(featureSet)) { Iterator fi = featureSet.iterator(); while (fi.hasNext()) { String featureId = (String) fi.next(); diff --git a/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java b/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java index 6227d1678c..47750debbf 100644 --- a/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java +++ b/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java @@ -342,7 +342,7 @@ public class DhlServices { "Charge"); List chargeList = new ArrayList(); - if (chargeNodeList != null && chargeNodeList.size() > 0) { + if (UtilValidate.isNotEmpty(chargeNodeList)) { for (int i = 0; chargeNodeList.size() > i; i++) { Map charge = new HashMap(); diff --git a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java index 8699102275..738eb6988c 100644 --- a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java +++ b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortSearchEvents.java @@ -27,6 +27,7 @@ import javax.servlet.http.HttpSession; import javolution.util.FastMap; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.webapp.stats.VisitHandler; import org.ofbiz.workeffort.workeffort.WorkEffortSearch.ResultSortOrder; @@ -68,7 +69,7 @@ public class WorkEffortSearchEvents { String visitId = VisitHandler.getVisitId(session); List workEffortSearchConstraintList = WorkEffortSearchOptions.getConstraintList(session); // if no constraints, don't do a search... - if (workEffortSearchConstraintList != null && workEffortSearchConstraintList.size() > 0) { + if (UtilValidate.isNotEmpty(workEffortSearchConstraintList)) { // if the search options have changed since the last search, put at the beginning of the options history list WorkEffortSearchSession.checkSaveSearchOptionsHistory(session); diff --git a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java index 1b1586d90e..5c66de306e 100644 --- a/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java +++ b/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java @@ -346,7 +346,7 @@ public class WorkEffortServices { if (UtilValidate.isNotEmpty(workEffortTypeId)) { typesList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, workEffortTypeId)); } - if (partyIds != null && partyIds.size() > 0) { + if (UtilValidate.isNotEmpty(partyIds)) { entityExprList.add(EntityCondition.makeCondition("partyId", EntityOperator.IN, partyIds)); } if (UtilValidate.isNotEmpty(facilityId)) { @@ -488,7 +488,7 @@ public class WorkEffortServices { if (partyIdsToUse.size() > 0 || UtilValidate.isNotEmpty(facilityId) || UtilValidate.isNotEmpty(fixedAssetId)) { try { List tempWorkEfforts = null; - if (partyIds != null && partyIds.size() > 0) { + if (UtilValidate.isNotEmpty(partyIds)) { tempWorkEfforts = EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssign", ecl, null, UtilMisc.toList("estimatedStartDate"), null, false)); } else { tempWorkEfforts = delegator.findList("WorkEffort", ecl, null, UtilMisc.toList("estimatedStartDate"), null, false); diff --git a/framework/base/src/org/ofbiz/base/component/ComponentConfig.java b/framework/base/src/org/ofbiz/base/component/ComponentConfig.java index 6ea4de1a6e..fef4fee65d 100644 --- a/framework/base/src/org/ofbiz/base/component/ComponentConfig.java +++ b/framework/base/src/org/ofbiz/base/component/ComponentConfig.java @@ -747,7 +747,7 @@ public class ComponentConfig { // load the virtual hosts List virtHostList = UtilXml.childElementList(element, "virtual-host"); - if (virtHostList != null && virtHostList.size() > 0) { + if (UtilValidate.isNotEmpty(virtHostList)) { for (Element e: virtHostList) { virtualHosts.add(e.getAttribute("host-name")); } @@ -755,7 +755,7 @@ public class ComponentConfig { // load the init parameters List initParamList = UtilXml.childElementList(element, "init-param"); - if (initParamList != null && initParamList.size() > 0) { + if (UtilValidate.isNotEmpty(initParamList)) { for (Element e: virtHostList) { this.initParameters.put(e.getAttribute("name"), e.getAttribute("value")); } diff --git a/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java b/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java index 461eadda91..8abc478d88 100644 --- a/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java +++ b/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java @@ -20,7 +20,6 @@ package org.ofbiz.base.component; import java.io.IOException; import java.net.URL; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; @@ -29,6 +28,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilURL; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.w3c.dom.Document; @@ -83,7 +83,7 @@ public class ComponentLoaderConfig { Element root = document.getDocumentElement(); List toLoad = UtilXml.childElementList(root); - if (toLoad != null && toLoad.size() > 0) { + if (UtilValidate.isNotEmpty(toLoad)) { componentsFromConfig = new LinkedList(); for (Element element: toLoad) { componentsFromConfig.add(new ComponentDef(element)); diff --git a/framework/base/src/org/ofbiz/base/container/ContainerConfig.java b/framework/base/src/org/ofbiz/base/container/ContainerConfig.java index 2624212060..f95e5aa49c 100644 --- a/framework/base/src/org/ofbiz/base/container/ContainerConfig.java +++ b/framework/base/src/org/ofbiz/base/container/ContainerConfig.java @@ -202,7 +202,7 @@ public class ContainerConfig { public List getPropertiesWithValue(String value) { List props = new LinkedList(); - if (properties != null && properties.size() > 0) { + if (UtilValidate.isNotEmpty(properties)) { for (Property p: properties.values()) { if (p != null && value.equals(p.value)) { props.add(p); @@ -237,7 +237,7 @@ public class ContainerConfig { public List getPropertiesWithValue(String value) { List props = new LinkedList(); - if (properties != null && properties.size() > 0) { + if (UtilValidate.isNotEmpty(properties)) { for (Property p: properties.values()) { if (p != null && value.equals(p.value)) { props.add(p); diff --git a/framework/base/src/org/ofbiz/base/util/HttpClient.java b/framework/base/src/org/ofbiz/base/util/HttpClient.java index c111c09b22..5a82cb87f1 100644 --- a/framework/base/src/org/ofbiz/base/util/HttpClient.java +++ b/framework/base/src/org/ofbiz/base/util/HttpClient.java @@ -399,7 +399,7 @@ public class HttpClient { if (rawStream != null) { arguments = rawStream; - } else if (parameters != null && parameters.size() > 0) { + } else if (UtilValidate.isNotEmpty(parameters)) { arguments = UtilHttp.urlEncodeArgs(parameters, false); } @@ -453,7 +453,7 @@ public class HttpClient { if (Debug.verboseOn() || debug) Debug.log("Header - Authorization: " + basicAuthString, module); } - if (headers != null && headers.size() > 0) { + if (UtilValidate.isNotEmpty(headers)) { for (Map.Entry entry: headers.entrySet()) { String headerName = entry.getKey(); String headerValue = entry.getValue(); diff --git a/framework/base/src/org/ofbiz/base/util/UtilHttp.java b/framework/base/src/org/ofbiz/base/util/UtilHttp.java index c0a9543344..fc80f4089f 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilHttp.java +++ b/framework/base/src/org/ofbiz/base/util/UtilHttp.java @@ -166,7 +166,7 @@ public class UtilHttp { if (paramMap.size() == 0) { // nothing found in the parameters; maybe we read the stream instead Map multiPartMap = UtilGenerics.checkMap(request.getAttribute("multiPartMap")); - if (multiPartMap != null && multiPartMap.size() > 0) { + if (UtilValidate.isNotEmpty(multiPartMap)) { paramMap.putAll(multiPartMap); } } diff --git a/framework/base/src/org/ofbiz/base/util/UtilProperties.java b/framework/base/src/org/ofbiz/base/util/UtilProperties.java index c49a4d4ee8..2e322e3b56 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilProperties.java +++ b/framework/base/src/org/ofbiz/base/util/UtilProperties.java @@ -430,7 +430,7 @@ public class UtilProperties implements java.io.Serializable { if (value == null || value.length() == 0) { return ""; } else { - if (arguments != null && arguments.size() > 0) { + if (UtilValidate.isNotEmpty(arguments)) { value = MessageFormat.format(value, arguments.toArray()); } return value; @@ -455,7 +455,7 @@ public class UtilProperties implements java.io.Serializable { if (value == null || value.length() == 0) { return ""; } else { - if (context != null && context.size() > 0) { + if (UtilValidate.isNotEmpty(context)) { value = FlexibleStringExpander.expandString(value, context, locale); } return value; diff --git a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java index c48430df98..c0ff40e811 100644 --- a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java +++ b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java @@ -23,7 +23,6 @@ import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -33,6 +32,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.LRUMap; @@ -235,7 +235,7 @@ public class CacheLineTable implements Serializable { } public synchronized void clear() { - if (fileTable != null && this.size() > 0) { + if (UtilValidate.isNotEmpty(fileTable)) { try { // remove this table long recid = fileTable.getRecid(); diff --git a/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java b/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java index 1dd94234ab..7eb4ecc86f 100644 --- a/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java +++ b/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java @@ -282,7 +282,7 @@ public class CatalinaContainer implements Container { throw new ContainerException("Only one cluster configuration allowed per engine"); } - if (clusterProps != null && clusterProps.size() > 0) { + if (UtilValidate.isNotEmpty(clusterProps)) { ContainerConfig.Container.Property clusterProp = clusterProps.get(0); createCluster(clusterProp, host); clusterConfig.put(engineName, clusterProp); @@ -464,7 +464,7 @@ public class CatalinaContainer implements Container { } Connector connector = null; - if (connectorProp.properties != null && connectorProp.properties.size() > 0) { + if (UtilValidate.isNotEmpty(connectorProp.properties)) { connector = embedded.createConnector(address, port, protocol); try { for (ContainerConfig.Container.Property prop: connectorProp.properties.values()) { @@ -621,7 +621,7 @@ public class CatalinaContainer implements Container { protected void configureMimeTypes(Context context) throws ContainerException { Map mimeTypes = CatalinaContainer.getMimeTypes(); - if (mimeTypes != null && mimeTypes.size() > 0) { + if (UtilValidate.isNotEmpty(mimeTypes)) { for (Map.Entry entry: mimeTypes.entrySet()) { context.addMimeMapping(entry.getKey(), entry.getValue()); } @@ -629,7 +629,7 @@ public class CatalinaContainer implements Container { } protected static synchronized Map getMimeTypes() throws ContainerException { - if (mimeTypes != null && mimeTypes.size() > 0) { + if (UtilValidate.isNotEmpty(mimeTypes)) { return mimeTypes; } diff --git a/framework/common/src/org/ofbiz/common/CommonServices.java b/framework/common/src/org/ofbiz/common/CommonServices.java index 2bc397946d..1878f97737 100644 --- a/framework/common/src/org/ofbiz/common/CommonServices.java +++ b/framework/common/src/org/ofbiz/common/CommonServices.java @@ -32,6 +32,8 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilValidate; + import static org.ofbiz.base.util.UtilGenerics.checkList; import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilMisc; @@ -321,7 +323,7 @@ public class CommonServices { public static Map displayXaDebugInfo(DispatchContext dctx, Map context) { if (TransactionUtil.debugResources) { - if (TransactionUtil.debugResMap != null && TransactionUtil.debugResMap.size() > 0) { + if (UtilValidate.isNotEmpty(TransactionUtil.debugResMap)) { TransactionUtil.logRunningTx(); } else { Debug.log("No running transaction to display.", module); diff --git a/framework/common/src/org/ofbiz/common/FindServices.java b/framework/common/src/org/ofbiz/common/FindServices.java index 1cd0841881..9bac13faf4 100644 --- a/framework/common/src/org/ofbiz/common/FindServices.java +++ b/framework/common/src/org/ofbiz/common/FindServices.java @@ -333,7 +333,7 @@ public class FindServices { // add to queryStringMap List origList = origValueMap.get(fieldName); - if (origList != null && origList.size() > 0) { + if (UtilValidate.isNotEmpty(origList)) { for (Object[] arr: origList) { queryStringMap.put((String) arr[0], arr[1]); } diff --git a/framework/common/src/org/ofbiz/common/geo/GeoWorker.java b/framework/common/src/org/ofbiz/common/geo/GeoWorker.java index ce412940c3..febe5fc296 100644 --- a/framework/common/src/org/ofbiz/common/geo/GeoWorker.java +++ b/framework/common/src/org/ofbiz/common/geo/GeoWorker.java @@ -18,21 +18,19 @@ *******************************************************************************/ package org.ofbiz.common.geo; -import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.GenericEntityException; -import org.ofbiz.entity.GenericDelegator; -import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.util.Debug; - import java.util.List; -import java.util.LinkedList; -import java.util.Iterator; -import java.util.ArrayList; import java.util.Set; import javolution.util.FastList; import javolution.util.FastSet; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; + /** * Worker methods for Geos */ @@ -67,7 +65,7 @@ public class GeoWorker { } catch (GenericEntityException e) { Debug.logError(e, "Unable to get associated Geo GROUP_MEMBER relationship(s)", module); } - if (thisGeoAssoc != null && thisGeoAssoc.size() > 0) { + if (UtilValidate.isNotEmpty(thisGeoAssoc)) { for (GenericValue nextGeoAssoc: thisGeoAssoc) { GenericValue nextGeo = null; try { diff --git a/framework/datafile/src/org/ofbiz/datafile/DataFile.java b/framework/datafile/src/org/ofbiz/datafile/DataFile.java index 6932e9f274..ee986dc55d 100644 --- a/framework/datafile/src/org/ofbiz/datafile/DataFile.java +++ b/framework/datafile/src/org/ofbiz/datafile/DataFile.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; /** @@ -231,7 +232,7 @@ public class DataFile { throw new DataFileException("Could not write to stream;", e); } - if (record.getChildRecords() != null && record.getChildRecords().size() > 0) { + if (UtilValidate.isNotEmpty(record.getChildRecords())) { writeRecords(outStream, record.getChildRecords()); } } diff --git a/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java b/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java index 764c1f9abf..f1f1bfb26b 100644 --- a/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java +++ b/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericModelException; @@ -58,7 +59,7 @@ public class EntityJoinOperator extends EntityOperator { } public void addSqlValue(StringBuilder sql, ModelEntity modelEntity, List entityConditionParams, List conditionList, DatasourceInfo datasourceInfo) { - if (conditionList != null && conditionList.size() > 0) { + if (UtilValidate.isNotEmpty(conditionList)) { sql.append('('); Iterator conditionIter = conditionList.iterator(); while (conditionIter.hasNext()) { @@ -91,7 +92,7 @@ public class EntityJoinOperator extends EntityOperator { } public void visit(EntityConditionVisitor visitor, List conditionList) { - if (conditionList != null && conditionList.size() > 0) { + if (UtilValidate.isNotEmpty(conditionList)) { for (EntityCondition condition: conditionList) { visitor.visit(condition); } @@ -136,7 +137,7 @@ public class EntityJoinOperator extends EntityOperator { } public boolean mapMatches(GenericDelegator delegator, Map map, List conditionList) { - if (conditionList != null && conditionList.size() > 0) { + if (UtilValidate.isNotEmpty(conditionList)) { for (EntityCondition condition: conditionList) { if (condition.mapMatches(delegator, map) == shortCircuitValue) return shortCircuitValue; } diff --git a/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java b/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java index 371b98a5e3..a4ba62d9c6 100644 --- a/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java +++ b/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java @@ -634,7 +634,7 @@ public class GenericDAO { // make two ArrayLists of fields, one for fields to select and the other for where clause fields (to find by) List selectFields = FastList.newInstance(); - if (fieldsToSelect != null && fieldsToSelect.size() > 0) { + if (UtilValidate.isNotEmpty(fieldsToSelect)) { Set tempKeys = FastSet.newInstance(); tempKeys.addAll(fieldsToSelect); Iterator fieldIter = modelEntity.getFieldsIterator(); diff --git a/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java b/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java index 494a832958..f53e47da1e 100644 --- a/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java +++ b/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java @@ -126,7 +126,7 @@ public class EntityFinderUtil { public static Set makeFieldsToSelect(List selectFieldExpanderList, Map context) { Set fieldsToSelect = null; - if (selectFieldExpanderList != null && selectFieldExpanderList.size() > 0) { + if (UtilValidate.isNotEmpty(selectFieldExpanderList)) { fieldsToSelect = new HashSet(); for (FlexibleStringExpander selectFieldExpander: selectFieldExpanderList) { fieldsToSelect.add(selectFieldExpander.expandString(context)); @@ -137,7 +137,7 @@ public class EntityFinderUtil { public static List makeOrderByFieldList(List orderByExpanderList, Map context) { List orderByFields = null; - if (orderByExpanderList != null && orderByExpanderList.size() > 0) { + if (UtilValidate.isNotEmpty(orderByExpanderList)) { orderByFields = new LinkedList(); for (FlexibleStringExpander orderByExpander: orderByExpanderList) { orderByFields.add(orderByExpander.expandString(context)); diff --git a/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java b/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java index 89e63423ca..06cc43947a 100644 --- a/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java +++ b/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java @@ -272,7 +272,7 @@ public class SqlJdbcUtil { public static String makeWhereClause(ModelEntity modelEntity, List modelFields, Map fields, String operator, String joinStyle) throws GenericEntityException { StringBuilder whereString = new StringBuilder(""); - if (modelFields != null && modelFields.size() > 0) { + if (UtilValidate.isNotEmpty(modelFields)) { whereString.append(makeWhereStringFromFields(modelFields, fields, "AND")); } @@ -370,7 +370,7 @@ public class SqlJdbcUtil { StringBuilder sql = new StringBuilder(""); //String fieldPrefix = includeTablenamePrefix ? (modelEntity.getTableName(datasourceInfo) + ".") : ""; - if (orderBy != null && orderBy.size() > 0) { + if (UtilValidate.isNotEmpty(orderBy)) { if (Debug.verboseOn()) Debug.logVerbose("Order by list contains: " + orderBy.size() + " entries.", module); OrderByList orderByList = new OrderByList(orderBy); orderByList.checkOrderBy(modelEntity); diff --git a/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java b/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java index 1b7da8bed9..e7f333e9fd 100644 --- a/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java +++ b/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java @@ -501,7 +501,7 @@ public class ModelEntity extends ModelInfo implements Comparable, S public String getFirstPkFieldName() { List pkFieldNames = this.getPkFieldNames(); String idFieldName = null; - if (pkFieldNames != null && pkFieldNames.size() > 0) { + if (UtilValidate.isNotEmpty(pkFieldNames)) { idFieldName = pkFieldNames.get(0); } return idFieldName; diff --git a/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java b/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java index 2d8ad95074..dc4583a953 100644 --- a/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java +++ b/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java @@ -689,7 +689,7 @@ public class ModelViewEntity extends ModelEntity { this.function = UtilXml.checkEmpty(aliasAllElement.getAttribute("function")); List excludes = UtilXml.childElementList(aliasAllElement, "exclude"); - if (excludes != null && excludes.size() > 0) { + if (UtilValidate.isNotEmpty(excludes)) { this.fieldsToExclude = new HashSet(); for (Element excludeElement: excludes) { this.fieldsToExclude.add(excludeElement.getAttribute("field").intern()); diff --git a/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java b/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java index 8d9606e18f..fb2677ddbc 100644 --- a/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java +++ b/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java @@ -470,7 +470,7 @@ public class TransactionUtil implements Status { public static void logRunningTx() { if (debugResources) { - if (debugResMap != null && debugResMap.size() > 0) { + if (UtilValidate.isNotEmpty(debugResMap)) { for (DebugXaResource dxa: debugResMap.values()) { dxa.log(); } @@ -518,7 +518,7 @@ public class TransactionUtil implements Status { } public static boolean suspendedTransactionsHeld() { List tl = suspendedTxStack.get(); - if (tl != null && tl.size() > 0) { + if (UtilValidate.isNotEmpty(tl)) { return true; } else { return false; @@ -536,7 +536,7 @@ public class TransactionUtil implements Status { } protected static Transaction popSuspendedTransaction() { List tl = suspendedTxStack.get(); - if (tl != null && tl.size() > 0) { + if (UtilValidate.isNotEmpty(tl)) { // restore the transaction start stamp popTransactionStartStamp(); return tl.remove(0); @@ -546,7 +546,7 @@ public class TransactionUtil implements Status { } protected static void removeSuspendedTransaction(Transaction t) { List tl = suspendedTxStack.get(); - if (tl != null && tl.size() > 0) { + if (UtilValidate.isNotEmpty(tl)) { tl.remove(t); popTransactionStartStamp(t); } @@ -576,13 +576,13 @@ public class TransactionUtil implements Status { // do the unofficial all threads Map one first, and don't do a real return Long curThreadId = Thread.currentThread().getId(); List ctEl = allThreadsTransactionBeginStackSave.get(curThreadId); - if (ctEl != null && ctEl.size() > 0) { + if (UtilValidate.isNotEmpty(ctEl)) { ctEl.remove(0); } // then do the more reliable ThreadLocal one List el = transactionBeginStackSave.get(); - if (el != null && el.size() > 0) { + if (UtilValidate.isNotEmpty(el)) { return el.remove(0); } else { return null; @@ -620,7 +620,7 @@ public class TransactionUtil implements Status { Debug.logInfo(transactionBeginStack, "===================================================\n===================================================\n Current tx begin stack for thread [" + curThreadId + "]:", module); - if (txBeginStackList != null && txBeginStackList.size() > 0) { + if (UtilValidate.isNotEmpty(txBeginStackList)) { int stackLevel = 0; for (Exception stack : txBeginStackList) { Debug.logInfo(stack, "===================================================\n===================================================\n Tx begin stack history for thread [" + curThreadId + "] history number [" + stackLevel + "]:", module); @@ -696,7 +696,7 @@ public class TransactionUtil implements Status { } private static RollbackOnlyCause popSetRollbackOnlyCauseSave() { List el = setRollbackOnlyCauseSave.get(); - if (el != null && el.size() > 0) { + if (UtilValidate.isNotEmpty(el)) { return el.remove(0); } else { return null; diff --git a/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java b/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java index ca770379bf..76189bee4b 100644 --- a/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java +++ b/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java @@ -35,15 +35,13 @@ import javolution.util.FastSet; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityDateFilterCondition; -import org.ofbiz.entity.condition.EntityFieldMap; -import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.condition.OrderByList; import org.ofbiz.entity.model.ModelField; @@ -411,7 +409,7 @@ public class EntityUtil { public static GenericValue newDatedInclusionEntity(GenericDelegator delegator, String entityName, Map find, Timestamp now) throws GenericEntityException { Map search; List entities = findDatedInclusionEntity(delegator, entityName, find, now); - if (entities != null && entities.size() > 0) { + if (UtilValidate.isNotEmpty(entities)) { search = null; for (GenericValue entity: entities) { if (now.equals(entity.get("fromDate"))) { diff --git a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java index b1f9a77b84..6f7a193b8c 100644 --- a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java +++ b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java @@ -21,7 +21,6 @@ package org.ofbiz.entityext.data; import java.net.URL; import java.net.MalformedURLException; import java.text.NumberFormat; -import java.util.Iterator; import java.util.List; import java.io.File; @@ -33,6 +32,7 @@ import org.ofbiz.base.container.ContainerException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilURL; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.util.EntityDataLoader; @@ -248,7 +248,7 @@ public class EntityDataLoadContainer implements Container { List errorMessages = FastList.newInstance(); List infoMessages = FastList.newInstance(); int totalRowsChanged = 0; - if (urlList != null && urlList.size() > 0) { + if (UtilValidate.isNotEmpty(urlList)) { Debug.logImportant("=-=-=-=-=-=-= Doing a data load with the following files:", module); for (URL dataUrl: urlList) { Debug.logImportant(dataUrl.toExternalForm(), module); diff --git a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java index abad63e056..615f033d8e 100644 --- a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java +++ b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java @@ -35,6 +35,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import javolution.util.FastList; @@ -44,8 +45,6 @@ import java.net.URI; import java.net.URL; import java.net.URISyntaxException; -import javolution.util.FastList; - /** * Entity Data Import/Export Services * @@ -94,7 +93,7 @@ public class EntityDataServices { // get the file list List files = getFileList(root); - if (files != null && files.size() > 0) { + if (UtilValidate.isNotEmpty(files)) { for (File file: files) { try { Map serviceCtx = UtilMisc.toMap("file", file, "delimiter", delimiter, "userLogin", userLogin); diff --git a/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java b/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java index 94fd612c8a..0428c1b321 100644 --- a/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java +++ b/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java @@ -770,7 +770,7 @@ public class SimpleMethod { summaryErrorStringBuffer.append(errorMsg); } List tempErrorMsgList = UtilGenerics.checkList(methodContext.getEnv(eventErrorMessageListName)); - if (tempErrorMsgList != null && tempErrorMsgList.size() > 0) { + if (UtilValidate.isNotEmpty(tempErrorMsgList)) { methodContext.getRequest().setAttribute("_ERROR_MESSAGE_LIST_", tempErrorMsgList); forceError = true; @@ -783,7 +783,7 @@ public class SimpleMethod { methodContext.getRequest().setAttribute("_EVENT_MESSAGE_", eventMsg); } List eventMsgList = UtilGenerics.checkList(methodContext.getEnv(eventEventMessageListName)); - if (eventMsgList != null && eventMsgList.size() > 0) { + if (UtilValidate.isNotEmpty(eventMsgList)) { methodContext.getRequest().setAttribute("_EVENT_MESSAGE_LIST_", eventMsgList); } @@ -814,7 +814,7 @@ public class SimpleMethod { } List errorMsgList = UtilGenerics.checkList(methodContext.getEnv(serviceErrorMessageListName)); - if (errorMsgList != null && errorMsgList.size() > 0) { + if (UtilValidate.isNotEmpty(errorMsgList)) { methodContext.putResult(ModelService.ERROR_MESSAGE_LIST, errorMsgList); forceError = true; @@ -823,7 +823,7 @@ public class SimpleMethod { } Map errorMsgMap = UtilGenerics.checkMap(methodContext.getEnv(serviceErrorMessageMapName)); - if (errorMsgMap != null && errorMsgMap.size() > 0) { + if (UtilValidate.isNotEmpty(errorMsgMap)) { methodContext.putResult(ModelService.ERROR_MESSAGE_MAP, errorMsgMap); forceError = true; @@ -837,7 +837,7 @@ public class SimpleMethod { } List successMsgList = UtilGenerics.checkList(methodContext.getEnv(serviceSuccessMessageListName)); - if (successMsgList != null && successMsgList.size() > 0) { + if (UtilValidate.isNotEmpty(successMsgList)) { methodContext.putResult(ModelService.SUCCESS_MESSAGE_LIST, successMsgList); } @@ -891,7 +891,7 @@ public class SimpleMethod { public static void readOperations(Element simpleMethodElement, List methodOperations, SimpleMethod simpleMethod) { List operationElements = UtilXml.childElementList(simpleMethodElement); - if (operationElements != null && operationElements.size() > 0) { + if (UtilValidate.isNotEmpty(operationElements)) { for (Element curOperElem: operationElements) { String nodeName = curOperElem.getNodeName(); MethodOperation methodOp = null; diff --git a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java index 07f8a3e95b..c3a4154f5b 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java @@ -128,14 +128,14 @@ public class CallService extends MethodOperation { defaultMessage = new FlexibleMessage(UtilXml.firstChildElement(element, "default-message"), "service.default.message"); List resultsToMapElements = UtilXml.childElementList(element, "results-to-map"); - if (resultsToMapElements != null && resultsToMapElements.size() > 0) { + if (UtilValidate.isNotEmpty(resultsToMapElements)) { for (Element resultsToMapElement: resultsToMapElements) { resultsToMap.add(resultsToMapElement.getAttribute("map-name")); } } List resultToFieldElements = UtilXml.childElementList(element, "result-to-field"); - if (resultToFieldElements != null && resultToFieldElements.size() > 0) { + if (UtilValidate.isNotEmpty(resultToFieldElements)) { for (Element resultToFieldElement: resultToFieldElements) { ResultToFieldDef rtfDef = new ResultToFieldDef(); @@ -149,7 +149,7 @@ public class CallService extends MethodOperation { // get result-to-request and result-to-session sub-ops List resultToRequestElements = UtilXml.childElementList(element, "result-to-request"); - if (resultToRequestElements != null && resultToRequestElements.size() > 0) { + if (UtilValidate.isNotEmpty(resultToRequestElements)) { for (Element resultToRequestElement: resultToRequestElements) { FlexibleServletAccessor reqAcsr = new FlexibleServletAccessor(resultToRequestElement.getAttribute("request-name"), resultToRequestElement.getAttribute("result-name")); ContextAccessor resultAcsr = new ContextAccessor(resultToRequestElement.getAttribute("result-name")); @@ -158,7 +158,7 @@ public class CallService extends MethodOperation { } List resultToSessionElements = UtilXml.childElementList(element, "result-to-session"); - if (resultToSessionElements != null && resultToSessionElements.size() > 0) { + if (UtilValidate.isNotEmpty(resultToSessionElements)) { for (Element resultToSessionElement: resultToSessionElements) { FlexibleServletAccessor sesAcsr = new FlexibleServletAccessor(resultToSessionElement.getAttribute("session-name"), resultToSessionElement.getAttribute("result-name")); ContextAccessor resultAcsr = new ContextAccessor(resultToSessionElement.getAttribute("result-name")); @@ -167,7 +167,7 @@ public class CallService extends MethodOperation { } List resultToResultElements = UtilXml.childElementList(element, "result-to-result"); - if (resultToResultElements != null && resultToResultElements.size() > 0) { + if (UtilValidate.isNotEmpty(resultToResultElements)) { for (Element resultToResultElement: resultToResultElements) { ContextAccessor serResAcsr = new ContextAccessor(resultToResultElement.getAttribute("service-result-name"), resultToResultElement.getAttribute("result-name")); ContextAccessor resultAcsr = new ContextAccessor(resultToResultElement.getAttribute("result-name")); diff --git a/framework/minilang/src/org/ofbiz/minilang/method/callops/CheckErrors.java b/framework/minilang/src/org/ofbiz/minilang/method/callops/CheckErrors.java index c87cc2b249..ab12fed225 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/callops/CheckErrors.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/callops/CheckErrors.java @@ -20,6 +20,7 @@ package org.ofbiz.minilang.method.callops; import java.util.List; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.method.ContextAccessor; @@ -65,7 +66,7 @@ public class CheckErrors extends MethodOperation { public boolean exec(MethodContext methodContext) { List messages = errorListAcsr.get(methodContext); - if (messages != null && messages.size() > 0) { + if (UtilValidate.isNotEmpty(messages)) { String errorCode = methodContext.expandString(this.errorCode); if (methodContext.getMethodType() == MethodContext.EVENT) { diff --git a/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java b/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java index 1aa4c2a3a4..4c1760255d 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java @@ -59,7 +59,7 @@ public class MasterIf extends MethodOperation { SimpleMethod.readOperations(thenElement, thenSubOps, simpleMethod); List elseIfElements = UtilXml.childElementList(element, "else-if"); - if (elseIfElements != null && elseIfElements.size() > 0) { + if (UtilValidate.isNotEmpty(elseIfElements)) { elseIfs = FastList.newInstance(); for (Element elseIfElement: elseIfElements) { elseIfs.add(new ElseIf(elseIfElement, simpleMethod)); @@ -85,7 +85,7 @@ public class MasterIf extends MethodOperation { return SimpleMethod.runSubOps(thenSubOps, methodContext); } else { // try the else-ifs - if (elseIfs != null && elseIfs.size() > 0) { + if (UtilValidate.isNotEmpty(elseIfs)) { for (ElseIf elseIf: elseIfs) { if (elseIf.checkCondition(methodContext)) { return elseIf.runSubOps(methodContext); 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 61570054c9..b09132e52a 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java @@ -89,7 +89,7 @@ public class StringAppend extends MethodOperation { if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(methodContext); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { value = MessageFormat.format(value, argList.toArray()); } } 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 2471bb252b..146ffda3a8 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java @@ -67,7 +67,7 @@ public class StringToField extends MethodOperation { if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(methodContext); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { valueStr = MessageFormat.format(valueStr, argList.toArray()); } } 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 ccfcd7e533..8596395157 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java @@ -62,7 +62,7 @@ public class StringToList extends MethodOperation { String valueStr = methodContext.expandString(string); if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(methodContext); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { valueStr = MessageFormat.format(valueStr, argList.toArray()); } } diff --git a/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java b/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java index 9d8f8496cd..5f884f71e4 100644 --- a/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java +++ b/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java @@ -84,7 +84,7 @@ public class PropertyToField extends MethodOperation { if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(methodContext); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { value = MessageFormat.format(value, argList.toArray()); } } diff --git a/framework/minilang/src/org/ofbiz/minilang/operation/MakeInString.java b/framework/minilang/src/org/ofbiz/minilang/operation/MakeInString.java index 8f7626c941..ab79a38fae 100644 --- a/framework/minilang/src/org/ofbiz/minilang/operation/MakeInString.java +++ b/framework/minilang/src/org/ofbiz/minilang/operation/MakeInString.java @@ -40,7 +40,7 @@ public class MakeInString { List operationElements = UtilXml.childElementList(makeInStringElement); - if (operationElements != null && operationElements.size() > 0) { + if (UtilValidate.isNotEmpty(operationElements)) { for (Element curOperElem: operationElements) { String nodeName = curOperElem.getNodeName(); diff --git a/framework/minilang/src/org/ofbiz/minilang/operation/MapProcessor.java b/framework/minilang/src/org/ofbiz/minilang/operation/MapProcessor.java index 2b632bc975..d3058c74aa 100644 --- a/framework/minilang/src/org/ofbiz/minilang/operation/MapProcessor.java +++ b/framework/minilang/src/org/ofbiz/minilang/operation/MapProcessor.java @@ -54,13 +54,13 @@ public class MapProcessor { } public void exec(Map inMap, Map results, List messages, Locale locale, ClassLoader loader) { - if (makeInStrings != null && makeInStrings.size() > 0) { + if (UtilValidate.isNotEmpty(makeInStrings)) { for (MakeInString makeInString: makeInStrings) { makeInString.exec(inMap, results, messages, locale, loader); } } - if (simpleMapProcesses != null && simpleMapProcesses.size() > 0) { + if (UtilValidate.isNotEmpty(simpleMapProcesses)) { for (SimpleMapProcess simpleMapProcess: simpleMapProcesses) { simpleMapProcess.exec(inMap, results, messages, locale, loader); } diff --git a/framework/minilang/src/org/ofbiz/minilang/operation/SimpleMapProcess.java b/framework/minilang/src/org/ofbiz/minilang/operation/SimpleMapProcess.java index c874c9e039..bc5fee3f5a 100644 --- a/framework/minilang/src/org/ofbiz/minilang/operation/SimpleMapProcess.java +++ b/framework/minilang/src/org/ofbiz/minilang/operation/SimpleMapProcess.java @@ -53,7 +53,7 @@ public class SimpleMapProcess { void readOperations(Element simpleMapProcessElement) { List operationElements = UtilXml.childElementList(simpleMapProcessElement); - if (operationElements != null && operationElements.size() > 0) { + if (UtilValidate.isNotEmpty(operationElements)) { for (Element curOperElem: operationElements) { String nodeName = curOperElem.getNodeName(); diff --git a/framework/service/src/org/ofbiz/service/ModelNotification.java b/framework/service/src/org/ofbiz/service/ModelNotification.java index 3c51cd990f..d12364ee5d 100644 --- a/framework/service/src/org/ofbiz/service/ModelNotification.java +++ b/framework/service/src/org/ofbiz/service/ModelNotification.java @@ -23,6 +23,7 @@ import org.ofbiz.service.config.ServiceConfigUtil; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilValidate; import java.util.List; import java.util.Map; @@ -102,7 +103,7 @@ public class ModelNotification { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { List addr = group.getAddress("to"); - if (addr != null && addr.size() > 0) { + if (UtilValidate.isNotEmpty(addr)) { return StringUtil.join(addr, ","); } } @@ -124,7 +125,7 @@ public class ModelNotification { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { List addr = group.getAddress("bcc"); - if (addr != null && addr.size() > 0) { + if (UtilValidate.isNotEmpty(addr)) { return StringUtil.join(addr, ","); } } @@ -135,7 +136,7 @@ public class ModelNotification { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { List addr = group.getAddress("from"); - if (addr != null && addr.size() > 0) { + if (UtilValidate.isNotEmpty(addr)) { return addr.get(0); } } diff --git a/framework/service/src/org/ofbiz/service/ModelParam.java b/framework/service/src/org/ofbiz/service/ModelParam.java index aa1e92139c..89c2dac9f7 100644 --- a/framework/service/src/org/ofbiz/service/ModelParam.java +++ b/framework/service/src/org/ofbiz/service/ModelParam.java @@ -30,6 +30,7 @@ import javax.xml.namespace.QName; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; /** * Generic Service Model Parameter @@ -108,7 +109,7 @@ public class ModelParam implements Serializable { } public String getPrimaryFailMessage(Locale locale) { - if (validators != null && validators.size() > 0) { + if (UtilValidate.isNotEmpty(validators)) { return validators.get(0).getFailMessage(locale); } else { return null; diff --git a/framework/service/src/org/ofbiz/service/ModelPermission.java b/framework/service/src/org/ofbiz/service/ModelPermission.java index b63b8c6743..b38c05f5c6 100644 --- a/framework/service/src/org/ofbiz/service/ModelPermission.java +++ b/framework/service/src/org/ofbiz/service/ModelPermission.java @@ -18,18 +18,18 @@ *******************************************************************************/ package org.ofbiz.service; +import java.io.Serializable; +import java.util.List; +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.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.security.Security; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - /** * Service Permission Model Class */ @@ -99,9 +99,9 @@ public class ModelPermission implements Serializable { Debug.logError(e, "Unable to lookup PartyRole records", module); } - if (partyRoles != null && partyRoles.size() > 0) { + if (UtilValidate.isNotEmpty(partyRoles)) { partyRoles = EntityUtil.filterByDate(partyRoles); - if (partyRoles != null && partyRoles.size() > 0) { + if (UtilValidate.isNotEmpty(partyRoles)) { return true; } } diff --git a/framework/service/src/org/ofbiz/service/ModelService.java b/framework/service/src/org/ofbiz/service/ModelService.java index ce76f2036a..3b29813be5 100644 --- a/framework/service/src/org/ofbiz/service/ModelService.java +++ b/framework/service/src/org/ofbiz/service/ModelService.java @@ -551,7 +551,7 @@ public class ModelService extends AbstractMap implements Serializable { Object testObject = test.get(key); String infoType = info.get(key); - if (param.validators != null && param.validators.size() > 0) { + if (UtilValidate.isNotEmpty(param.validators)) { for (ModelParam.ModelParamValidator val: param.validators) { if (UtilValidate.isNotEmpty(val.getMethodName())) { try { @@ -773,13 +773,13 @@ public class ModelService extends AbstractMap implements Serializable { // internal map of strings if (param.stringMapPrefix != null && param.stringMapPrefix.length() > 0 && !source.containsKey(key)) { Map paramMap = this.makePrefixMap(source, param); - if (paramMap != null && paramMap.size() > 0) { + if (UtilValidate.isNotEmpty(paramMap)) { target.put(key, paramMap); } // internal list of strings } else if (param.stringListSuffix != null && param.stringListSuffix.length() > 0 && !source.containsKey(key)) { List paramList = this.makeSuffixList(source, param); - if (paramList != null && paramList.size() > 0) { + if (UtilValidate.isNotEmpty(paramList)) { target.put(key, paramList); } // other attributes @@ -1034,7 +1034,7 @@ public class ModelService extends AbstractMap implements Serializable { } // handle any override parameters - if (overrideParameters != null && overrideParameters.size() > 0) { + if (UtilValidate.isNotEmpty(overrideParameters)) { for (ModelParam overrideParam: overrideParameters) { ModelParam existingParam = contextInfo.get(overrideParam.name); diff --git a/framework/service/src/org/ofbiz/service/ModelServiceReader.java b/framework/service/src/org/ofbiz/service/ModelServiceReader.java index b0f222efe7..39a9fa7490 100644 --- a/framework/service/src/org/ofbiz/service/ModelServiceReader.java +++ b/framework/service/src/org/ofbiz/service/ModelServiceReader.java @@ -435,7 +435,7 @@ public class ModelServiceReader implements Serializable { protected void createGroupDefs(Element baseElement, ModelService service) { List group = UtilXml.childElementList(baseElement, "group"); - if (group != null && group.size() > 0) { + if (UtilValidate.isNotEmpty(group)) { Element groupElement = group.get(0); groupElement.setAttribute("name", "_" + service.name + ".group"); service.internalGroup = new GroupModel(groupElement); @@ -705,7 +705,7 @@ public class ModelServiceReader implements Serializable { protected void addValidators(Element attribute, ModelParam param) { List validateElements = UtilXml.childElementList(attribute, "type-validate"); - if (validateElements != null && validateElements.size() > 0) { + if (UtilValidate.isNotEmpty(validateElements)) { // always clear out old ones; never append param.validators = FastList.newInstance(); diff --git a/framework/service/src/org/ofbiz/service/ServiceDispatcher.java b/framework/service/src/org/ofbiz/service/ServiceDispatcher.java index 582a33668f..74a5b73270 100644 --- a/framework/service/src/org/ofbiz/service/ServiceDispatcher.java +++ b/framework/service/src/org/ofbiz/service/ServiceDispatcher.java @@ -996,7 +996,7 @@ public class ServiceDispatcher { int servicesScheduled = 0; List startupServices = UtilXml.childElementList(root, "startup-service"); - if (startupServices != null && startupServices.size() > 0) { + if (UtilValidate.isNotEmpty(startupServices)) { for (Element ss: startupServices) { String serviceName = ss.getAttribute("name"); String runtimeDataId = ss.getAttribute("runtime-data-id"); diff --git a/framework/service/src/org/ofbiz/service/ServiceUtil.java b/framework/service/src/org/ofbiz/service/ServiceUtil.java index a52b748f5b..074b58de09 100644 --- a/framework/service/src/org/ofbiz/service/ServiceUtil.java +++ b/framework/service/src/org/ofbiz/service/ServiceUtil.java @@ -297,7 +297,7 @@ public class ServiceUtil { public static String makeMessageList(List msgList, String msgPrefix, String msgSuffix) { StringBuilder outMsg = new StringBuilder(); - if (msgList != null && msgList.size() > 0) { + if (UtilValidate.isNotEmpty(msgList)) { for (Object msg: msgList) { if (msg == null) continue; String curMsg = msg.toString(); @@ -410,7 +410,7 @@ public class ServiceUtil { } // remove each from the list in its own transaction - if (curList != null && curList.size() > 0) { + if (UtilValidate.isNotEmpty(curList)) { // list of runtime data IDs to attempt to delete List runtimeToDelete = FastList.newInstance(); diff --git a/framework/service/src/org/ofbiz/service/ServiceValidationException.java b/framework/service/src/org/ofbiz/service/ServiceValidationException.java index eaa1360233..51d0d629cc 100644 --- a/framework/service/src/org/ofbiz/service/ServiceValidationException.java +++ b/framework/service/src/org/ofbiz/service/ServiceValidationException.java @@ -20,7 +20,8 @@ package org.ofbiz.service; import java.util.List; import java.util.ArrayList; -import java.util.Iterator; + +import org.ofbiz.base.util.UtilValidate; /** * ServiceValidationException @@ -129,7 +130,7 @@ public class ServiceValidationException extends GenericServiceException { public String getMessage() { String msg = super.getMessage(); - if (this.messages != null && this.messages.size() > 0) { + if (UtilValidate.isNotEmpty(this.messages)) { StringBuilder sb = new StringBuilder(); if (msg != null) { sb.append(msg).append('\n'); diff --git a/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java b/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java index 357d1ea872..3c9a6e7c76 100644 --- a/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java +++ b/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java @@ -26,6 +26,7 @@ import java.util.List; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -266,7 +267,7 @@ public class RecurrenceInfo { private long checkDateList(List dateList, long time, long fromTime) { long nextTime = time; - if (dateList != null && dateList.size() > 0) { + if (UtilValidate.isNotEmpty(dateList)) { for (Date thisDate: dateList) { if (nextTime > 0 && thisDate.getTime() < nextTime && thisDate.getTime() > fromTime) nextTime = thisDate.getTime(); diff --git a/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java b/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java index 4ae146cc95..ecc02a8cf9 100644 --- a/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java +++ b/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java @@ -26,6 +26,7 @@ import java.util.List; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -488,19 +489,19 @@ public class RecurrenceRule { cal.setTime(date); // Test each byXXX rule. - if (bySecondList != null && bySecondList.size() > 0) { + if (UtilValidate.isNotEmpty(bySecondList)) { if (!bySecondList.contains(String.valueOf(cal.get(Calendar.SECOND)))) return false; } - if (byMinuteList != null && byMinuteList.size() > 0) { + if (UtilValidate.isNotEmpty(byMinuteList)) { if (!byMinuteList.contains(String.valueOf(cal.get(Calendar.MINUTE)))) return false; } - if (byHourList != null && byHourList.size() > 0) { + if (UtilValidate.isNotEmpty(byHourList)) { if (!byHourList.contains(String.valueOf(cal.get(Calendar.HOUR_OF_DAY)))) return false; } - if (byDayList != null && byDayList.size() > 0) { + if (UtilValidate.isNotEmpty(byDayList)) { Iterator iter = byDayList.iterator(); boolean foundDay = false; @@ -569,7 +570,7 @@ public class RecurrenceRule { return false; } } - if (byMonthDayList != null && byMonthDayList.size() > 0) { + if (UtilValidate.isNotEmpty(byMonthDayList)) { Iterator iter = byMonthDayList.iterator(); boolean foundDay = false; @@ -596,7 +597,7 @@ public class RecurrenceRule { return false; } } - if (byYearDayList != null && byYearDayList.size() > 0) { + if (UtilValidate.isNotEmpty(byYearDayList)) { Iterator iter = byYearDayList.iterator(); boolean foundDay = false; @@ -620,7 +621,7 @@ public class RecurrenceRule { if (!foundDay) return false; } - if (byWeekNoList != null && byWeekNoList.size() > 0) { + if (UtilValidate.isNotEmpty(byWeekNoList)) { Iterator iter = byWeekNoList.iterator(); boolean foundWeek = false; @@ -644,7 +645,7 @@ public class RecurrenceRule { if (!foundWeek) return false; } - if (byMonthList != null && byMonthList.size() > 0) { + if (UtilValidate.isNotEmpty(byMonthList)) { Iterator iter = byMonthList.iterator(); boolean foundMonth = false; diff --git a/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java b/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java index 791646fa5d..a5afb40ffe 100644 --- a/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java +++ b/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java @@ -208,7 +208,7 @@ public class ServiceEcaAction implements java.io.Serializable { } } // do something with the errorMessageList - if (errorMessageList != null && errorMessageList.size() > 0) { + if (UtilValidate.isNotEmpty(errorMessageList)) { List origErrorMessageList = UtilGenerics.checkList(result.get(ModelService.ERROR_MESSAGE_LIST)); if (origErrorMessageList == null) { result.put(ModelService.ERROR_MESSAGE_LIST, errorMessageList); @@ -217,7 +217,7 @@ public class ServiceEcaAction implements java.io.Serializable { } } // do something with the errorMessageMap - if (errorMessageMap != null && errorMessageMap.size() > 0) { + if (UtilValidate.isNotEmpty(errorMessageMap)) { Map origErrorMessageMap = UtilGenerics.checkMap(result.get(ModelService.ERROR_MESSAGE_MAP)); if (origErrorMessageMap == null) { result.put(ModelService.ERROR_MESSAGE_MAP, errorMessageMap); diff --git a/framework/service/src/org/ofbiz/service/job/JobManager.java b/framework/service/src/org/ofbiz/service/job/JobManager.java index 14023b9b0d..72ac9d89be 100644 --- a/framework/service/src/org/ofbiz/service/job/JobManager.java +++ b/framework/service/src/org/ofbiz/service/job/JobManager.java @@ -151,7 +151,7 @@ public class JobManager { List jobEnt = delegator.findByAnd("JobSandbox", updateFields, order); //jobEnt = delegator.findByCondition("JobSandbox", mainCondition, null, order); - if (jobEnt != null && jobEnt.size() > 0) { + if (UtilValidate.isNotEmpty(jobEnt)) { for (GenericValue v: jobEnt) { DispatchContext dctx = getDispatcher().getDispatchContext(); if (dctx == null) { @@ -212,7 +212,7 @@ public class JobManager { Debug.logError(e, "Unable to load crashed jobs", module); } - if (crashed != null && crashed.size() > 0) { + if (UtilValidate.isNotEmpty(crashed)) { try { int rescheduled = 0; for (GenericValue job: crashed) { diff --git a/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java b/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java index b998821f7b..d6abaad197 100644 --- a/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java +++ b/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java @@ -116,7 +116,7 @@ public class JavaMailContainer implements Container { } // start the polling timer - if (stores != null && stores.size() > 0) { + if (UtilValidate.isNotEmpty(stores)) { pollTimer.schedule(new PollerTask(dispatcher, userLogin), timerDelay, timerDelay); } else { Debug.logWarning("No JavaMail Store(s) configured; poller disabled.", module); @@ -248,7 +248,7 @@ public class JavaMailContainer implements Container { } public void run() { - if (stores != null && stores.size() > 0) { + if (UtilValidate.isNotEmpty(stores)) { for (Map.Entry entry: stores.entrySet()) { Store store = entry.getKey(); Session session = entry.getValue(); diff --git a/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java b/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java index 9b5fc53c9b..2a2c011ac9 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java @@ -759,7 +759,7 @@ public class ConfigXMLReader { Debug.logVerbose("-------- Handler Mappings --------", module); Map debugMap = checkMap(map.get("event"), String.class, String.class); - if (debugMap != null && debugMap.size() > 0) { + if (UtilValidate.isNotEmpty(debugMap)) { Debug.logVerbose("-------------- EVENT -------------", module); for (Map.Entry entry: debugMap.entrySet()) { String handlerName = entry.getKey(); @@ -768,7 +768,7 @@ public class ConfigXMLReader { } } debugMap = checkMap(map.get("view"), String.class, String.class); - if (debugMap != null && debugMap.size() > 0) { + if (UtilValidate.isNotEmpty(debugMap)) { Debug.logVerbose("-------------- VIEW --------------", module); for (Map.Entry entry: debugMap.entrySet()) { String handlerName = entry.getKey(); diff --git a/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java b/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java index 262079e8a4..bd026b79af 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java @@ -21,6 +21,7 @@ package org.ofbiz.webapp.control; import java.sql.Timestamp; import java.util.Enumeration; import java.util.Map; + import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; @@ -28,7 +29,7 @@ import javax.servlet.http.HttpSessionListener; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.webapp.stats.VisitHandler; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.serialize.XmlSerializer; @@ -194,7 +195,7 @@ public class ControlEventListener implements HttpSessionListener { Map userLoginSession = (Map) session.getAttribute("userLoginSession"); String sessionData = null; - if (userLoginSession != null && userLoginSession.size() > 0) { + if (UtilValidate.isNotEmpty(userLoginSession)) { try { sessionData = XmlSerializer.serialize(userLoginSession); } catch (Exception e) { diff --git a/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java index 4a76660d5c..7c76f66faa 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java @@ -332,7 +332,7 @@ public class RequestHandler implements Serializable { request.getSession().removeAttribute("_REQ_ATTR_MAP_"); byte[] reqAttrMapBytes = StringUtil.fromHexString(preReqAttStr); Map preRequestMap = checkMap(UtilObject.getObject(reqAttrMapBytes), String.class, Object.class); - if (preRequestMap != null && preRequestMap.size() > 0) { + if (UtilValidate.isNotEmpty(preRequestMap)) { for (Map.Entry entry: preRequestMap.entrySet()) { String key = entry.getKey(); if("_ERROR_MESSAGE_LIST_".equals(key) || "_ERROR_MESSAGE_MAP_".equals(key) || "_ERROR_MESSAGE_".equals(key) || @@ -454,7 +454,7 @@ public class RequestHandler implements Serializable { public String makeQueryString(HttpServletRequest request) { Map paramMap = UtilHttp.getParameterMap(request); StringBuilder queryString = new StringBuilder(); - if (paramMap != null && paramMap.size() > 0) { + if (UtilValidate.isNotEmpty(paramMap)) { queryString.append("?"); for (Map.Entry entry: paramMap.entrySet()) { String name = entry.getKey(); diff --git a/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java b/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java index 82ce61dad1..c151afd0cd 100644 --- a/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java +++ b/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java @@ -28,6 +28,7 @@ import javax.servlet.jsp.tagext.TagSupport; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilJ2eeCompat; +import org.ofbiz.base.util.UtilValidate; /** * I18nMessageTag - JSP tag to use a resource bundle to internationalize @@ -98,7 +99,7 @@ public class I18nMessageTag extends BodyTagSupport { public int doEndTag() throws JspException { try { - if (this.value != null && this.arguments != null && this.arguments.size() > 0) { + if (this.value != null && UtilValidate.isNotEmpty(this.arguments)) { MessageFormat messageFormat = new MessageFormat(this.value); messageFormat.setLocale(this.bundle.getLocale()); diff --git a/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java index 139c5747f6..b4eec5778a 100644 --- a/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java @@ -382,7 +382,7 @@ public class WebToolsServices { List errorMessages = FastList.newInstance(); List infoMessages = FastList.newInstance(); int totalRowsChanged = 0; - if (urlList != null && urlList.size() > 0) { + if (UtilValidate.isNotEmpty(urlList)) { messages.add("=-=-=-=-=-=-= Doing a data " + (checkDataOnly ? "check" : "load") + " with the following files:"); for (URL dataUrl: urlList) { messages.add(dataUrl.toExternalForm()); diff --git a/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java b/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java index 2d2b06e143..d61eaeb4f1 100644 --- a/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java +++ b/framework/webtools/src/org/ofbiz/webtools/print/FoPrintServerEvents.java @@ -33,7 +33,7 @@ import org.ofbiz.service.DispatchContext; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.widget.screen.ScreenRenderer; @@ -54,7 +54,7 @@ public class FoPrintServerEvents { reqParams.put("locale", UtilHttp.getLocale(req)); String screenUri = (String) reqParams.remove("screenUri"); - if (screenUri != null && reqParams.size() > 0) { + if (UtilValidate.isNotEmpty(screenUri)) { String base64String = null; try { byte[] bytes = FoPrintServerEvents.getXslFo(dispatcher.getDispatchContext(), screenUri, reqParams); diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java index 4d0e56f44e..9fbe4a46d2 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java @@ -247,7 +247,7 @@ public abstract class ModelFormAction { if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(context); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { value = MessageFormat.format(value, argList.toArray()); } } diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java index 1ea578f06c..4a11e2b289 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java @@ -1687,7 +1687,7 @@ public class ModelFormField { this.filterByDate = entityOptionsElement.getAttribute("filter-by-date"); List constraintElements = UtilXml.childElementList(entityOptionsElement, "entity-constraint"); - if (constraintElements != null && constraintElements.size() > 0) { + if (UtilValidate.isNotEmpty(constraintElements)) { this.constraintList = new LinkedList(); Iterator constraintElementIter = constraintElements.iterator(); while (constraintElementIter.hasNext()) { @@ -1697,7 +1697,7 @@ public class ModelFormField { } List orderByElements = UtilXml.childElementList(entityOptionsElement, "entity-order-by"); - if (orderByElements != null && orderByElements.size() > 0) { + if (UtilValidate.isNotEmpty(orderByElements)) { this.orderByList = new LinkedList(); Iterator orderByElementIter = orderByElements.iterator(); while (orderByElementIter.hasNext()) { @@ -1721,7 +1721,7 @@ public class ModelFormField { public void addOptionValues(List optionValues, Map context, GenericDelegator delegator) { // first expand any conditions that need expanding based on the current context EntityCondition findCondition = null; - if (this.constraintList != null && this.constraintList.size() > 0) { + if (UtilValidate.isNotEmpty(this.constraintList)) { List expandedConditionList = new LinkedList(); Iterator constraintIter = constraintList.iterator(); while (constraintIter.hasNext()) { diff --git a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java index 7ebdba4330..96461f72ff 100644 --- a/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java +++ b/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java @@ -311,7 +311,7 @@ public abstract class ModelMenuAction { if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(context); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { value = MessageFormat.format(value, argList.toArray()); } } diff --git a/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java b/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java index cc4ba7aec7..dcde1a8289 100644 --- a/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java +++ b/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -32,6 +33,7 @@ import javax.servlet.http.HttpServletResponse; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; @@ -332,8 +334,9 @@ public class IterateSectionWidget extends ModelScreenWidget { linkText += "VIEW_SIZE=" + viewSize + "&VIEW_INDEX=" + (viewIndex - 1) + "\""; // make the link - writer.append(rh.makeLink(request, response, linkText, false, false, false)); - writer.append(" class=\"buttontext\">[Previous]\n"); + writer.append(rh.makeLink(request, response, linkText, false, false, false)); + String previous = UtilProperties.getMessage("CommonUiLabels", "CommonPrevious", (Locale) context.get("locale")); + writer.append(" class=\"buttontext\">[" + previous +"]\n"); } if (listSize > 0) { @@ -348,7 +351,8 @@ public class IterateSectionWidget extends ModelScreenWidget { // make the link writer.append(rh.makeLink(request, response, linkText, false, false, false)); - writer.append(" class=\"buttontext\">[Next]\n"); + String next = UtilProperties.getMessage("CommonUiLabels", "CommonNext", (Locale) context.get("locale")); + writer.append(" class=\"buttontext\">[" + next +"]\n"); } writer.append(" \n"); diff --git a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java index 75960f4dc7..3858ec511b 100644 --- a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java +++ b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java @@ -370,7 +370,7 @@ public abstract class ModelScreenAction implements Serializable { if (!argListAcsr.isEmpty()) { List argList = argListAcsr.get(context); - if (argList != null && argList.size() > 0) { + if (UtilValidate.isNotEmpty(argList)) { value = MessageFormat.format(value, argList.toArray()); } } diff --git a/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java b/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java index 9852b74ec6..f7cefd3d01 100755 --- a/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java +++ b/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java @@ -933,7 +933,7 @@ public class ImportOrdersFromEbay { Map paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_RECEIVED", "paymentMethodTypeId", "EXT_EBAY"); paymentPreferences = delegator.findByAnd("OrderPaymentPreference", paymentFields); - if (paymentPreferences != null && paymentPreferences.size() > 0) { + if (UtilValidate.isNotEmpty(paymentPreferences)) { Iterator i = paymentPreferences.iterator(); while (i.hasNext()) { GenericValue pref = (GenericValue) i.next(); @@ -1203,7 +1203,7 @@ public class ImportOrdersFromEbay { Debug.logInfo("Checking for existing externalId: " + externalId +" and transactionId: " + transactionId, module); GenericValue orderHeader = null; List entities = delegator.findByAnd("OrderHeader", UtilMisc.toMap("externalId", externalId, "transactionId", transactionId)); - if (entities != null && entities.size() > 0) { + if (UtilValidate.isNotEmpty(entities)) { orderHeader = EntityUtil.getFirst(entities); } return orderHeader; diff --git a/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java b/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java index 625f3c5f8e..929caf9e1b 100644 --- a/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java +++ b/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java @@ -77,7 +77,7 @@ public class FacilityServices { // Send back the results Map result = ServiceUtil.returnSuccess(); - if (productsFound != null && productsFound.size() > 0) { + if (UtilValidate.isNotEmpty(productsFound)) { result.put("productList", productsFound); } return result; diff --git a/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java b/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java index 4304f15f67..667a8b33ec 100644 --- a/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java +++ b/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java @@ -298,7 +298,7 @@ public class PosTransaction implements Serializable { fields.put("orderId", this.getOrderId()); List paymentPrefs = session.getDelegator().findByAnd("OrderPaymentPreference", fields); - if (paymentPrefs != null && paymentPrefs.size() > 0) { + if (UtilValidate.isNotEmpty(paymentPrefs)) { //Debug.log("Found some prefs - " + paymentPrefs.size(), module); if (paymentPrefs.size() > 1) { Debug.logError("Multiple OrderPaymentPreferences found for the same payment method!", module); @@ -953,7 +953,7 @@ public class PosTransaction implements Serializable { } } - if (adjustments != null && adjustments.size() > 0) { + if (UtilValidate.isNotEmpty(adjustments)) { Iterator iter = adjustments.iterator(); while(iter.hasNext()){ GenericValue orderAdjustment = (GenericValue) iter.next(); diff --git a/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Keyboard.java b/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Keyboard.java index cdd78de715..76cfba3132 100644 --- a/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Keyboard.java +++ b/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Keyboard.java @@ -23,6 +23,7 @@ import java.util.List; import jpos.JposException; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.pos.adaptor.DataEventAdaptor; import org.ofbiz.pos.config.ButtonEventConfig; import org.ofbiz.pos.device.GenericDevice; @@ -68,7 +69,7 @@ public class Keyboard extends GenericDevice { } List buttonEvents = ButtonEventConfig.findButtonKeyAssign(keyCode); - if (buttonEvents != null && buttonEvents.size() > 0) { + if (UtilValidate.isNotEmpty(buttonEvents)) { Debug.log("Key -> Button Mapping(s) Found [" + keyCode + "]", module); try { diff --git a/specialpurpose/shark/src/org/ofbiz/shark/audit/EntityAuditMgr.java b/specialpurpose/shark/src/org/ofbiz/shark/audit/EntityAuditMgr.java index 1eeec2b95c..1e386a1f88 100644 --- a/specialpurpose/shark/src/org/ofbiz/shark/audit/EntityAuditMgr.java +++ b/specialpurpose/shark/src/org/ofbiz/shark/audit/EntityAuditMgr.java @@ -176,7 +176,7 @@ public class EntityAuditMgr implements EventAuditManagerInterface { Debug.logError(e, module); throw new EventAuditException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -199,7 +199,7 @@ public class EntityAuditMgr implements EventAuditManagerInterface { Debug.logError(e, module); throw new EventAuditException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -222,7 +222,7 @@ public class EntityAuditMgr implements EventAuditManagerInterface { Debug.logError(e, module); throw new EventAuditException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -246,7 +246,7 @@ public class EntityAuditMgr implements EventAuditManagerInterface { Debug.logError(e, module); throw new EventAuditException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -269,7 +269,7 @@ public class EntityAuditMgr implements EventAuditManagerInterface { Debug.logError(e, module); throw new EventAuditException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -292,7 +292,7 @@ public class EntityAuditMgr implements EventAuditManagerInterface { Debug.logError(e, module); throw new EventAuditException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); diff --git a/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java b/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java index a15798e8b7..462bb9e947 100644 --- a/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java +++ b/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java @@ -362,7 +362,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { Debug.logError(e, module); throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -391,7 +391,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -411,7 +411,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -430,7 +430,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -461,7 +461,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -563,7 +563,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -627,7 +627,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -691,7 +691,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { Debug.logError(e, module); throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Debug.log("Lookup list contains : " + lookupList.size(), module); Iterator i = lookupList.iterator(); while (i.hasNext()) { @@ -716,7 +716,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -752,7 +752,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { List createdList = new ArrayList(); List lookupList = getAndJoinValues(procId, asDefId, aDefId); - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -1012,7 +1012,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -1150,7 +1150,7 @@ public class EntityPersistentMgr implements PersistentManagerInterface { } catch (GenericEntityException e) { throw new PersistenceException(e); } - if (lookupList != null && lookupList.size() > 0) { + if (UtilValidate.isNotEmpty(lookupList)) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); diff --git a/specialpurpose/shark/src/org/ofbiz/shark/mapping/EntityParticipantMappingMgr.java b/specialpurpose/shark/src/org/ofbiz/shark/mapping/EntityParticipantMappingMgr.java index 4cfeabbb52..e4b19b7e0d 100644 --- a/specialpurpose/shark/src/org/ofbiz/shark/mapping/EntityParticipantMappingMgr.java +++ b/specialpurpose/shark/src/org/ofbiz/shark/mapping/EntityParticipantMappingMgr.java @@ -83,7 +83,7 @@ public class EntityParticipantMappingMgr implements ParticipantMappingManager { public boolean doesParticipantMappingExist(ParticipantMappingTransaction mappingTransaction, ParticipantMap participantMap) throws RootException { List mappings = getParticipantMappings(mappingTransaction, participantMap.getPackageId(), participantMap.getProcessDefinitionId(), participantMap.getParticipantId()); - if (mappings != null && mappings.size() > 0) { + if (UtilValidate.isNotEmpty(mappings)) { return true; } return false; diff --git a/specialpurpose/shark/src/org/ofbiz/shark/user/GenericUserGroupMgr.java b/specialpurpose/shark/src/org/ofbiz/shark/user/GenericUserGroupMgr.java index 110415b771..bf4ddb45d5 100644 --- a/specialpurpose/shark/src/org/ofbiz/shark/user/GenericUserGroupMgr.java +++ b/specialpurpose/shark/src/org/ofbiz/shark/user/GenericUserGroupMgr.java @@ -57,7 +57,7 @@ public class GenericUserGroupMgr implements UserGroupManager { Debug.logError(e, module); throw new RootException(e); } - if (groups != null && groups.size() > 0) { + if (UtilValidate.isNotEmpty(groups)) { Iterator i = groups.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -77,7 +77,7 @@ public class GenericUserGroupMgr implements UserGroupManager { Debug.logError(e, module); throw new RootException(e); } - if (users != null && users.size() > 0) { + if (UtilValidate.isNotEmpty(users)) { Iterator i = users.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -97,7 +97,7 @@ public class GenericUserGroupMgr implements UserGroupManager { Debug.logError(e, module); throw new RootException(e); } - if (members != null && members.size() > 0) { + if (UtilValidate.isNotEmpty(members)) { Iterator i = members.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -109,7 +109,7 @@ public class GenericUserGroupMgr implements UserGroupManager { public List getAllUsers(UserTransaction trans, List groupNames) throws RootException { List userNames = new ArrayList(); - if (groupNames != null && groupNames.size() > 0) { + if (UtilValidate.isNotEmpty(groupNames)) { Iterator i = groupNames.iterator(); while (i.hasNext()) { String groupName = (String) i.next(); @@ -133,7 +133,7 @@ public class GenericUserGroupMgr implements UserGroupManager { Debug.logError(e, module); throw new RootException(e); } - if (rollups != null && rollups.size() > 0) { + if (UtilValidate.isNotEmpty(rollups)) { Iterator i = rollups.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); @@ -145,7 +145,7 @@ public class GenericUserGroupMgr implements UserGroupManager { public List getAllSubgroups(UserTransaction trans, List groupNames) throws RootException { List subGroups = new ArrayList(); - if (groupNames != null && groupNames.size() > 0) { + if (UtilValidate.isNotEmpty(groupNames)) { Iterator i = groupNames.iterator(); while (i.hasNext()) { String groupName = (String) i.next(); diff --git a/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java b/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java index 9946d71276..108e73910d 100644 --- a/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java +++ b/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java @@ -600,7 +600,7 @@ public class XpdlReader { } else if (loopElement != null) { activityValue.set("activityTypeEnumId", "WAT_LOOP"); readLoop(loopElement, packageId, packageVersion, processId, processVersion, activityId); - } else if (tools != null && tools.size() > 0) { + } else if (UtilValidate.isNotEmpty(tools)) { activityValue.set("activityTypeEnumId", "WAT_TOOL"); readTools(tools, packageId, packageVersion, processId, processVersion, activityId); } else { @@ -902,7 +902,7 @@ public class XpdlReader { // a Condition will have either a list of XPression elements, or plain PCDATA List xPressions = UtilXml.childElementList(conditionElement, "XPression"); - if (xPressions != null && xPressions.size() > 0) { + if (UtilValidate.isNotEmpty(xPressions)) { throw new DefinitionParserException("XPression elements under Condition not yet supported, just use text inside Condition with the expression"); } else { transitionValue.set("conditionExpr", UtilXml.elementValue(conditionElement)); diff --git a/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java b/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java index 9b72ea7828..3d38a8d97f 100644 --- a/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java +++ b/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java @@ -441,7 +441,7 @@ public class WfActivityImpl extends WfExecutionObjectImpl implements WfActivity * @see org.ofbiz.workflow.WfActivity#setResult(java.util.Map) */ public void setResult(Map newResult) throws WfException, InvalidData { - if (newResult != null && newResult.size() > 0) { + if (UtilValidate.isNotEmpty(newResult)) { if (Debug.verboseOn()) Debug.logVerbose( "[WfActivity.setResult]: putting (" + newResult.size() + ") keys into context.", @@ -727,7 +727,7 @@ public class WfActivityImpl extends WfExecutionObjectImpl implements WfActivity // extended attributes take priority over context attributes Map extendedAttributes = StringUtil.strToMap(extendedAttr); - if (extendedAttributes != null && extendedAttributes.size() > 0) { + if (UtilValidate.isNotEmpty(extendedAttributes)) { context.putAll(extendedAttributes); }