This is an automated email from the ASF dual-hosted git repository.
akashjain 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 66a76ff Improved: Fix Literals comparisons with variable to avoid NPE
(OFBIZ-11929)
66a76ff is described below
commit 66a76ffd5af92e571b5a052c50f3725ee4eccadf
Author: Akash Jain <[email protected]>
AuthorDate: Sun Aug 30 17:20:23 2020 +0530
Improved: Fix Literals comparisons with variable to avoid NPE (OFBIZ-11929)
Thanks, Devanshu Vyas for your contribution.
---
.../ofbiz/accounting/invoice/InvoiceServices.java | 6 +--
.../thirdparty/eway/GatewayResponse.java | 4 +-
.../ofbiz/content/content/ContentMapFacade.java | 6 +--
.../ofbiz/content/data/DataResourceWorker.java | 2 +-
.../webapp/ftl/OfbizContentAltUrlTransforms.java | 2 +-
.../apache/ofbiz/manufacturing/bom/BOMNode.java | 4 +-
.../marketing/tracking/TrackingCodeEvents.java | 2 +-
.../order/shoppingcart/ShoppingCartEvents.java | 4 +-
.../order/shoppinglist/ShoppingListEvents.java | 2 +-
.../ofbiz/product/category/CategoryWorker.java | 2 +-
.../ofbiz/product/inventory/InventoryServices.java | 2 +-
.../product/product/ProductSearchSession.java | 2 +-
.../spreadsheetimport/ImportProductServices.java | 2 +-
.../ofbiz/shipment/thirdparty/ups/UpsServices.java | 2 +-
.../org/apache/ofbiz/base/util/GroovyUtil.java | 2 +-
.../java/org/apache/ofbiz/common/FindServices.java | 10 ++--
.../apache/ofbiz/common/email/EmailServices.java | 4 +-
.../apache/ofbiz/common/qrcode/QRCodeServices.java | 2 +-
.../java/org/apache/ofbiz/datafile/Record.java | 58 +++++++++++-----------
.../ofbiz/entity/condition/EntityClause.java | 2 +-
.../permission/EntityPermissionChecker.java | 16 +++---
.../apache/ofbiz/security/CsrfDefenseStrategy.java | 2 +-
.../org/apache/ofbiz/security/SecurityFactory.java | 4 +-
.../ofbiz/service/engine/XMLRPCClientEngine.java | 2 +-
.../java/org/apache/ofbiz/base/start/Config.java | 4 +-
.../org/apache/ofbiz/testtools/ModelTestSuite.java | 4 +-
.../apache/ofbiz/webapp/control/LoginWorker.java | 6 +--
.../ofbiz/webapp/control/RequestHandler.java | 2 +-
.../org/apache/ofbiz/widget/model/HtmlWidget.java | 2 +-
29 files changed, 81 insertions(+), 81 deletions(-)
diff --git
a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
index ecb07f8..e2eb95e 100644
---
a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
+++
b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
@@ -2782,7 +2782,7 @@ public class InvoiceServices {
// amount available on the payment reduced by the already applied
amounts
GenericValue payment = null;
String currencyUomId = null;
- if (paymentId == null || paymentId.equals("")) {
+ if (paymentId == null || "".equals(paymentId)) {
errorMessageList.add(UtilProperties.getMessage(RESOURCE,
"AccountingPaymentIdBlankNotSupplied", locale));
} else {
try {
@@ -2813,7 +2813,7 @@ public class InvoiceServices {
// the "TO" Payment.....
BigDecimal toPaymentApplyAvailable = BigDecimal.ZERO;
GenericValue toPayment = null;
- if (toPaymentId != null && !toPaymentId.equals("")) {
+ if (toPaymentId != null && !"".equals(toPaymentId)) {
try {
toPayment =
EntityQuery.use(delegator).from("Payment").where("paymentId",
toPaymentId).queryOne();
} catch (GenericEntityException e) {
@@ -2887,7 +2887,7 @@ public class InvoiceServices {
// billing account
GenericValue billingAccount = null;
- if (billingAccountId != null && !billingAccountId.equals("")) {
+ if (billingAccountId != null && !"".equals(billingAccountId)) {
try {
billingAccount =
EntityQuery.use(delegator).from("BillingAccount").where("billingAccountId",
billingAccountId).queryOne();
} catch (GenericEntityException e) {
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 4f1cd8f..e645f79 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
@@ -214,7 +214,7 @@ public class GatewayResponse {
txTrxnOption3 = value;
break;
case "ewayReturnAmount":
- if (!value.equals("")) {
+ if (!"".equals(value)) {
txReturnAmount = Integer.parseInt(value);
}
break;
@@ -225,7 +225,7 @@ public class GatewayResponse {
txTrxnReference = value;
break;
case "ewayBeagleScore":
- if (!value.equals("")) {
+ if (!"".equals(value)) {
txBeagleScore = Double.parseDouble(value);
}
break;
diff --git
a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
index 67a47a4..1edbb4d 100644
---
a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
+++
b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
@@ -320,10 +320,10 @@ public class ContentMapFacade implements Map<Object,
Object> {
try {
Map<String, Object> expressions = new HashMap<>();
expressions.put("contentIdStart", contentId);
- if (!this.mapKeyFilter.equals("")) {
+ if (!"".equals(this.mapKeyFilter)) {
expressions.put("caMapKey", this.mapKeyFilter);
}
- if (!this.statusFilter.equals("")) {
+ if (!"".equals(this.statusFilter)) {
expressions.put("statusId", this.statusFilter);
}
@@ -505,7 +505,7 @@ public class ContentMapFacade implements Map<Object,
Object> {
Map<String, Object> expressions = new HashMap<>();
expressions.put("contentIdStart", contentId);
expressions.put("caMapKey", name);
- if (!this.statusFilter.equals("")) {
+ if (!"".equals(this.statusFilter)) {
expressions.put("statusId", this.statusFilter);
}
sub = EntityQuery.use(delegator).from("ContentAssocViewTo")
diff --git
a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
index d74c1d8..575022e 100644
---
a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
+++
b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
@@ -191,7 +191,7 @@ public class DataResourceWorker implements
org.apache.ofbiz.widget.content.Data
spcBuilder.append(nm);
map.put("dataCategoryId", id);
map.put("categoryName", spcBuilder.toString());
- if (id != null && !"ROOT".equals(id) && !id.equals("")) {
+ if (id != null && !"ROOT".equals(id) && !"".equals(id)) {
lst.add(map);
}
List<Map<String, Object>> kids = UtilGenerics.cast(nd.get("kids"));
diff --git
a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java
b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java
index fd0a4e8..952aaef 100644
---
a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java
+++
b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java
@@ -132,7 +132,7 @@ public class OfbizContentAltUrlTransforms implements
TemplateTransformModel {
url = contentAssocDataResource.getString("drObjectInfo");
url = UtilCodec.getDecoder("url").decode(url);
String mountPoint = request.getContextPath();
- if (!("/".equals(mountPoint)) && !(mountPoint.equals(""))) {
+ if (!("/".equals(mountPoint)) && !("".equals(mountPoint))) {
url = mountPoint + url;
}
}
diff --git
a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
index e4800e9..bf902df 100644
---
a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
+++
b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
@@ -163,7 +163,7 @@ public class BOMNode {
GenericValue feature = null;
boolean ruleSatisfied = false;
- if (ruleCondition == null || ruleCondition.equals("")) {
+ if (ruleCondition == null || "".equals(ruleCondition)) {
ruleSatisfied = true;
} else {
if (productFeatures != null) {
@@ -178,7 +178,7 @@ public class BOMNode {
}
if (ruleSatisfied && "OR".equals(ruleOperator)) {
BOMNode tmpNode = oneChildNode;
- if (newPart == null || newPart.equals("")) {
+ if (newPart == null || "".equals(newPart)) {
oneChildNode = null;
} else {
BOMNode origNode = oneChildNode;
diff --git
a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java
b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java
index 3f9290b..5e18190 100644
---
a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java
+++
b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java
@@ -507,7 +507,7 @@ public class TrackingCodeEvents {
// find the referred timestamp cookie if it exists
if ("Ofbiz.TKCD.UpdatedTimeStamp".equals(cookieName)) {
String affiliateReferredTime = cookies[i].getValue();
- if (affiliateReferredTime != null &&
!affiliateReferredTime.equals("")) {
+ if (affiliateReferredTime != null &&
!"".equals(affiliateReferredTime)) {
try {
affiliateReferredTimeStamp =
Timestamp.valueOf(affiliateReferredTime);
} catch (IllegalArgumentException e) {
diff --git
a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
index 4fc6ce7..d6d183a 100644
---
a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
+++
b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
@@ -1822,7 +1822,7 @@ public class ShoppingCartEvents {
if (paramMap.containsKey("quantity" + thisSuffix)) {
quantityStr = (String) paramMap.remove("quantity" +
thisSuffix);
}
- if ((quantityStr == null) || (quantityStr.equals(""))) { //
otherwise, every empty value causes an exception and makes the log ugly
+ if ((quantityStr == null) || ("".equals(quantityStr))) { //
otherwise, every empty value causes an exception and makes the log ugly
quantityStr = "0"; // default quantity is 0, so without a
quantity input, this field will not be added
}
@@ -2041,7 +2041,7 @@ public class ShoppingCartEvents {
if (paramMap.containsKey("quantity" + thisSuffix)) {
quantityStr = (String) paramMap.remove("quantity" +
thisSuffix);
}
- if ((quantityStr == null) || (quantityStr.equals(""))) {
+ if ((quantityStr == null) || ("".equals(quantityStr))) {
quantityStr = "0";
}
try {
diff --git
a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
index ea26c00..6407ff4 100644
---
a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
+++
b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java
@@ -126,7 +126,7 @@ public class ShoppingListEvents {
}
// if no list was created throw an error
- if (shoppingListId == null || shoppingListId.equals("")) {
+ if (shoppingListId == null || "".equals(shoppingListId)) {
errMsg = UtilProperties.getMessage(RES_ERROR,
"shoppinglistevents.shoppingListId_is_required_parameter", cart.getLocale());
throw new IllegalArgumentException(errMsg);
}
diff --git
a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java
b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java
index c864e66..51a8489 100644
---
a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java
+++
b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java
@@ -109,7 +109,7 @@ public final class CategoryWorker {
requestId = UtilFormatOut.checkNull((String)
requestParameters.get("catalog_id"), (String)
requestParameters.get("CATALOG_ID"),
(String) requestParameters.get("category_id"), (String)
requestParameters.get("CATEGORY_ID"));
- if (requestId.equals(""))
+ if ("".equals(requestId))
return;
if (Debug.infoOn()) {
Debug.logInfo("[CategoryWorker.getRelatedCategories] RequestID: "
+ requestId, MODULE);
diff --git
a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java
b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java
index ddf92e0..060d011 100644
---
a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java
+++
b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java
@@ -788,7 +788,7 @@ public class InventoryServices {
for (GenericValue orderItem: orderItems) {
String productId = orderItem.getString("productId");
- if ((productId == null) || productId.equals("")) {
+ if ((productId == null) || "".equals(productId)) {
continue;
}
diff --git
a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
index 64ab234..baba193 100644
---
a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
+++
b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
@@ -638,7 +638,7 @@ public class ProductSearchSession {
// if there is any category selected try to use catalog and add a
constraint for it
if (UtilValidate.isNotEmpty(parameters.get("SEARCH_CATALOG_ID"))) {
String searchCatalogId = (String)
parameters.get("SEARCH_CATALOG_ID");
- if (searchCatalogId != null &&
!searchCatalogId.equalsIgnoreCase("")) {
+ if (searchCatalogId != null &&
!"".equalsIgnoreCase(searchCatalogId)) {
String topCategory =
CatalogWorker.getCatalogTopCategoryId(request, searchCatalogId);
if (UtilValidate.isEmpty(topCategory)) {
topCategory =
CatalogWorker.getCatalogTopEbayCategoryId(request, searchCatalogId);
diff --git
a/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java
b/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java
index 29cef3b..9f7ee63 100644
---
a/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java
+++
b/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java
@@ -134,7 +134,7 @@ public class ImportProductServices {
// too.
boolean productExists =
ImportProductHelper.checkProductExists(productId, delegator);
- if (!productId.trim().equalsIgnoreCase("") &&
!productExists) {
+ if (!"".equalsIgnoreCase(productId.trim()) &&
!productExists) {
products.add(ImportProductHelper.prepareProduct(productId));
if (quantityOnHand.compareTo(BigDecimal.ZERO) >= 0) {
inventoryItems.add(ImportProductHelper.prepareInventoryItem(productId,
quantityOnHand,
diff --git
a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java
b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java
index a828d8e..5dff537 100644
---
a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java
+++
b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java
@@ -2108,7 +2108,7 @@ public class UpsServices {
Element shiptoElement = UtilXml.addChildElement(shipmentElement,
"ShipTo", rateRequestDoc);
Element shiptoAddrElement = UtilXml.addChildElement(shiptoElement,
"Address", rateRequestDoc);
UtilXml.addChildElementValue(shiptoAddrElement, "PostalCode",
shippingPostalCode, rateRequestDoc);
- if (shippingCountryCode != null && !shippingCountryCode.equals("")) {
+ if (shippingCountryCode != null && !"".equals(shippingCountryCode)) {
UtilXml.addChildElementValue(shiptoAddrElement, "CountryCode",
shippingCountryCode, rateRequestDoc);
}
diff --git
a/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
b/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
index 3e8f6e6..f6d6dc7 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
@@ -71,7 +71,7 @@ public final class GroovyUtil {
@SuppressWarnings("unchecked")
public static Object eval(String expression, Map<String, Object> context)
throws CompilationFailedException {
Object o;
- if (expression == null || expression.equals("")) {
+ if (expression == null || "".equals(expression)) {
Debug.logError("Groovy Evaluation error. Empty expression",
MODULE);
return null;
}
diff --git
a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java
b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java
index b395e5b..eb87687 100644
--- a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java
+++ b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java
@@ -328,15 +328,15 @@ public class FindServices {
TimeZone timeZone = (TimeZone) context.get("timeZone");
EntityComparisonOperator<?, ?> fieldOp = null;
if (operation != null) {
- if (operation.equals("contains")) {
+ if ("contains".equals(operation)) {
fieldOp = EntityOperator.LIKE;
fieldValue = "%" + fieldValue + "%";
} else if ("not-contains".equals(operation) ||
"notContains".equals(operation)) {
fieldOp = EntityOperator.NOT_LIKE;
fieldValue = "%" + fieldValue + "%";
- } else if (operation.equals("empty")) {
+ } else if ("empty".equals(operation)) {
return EntityCondition.makeCondition(fieldName,
EntityOperator.EQUALS, null);
- } else if (operation.equals("like")) {
+ } else if ("like".equals(operation)) {
fieldOp = EntityOperator.LIKE;
fieldValue = fieldValue + "%";
} else if ("not-like".equals(operation) ||
"notLike".equals(operation)) {
@@ -348,11 +348,11 @@ public class FindServices {
fieldOp = EntityOperator.LESS_THAN;
} else if ("upThruDay".equals(operation)) {
fieldOp = EntityOperator.LESS_THAN_EQUAL_TO;
- } else if (operation.equals("greaterThanFromDayStart")) {
+ } else if ("greaterThanFromDayStart".equals(operation)) {
String timeStampString = (String) fieldValue;
Object startValue =
modelField.getModelEntity().convertFieldValue(modelField,
dayStart(timeStampString, 0, timeZone, locale), delegator, context);
return EntityCondition.makeCondition(fieldName,
EntityOperator.GREATER_THAN_EQUAL_TO, startValue);
- } else if (operation.equals("sameDay")) {
+ } else if ("sameDay".equals(operation)) {
String timeStampString = (String) fieldValue;
Object startValue =
modelField.getModelEntity().convertFieldValue(modelField,
dayStart(timeStampString, 0, timeZone, locale), delegator, context);
EntityCondition startCond =
EntityCondition.makeCondition(fieldName, EntityOperator.GREATER_THAN_EQUAL_TO,
startValue);
diff --git
a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java
b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java
index 3ec2941..9384fca 100644
---
a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java
+++
b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java
@@ -179,7 +179,7 @@ public class EmailServices {
boolean useSmtpAuth = false;
// define some default
- if (sendType == null || sendType.equals("mail.smtp.host")) {
+ if (sendType == null || "mail.smtp.host".equals(sendType)) {
sendType = "mail.smtp.host";
if (UtilValidate.isEmpty(sendVia)) {
sendVia = EntityUtilProperties.getPropertyValue("general",
"mail.smtp.relay.host", "localhost", delegator);
@@ -589,7 +589,7 @@ public class EmailServices {
// Only override the default contentType in case of plaintext,
since other contentTypes may be multipart
// and would require specific handling.
- if (contentType != null &&
contentType.equalsIgnoreCase("text/plain")) {
+ if (contentType != null &&
"text/plain".equalsIgnoreCase(contentType)) {
serviceContext.put("contentType", "text/plain");
} else {
serviceContext.put("contentType", "text/html");
diff --git
a/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java
b/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java
index b5fb960..112880c 100644
---
a/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java
+++
b/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java
@@ -233,7 +233,7 @@ public class QRCodeServices {
BufferedImage image = null;
String osName = System.getProperty("os.name").toLowerCase(locale);
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
- if (osName.startsWith("mac os") && format.equals("png")) {
+ if (osName.startsWith("mac os") && "png".equals(format)) {
image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
}
for (int x = 0; x < width; x++) {
diff --git
a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java
b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java
index b5b5e70..75f5376 100644
--- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java
+++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java
@@ -256,7 +256,7 @@ public class Record implements Serializable {
* @param value The String value to convert and set
*/
public void setString(String name, String value) throws ParseException {
- if (name == null || value == null || value.equals("")) {
+ if (name == null || value == null || "".equals(value)) {
return;
}
ModelField field = getModelRecord().getModelField(name);
@@ -281,7 +281,7 @@ public class Record implements Serializable {
String fieldType = field.getType();
// first the custom types that need to be parsed
- if (fieldType.equals("CustomTimestamp")) {
+ if ("CustomTimestamp".equals(fieldType)) {
// this custom type will take a string a parse according to date
formatting
// string then put the result in a java.sql.Timestamp
// a common timestamp format for flat files is with no separators:
yyyyMMddHHmmss
@@ -290,21 +290,21 @@ public class Record implements Serializable {
java.sql.Timestamp timestamp = new
java.sql.Timestamp(tempDate.getTime());
set(name, timestamp);
- } else if (fieldType.equals("CustomDate")) {
+ } else if ("CustomDate".equals(fieldType)) {
// a common date only format for flat files is with no separators:
yyyyMMdd or MMddyyyy
SimpleDateFormat sdf = new SimpleDateFormat(field.getFormat());
java.util.Date tempDate = sdf.parse(value);
java.sql.Date date = new java.sql.Date(tempDate.getTime());
set(name, date);
- } else if (fieldType.equals("CustomTime")) {
+ } else if ("CustomTime".equals(fieldType)) {
// a common time only format for flat files is with no separators:
HHmmss
SimpleDateFormat sdf = new SimpleDateFormat(field.getFormat());
java.util.Date tempDate = sdf.parse(value);
java.sql.Time time = new java.sql.Time(tempDate.getTime());
set(name, time);
- } else if (fieldType.equals("FixedPointDouble")) {
+ } else if ("FixedPointDouble".equals(fieldType)) {
// this custom type will parse a fixed point number according to
the number
// of decimal places in the formatting string then place it in a
Double
NumberFormat nf = NumberFormat.getNumberInstance();
@@ -315,35 +315,35 @@ public class Record implements Serializable {
number = number / divisor;
set(name, number);
- } else if (fieldType.equals("java.lang.String") ||
fieldType.equals("String")) {
+ } else if ("java.lang.String".equals(fieldType) ||
"String".equals(fieldType)) {
if (field.getFormat().equals("EncryptedString")) {
String hashType = LoginServices.getHashType();
set(name, HashCrypt.digestHash(hashType,
value.getBytes(StandardCharsets.UTF_8)));
} else {
set(name, value);
}
- } else if (fieldType.equals("NullTerminatedString")) {
+ } else if ("NullTerminatedString".equals(fieldType)) {
int terminate = value.indexOf(0x0);
set(name, terminate > 0 ? value.substring(0, terminate) : value);
- } else if (fieldType.equals("java.sql.Timestamp") ||
fieldType.equals("Timestamp")) {
+ } else if ("java.sql.Timestamp".equals(fieldType) ||
"Timestamp".equals(fieldType)) {
set(name, java.sql.Timestamp.valueOf(value));
- } else if (fieldType.equals("java.sql.Time") ||
fieldType.equals("Time")) {
+ } else if ("java.sql.Time".equals(fieldType) ||
"Time".equals(fieldType)) {
set(name, java.sql.Time.valueOf(value));
- } else if (fieldType.equals("java.sql.Date") ||
fieldType.equals("Date")) {
+ } else if ("java.sql.Date".equals(fieldType) ||
"Date".equals(fieldType)) {
set(name, java.sql.Date.valueOf(value));
- } else if (fieldType.equals("java.lang.Integer") ||
fieldType.equals("Integer")) {
+ } else if ("java.lang.Integer".equals(fieldType) ||
"Integer".equals(fieldType)) {
set(name, Integer.valueOf(value));
- } else if (fieldType.equals("java.lang.Long") ||
fieldType.equals("Long")) {
+ } else if ("java.lang.Long".equals(fieldType) ||
"Long".equals(fieldType)) {
set(name, Long.valueOf(value));
- } else if (fieldType.equals("java.lang.Float") ||
fieldType.equals("Float")) {
+ } else if ("java.lang.Float".equals(fieldType) ||
"Float".equals(fieldType)) {
set(name, Float.valueOf(value));
- } else if (fieldType.equals("java.lang.Double") ||
fieldType.equals("Double")) {
+ } else if ("java.lang.Double".equals(fieldType) ||
"Double".equals(fieldType)) {
set(name, Double.valueOf(value));
- } else if (fieldType.equals("LEShort")) {
+ } else if ("LEShort".equals(fieldType)) {
set(name, readLEShort(value.getBytes(StandardCharsets.UTF_8)));
- } else if (fieldType.equals("LEInteger")) {
+ } else if ("LEInteger".equals(fieldType)) {
set(name, readLEInt(value.getBytes(StandardCharsets.UTF_8)));
- } else if (fieldType.equals("LELong")) {
+ } else if ("LELong".equals(fieldType)) {
set(name, readLELong(value.getBytes(StandardCharsets.UTF_8)));
} else {
throw new IllegalArgumentException("Field type " + fieldType + "
not currently supported. Sorry.");
@@ -375,25 +375,25 @@ public class Record implements Serializable {
String str = null;
// first the custom types that need to be parsed
- if (fieldType.equals("CustomTimestamp")) {
+ if ("CustomTimestamp".equals(fieldType)) {
// a common timestamp format for flat files is with no separators:
yyyyMMddHHmmss
SimpleDateFormat sdf = new SimpleDateFormat(field.getFormat());
java.sql.Timestamp timestamp = (java.sql.Timestamp) value;
str = sdf.format(new Date(timestamp.getTime()));
- } else if (fieldType.equals("CustomDate")) {
+ } else if ("CustomDate".equals(fieldType)) {
// a common date only format for flat files is with no separators:
yyyyMMdd or MMddyyyy
SimpleDateFormat sdf = new SimpleDateFormat(field.getFormat());
java.sql.Date date = (java.sql.Date) value;
str = sdf.format(new Date(date.getTime()));
- } else if (fieldType.equals("CustomTime")) {
+ } else if ("CustomTime".equals(fieldType)) {
// a common time only format for flat files is with no separators:
HHmmss
SimpleDateFormat sdf = new SimpleDateFormat(field.getFormat());
java.sql.Time time = (java.sql.Time) value;
str = sdf.format(new Date(time.getTime()));
- } else if (fieldType.equals("FixedPointDouble")) {
+ } else if ("FixedPointDouble".equals(fieldType)) {
// this custom type will parse a fixed point number according to
the number
// of decimal places in the formatting string then place it in a
Double
double decimalPlaces = Double.parseDouble(field.getFormat());
@@ -402,21 +402,21 @@ public class Record implements Serializable {
long number = Math.round(dnum);
str = padFrontZeros(Long.toString(number), field.getLength());
- } else if (fieldType.equals("java.lang.String") ||
fieldType.equals("String")) {
+ } else if ("java.lang.String".equals(fieldType) ||
"String".equals(fieldType)) {
str = value.toString();
- } else if (fieldType.equals("java.sql.Timestamp") ||
fieldType.equals("Timestamp")) {
+ } else if ("java.sql.Timestamp".equals(fieldType) ||
"Timestamp".equals(fieldType)) {
str = value.toString();
- } else if (fieldType.equals("java.sql.Time") ||
fieldType.equals("Time")) {
+ } else if ("java.sql.Time".equals(fieldType) ||
"Time".equals(fieldType)) {
str = value.toString();
- } else if (fieldType.equals("java.sql.Date") ||
fieldType.equals("Date")) {
+ } else if ("java.sql.Date".equals(fieldType) ||
"Date".equals(fieldType)) {
str = value.toString();
- } else if (fieldType.equals("java.lang.Integer") ||
fieldType.equals("Integer")) {
+ } else if ("java.lang.Integer".equals(fieldType) ||
"Integer".equals(fieldType)) {
str = padFrontZeros(value.toString(), field.getLength());
- } else if (fieldType.equals("java.lang.Long") ||
fieldType.equals("Long")) {
+ } else if ("java.lang.Long".equals(fieldType) ||
"Long".equals(fieldType)) {
str = padFrontZeros(value.toString(), field.getLength());
- } else if (fieldType.equals("java.lang.Float") ||
fieldType.equals("Float")) {
+ } else if ("java.lang.Float".equals(fieldType) ||
"Float".equals(fieldType)) {
str = padFrontZeros(value.toString(), field.getLength());
- } else if (fieldType.equals("java.lang.Double") ||
fieldType.equals("Double")) {
+ } else if ("java.lang.Double".equals(fieldType) ||
"Double".equals(fieldType)) {
str = padFrontZeros(value.toString(), field.getLength());
} else {
throw new IllegalArgumentException("Field type " + fieldType + "
not currently supported. Sorry.");
diff --git
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java
index d095e95..0e8a2f1 100644
---
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java
+++
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java
@@ -184,7 +184,7 @@ public class EntityClause {
*/
protected void setModelEntities(ModelReader modelReader) throws
GenericEntityException {
firstModelEntity = modelReader.getModelEntity(firstEntity);
- if (secondEntity != null && !secondEntity.equals("")) {
+ if (secondEntity != null && !"".equals(secondEntity)) {
secondModelEntity = modelReader.getModelEntity(secondEntity);
}
}
diff --git
a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
index 698c445..e01ef58 100644
---
a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
+++
b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
@@ -697,10 +697,10 @@ public class EntityPermissionChecker {
//testPrivilegeEnumId = (String)
targetOp.get("privilegeEnumId");
//int testPrivilegeSeq = 0;
- boolean purposesCond = (!hasPurposeOp || (purposes != null &&
purposes.contains(testContentPurposeTypeId)) ||
testContentPurposeTypeId.equals("_NA_"));
- boolean statusCond = (!hasStatusOp || testStatusId.equals("_NA_")
|| (targStatusId != null && targStatusId.equals(testStatusId)));
+ boolean purposesCond = (!hasPurposeOp || (purposes != null &&
purposes.contains(testContentPurposeTypeId)) ||
"_NA_".equals(testContentPurposeTypeId));
+ boolean statusCond = (!hasStatusOp || "_NA_".equals(testStatusId)
|| (targStatusId != null && targStatusId.equals(testStatusId)));
//boolean privilegeCond = (!hasPrivilegeOp ||
testPrivilegeEnumId.equals("_NA_") || testPrivilegeSeq <= targPrivilegeSeq ||
testPrivilegeEnumId.equals(targPrivilegeEnumId));
- boolean roleCond = (testRoleTypeId.equals("_NA_") || (roles !=
null && roles.contains(testRoleTypeId)));
+ boolean roleCond = ("_NA_".equals(testRoleTypeId) || (roles !=
null && roles.contains(testRoleTypeId)));
if (purposesCond && statusCond && roleCond) {
@@ -764,9 +764,9 @@ public class EntityPermissionChecker {
String auxiliaryConditionId =
permissionConditionGetter.getAuxiliaryValue();
String statusConditionId =
permissionConditionGetter.getStatusValue();
- boolean auxiliaryCond = (auxiliaryConditionId == null ||
auxiliaryConditionId.equals("_NA_") || (auxiliaryValueList != null &&
auxiliaryValueList.contains(auxiliaryConditionId)) );
- boolean statusCond = (statusConditionId == null ||
statusConditionId.equals("_NA_") || (targStatusId != null &&
targStatusId.equals(statusConditionId)));
- boolean roleCond = (roleConditionId == null ||
roleConditionId.equals("_NA_") || (roleValueList != null &&
roleValueList.contains(roleConditionId)));
+ boolean auxiliaryCond = (auxiliaryConditionId == null ||
"_NA_".equals(auxiliaryConditionId) || (auxiliaryValueList != null &&
auxiliaryValueList.contains(auxiliaryConditionId)) );
+ boolean statusCond = (statusConditionId == null ||
"_NA_".equals(statusConditionId) || (targStatusId != null &&
targStatusId.equals(statusConditionId)));
+ boolean roleCond = (roleConditionId == null ||
"_NA_".equals(roleConditionId) || (roleValueList != null &&
roleValueList.contains(roleConditionId)));
if (auxiliaryCond && statusCond && roleCond) {
if (Debug.verboseOn()) {
@@ -851,7 +851,7 @@ public class EntityPermissionChecker {
if (!roles.contains(roleTypeId)) {
roles.add(roleTypeId);
}
- if (roleTypeId.equals("AUTHOR") &&
!roles.contains("OWNER")) {
+ if ("AUTHOR".equals(roleTypeId) &&
!roles.contains("OWNER")) {
roles.add("OWNER");
}
} else { // Party may be of "PARTY_GROUP" type, in which case
the userLogin may still possess this role
@@ -860,7 +860,7 @@ public class EntityPermissionChecker {
try {
party = contentRole.getRelatedOne("Party", false);
partyTypeId = (String) party.get("partyTypeId");
- if (partyTypeId != null &&
partyTypeId.equals("PARTY_GROUP")) {
+ if (partyTypeId != null &&
"PARTY_GROUP".equals(partyTypeId)) {
Map<String, Object> map = new HashMap<>();
// At some point from/thru date will need to be
added
diff --git
a/framework/security/src/main/java/org/apache/ofbiz/security/CsrfDefenseStrategy.java
b/framework/security/src/main/java/org/apache/ofbiz/security/CsrfDefenseStrategy.java
index 177d908..40b63eb 100644
---
a/framework/security/src/main/java/org/apache/ofbiz/security/CsrfDefenseStrategy.java
+++
b/framework/security/src/main/java/org/apache/ofbiz/security/CsrfDefenseStrategy.java
@@ -66,7 +66,7 @@ public class CsrfDefenseStrategy implements
ICsrfDefenseStrategy {
@Override
public boolean modifySecurityCsrfToken(String requestUri, String
requestMapMethod, String securityCsrfToken) {
// main request URI is exempted from CSRF token check
- if (requestUri.equals("main")) {
+ if ("main".equals(requestUri)) {
return false;
} else {
return !"false".equals(securityCsrfToken);
diff --git
a/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java
b/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java
index 65f67c0..6a98f80 100644
---
a/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java
+++
b/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java
@@ -219,7 +219,7 @@ public final class SecurityFactory {
if (userLogin == null) {
return false;
}
- if (primaryKey.equals("") && roles == null) {
+ if ("".equals(primaryKey) && roles == null) {
if (hasEntityPermission(application, action, userLogin))
return true;
if (hasEntityPermission(application + "_ROLE", action,
userLogin)) return true;
}
@@ -253,7 +253,7 @@ public final class SecurityFactory {
@Override
public boolean hasRolePermission(String application, String action,
String primaryKey, String role, GenericValue userLogin) {
List<String> roles = null;
- if (role != null && !role.equals("")) {
+ if (role != null && !"".equals(role)) {
roles = UtilMisc.toList(role);
}
return hasRolePermission(application, action, primaryKey, roles,
userLogin);
diff --git
a/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
b/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
index 60b98bc..4a986dc 100644
---
a/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
+++
b/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java
@@ -100,7 +100,7 @@ public class XMLRPCClientEngine extends GenericAsyncEngine {
url = url.replace(rpcPort.toString(), port.toString());
}
// Necessary for "service-xml-rpc-local-engine" test
- if (serviceName.equals("testXmlRpcAdd")) {
+ if ("testXmlRpcAdd".equals(serviceName)) {
url = url + "?USERNAME=admin&PASSWORD=ofbiz";
}
login = ServiceConfigUtil.getEngineParameter(engine, "login");
diff --git
a/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java
b/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java
index 412ba6e..46eea95 100644
--- a/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java
+++ b/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java
@@ -98,8 +98,8 @@ public final class Config {
adminPort = getAdminPort(props, 0, portOffset);
loaders = Arrays.asList(getProperty(props, "ofbiz.start.loaders",
"").split(","));
logDir = getAbsolutePath(props, "ofbiz.log.dir",
DEFAULT_LOG_DIRECTORY, ofbizHome);
- shutdownAfterLoad = getProperty(props, "ofbiz.auto.shutdown",
"false").equalsIgnoreCase("true");
- useShutdownHook = getProperty(props, "ofbiz.enable.hook",
"true").equalsIgnoreCase("true");
+ shutdownAfterLoad = "true".equalsIgnoreCase(getProperty(props,
"ofbiz.auto.shutdown", "false"));
+ useShutdownHook = "true".equalsIgnoreCase(getProperty(props,
"ofbiz.enable.hook", "true"));
System.out.println("Set OFBIZ_HOME to - " + ofbizHome);
diff --git
a/framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java
b/framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java
index 63b8b33..9477322 100644
---
a/framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java
+++
b/framework/testtools/src/main/java/org/apache/ofbiz/testtools/ModelTestSuite.java
@@ -67,9 +67,9 @@ public class ModelTestSuite {
String caseName = testCaseElement.getAttribute("case-name");
String nodeName = testCaseElement.getNodeName();
if (testCase == null || caseName.equals(testCase)) {
- if (nodeName.equals("test-case")) {
+ if ("test-case".equals(nodeName)) {
parseTestElement(caseName,
UtilXml.firstChildElement(testCaseElement));
- } else if (nodeName.equals("test-group")) {
+ } else if ("test-group".equals(nodeName)) {
int i = 0;
for (Element childElement:
UtilXml.childElementList(testCaseElement)) {
parseTestElement(caseName + '-' + i, childElement);
diff --git
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
index ee5c26b..249a021 100644
---
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
+++
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
@@ -963,7 +963,7 @@ public final class LoginWorker {
Cookie autoLoginCookie = new
Cookie(getAutoLoginCookieName(request), userLogin.getString("userLoginId"));
autoLoginCookie.setMaxAge(60 * 60 * 24 * 365);
autoLoginCookie.setDomain(EntityUtilProperties.getPropertyValue("url",
"cookie.domain", delegator));
- autoLoginCookie.setPath(applicationName.equals("root") ? "/" :
request.getContextPath());
+ autoLoginCookie.setPath("root".equals(applicationName) ? "/" :
request.getContextPath());
autoLoginCookie.setSecure(true);
autoLoginCookie.setHttpOnly(true);
response.addCookie(autoLoginCookie);
@@ -984,7 +984,7 @@ public final class LoginWorker {
Cookie securedLoginIdCookie = new
Cookie(getSecuredLoginIdCookieName(request),
userLogin.getString("userLoginId"));
securedLoginIdCookie.setMaxAge(-1);
securedLoginIdCookie.setDomain(EntityUtilProperties.getPropertyValue("url",
"cookie.domain", delegator));
- securedLoginIdCookie.setPath(applicationName.equals("root") ? "/"
: request.getContextPath());
+ securedLoginIdCookie.setPath("root".equals(applicationName) ? "/"
: request.getContextPath());
securedLoginIdCookie.setSecure(true);
securedLoginIdCookie.setHttpOnly(true);
response.addCookie(securedLoginIdCookie);
@@ -1083,7 +1083,7 @@ public final class LoginWorker {
Cookie autoLoginCookie = new
Cookie(getAutoLoginCookieName(request), userLogin.getString("userLoginId"));
autoLoginCookie.setMaxAge(0);
autoLoginCookie.setDomain(EntityUtilProperties.getPropertyValue("url",
"cookie.domain", delegator));
- autoLoginCookie.setPath(applicationName.equals("root") ? "/" :
request.getContextPath());
+ autoLoginCookie.setPath("root".equals(applicationName) ? "/" :
request.getContextPath());
response.addCookie(autoLoginCookie);
}
// remove the session attributes
diff --git
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
index ec67a560..2aceed2 100644
---
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
+++
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
@@ -163,7 +163,7 @@ public class RequestHandler {
}
if (method.isEmpty()) {
return Optional.empty();
- } else if (method.equals("all")) {
+ } else if ("all".equals(method)) {
return resolveMethod("", rmaps);
} else {
return resolveMethod("all", rmaps);
diff --git
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
index 891710b..0ae8dea 100644
---
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
+++
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
@@ -226,7 +226,7 @@ public class HtmlWidget extends ModelScreenWidget {
String type = script.attr("type");
String src = script.attr("src");
if (UtilValidate.isEmpty(src)) {
- if (UtilValidate.isEmpty(type) ||
type.equals("application/javascript")) {
+ if (UtilValidate.isEmpty(type) ||
"application/javascript".equals(type)) {
scripts.append(script.data());
script.remove();
}