You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/12/08 22:19:44 UTC
svn commit: r1817584 - in
/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party:
PartyHelper.java PartyServices.java PartyWorker.java
Author: mbrohl
Date: Fri Dec 8 22:19:44 2017
New Revision: 1817584
URL: http://svn.apache.org/viewvc?rev=1817584&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.party.contact.
(OFBIZ-9735)
Thanks Julian Leichert for reporting and providing the patch.
Modified:
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyWorker.java
Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java?rev=1817584&r1=1817583&r2=1817584&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyHelper.java Fri Dec 8 22:19:44 2017
@@ -85,7 +85,7 @@ public class PartyHelper {
ModelEntity modelEntity = partyValue.getModelEntity();
if (modelEntity.isField("firstName") && modelEntity.isField("middleName") && modelEntity.isField("lastName")) {
if (lastNameFirst) {
- if (UtilFormatOut.checkNull(partyValue.getString("lastName")) != null) {
+ if (!UtilFormatOut.checkNull(partyValue.getString("lastName")).isEmpty()) {
result.append(UtilFormatOut.checkNull(partyValue.getString("lastName")));
if (partyValue.getString("firstName") != null) {
result.append(", ");
Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java?rev=1817584&r1=1817583&r2=1817584&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java Fri Dec 8 22:19:44 2017
@@ -715,7 +715,7 @@ public class PartyServices {
try {
List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase())))
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase(Locale.getDefault()))))
.orderBy("infoString")
.filterByDate()
.queryList();
@@ -753,7 +753,7 @@ public class PartyServices {
try {
List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase()) + "%")))
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase(Locale.getDefault())) + "%")))
.orderBy("infoString")
.filterByDate()
.queryList();
@@ -797,7 +797,7 @@ public class PartyServices {
try {
Collection<GenericValue> ulc = EntityQuery.use(delegator).from("PartyAndUserLogin")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase() + "%")))
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase(Locale.getDefault()) + "%")))
.orderBy("userLoginId")
.queryList();
@@ -848,8 +848,10 @@ public class PartyServices {
try {
EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(EntityOperator.AND,
- EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + firstName.toUpperCase() + "%")),
- EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + lastName.toUpperCase() + "%")));
+ EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + firstName.toUpperCase(Locale.getDefault()) + "%")),
+ EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + lastName.toUpperCase(Locale.getDefault()) + "%")));
Collection<GenericValue> pc = EntityQuery.use(delegator).from("Person").where(ecl).orderBy("lastName", "firstName", "partyId").queryList();
if (Debug.infoOn()) Debug.logInfo("PartyFromPerson number found: " + pc.size(), module);
@@ -891,7 +893,7 @@ public class PartyServices {
try {
Collection<GenericValue> pc = EntityQuery.use(delegator).from("PartyGroup")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase() + "%")))
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase(Locale.getDefault()) + "%")))
.orderBy("groupName", "partyId")
.queryList();
@@ -923,7 +925,7 @@ public class PartyServices {
public static Map<String, Object> getPartiesFromExternalId(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> result = ServiceUtil.returnSuccess();
Delegator delegator = dctx.getDelegator();
- List<GenericValue> parties = new ArrayList<>();
+ List<GenericValue> parties;
String externalId = (String) context.get("externalId");
Locale locale = (Locale) context.get("locale");
@@ -2137,8 +2139,8 @@ public class PartyServices {
"PartyImportInvalidCsvFile", locale));
} else {
GenericValue addrMap = delegator.makeValue("AddressMatchMap");
- addrMap.put("mapKey", map[0].trim().toUpperCase());
- addrMap.put("mapValue", map[1].trim().toUpperCase());
+ addrMap.put("mapKey", map[0].trim().toUpperCase(Locale.getDefault()));
+ addrMap.put("mapValue", map[1].trim().toUpperCase(Locale.getDefault()));
int seq = i + 1;
if (map.length == 3) {
char[] chars = map[2].toCharArray();
@@ -2263,9 +2265,6 @@ public class PartyServices {
Boolean addParty = false; // when modify party, contact mech not added again
- if (fileBytes == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "PartyUploadedFileDataNotFound", locale));
- }
try {
for (final CSVRecord rec : fmt.parse(csvReader)) {
Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyWorker.java?rev=1817584&r1=1817583&r2=1817584&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyWorker.java Fri Dec 8 22:19:44 2017
@@ -50,7 +50,7 @@ import org.apache.ofbiz.entity.util.Enti
*/
public class PartyWorker {
- public static String module = PartyWorker.class.getName();
+ public static final String module = PartyWorker.class.getName();
private PartyWorker() {}
@@ -265,10 +265,10 @@ public class PartyWorker {
String fName = p.getString("firstName");
String lName = p.getString("lastName");
String mName = p.getString("middleName");
- if (lName.toUpperCase().equals(lastName.toUpperCase())) {
- if (fName.toUpperCase().equals(firstName.toUpperCase())) {
+ if (lName.toUpperCase(Locale.getDefault()).equals(lastName.toUpperCase(Locale.getDefault()))) {
+ if (fName.toUpperCase(Locale.getDefault()).equals(firstName.toUpperCase(Locale.getDefault()))) {
if (mName != null && middleName != null) {
- if (mName.toUpperCase().equals(middleName.toUpperCase())) {
+ if (mName.toUpperCase(Locale.getDefault()).equals(middleName.toUpperCase(Locale.getDefault()))) {
returnList.add(partyAndAddr);
}
} else if (middleName == null) {
@@ -325,12 +325,12 @@ public class PartyWorker {
} else if ("NA".equals(stateProvinceGeoId)) {
addrExprs.add(EntityCondition.makeCondition("stateProvinceGeoId", EntityOperator.EQUALS, "_NA_"));
} else {
- addrExprs.add(EntityCondition.makeCondition("stateProvinceGeoId", EntityOperator.EQUALS, stateProvinceGeoId.toUpperCase()));
+ addrExprs.add(EntityCondition.makeCondition("stateProvinceGeoId", EntityOperator.EQUALS, stateProvinceGeoId.toUpperCase(Locale.getDefault())));
}
}
if (!postalCode.startsWith("*")) {
- if (postalCode.length() == 10 && postalCode.indexOf("-") != -1) {
+ if (postalCode.length() == 10 && postalCode.indexOf('-') != -1) {
String[] zipSplit = postalCode.split("-", 2);
postalCode = zipSplit[0];
postalCodeExt = zipSplit[1];
@@ -345,7 +345,7 @@ public class PartyWorker {
addrExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("city"), EntityOperator.EQUALS, EntityFunction.UPPER(city)));
if (countryGeoId != null) {
- addrExprs.add(EntityCondition.makeCondition("countryGeoId", EntityOperator.EQUALS, countryGeoId.toUpperCase()));
+ addrExprs.add(EntityCondition.makeCondition("countryGeoId", EntityOperator.EQUALS, countryGeoId.toUpperCase(Locale.getDefault())));
}
// limit to only non-disabled status
@@ -418,7 +418,7 @@ public class PartyWorker {
}
// upper case the address
- String str = address.trim().toUpperCase();
+ String str = address.trim().toUpperCase(Locale.getDefault());
// replace mapped words
List<GenericValue> addressMap = null;
@@ -430,7 +430,7 @@ public class PartyWorker {
if (addressMap != null) {
for (GenericValue v: addressMap) {
- str = str.replaceAll(v.getString("mapKey").toUpperCase(), v.getString("mapValue").toUpperCase());
+ str = str.replaceAll(v.getString("mapKey").toUpperCase(Locale.getDefault()), v.getString("mapValue").toUpperCase(Locale.getDefault()));
}
}