Author: mbrohl
Date: Fri Dec 8 22:26:26 2017
New Revision: 1817585
URL: http://svn.apache.org/viewvc?rev=1817585&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.party.party.
(OFBIZ-9736)
Thanks Julian Leichert for reporting and providing the patch.
Modified:
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java?rev=1817585&r1=1817584&r2=1817585&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java
Fri Dec 8 22:26:26 2017
@@ -33,6 +33,7 @@ import org.apache.ofbiz.base.crypto.Hash
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.UtilDateTime;
import org.apache.ofbiz.base.util.UtilGenerics;
+import org.apache.ofbiz.base.util.UtilIO;
import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.base.util.UtilProperties;
import org.apache.ofbiz.base.util.UtilValidate;
@@ -504,7 +505,7 @@ public class ContactMechServices {
toBeStored.add(newPartyContactMech);
if (isModified) {
- if (relatedEntityToSet != null) toBeStored.add(relatedEntityToSet);
+ toBeStored.add(relatedEntityToSet);
newContactMech.set("contactMechId", newCmId);
if (newPartyContactMech != null) {
@@ -706,7 +707,7 @@ public class ContactMechServices {
toBeStored.add(newPartyContactMech);
if (isModified) {
- if (relatedEntityToSet != null) toBeStored.add(relatedEntityToSet);
+ toBeStored.add(relatedEntityToSet);
newContactMech.set("contactMechId", newCmId);
newPartyContactMech.set("contactMechId", newCmId);
@@ -1060,7 +1061,7 @@ public class ContactMechServices {
synchronized(ContactMechServices.class) {
while (true) {
Long random = secureRandom.nextLong();
- verifyHash = HashCrypt.digestHash("MD5",
Long.toString(random).getBytes());
+ verifyHash = HashCrypt.digestHash("MD5",
Long.toString(random).getBytes(UtilIO.getUtf8()));
List<GenericValue> emailAddVerifications = null;
try {
emailAddVerifications =
EntityQuery.use(delegator).from("EmailAddressVerification").where("verifyHash",
verifyHash).queryList();
Modified:
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java?rev=1817585&r1=1817584&r2=1817585&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java
Fri Dec 8 22:26:26 2017
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import javax.servlet.ServletRequest;
@@ -822,10 +823,10 @@ public class ContactMechWorker {
// get the matching string from general.properties
String matcher = EntityUtilProperties.getPropertyValue("general",
"usps.address.match", postalAddress.getDelegator());
if (UtilValidate.isNotEmpty(matcher)) {
- if (addr1 != null && addr1.toLowerCase().matches(matcher)) {
+ if (addr1 != null &&
addr1.toLowerCase(Locale.getDefault()).matches(matcher)) {
return true;
}
- if (addr2 != null && addr2.toLowerCase().matches(matcher)) {
+ if (addr2 != null &&
addr2.toLowerCase(Locale.getDefault()).matches(matcher)) {
return true;
}
}
@@ -851,17 +852,17 @@ public class ContactMechWorker {
String addr1 = postalAddress.getString("address1");
String addr2 = postalAddress.getString("address2");
if (state != null) {
- state = state.replaceAll("\\W", "").toLowerCase();
+ state = state.replaceAll("\\W",
"").toLowerCase(Locale.getDefault());
} else {
state = "";
}
if (addr1 != null) {
- addr1 = addr1.replaceAll("\\W", "").toLowerCase();
+ addr1 = addr1.replaceAll("\\W",
"").toLowerCase(Locale.getDefault());
} else {
addr1 = "";
}
if (addr2 != null) {
- addr2 = addr2.replaceAll("\\W", "").toLowerCase();
+ addr2 = addr2.replaceAll("\\W",
"").toLowerCase(Locale.getDefault());
} else {
addr2 = "";
}
@@ -886,29 +887,27 @@ public class ContactMechWorker {
Debug.logError(e, "Unable to get party postal addresses", module);
}
- if (postalAddresses != null) {
- for (GenericValue addr: postalAddresses) {
- String thisAddr1 = addr.getString("address1");
- String thisAddr2 = addr.getString("address2");
- String thisState = addr.getString("stateProvinceGeoId");
- if (thisState != null) {
- thisState = thisState.replaceAll("\\W", "").toLowerCase();
- } else {
- thisState = "";
- }
- if (thisAddr1 != null) {
- thisAddr1 = thisAddr1.replaceAll("\\W", "").toLowerCase();
- } else {
- thisAddr1 = "";
- }
- if (thisAddr2 != null) {
- thisAddr2 = thisAddr2.replaceAll("\\W", "").toLowerCase();
- } else {
- thisAddr2 = "";
- }
- if (thisAddr1.equals(addr1) && thisAddr2.equals(addr2) &&
thisState.equals(state)) {
- return true;
- }
+ for (GenericValue addr: postalAddresses) {
+ String thisAddr1 = addr.getString("address1");
+ String thisAddr2 = addr.getString("address2");
+ String thisState = addr.getString("stateProvinceGeoId");
+ if (thisState != null) {
+ thisState = thisState.replaceAll("\\W",
"").toLowerCase(Locale.getDefault());
+ } else {
+ thisState = "";
+ }
+ if (thisAddr1 != null) {
+ thisAddr1 = thisAddr1.replaceAll("\\W",
"").toLowerCase(Locale.getDefault());
+ } else {
+ thisAddr1 = "";
+ }
+ if (thisAddr2 != null) {
+ thisAddr2 = thisAddr2.replaceAll("\\W",
"").toLowerCase(Locale.getDefault());
+ } else {
+ thisAddr2 = "";
+ }
+ if (thisAddr1.equals(addr1) && thisAddr2.equals(addr2) &&
thisState.equals(state)) {
+ return true;
}
}