Author: jacopoc
Date: Sat Mar 3 22:59:23 2007 New Revision: 514366 URL: http://svn.apache.org/viewvc?view=rev&rev=514366 Log: Applied (modified) patch from Stefan Huehner (OFBIZ-770) to use isEmpty(...) method for null/empty validation. Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/thirdparty/truition/TruitionCoReg.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java?view=diff&rev=514366&r1=514365&r2=514366 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java Sat Mar 3 22:59:23 2007 @@ -153,7 +153,7 @@ private static void walkParentTree(Map nodeMap, List parentList) { List kids = (List)nodeMap.get("kids"); - if (kids == null || kids.size() == 0) { + if (UtilValidate.isEmpty(kids)) { parentList.add(nodeMap.get("contentId")); } else { Iterator iter = kids.iterator(); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?view=diff&rev=514366&r1=514365&r2=514366 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java Sat Mar 3 22:59:23 2007 @@ -706,8 +706,9 @@ GenericDelegator delegator = currentContent.getDelegator(); List assocList = getAssociations(currentContent, linkDir, assocTypes, fromDate, thruDate); - if (assocList == null || assocList.size() == 0) + if (UtilValidate.isEmpty(assocList)) { return assocList; + } if (Debug.infoOn()) Debug.logInfo("assocList:" + assocList.size() + " contentId:" + currentContent.getString("contentId"), ""); List contentList = new ArrayList(); @@ -1060,14 +1061,14 @@ Map results = null; results = ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, "To", fromDate, null, null, null, assocTypes, null); List entityList = (List) results.get("entityList"); - if (entityList == null || entityList.size() == 0) { + if (UtilValidate.isEmpty(entityList)) { //throw new IOException("No subcontent found."); } else { view = (GenericValue) entityList.get(0); } } else { List lst = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", subContentId)); - if (lst == null || lst.size() == 0) { + if (UtilValidate.isEmpty(lst)) { throw new IOException("No subContent found for subContentId=." + subContentId); } view = (GenericValue) lst.get(0); @@ -1106,7 +1107,7 @@ throw new RuntimeException(e.getMessage()); } List entityList = (List) results.get("entityList"); - if (entityList == null || entityList.size() == 0) { + if (UtilValidate.isEmpty(entityList)) { //throw new IOException("No subcontent found."); } else { view = (GenericValue) entityList.get(0); @@ -1298,12 +1299,12 @@ if (Debug.infoOn()) Debug.logInfo("in prepTargetOperationList, targetOperationString(0):" + targetOperationString, ""); if (UtilValidate.isNotEmpty(targetOperationString) ) { List opsFromString = StringUtil.split(targetOperationString, "|"); - if (targetOperationList == null || targetOperationList.size() == 0) { + if (UtilValidate.isEmpty(targetOperationList)) { targetOperationList = new ArrayList(); } targetOperationList.addAll(opsFromString); } - if (targetOperationList == null || targetOperationList.size() == 0) { + if (UtilValidate.isEmpty(targetOperationList)) { targetOperationList = new ArrayList(); if (UtilValidate.isEmpty(md)) md ="_CREATE"; @@ -1326,12 +1327,12 @@ if (Debug.infoOn()) Debug.logInfo("in prepContentPurposeList, contentPurposeString(0):" + contentPurposeString, ""); if (UtilValidate.isNotEmpty(contentPurposeString) ) { List purposesFromString = StringUtil.split(contentPurposeString, "|"); - if (contentPurposeList == null || contentPurposeList.size() == 0) { + if (UtilValidate.isEmpty(contentPurposeList)) { contentPurposeList = new ArrayList(); } contentPurposeList.addAll(purposesFromString); } - if (contentPurposeList == null || contentPurposeList.size() == 0) { + if (UtilValidate.isEmpty(contentPurposeList)) { contentPurposeList = new ArrayList(); } if (Debug.infoOn()) Debug.logInfo("in prepContentPurposeList, contentPurposeList(0):" + contentPurposeList, ""); Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java?view=diff&rev=514366&r1=514365&r2=514366 ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Sat Mar 3 22:59:23 2007 @@ -30,6 +30,7 @@ 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; @@ -97,7 +98,7 @@ "productAssocTypeId", partBomTypeId), UtilMisc.toList("sequenceNum")); rows = EntityUtil.filterByDate(rows, inDate); - if ((rows == null || rows.size() == 0) && substitutedNode != null) { + if ((UtilValidate.isEmpty(rows)) && substitutedNode != null) { // If no child is found and this is a substituted node // we try to search for substituted node's children. rows = delegator.findByAnd("ProductAssoc", @@ -319,7 +320,7 @@ "productAssocTypeId", partBomTypeId), UtilMisc.toList("sequenceNum")); rows = EntityUtil.filterByDate(rows, inDate); - if ((rows == null || rows.size() == 0) && substitutedNode != null) { + if ((UtilValidate.isEmpty(rows)) && substitutedNode != null) { // If no parent is found and this is a substituted node // we try to search for substituted node's parents. rows = delegator.findByAnd("ProductAssoc", Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?view=diff&rev=514366&r1=514365&r2=514366 ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Sat Mar 3 22:59:23 2007 @@ -208,7 +208,7 @@ if (routing == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductRoutingNotExist", locale)); } - if (routingTaskAssocs == null || routingTaskAssocs.size()==0) { + if (UtilValidate.isEmpty(routingTaskAssocs)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingHasNoRoutingTask", locale)); } @@ -943,7 +943,7 @@ ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); List tasks = productionRun.getProductionRunRoutingTasks(); - if (tasks == null || tasks.size() == 0){ + if (UtilValidate.isEmpty(tasks)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } @@ -1012,7 +1012,7 @@ ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); List components = productionRun.getProductionRunComponents(); - if (components == null || components.size() == 0){ + if (UtilValidate.isEmpty(components)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunComponentNotExists", locale)); } Modified: ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/thirdparty/truition/TruitionCoReg.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/thirdparty/truition/TruitionCoReg.java?view=diff&rev=514366&r1=514365&r2=514366 ============================================================================== --- ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/thirdparty/truition/TruitionCoReg.java (original) +++ ofbiz/trunk/applications/securityext/src/org/ofbiz/securityext/thirdparty/truition/TruitionCoReg.java Sat Mar 3 22:59:23 2007 @@ -203,10 +203,10 @@ // email address String emailAddress = null; Collection emCol = ContactHelper.getContactMech(party, "PRIMARY_EMAIL", "EMAIL_ADDRESS", false); - if (emCol == null || emCol.size() == 0) { + if (UtilValidate.isEmpty(emCol)) { emCol = ContactHelper.getContactMech(party, null, "EMAIL_ADDRESS", false); } - if (emCol != null && emCol.size() > 0) { + if (!UtilValidate.isEmpty(emCol)) { GenericValue emVl = (GenericValue) emCol.iterator().next(); if (emVl != null) { emailAddress = emVl.getString("infoString"); @@ -224,10 +224,10 @@ String zipCode = null; String country = null; Collection adCol = ContactHelper.getContactMech(party, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false); - if (adCol == null || adCol.size() == 0) { + if (UtilValidate.isEmpty(adCol)) { adCol = ContactHelper.getContactMech(party, null, "POSTAL_ADDRESS", false); } - if (adCol != null && adCol.size() > 0) { + if (!UtilValidate.isEmpty(adCol)) { GenericValue adVl = (GenericValue) adCol.iterator().next(); if (adVl != null) { GenericValue addr = null; @@ -260,10 +260,10 @@ // phone number String phoneNumber = null; Collection phCol = ContactHelper.getContactMech(party, "PHONE_HOME", "TELECOM_NUMBER", false); - if (phCol == null || phCol.size() == 0) { + if (UtilValidate.isEmpty(phCol)) { phCol = ContactHelper.getContactMech(party, null, "TELECOM_NUMBER", false); } - if (phCol != null && phCol.size() > 0) { + if (!UtilValidate.isEmpty(phCol)) { GenericValue phVl = (GenericValue) phCol.iterator().next(); if (phVl != null) { GenericValue tele = null; Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?view=diff&rev=514366&r1=514365&r2=514366 ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Sat Mar 3 22:59:23 2007 @@ -514,7 +514,7 @@ } final String externalCode = "PRDS_PAY_EXTERNAL"; - if (values == null || values.size() == 0) { + if (UtilValidate.isEmpty(values)) { return NO_PAYMENT; } else { boolean isExternal = true; |
Free forum by Nabble | Edit this page |