Author: mbrohl
Date: Sun Oct 22 12:04:00 2017 New Revision: 1812900 URL: http://svn.apache.org/viewvc?rev=1812900&view=rev Log: Improved: Fixing defects reported by FindBugs, package org.apache.ofbiz.workeffort.workeffort. (OFBIZ-9703) Thanks Julian Leichert for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java Sun Oct 22 12:04:00 2017 @@ -36,6 +36,7 @@ import java.util.Set; import org.apache.ofbiz.base.util.DateRange; import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.GeneralException; import org.apache.ofbiz.base.util.ObjectType; import org.apache.ofbiz.base.util.TimeDuration; import org.apache.ofbiz.base.util.UtilGenerics; @@ -226,7 +227,7 @@ public class ICalConverter { } Dur dur = iCalObj.getDuration(); TimeDuration td = new TimeDuration(0, 0, (dur.getWeeks() * 7) + dur.getDays(), dur.getHours(), dur.getMinutes(), dur.getSeconds(), 0); - return new Double(TimeDuration.toLong(td)); + return Double.valueOf(TimeDuration.toLong(td)); } protected static Timestamp fromLastModified(PropertyList propertyList) { @@ -258,7 +259,7 @@ public class ICalConverter { if (iCalObj == null) { return null; } - return new Long(iCalObj.getPercentage()); + return Long.valueOf(iCalObj.getPercentage()); } protected static Double fromPriority(PropertyList propertyList) { @@ -266,7 +267,7 @@ public class ICalConverter { if (iCalObj == null) { return null; } - return new Double(iCalObj.getLevel()); + return Double.valueOf(iCalObj.getLevel()); } protected static String fromStatus(PropertyList propertyList) { @@ -476,7 +477,7 @@ public class ICalConverter { localMap.put(modelParam.name, value); } } - } catch (Exception e) { + } catch (GeneralException e) { String errMsg = UtilProperties.getMessage("WorkEffortUiLabels", "WorkeffortErrorWhileCreatingServiceMapForService", UtilMisc.toMap("serviceName", serviceName), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg + e); @@ -513,11 +514,9 @@ public class ICalConverter { } } ParameterList parameterList = property.getParameters(); - if (partyAssign != null) { - replaceParameter(parameterList, toXParameter(partyIdXParamName, partyAssign.getString("partyId"))); - replaceParameter(parameterList, new Cn(makePartyName(partyAssign))); - replaceParameter(parameterList, toParticipationStatus(partyAssign.getString("assignmentStatusId"))); - } + replaceParameter(parameterList, toXParameter(partyIdXParamName, partyAssign.getString("partyId"))); + replaceParameter(parameterList, new Cn(makePartyName(partyAssign))); + replaceParameter(parameterList, toParticipationStatus(partyAssign.getString("assignmentStatusId"))); } protected static void loadRelatedParties(List<GenericValue> relatedParties, PropertyList componentProps, Map<String, Object> context) { @@ -786,7 +785,7 @@ public class ICalConverter { if (partyId == null) { serviceMap.clear(); String address = property.getValue(); - if (address.toUpperCase().startsWith("MAILTO:")) { + if (address.toUpperCase(Locale.getDefault()).startsWith("MAILTO:")) { address = address.substring(7); } serviceMap.put("address", address); Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java Sun Oct 22 12:04:00 2017 @@ -286,6 +286,8 @@ public class ICalRecurConverter implemen case Calendar.YEAR: this.state.addRecur((new Recur(Recur.YEARLY, freqCount))); break; + default: + break; } } Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java Sun Oct 22 12:04:00 2017 @@ -33,6 +33,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.xml.parsers.ParserConfigurationException; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilGenerics; @@ -52,6 +53,7 @@ import org.apache.ofbiz.webapp.webdav.Re import org.apache.ofbiz.webapp.webdav.WebDavUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.xml.sax.SAXException; /** iCalendar worker class. This class handles the WebDAV requests and * delegates the calendar conversion tasks to <code>ICalConverter</code>. @@ -59,7 +61,7 @@ import org.w3c.dom.Element; public final class ICalWorker { public static final String module = ICalWorker.class.getName(); - + private ICalWorker() {}; public static final class ResponseProperties { @@ -213,7 +215,7 @@ public final class ICalWorker { } return; } - } catch (Exception e) { + } catch (RuntimeException | GenericEntityException | SAXException | ParserConfigurationException e) { Debug.logError(e, "PROPFIND error: ", module); } response.setStatus(HttpServletResponse.SC_OK); Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java Sun Oct 22 12:04:00 2017 @@ -22,6 +22,7 @@ package org.apache.ofbiz.workeffort.work import java.io.IOException; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -61,7 +62,7 @@ public class WorkEffortKeywordIndex { } catch (Exception e) { Debug.logWarning("Could not parse weight number: " + e.toString(), module); } - keywords.put(workEffort.getString("workEffortId").toLowerCase(), Long.valueOf(widWeight)); + keywords.put(workEffort.getString("workEffortId").toLowerCase(Locale.getDefault()), Long.valueOf(widWeight)); addWeightedKeywordSourceString(workEffort, "workEffortName", strings); addWeightedKeywordSourceString(workEffort, "workEffortTypeId", strings); Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java Sun Oct 22 12:04:00 2017 @@ -583,38 +583,48 @@ public class WorkEffortSearch { } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (includeSubWorkEfforts ? 1231 : 1237); + result = prime * result + ((workEffortAssocTypeId == null) ? 0 : workEffortAssocTypeId.hashCode()); + result = prime * result + ((workEffortId == null) ? 0 : workEffortId.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { - WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; - if (psc instanceof WorkEffortAssocConstraint) { - WorkEffortAssocConstraint that = (WorkEffortAssocConstraint) psc; - if (this.includeSubWorkEfforts != that.includeSubWorkEfforts) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof WorkEffortAssocConstraint)) { + return false; + } + WorkEffortAssocConstraint other = (WorkEffortAssocConstraint) obj; + if (includeSubWorkEfforts != other.includeSubWorkEfforts) { + return false; + } + if (workEffortAssocTypeId == null) { + if (other.workEffortAssocTypeId != null) { return false; } - if (this.workEffortId == null) { - if (that.workEffortId != null) { - return false; - } - } else { - if (!this.workEffortId.equals(that.workEffortId)) { - return false; - } - } - if (this.workEffortAssocTypeId == null) { - if (that.workEffortAssocTypeId != null) { - return false; - } - } else { - if (!this.workEffortAssocTypeId.equals(that.workEffortAssocTypeId)) { - return false; - } + } else if (!workEffortAssocTypeId.equals(other.workEffortAssocTypeId)) { + return false; + } + if (workEffortId == null) { + if (other.workEffortId != null) { + return false; } - return true; - } else { + } else if (!workEffortId.equals(other.workEffortId)) { return false; } + return true; } } - + @SuppressWarnings("serial") public static class WorkEffortReviewConstraint extends WorkEffortSearchConstraint { public static final String constraintName = "WorkEffortReview"; @@ -649,23 +659,33 @@ public class WorkEffortSearch { } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((reviewTextString == null) ? 0 : reviewTextString.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { - WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; - if (psc instanceof WorkEffortReviewConstraint) { - WorkEffortReviewConstraint that = (WorkEffortReviewConstraint) psc; - if (this.reviewTextString == null) { - if (that.reviewTextString != null) { - return false; - } - } else { - if (!this.reviewTextString.equals(that.reviewTextString)) { - return false; - } - } + if (this == obj) { return true; - } else { + } + if (obj == null) { + return false; + } + if (!(obj instanceof WorkEffortReviewConstraint)) { + return false; + } + WorkEffortReviewConstraint other = (WorkEffortReviewConstraint) obj; + if (reviewTextString == null) { + if (other.reviewTextString != null) { + return false; + } + } else if (!reviewTextString.equals(other.reviewTextString)) { return false; } + return true; } } @@ -751,32 +771,41 @@ public class WorkEffortSearch { } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((partyId == null) ? 0 : partyId.hashCode()); + result = prime * result + ((roleTypeId == null) ? 0 : roleTypeId.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { - WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; - if (psc instanceof PartyAssignmentConstraint) { - PartyAssignmentConstraint that = (PartyAssignmentConstraint) psc; - if (this.partyId == null) { - if (that.partyId != null) { - return false; - } - } else { - if (!this.partyId.equals(that.partyId)) { - return false; - } + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof PartyAssignmentConstraint)) { + return false; + } + PartyAssignmentConstraint other = (PartyAssignmentConstraint) obj; + if (partyId == null) { + if (other.partyId != null) { + return false; } - if (this.roleTypeId == null) { - if (that.roleTypeId != null) { - return false; - } - } else { - if (!this.roleTypeId.equals(that.roleTypeId)) { - return false; - } + } else if (!partyId.equals(other.partyId)) { + return false; + } + if (roleTypeId == null) { + if (other.roleTypeId != null) { + return false; } - return true; - } else { + } else if (!roleTypeId.equals(other.roleTypeId)) { return false; } + return true; } } @@ -848,23 +877,33 @@ public class WorkEffortSearch { } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((productIdSet == null) ? 0 : productIdSet.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { - WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; - if (psc instanceof ProductSetConstraint) { - ProductSetConstraint that = (ProductSetConstraint) psc; - if (this.productIdSet == null) { - if (that.productIdSet != null) { - return false; - } - } else { - if (!this.productIdSet.equals(that.productIdSet)) { - return false; - } - } + if (this == obj) { return true; - } else { + } + if (obj == null) { + return false; + } + if (!(obj instanceof ProductSetConstraint)) { return false; } + ProductSetConstraint other = (ProductSetConstraint) obj; + if (productIdSet == null) { + if (other.productIdSet != null) { + return false; + } + } else if (!productIdSet.equals(other.productIdSet)) { + return false; + } + return true; } } @@ -957,35 +996,49 @@ public class WorkEffortSearch { } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (anyPrefix ? 1231 : 1237); + result = prime * result + (anySuffix ? 1231 : 1237); + result = prime * result + (isAnd ? 1231 : 1237); + result = prime * result + ((keywordsString == null) ? 0 : keywordsString.hashCode()); + result = prime * result + (removeStems ? 1231 : 1237); + return result; + } + + @Override public boolean equals(Object obj) { - WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; - if (psc instanceof KeywordConstraint) { - KeywordConstraint that = (KeywordConstraint) psc; - if (this.anyPrefix != that.anyPrefix) { - return false; - } - if (this.anySuffix != that.anySuffix) { - return false; - } - if (this.isAnd != that.isAnd) { - return false; - } - if (this.removeStems != that.removeStems) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof KeywordConstraint)) { + return false; + } + KeywordConstraint other = (KeywordConstraint) obj; + if (anyPrefix != other.anyPrefix) { + return false; + } + if (anySuffix != other.anySuffix) { + return false; + } + if (isAnd != other.isAnd) { + return false; + } + if (keywordsString == null) { + if (other.keywordsString != null) { return false; } - if (this.keywordsString == null) { - if (that.keywordsString != null) { - return false; - } - } else { - if (!this.keywordsString.equals(that.keywordsString)) { - return false; - } - } - return true; - } else { + } else if (!keywordsString.equals(other.keywordsString)) { return false; } + if (removeStems != other.removeStems) { + return false; + } + return true; } } @@ -1045,32 +1098,41 @@ public class WorkEffortSearch { @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fromDate == null) ? 0 : fromDate.hashCode()); + result = prime * result + ((thruDate == null) ? 0 : thruDate.hashCode()); + return result; + } + + @Override public boolean equals(Object obj) { - WorkEffortSearchConstraint psc = (WorkEffortSearchConstraint) obj; - if (psc instanceof LastUpdatedRangeConstraint) { - LastUpdatedRangeConstraint that = (LastUpdatedRangeConstraint) psc; - if (this.fromDate == null) { - if (that.fromDate != null) { - return false; - } - } else { - if (!this.fromDate.equals(that.fromDate)) { - return false; - } + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof LastUpdatedRangeConstraint)) { + return false; + } + LastUpdatedRangeConstraint other = (LastUpdatedRangeConstraint) obj; + if (fromDate == null) { + if (other.fromDate != null) { + return false; } - if (this.thruDate == null) { - if (that.thruDate != null) { - return false; - } - } else { - if (!this.thruDate.equals(that.thruDate)) { - return false; - } + } else if (!fromDate.equals(other.fromDate)) { + return false; + } + if (thruDate == null) { + if (other.thruDate != null) { + return false; } - return true; - } else { + } else if (!thruDate.equals(other.thruDate)) { return false; } + return true; } } Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java Sun Oct 22 12:04:00 2017 @@ -40,7 +40,7 @@ import org.apache.ofbiz.workeffort.worke public class WorkEffortSearchSession { public static final String module = WorkEffortSearchSession.class.getName(); - + @SuppressWarnings("serial") public static class WorkEffortSearchOptions implements java.io.Serializable { protected List<WorkEffortSearchConstraint> constraintList = null; @@ -305,7 +305,6 @@ public class WorkEffortSearchSession { public static String searchGetSortOrderString(boolean detailed, HttpServletRequest request) { Locale locale = UtilHttp.getLocale(request); ResultSortOrder resultSortOrder = WorkEffortSearchOptions.getResultSortOrder(request); - if (resultSortOrder == null) return ""; return resultSortOrder.prettyPrintSortOrder(detailed, locale); } public static void checkSaveSearchOptionsHistory(HttpSession session) { Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=1812900&r1=1812899&r2=1812900&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java Sun Oct 22 12:04:00 2017 @@ -374,7 +374,7 @@ public class WorkEffortServices { if (calEntryRange.intersectsRange(dateRange) && !(calEntryRange.end().equals(dateRange.start()) || calEntryRange.start().equals(dateRange.end()))) { List<Map<String, Object>> calendarEntryByDateRangeList = calendarEntriesByDateRange.get(dateRange); if (calendarEntryByDateRangeList == null) { - calendarEntryByDateRangeList = new LinkedList(); + calendarEntryByDateRangeList = new LinkedList<>(); } calendarEntryByDateRangeList.add(calendarEntry); calendarEntriesByDateRange.put(dateRange, calendarEntryByDateRangeList); @@ -1072,7 +1072,7 @@ public class WorkEffortServices { resultList = WorkEffortWorker.removeDuplicateWorkEfforts(workEfforts); } } - } catch (Exception e) { + } catch (GenericEntityException e) { Debug.logError(e, module); } Map<String, Object> result = ServiceUtil.returnSuccess(); |
Free forum by Nabble | Edit this page |