[ofbiz-framework] branch trunk updated: Improved: Inconsistent String Comparisons(OFBIZ-9254)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Inconsistent String Comparisons(OFBIZ-9254)

Pawan Verma-2
This is an automated email from the ASF dual-hosted git repository.

pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 034e03a  Improved: Inconsistent String Comparisons(OFBIZ-9254)
034e03a is described below

commit 034e03abf47b10c94b365357f9ed91bcba1251c4
Author: Pawan Verma <[hidden email]>
AuthorDate: Thu Jul 30 17:01:54 2020 +0530

    Improved: Inconsistent String Comparisons(OFBIZ-9254)
   
    There are some inconsistencies in the code for string comparison statusId.equals(PRUN_COMPLETED) whereas it should be written as PRUN_COMPLETED.equals(statusId) cause the former can throw NullPointerException if the variable found to be NULL.
   
    Thanks: Devanshu for your contribution.
---
 .../groovyScripts/reports/CashFlowStatement.groovy |  2 +-
 .../thirdparty/eway/GatewayResponse.java           |  4 +--
 .../order/groovyScripts/return/ReturnItems.groovy  |  2 +-
 .../party/groovyScripts/party/FindLookUp.groovy    |  2 +-
 .../catalog/category/EditCategorySEO.groovy        |  6 ++--
 .../catalog/imagemanagement/SeoLocales.groovy      | 18 ++++++------
 .../catalog/product/EditProductSEO.groovy          |  6 ++--
 .../catalog/store/EditProductStorePaySetup.groovy  | 32 +++++++++++-----------
 .../facility/shipment/PrintPickSheets.groovy       |  2 +-
 .../product/catalog/CatalogServices.groovy         |  2 +-
 .../product/category/CategoryServices.groovy       |  2 +-
 11 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy b/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy
index b649489..7ec6e99 100644
--- a/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy
+++ b/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy
@@ -103,7 +103,7 @@ transactionTotals.each { transactionTotal ->
         accountMap.remove("debitCreditFlag")
         accountMap.remove("amount")
     }
-    if (transactionTotal.debitCreditFlag == "C") {
+    if ("C" == transactionTotal.debitCreditFlag) {
         accountMap.C = ((BigDecimal)accountMap.get("C")).add(transactionTotal.amount)
         accountMap.balance = (accountMap.balance).subtract(transactionTotal.amount)
     } else {
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java
index e838d48..f2d0f70 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java
@@ -135,7 +135,7 @@ public class GatewayResponse {
         Node rootnode = doc.getDocumentElement();
         String root = rootnode.getNodeName();
 
-        if (root != "ewayResponse") {
+        if ("ewayResponse" != root) {
             throw new Exception("Bad root element in response: " + root);
         }
 
@@ -145,7 +145,7 @@ public class GatewayResponse {
         for (int i = 0; i < length; i++) {
             Node node = list.item(i);
             String name = node.getNodeName();
-            if (name == "ewayResponse") {
+            if ("ewayResponse" == name) {
                 continue;
             }
             Text textnode = (Text) node.getFirstChild();
diff --git a/applications/order/groovyScripts/return/ReturnItems.groovy b/applications/order/groovyScripts/return/ReturnItems.groovy
index 69f7e67..8263e4e 100644
--- a/applications/order/groovyScripts/return/ReturnItems.groovy
+++ b/applications/order/groovyScripts/return/ReturnItems.groovy
@@ -74,7 +74,7 @@ if (orderId) {
 }
 roleTypeId = "PLACING_CUSTOMER"
 partyId = returnHeader.fromPartyId
-if (returnHeaderTypeId == "VENDOR_RETURN") {
+if ("VENDOR_RETURN" == returnHeaderTypeId) {
     roleTypeId = "BILL_FROM_VENDOR"
     partyId = returnHeader.toPartyId
 }
diff --git a/applications/party/groovyScripts/party/FindLookUp.groovy b/applications/party/groovyScripts/party/FindLookUp.groovy
index 7a1b3d1..c319692 100644
--- a/applications/party/groovyScripts/party/FindLookUp.groovy
+++ b/applications/party/groovyScripts/party/FindLookUp.groovy
@@ -47,7 +47,7 @@ entityConditionList = null
 if (prepareResult.entityConditionList != null) {
     ConditionList = [prepareResult.entityConditionList, statusPartyDisable]
     entityConditionList = EntityCondition.makeCondition(ConditionList)
-} else if (context.noConditionFind == "Y") {
+} else if ("Y" == context.noConditionFind) {
     entityConditionList = statusPartyDisable
 }
 
diff --git a/applications/product/groovyScripts/catalog/category/EditCategorySEO.groovy b/applications/product/groovyScripts/catalog/category/EditCategorySEO.groovy
index f401417..df750f1 100644
--- a/applications/product/groovyScripts/catalog/category/EditCategorySEO.groovy
+++ b/applications/product/groovyScripts/catalog/category/EditCategorySEO.groovy
@@ -21,17 +21,17 @@ productCategoryId = parameters.productCategoryId
 if (productCategoryId) {
     productCategoryContents  = from("ProductCategoryContent").where("productCategoryId", productCategoryId).queryList()
     productCategoryContents.each{ productCategoryContent->
-        if (productCategoryContent.prodCatContentTypeId == "PAGE_TITLE") {
+        if ("PAGE_TITLE" == productCategoryContent.prodCatContentTypeId) {
             contentTitle  = from("Content").where("contentId", productCategoryContent.contentId).queryOne()
             dataTextTitle  = from("ElectronicText").where("dataResourceId", contentTitle.dataResourceId).queryOne()
             context.title = dataTextTitle.textData
         }
-        if (productCategoryContent.prodCatContentTypeId == "META_KEYWORD") {
+        if ("META_KEYWORD" == productCategoryContent.prodCatContentTypeId) {
             contentMetaKeyword  = from("Content").where("contentId", productCategoryContent.contentId).queryOne()
             dataTextMetaKeyword  = from("ElectronicText").where("dataResourceId", contentMetaKeyword.dataResourceId).queryOne()
             context.metaKeyword = dataTextMetaKeyword.textData
         }
-        if (productCategoryContent.prodCatContentTypeId == "META_DESCRIPTION") {
+        if ("META_DESCRIPTION" == productCategoryContent.prodCatContentTypeId) {
             contentMetaDescription  = from("Content").where("contentId", productCategoryContent.contentId).queryOne()
             dataTextMetaDescription  = from("ElectronicText").where("dataResourceId", contentMetaDescription.dataResourceId).queryOne()
             context.metaDescription = dataTextMetaDescription.textData
diff --git a/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy b/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy
index 024d6a0..cfa7c0c 100644
--- a/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy
+++ b/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy
@@ -35,23 +35,23 @@ contentAssocs.each { contentAssoc ->
 content = from("Content").where("contentId", contentAssoc.contentIdTo).queryOne()
 localeString = content.localeString
 
-    if (serverLocal == "au") {
+    if ("au" == serverLocal) {
         nameLocal = "en_AU"
-    } else if (serverLocal == "ca") {
+    } else if ("ca" == serverLocal) {
         nameLocal = "en_CA"
-    } else if (serverLocal == "de") {
+    } else if ("de" == serverLocal) {
         nameLocal = "de"
-    } else if (serverLocal == "ie") {
+    } else if ("ie" == serverLocal) {
         nameLocal = "en_IE"
-    } else if (serverLocal == "fr") {
+    } else if ("fr" == serverLocal) {
         nameLocal = "fr"
-    } else if (serverLocal == "es") {
+    } else if ("es" == serverLocal) {
         nameLocal = "es"
-    } else if (serverLocal == "it") {
+    } else if ("it" == serverLocal) {
         nameLocal = "it"
-    } else if (serverLocal == "uk") {
+    } else if ("uk" == serverLocal) {
         nameLocal = "en_GB"
-    } else if (serverLocal == "sg") {
+    } else if ("sg" == serverLocal) {
         nameLocal = "en_SG"
     } else {
         nameLocal = "en_US"
diff --git a/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy b/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy
index 727bd5d..12647e6 100644
--- a/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy
+++ b/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy
@@ -21,17 +21,17 @@ productId = parameters.productId
 if (productId) {
     productContents  = from("ProductContent").where("productId", productId).queryList()
     productContents.each{ productContent->
-        if (productContent.productContentTypeId == "PAGE_TITLE") {
+        if ("PAGE_TITLE" == productContent.productContentTypeId) {
             contentTitle  = from("Content").where("contentId", productContent.contentId).queryOne()
             dataTextTitle  = from("ElectronicText").where("dataResourceId", contentTitle.dataResourceId).queryOne()
             context.title = dataTextTitle.textData
         }
-        if (productContent.productContentTypeId == "META_KEYWORD") {
+        if ("META_KEYWORD" == productContent.productContentTypeId) {
             contentMetaKeyword  = from("Content").where("contentId", productContent.contentId).queryOne()
             dataTextMetaKeyword  = from("ElectronicText").where("dataResourceId", contentMetaKeyword.dataResourceId).queryOne()
             context.metaKeyword = dataTextMetaKeyword.textData
         }
-        if (productContent.productContentTypeId == "META_DESCRIPTION") {
+        if ("META_DESCRIPTION" == productContent.productContentTypeId) {
             contentMetaDescription  = from("Content").where("contentId", productContent.contentId).queryOne()
             dataTextMetaDescription  = from("ElectronicText").where("dataResourceId", contentMetaDescription.dataResourceId).queryOne()
             context.metaDescription = dataTextMetaDescription.textData
diff --git a/applications/product/groovyScripts/catalog/store/EditProductStorePaySetup.groovy b/applications/product/groovyScripts/catalog/store/EditProductStorePaySetup.groovy
index f00c1b7..36fb4c0 100644
--- a/applications/product/groovyScripts/catalog/store/EditProductStorePaySetup.groovy
+++ b/applications/product/groovyScripts/catalog/store/EditProductStorePaySetup.groovy
@@ -25,35 +25,35 @@ paymentServiceTypeEnumId = request.getParameter("paymentServiceTypeEnumId")
 customMethodsCond = null
 
 if (paymentMethodTypeId && paymentServiceTypeEnumId) {
-    if (paymentMethodTypeId == "CREDIT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_AUTH" ) {
+    if ("CREDIT_CARD" == paymentMethodTypeId && "PRDS_PAY_AUTH" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "CC_AUTH")
-    } else if (paymentMethodTypeId == "CREDIT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_CAPTURE" ) {
+    } else if ("CREDIT_CARD" == paymentMethodTypeId && "PRDS_PAY_CAPTURE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "CC_CAPTURE")
-    } else if (paymentMethodTypeId == "CREDIT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_REAUTH" ) {
+    } else if ("CREDIT_CARD" == paymentMethodTypeId && "PRDS_PAY_REAUTH" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "CC_AUTH")
-    } else if (paymentMethodTypeId == "CREDIT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_REFUND" ) {
+    } else if ("CREDIT_CARD" == paymentMethodTypeId && "PRDS_PAY_REFUND" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "CC_REFUND")
-    } else if (paymentMethodTypeId == "CREDIT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_RELEASE" ) {
+    } else if ("CREDIT_CARD" == paymentMethodTypeId && "PRDS_PAY_RELEASE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "CC_RELEASE")
-    } else if (paymentMethodTypeId == "EFT_ACCOUNT" && paymentServiceTypeEnumId == "PRDS_PAY_AUTH" ) {
+    } else if ("EFT_ACCOUNT" == paymentMethodTypeId && "PRDS_PAY_AUTH" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "EFT_AUTH")
-    } else if (paymentMethodTypeId == "EFT_ACCOUNT" && paymentServiceTypeEnumId == "PRDS_PAY_RELEASE" ) {
+    } else if ("EFT_ACCOUNT" == paymentMethodTypeId && "PRDS_PAY_RELEASE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "EFT_RELEASE")
-    } else if (paymentMethodTypeId == "FIN_ACCOUNT" && paymentServiceTypeEnumId == "PRDS_PAY_AUTH" ) {
+    } else if ("FIN_ACCOUNT" == paymentMethodTypeId && "PRDS_PAY_AUTH" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "FIN_AUTH")
-    } else if (paymentMethodTypeId == "FIN_ACCOUNT" && paymentServiceTypeEnumId == "PRDS_PAY_CAPTURE" ) {
+    } else if ("FIN_ACCOUNT" == paymentMethodTypeId && "PRDS_PAY_CAPTURE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "FIN_CAPTURE")
-    } else if (paymentMethodTypeId == "FIN_ACCOUNT" && paymentServiceTypeEnumId == "PRDS_PAY_REFUND" ) {
+    } else if ("FIN_ACCOUNT" == paymentMethodTypeId && "PRDS_PAY_REFUND" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "FIN_REFUND")
-    } else if (paymentMethodTypeId == "FIN_ACCOUNT" && paymentServiceTypeEnumId == "PRDS_PAY_RELEASE" ) {
+    } else if ("FIN_ACCOUNT" == paymentMethodTypeId && "PRDS_PAY_RELEASE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "FIN_RELEASE")
-    } else if (paymentMethodTypeId == "GIFT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_AUTH" ) {
+    } else if ("GIFT_CARD" == paymentMethodTypeId && "PRDS_PAY_AUTH" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "GIFT_AUTH")
-    } else if (paymentMethodTypeId == "GIFT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_CAPTURE" ) {
+    } else if ("GIFT_CARD" == paymentMethodTypeId && "PRDS_PAY_CAPTURE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "GIFT_CAPTURE")
-    } else if (paymentMethodTypeId == "GIFT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_REFUND" ) {
+    } else if ("GIFT_CARD" == paymentMethodTypeId && "PRDS_PAY_REFUND" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "GIFT_REFUND")
-    } else if (paymentMethodTypeId == "GIFT_CARD" && paymentServiceTypeEnumId == "PRDS_PAY_RELEASE" ) {
+    } else if ("GIFT_CARD" == paymentMethodTypeId && "PRDS_PAY_RELEASE" == paymentServiceTypeEnumId ) {
         customMethodsCond = EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "GIFT_RELEASE")
     }
 }
@@ -78,7 +78,7 @@ if (!paymentMethodTypeId || !paymentServiceTypeEnumId) {
     customMethods.add(EntityCondition.makeCondition("customMethodTypeId", EntityOperator.EQUALS, "GIFT_RELEASE"))
     customMethodsCond = EntityCondition.makeCondition(customMethods, EntityOperator.OR)
 }
-if (paymentServiceTypeEnumId == "PRDS_PAY_EXTERNAL") {
+if ("PRDS_PAY_EXTERNAL" == paymentServiceTypeEnumId) {
     context.paymentCustomMethods = null
 } else if (customMethodsCond) {
     context.paymentCustomMethods = from("CustomMethod").where(customMethodsCond).orderBy("description").queryList()
diff --git a/applications/product/groovyScripts/facility/shipment/PrintPickSheets.groovy b/applications/product/groovyScripts/facility/shipment/PrintPickSheets.groovy
index 6040b37..e1602d6 100644
--- a/applications/product/groovyScripts/facility/shipment/PrintPickSheets.groovy
+++ b/applications/product/groovyScripts/facility/shipment/PrintPickSheets.groovy
@@ -87,7 +87,7 @@ if (toPrintOrders) {
                     orderItemMap = [:]
                     orderItemShipGrpInvResInfoList.each { orderItemShipGrpInvResInfos ->
                         orderItemShipGrpInvResInfos.each { orderItemShipGrpInvResInfo ->
-                            if (orderItemShipGrpInvResInfo.orderItemShipGrpInvRes.orderId == orderId && addInMap == "true") {
+                            if (orderItemShipGrpInvResInfo.orderItemShipGrpInvRes.orderId == orderId && "true" == addInMap) {
                                 orderItemMap.(orderHeader.orderId) = orderItemShipGrpInvResInfos
                                 addInMap = "false"
                             }
diff --git a/applications/product/groovyScripts/product/catalog/CatalogServices.groovy b/applications/product/groovyScripts/product/catalog/CatalogServices.groovy
index 67dcf7f..efda16a 100644
--- a/applications/product/groovyScripts/product/catalog/CatalogServices.groovy
+++ b/applications/product/groovyScripts/product/catalog/CatalogServices.groovy
@@ -247,7 +247,7 @@ def imageUrlCheck(prodOrCat, imageType, filesImageMap) {
         filesImageMap."${imageType}Map" = [:]
         filesImageMap."${imageType}Map"."${imageType}" = prodOrCat."${imageType}"
         filesImageMap."${imageType}Map".isExists = isExists
-        if (isExists == "N") {
+        if ("N" == isExists) {
             prodOrCat."${imageType}" = null
         }
     }
diff --git a/applications/product/groovyScripts/product/category/CategoryServices.groovy b/applications/product/groovyScripts/product/category/CategoryServices.groovy
index da9df54..86bf733 100644
--- a/applications/product/groovyScripts/product/category/CategoryServices.groovy
+++ b/applications/product/groovyScripts/product/category/CategoryServices.groovy
@@ -320,7 +320,7 @@ def copyCategoryProductMembers() {
     }
     delegator.storeAll(pcmsToStore)
 
-    if (parameters.recurse == "Y") {
+    if ("Y" == parameters.recurse) {
         // call this service for each sub-category in the rollup with the same productCategoryIdTo
         Map lookupChildrenMap = [parentProductCategoryId: parameters.productCategoryId]
         query = from("ProductCategoryRollup").where(lookupChildrenMap)