This is an automated email from the ASF dual-hosted git repository. jleroux 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 4de3a37 Improved: Fix some bugs Spotbugs reports (OFBIZ-12386) 4de3a37 is described below commit 4de3a37c5463da0d2c9a6367bbbbf929b58a9af6 Author: Jacques Le Roux <jacques.le.r...@les7arts.com> AuthorDate: Sat Dec 11 16:21:36 2021 +0100 Improved: Fix some bugs Spotbugs reports (OFBIZ-12386) In ProposedOrder::calculateStartDate and TimeDuration::TimeDuration better use a long directly (efficiency) In ConfigXMLReader, removes unused getViewMap method In ServiceArtifactInfo, some formatting and in writeServiceCallGraphEoModel method add missing <<if (calledServiceSet != null) {>> Adds and documents false positives in exclude.xml. Remains 14 issues, I'll document them in the Jira and 'll later discuss them on dev ML (committers attention needed). None of them are security issues :) C:/projectsASF/Git/ofbiz-framework/plugins/rest-api/src/main/java/org/apache/ofbiz/ws/rs/listener/ApiContextListener.java:38 Ecriture d'un champ statique org.apache.ofbiz.ws.rs.listener.ApiContextListener.servletContext depuis la méthode d'une instance org.apache.ofbiz.ws.rs.listener.ApiContextListener.contextInitialized(ServletContextEvent) [Of Concern(15), High confidence] C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java:49 org.apache.ofbiz.base.util.collections.GenericMapValues.equals(Object) checks for operand being a java.util.List [Troubling(14), High confidence] C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java:91 Déréférencement immédiat du résultat d'un readLine() dans org.apache.ofbiz.ldap.cas.OFBizCasAuthenticationHandler.login(HttpServletRequest, HttpServletResponse, Element) [Of Concern(15), Normal confidence] C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java:49 org.apache.ofbiz.base.util.collections.GenericMapValues.equals(Object) checks for operand being a java.util.Set [Troubling(14), High confidence] C:/projectsASF/Git/ofbiz-framework/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:875 Un appel de méthode dans new org.apache.ofbiz.widget.renderer.macro.MacroFormRendererTest$36(MacroFormRendererTest, ModelForm) passe null à un paramètre déréférencé de façon inconditionnelle dans org.apache.ofbiz.webapp.control.RequestHandler.makeLink(HttpServletRequest, HttpServletResponse, String) [Scary(8), Normal confidence] C:/projectsASF/Git/ofbiz-framework/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:848 Un appel de méthode dans new org.apache.ofbiz.widget.renderer.macro.MacroFormRendererTest$35(MacroFormRendererTest, ModelForm) passe null à un paramètre déréférencé de façon inconditionnelle dans org.apache.ofbiz.webapp.control.RequestHandler.makeLink(HttpServletRequest, HttpServletResponse, String) [Scary(8), Normal confidence] C:/projectsASF/Git/ofbiz-framework/plugins/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java:71 Ecriture d'un champ statique org.apache.ofbiz.ecommerce.janrain.JanrainHelper.apiKey depuis la méthode d'une instance new org.apache.ofbiz.ecommerce.janrain.JanrainHelper(String, String) [Of Concern(15), High confidence] C:/projectsASF/Git/ofbiz-framework/plugins/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java:160 Champ jamais écrit : org.apache.ofbiz.htmlreport.AbstractReportThread.report [Troubling(12), Normal confidence] C:/projectsASF/Git/ofbiz-framework/plugins/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java:72 Ecriture d'un champ statique org.apache.ofbiz.ecommerce.janrain.JanrainHelper.baseUrl depuis la méthode d'une instance new org.apache.ofbiz.ecommerce.janrain.JanrainHelper(String, String) [Of Concern(15), High confidence] C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheSoftReference.java:29 org.apache.ofbiz.base.util.cache.CacheSoftReference est Serializable mais sa super-classe ne possède pas de constructeur par défaut visible [Troubling(14), High confidence] C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/activedirectory/OFBizActiveDirectoryAuthenticationHandler.java:110 Alimentation à perte d'une variable locale dans la méthode org.apache.ofbiz.ldap.activedirectory.OFBizActiveDirectoryAuthenticationHandler.getLdapSearchResult(String, String, Element, boolean) [Of Concern(15), High confidence] C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/openldap/OFBizLdapAuthenticationHandler.java:95 Alimentation à perte d'une variable locale dans la méthode org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler.getLdapSearchResult(String, String, Element, boolean) [Of Concern(15), High confidence] C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java:193 org.apache.ofbiz.base.util.collections.FlexibleServletAccessor.equals(Object) checks for operand being a String [Troubling(14), High confidence] C:/projectsASF/Git/ofbiz-framework/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java:47 Ecriture d'un champ statique org.apache.ofbiz.service.test.XmlRpcTests.url depuis la méthode d'une instance new org.apache.ofbiz.service.test.XmlRpcTests(String) [Of Concern(15), High confidence] --- .../ofbiz/manufacturing/mrp/ProposedOrder.java | 2 +- .../org/apache/ofbiz/base/util/TimeDuration.java | 10 +- .../ofbiz/webapp/control/ConfigXMLReader.java | 8 - .../webtools/artifactinfo/ServiceArtifactInfo.java | 246 +++++++++++---------- spotbugs/exclude.xml | 98 +++++++- 5 files changed, 231 insertions(+), 133 deletions(-) diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java index 4e655fc..bf1ceab 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java @@ -111,7 +111,7 @@ public class ProposedOrder { Map<String, Object> result = null; Timestamp endDate = (Timestamp) requiredByDate.clone(); Timestamp startDate = endDate; - long timeToShip = daysToShip * 8 * 60 * 60 * 1000; + long timeToShip = daysToShip * 8 * 60 * 60 * 1000L; if (isBuilt) { List<GenericValue> listRoutingTaskAssoc = null; if (routing == null) { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java index 7eef8ba..e82514a 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java @@ -103,13 +103,13 @@ public class TimeDuration implements Serializable, Comparable<TimeDuration> { } // compute elapsed years - long yearMillis = 86400000 * calStart.getLeastMaximum(Calendar.DAY_OF_YEAR); + long yearMillis = 86400000L * calStart.getLeastMaximum(Calendar.DAY_OF_YEAR); float units = deltaMillis / yearMillis; this.years = factor * advanceCalendar(calStart, calEnd, (int) units, Calendar.YEAR); deltaMillis = computeDeltaMillis(calStart.getTimeInMillis(), targetMillis); // compute elapsed months - long monthMillis = 86400000 * (calStart.getMaximum(Calendar.DAY_OF_MONTH) / 2); + long monthMillis = 86400000L * (calStart.getMaximum(Calendar.DAY_OF_MONTH) / 2); units = deltaMillis / monthMillis; this.months = factor * advanceCalendar(calStart, calEnd, (int) units, Calendar.MONTH); deltaMillis = computeDeltaMillis(calStart.getTimeInMillis(), targetMillis); @@ -329,9 +329,9 @@ public class TimeDuration implements Serializable, Comparable<TimeDuration> { units = duration / 0x9CA41900L; int months = (int) units; duration -= 0x9CA41900L * months; - units = duration / 86400000; + units = duration / 86400000L; int days = (int) units; - duration -= 86400000 * (long) days; + duration -= 86400000L * (long) days; units = duration / 3600000; int hours = (int) units; duration -= 3600000 * (long) hours; @@ -390,7 +390,7 @@ public class TimeDuration implements Serializable, Comparable<TimeDuration> { public static long toLong(TimeDuration duration) { return (0x757B12C00L * duration.years) + (0x9CA41900L * duration.months) - + (86400000 * (long) duration.days) + + (86400000L * (long) duration.days) + (3600000 * (long) duration.hours) + (60000 * (long) duration.minutes) + (1000 * (long) duration.seconds) diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java index 926b080..4d76e22 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java @@ -955,14 +955,6 @@ public final class ConfigXMLReader { private boolean noCache = false; /** - * Gets view map. - * @return the view map - */ - public String getViewMap() { - return viewMap; - } - - /** * Gets name. * * @return the name diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java index effde04..2516c35 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java @@ -121,7 +121,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { Set<String> allEntityNameSet = UtilJavaParse.findEntityUseInBlock(methodBlockStart, methodBlockEnd, javaFile); populateEntitiesFromNameSet(allEntityNameSet); } - //} else if ("group".equals(this.modelService.getEngineName())) { + // } else if ("group".equals(this.modelService.getEngineName())) { // nothing to do, there won't be entities referred to in these } } @@ -132,7 +132,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { * @throws GeneralException the general exception */ protected void populateEntitiesFromNameSet(Set<String> allEntityNameSet) throws GeneralException { - for (String entityName: allEntityNameSet) { + for (String entityName : allEntityNameSet) { if (UtilValidate.isEmpty(entityName) || entityName.contains("${")) { continue; } @@ -202,7 +202,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { if (groupModel != null) { List<GroupServiceModel> groupServiceModels = groupModel.getServices(); - for (GroupServiceModel groupServiceModel: groupServiceModels) { + for (GroupServiceModel groupServiceModel : groupServiceModels) { allServiceNameSet.add(groupServiceModel.getName()); } } @@ -217,7 +217,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { * @throws GeneralException the general exception */ protected void populateServicesFromNameSet(Set<String> allServiceNameSet) throws GeneralException { - for (String serviceName: allServiceNameSet) { + for (String serviceName : allServiceNameSet) { if (serviceName.contains("${")) { continue; } @@ -240,9 +240,11 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { protected void populateTriggeredServiceEcas() throws GeneralException { // populate serviceEcasTriggeredByThisService and for each the reverse-associate cache in the aif Map<String, List<ServiceEcaRule>> serviceEventMap = ServiceEcaUtil.getServiceEventMap(this.modelService.getName()); - if (serviceEventMap == null) return; - for (List<ServiceEcaRule> ecaRuleList: serviceEventMap.values()) { - for (ServiceEcaRule ecaRule: ecaRuleList) { + if (serviceEventMap == null) { + return; + } + for (List<ServiceEcaRule> ecaRuleList : serviceEventMap.values()) { + for (ServiceEcaRule ecaRule : ecaRuleList) { this.serviceEcasTriggeredByThisService.add(getAif().getServiceEcaArtifactInfo(ecaRule)); // the reverse reference UtilMisc.addToSortedSetInMap(this, getAif().getAllServiceInfosReferringToServiceEcaRule(), ecaRule); @@ -401,8 +403,8 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { /** * Write service call graph eo model. * @param eomodeldFullPath the eomodeld full path - * @throws GeneralException the general exception - * @throws FileNotFoundException the file not found exception + * @throws GeneralException the general exception + * @throws FileNotFoundException the file not found exception * @throws UnsupportedEncodingException the unsupported encoding exception */ public void writeServiceCallGraphEoModel(String eomodeldFullPath) throws GeneralException, FileNotFoundException, UnsupportedEncodingException { @@ -424,7 +426,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { Set<ServiceArtifactInfo> callingServiceSet = this.getServicesCallingService(); if (callingServiceSet != null) { // set the prefix and add to the all list - for (ServiceArtifactInfo callingService: callingServiceSet) { + for (ServiceArtifactInfo callingService : callingServiceSet) { callingService.setDisplayPrefix("Calling_"); allDiagramEntitiesWithPrefixes.add(callingService.getDisplayPrefixedName()); allServiceList.add(callingService); @@ -433,129 +435,139 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { // all services this service calls Set<ServiceArtifactInfo> calledServiceSet = this.getServicesCalledByService(); - for (ServiceArtifactInfo calledService: calledServiceSet) { - calledService.setDisplayPrefix("Called_"); - allDiagramEntitiesWithPrefixes.add(calledService.getDisplayPrefixedName()); - allServiceList.add(calledService); - } + if (calledServiceSet != null) { - Map<String, Integer> displaySuffixNumByEcaName = new HashMap<>(); - - // all SECAs and triggering services that call this service as an action - Set<ServiceEcaArtifactInfo> callingServiceEcaSet = this.getServiceEcaRulesCallingService(); - if (callingServiceEcaSet != null) { - for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) { - callingServiceEca.setDisplayPrefix("Triggering_"); + for (ServiceArtifactInfo calledService : calledServiceSet) { + calledService.setDisplayPrefix("Called_"); + allDiagramEntitiesWithPrefixes.add(calledService.getDisplayPrefixedName()); + allServiceList.add(calledService); + } - Integer displaySuffix = displaySuffixNumByEcaName.get(callingServiceEca.getDisplayPrefixedName()); - if (displaySuffix == null) { - displaySuffix = 1; - } else { - displaySuffix++; + Map<String, Integer> displaySuffixNumByEcaName = new HashMap<>(); + + // all SECAs and triggering services that call this service as an action + Set<ServiceEcaArtifactInfo> callingServiceEcaSet = this.getServiceEcaRulesCallingService(); + if (callingServiceEcaSet != null) { + for (ServiceEcaArtifactInfo callingServiceEca : callingServiceEcaSet) { + callingServiceEca.setDisplayPrefix("Triggering_"); + + Integer displaySuffix = displaySuffixNumByEcaName.get(callingServiceEca.getDisplayPrefixedName()); + if (displaySuffix == null) { + displaySuffix = 1; + } else { + displaySuffix++; + } + displaySuffixNumByEcaName.put(callingServiceEca.getDisplayPrefixedName(), displaySuffix); + callingServiceEca.setDisplaySuffixNum(displaySuffix); + + allDiagramEntitiesWithPrefixes.add(callingServiceEca.getDisplayPrefixedName()); + allServiceEcaList.add(callingServiceEca); } - displaySuffixNumByEcaName.put(callingServiceEca.getDisplayPrefixedName(), displaySuffix); - callingServiceEca.setDisplaySuffixNum(displaySuffix); - - allDiagramEntitiesWithPrefixes.add(callingServiceEca.getDisplayPrefixedName()); - allServiceEcaList.add(callingServiceEca); } - } - // all SECAs and corresponding services triggered by this service - Set<ServiceEcaArtifactInfo> calledServiceEcaSet = this.getServiceEcaRulesTriggeredByService(); - if (calledServiceEcaSet != null) { - for (ServiceEcaArtifactInfo calledServiceEca : calledServiceEcaSet) { - calledServiceEca.setDisplayPrefix("Triggered_"); - - Integer displaySuffix = displaySuffixNumByEcaName.get(calledServiceEca.getDisplayPrefixedName()); - if (displaySuffix == null) { - displaySuffix = 1; - } else { - displaySuffix++; + // all SECAs and corresponding services triggered by this service + Set<ServiceEcaArtifactInfo> calledServiceEcaSet = this.getServiceEcaRulesTriggeredByService(); + if (calledServiceEcaSet != null) { + for (ServiceEcaArtifactInfo calledServiceEca : calledServiceEcaSet) { + calledServiceEca.setDisplayPrefix("Triggered_"); + + Integer displaySuffix = displaySuffixNumByEcaName.get(calledServiceEca.getDisplayPrefixedName()); + if (displaySuffix == null) { + displaySuffix = 1; + } else { + displaySuffix++; + } + displaySuffixNumByEcaName.put(calledServiceEca.getDisplayPrefixedName(), displaySuffix); + calledServiceEca.setDisplaySuffixNum(displaySuffix); + + allDiagramEntitiesWithPrefixes.add(calledServiceEca.getDisplayPrefixedName()); + allServiceEcaList.add(calledServiceEca); } - displaySuffixNumByEcaName.put(calledServiceEca.getDisplayPrefixedName(), displaySuffix); - calledServiceEca.setDisplaySuffixNum(displaySuffix); - - allDiagramEntitiesWithPrefixes.add(calledServiceEca.getDisplayPrefixedName()); - allServiceEcaList.add(calledServiceEca); - } - // write index.eomodeld file - Map<String, Object> indexEoModelMap = new HashMap<>(); - indexEoModelMap.put("EOModelVersion", "\"2.1\""); - List<Map<String, Object>> entitiesMapList = new LinkedList<>(); - indexEoModelMap.put("entities", entitiesMapList); - for (String entityName : allDiagramEntitiesWithPrefixes) { - Map<String, Object> entitiesMap = new HashMap<>(); - entitiesMapList.add(entitiesMap); - entitiesMap.put("className", "EOGenericRecord"); - entitiesMap.put("name", entityName); - } - UtilPlist.writePlistFile(indexEoModelMap, eomodeldFullPath, "index.eomodeld", true); - - // write this service description file - Map<String, Object> thisServiceEoModelMap = createEoModelMap(callingServiceSet, calledServiceSet, callingServiceEcaSet, - calledServiceEcaSet, - useMoreDetailedNames); - UtilPlist.writePlistFile(thisServiceEoModelMap, eomodeldFullPath, this.modelService.getName() + ".plist", true); - - // write service description files - if (callingServiceSet != null) { - for (ServiceArtifactInfo callingService : callingServiceSet) { - Map<String, Object> serviceEoModelMap = callingService.createEoModelMap(null, UtilMisc.toSet(this), null, null, - useMoreDetailedNames); - UtilPlist.writePlistFile(serviceEoModelMap, eomodeldFullPath, callingService.getDisplayPrefixedName() + ".plist", true); + // write index.eomodeld file + Map<String, Object> indexEoModelMap = new HashMap<>(); + indexEoModelMap.put("EOModelVersion", "\"2.1\""); + List<Map<String, Object>> entitiesMapList = new LinkedList<>(); + indexEoModelMap.put("entities", entitiesMapList); + for (String entityName : allDiagramEntitiesWithPrefixes) { + Map<String, Object> entitiesMap = new HashMap<>(); + entitiesMapList.add(entitiesMap); + entitiesMap.put("className", "EOGenericRecord"); + entitiesMap.put("name", entityName); } - } - if (calledServiceSet != null) { + UtilPlist.writePlistFile(indexEoModelMap, eomodeldFullPath, "index.eomodeld", true); + + // write this service description file + Map<String, Object> thisServiceEoModelMap = createEoModelMap(callingServiceSet, calledServiceSet, callingServiceEcaSet, + calledServiceEcaSet, + useMoreDetailedNames); + UtilPlist.writePlistFile(thisServiceEoModelMap, eomodeldFullPath, this.modelService.getName() + ".plist", true); + + // write service description files + if (callingServiceSet != null) { + for (ServiceArtifactInfo callingService : callingServiceSet) { + Map<String, Object> serviceEoModelMap = callingService.createEoModelMap(null, UtilMisc.toSet(this), null, null, + useMoreDetailedNames); + UtilPlist.writePlistFile(serviceEoModelMap, eomodeldFullPath, callingService.getDisplayPrefixedName() + ".plist", true); + } + } + for (ServiceArtifactInfo calledService : calledServiceSet) { Map<String, Object> serviceEoModelMap = calledService.createEoModelMap(UtilMisc.toSet(this), null, null, null, useMoreDetailedNames); UtilPlist.writePlistFile(serviceEoModelMap, eomodeldFullPath, calledService.getDisplayPrefixedName() + ".plist", true); } - } - // write SECA description files - for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) { - // add List<ServiceArtifactInfo> for services that trigger this eca rule - Set<ServiceArtifactInfo> ecaCallingServiceSet = callingServiceEca.getServicesTriggeringServiceEca(); - for (ServiceArtifactInfo ecaCallingService: ecaCallingServiceSet) { - ecaCallingService.setDisplayPrefix("Triggering_"); + // write SECA description files + for (ServiceEcaArtifactInfo callingServiceEca : callingServiceEcaSet) { + // add List<ServiceArtifactInfo> for services that trigger this eca rule + Set<ServiceArtifactInfo> ecaCallingServiceSet = callingServiceEca.getServicesTriggeringServiceEca(); + for (ServiceArtifactInfo ecaCallingService : ecaCallingServiceSet) { + ecaCallingService.setDisplayPrefix("Triggering_"); + } + ecaCallingServiceSet.add(this); + + Map<String, Object> serviceEcaEoModelMap = callingServiceEca.createEoModelMap(ecaCallingServiceSet, null, useMoreDetailedNames); + UtilPlist.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, callingServiceEca.getDisplayPrefixedName() + ".plist", true); } - ecaCallingServiceSet.add(this); - - Map<String, Object> serviceEcaEoModelMap = callingServiceEca.createEoModelMap(ecaCallingServiceSet, null, useMoreDetailedNames); - UtilPlist.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, callingServiceEca.getDisplayPrefixedName() + ".plist", true); - } - for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaSet) { - // add List<ServiceArtifactInfo> for services this eca rule calls in action - Set<ServiceArtifactInfo> ecaCalledServiceSet = calledServiceEca.getServicesCalledByServiceEcaActions(); - for (ServiceArtifactInfo ecaCalledService: ecaCalledServiceSet) { - ecaCalledService.setDisplayPrefix("Triggered_"); + for (ServiceEcaArtifactInfo calledServiceEca : calledServiceEcaSet) { + // add List<ServiceArtifactInfo> for services this eca rule calls in action + Set<ServiceArtifactInfo> ecaCalledServiceSet = calledServiceEca.getServicesCalledByServiceEcaActions(); + for (ServiceArtifactInfo ecaCalledService : ecaCalledServiceSet) { + ecaCalledService.setDisplayPrefix("Triggered_"); + } + ecaCalledServiceSet.add(this); + + Map<String, Object> serviceEcaEoModelMap = calledServiceEca.createEoModelMap(null, ecaCalledServiceSet, useMoreDetailedNames); + UtilPlist.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, calledServiceEca.getDisplayPrefixedName() + ".plist", true); } - ecaCalledServiceSet.add(this); - - Map<String, Object> serviceEcaEoModelMap = calledServiceEca.createEoModelMap(null, ecaCalledServiceSet, useMoreDetailedNames); - UtilPlist.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, calledServiceEca.getDisplayPrefixedName() + ".plist", true); } } } /** * Create eo model map map. - * @param callingServiceSet the calling service set - * @param calledServiceSet the called service set + * @param callingServiceSet the calling service set + * @param calledServiceSet the called service set * @param callingServiceEcaSet the calling service eca set - * @param calledServiceEcaSet the called service eca set + * @param calledServiceEcaSet the called service eca set * @param useMoreDetailedNames the use more detailed names * @return the map */ public Map<String, Object> createEoModelMap(Set<ServiceArtifactInfo> callingServiceSet, Set<ServiceArtifactInfo> calledServiceSet, Set<ServiceEcaArtifactInfo> callingServiceEcaSet, Set<ServiceEcaArtifactInfo> calledServiceEcaSet, boolean useMoreDetailedNames) { - if (callingServiceSet == null) callingServiceSet = new HashSet<>(); - if (calledServiceSet == null) calledServiceSet = new HashSet<>(); - if (callingServiceEcaSet == null) callingServiceEcaSet = new HashSet<>(); - if (calledServiceEcaSet == null) calledServiceEcaSet = new HashSet<>(); + if (callingServiceSet == null) { + callingServiceSet = new HashSet<>(); + } + if (calledServiceSet == null) { + calledServiceSet = new HashSet<>(); + } + if (callingServiceEcaSet == null) { + callingServiceEcaSet = new HashSet<>(); + } + if (calledServiceEcaSet == null) { + calledServiceEcaSet = new HashSet<>(); + } Map<String, Object> topLevelMap = new HashMap<>(); topLevelMap.put("name", this.getDisplayPrefixedName()); @@ -564,9 +576,11 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { // for classProperties add attribute names AND relationship names to get a nice, complete chart List<String> classPropertiesList = new LinkedList<>(); topLevelMap.put("classProperties", classPropertiesList); - for (ModelParam param: this.modelService.getModelParamList()) { + for (ModelParam param : this.modelService.getModelParamList()) { // skip the internal parameters, very redundant in the diagrams - if (param.getInternal()) continue; + if (param.getInternal()) { + continue; + } if (useMoreDetailedNames) { classPropertiesList.add(param.getShortDisplayDescription()); @@ -574,23 +588,23 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { classPropertiesList.add(param.getName()); } } - for (ServiceArtifactInfo sai: callingServiceSet) { + for (ServiceArtifactInfo sai : callingServiceSet) { classPropertiesList.add(sai.getDisplayPrefixedName()); } - for (ServiceArtifactInfo sai: calledServiceSet) { + for (ServiceArtifactInfo sai : calledServiceSet) { classPropertiesList.add(sai.getDisplayPrefixedName()); } - for (ServiceEcaArtifactInfo seai: callingServiceEcaSet) { + for (ServiceEcaArtifactInfo seai : callingServiceEcaSet) { classPropertiesList.add(seai.getDisplayPrefixedName()); } - for (ServiceEcaArtifactInfo seai: calledServiceEcaSet) { + for (ServiceEcaArtifactInfo seai : calledServiceEcaSet) { classPropertiesList.add(seai.getDisplayPrefixedName()); } // attributes List<Map<String, Object>> attributesList = new LinkedList<>(); topLevelMap.put("attributes", attributesList); - for (ModelParam param: this.modelService.getModelParamList()) { + for (ModelParam param : this.modelService.getModelParamList()) { Map<String, Object> attributeMap = new HashMap<>(); attributesList.add(attributeMap); @@ -606,7 +620,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { // relationships List<Map<String, Object>> relationshipsMapList = new LinkedList<>(); - for (ServiceArtifactInfo sai: callingServiceSet) { + for (ServiceArtifactInfo sai : callingServiceSet) { Map<String, Object> relationshipMap = new HashMap<>(); relationshipsMapList.add(relationshipMap); @@ -615,7 +629,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { relationshipMap.put("isToMany", "N"); relationshipMap.put("isMandatory", "Y"); } - for (ServiceArtifactInfo sai: calledServiceSet) { + for (ServiceArtifactInfo sai : calledServiceSet) { Map<String, Object> relationshipMap = new HashMap<>(); relationshipsMapList.add(relationshipMap); @@ -625,7 +639,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { relationshipMap.put("isMandatory", "Y"); } - for (ServiceEcaArtifactInfo seai: callingServiceEcaSet) { + for (ServiceEcaArtifactInfo seai : callingServiceEcaSet) { Map<String, Object> relationshipMap = new HashMap<>(); relationshipsMapList.add(relationshipMap); @@ -634,7 +648,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { relationshipMap.put("isToMany", "N"); relationshipMap.put("isMandatory", "Y"); } - for (ServiceEcaArtifactInfo seai: calledServiceEcaSet) { + for (ServiceEcaArtifactInfo seai : calledServiceEcaSet) { Map<String, Object> relationshipMap = new HashMap<>(); relationshipsMapList.add(relationshipMap); diff --git a/spotbugs/exclude.xml b/spotbugs/exclude.xml index 71c9b5c..c4b710e 100644 --- a/spotbugs/exclude.xml +++ b/spotbugs/exclude.xml @@ -3,9 +3,9 @@ xmlns="https://github.com/spotbugs/filter/3.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd"> - - <!-- CN_IDIOM_NO_SUPER_CALL = clone method does not call supper.clone(). OK since shallow clone wanted--> - <Match> + + <!-- v v CN_IDIOM_NO_SUPER_CALL = clone method does not call supper.clone(). OK since shallow clone wanted--> + <Match> <Class name="org.apache.ofbiz.entity.GenericEntity" /> <Method name="clone" /> <Bug pattern="CN_IDIOM_NO_SUPER_CALL" /> @@ -20,6 +20,10 @@ <Method name="clone" /> <Bug pattern="CN_IDIOM_NO_SUPER_CALL" /> </Match> +<!-- ^ ^ CN_IDIOM_NO_SUPER_CALL = clone method does not call supper.clone(). OK since shallow clone wanted--> + + +<!-- v v OK because of synchronized use --> <Match> <Class name="org.apache.ofbiz.webapp.view.ApacheFopWorker" /> <Method name="getFactoryInstance" /> @@ -30,6 +34,9 @@ <Method name="getWorkingKeyIndex" /> <Bug pattern="DC_DOUBLECHECK" /> </Match> +<!-- ^ ^ OK because of synchronized use --> + +<!-- v v OK see remark about OWASP advice at bottom of OFBIZ-9973 --> <Match> <Class name="org.apache.ofbiz.pricat.PricatParseExcelHtmlThread" /> <Method name="storePricatFile" /> @@ -40,4 +47,89 @@ <Method name="isValidFile" /> <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" /> </Match> +<!-- ^ ^ OK see remark about OWASP advice at bottom of OFBIZ-9973 --> + +<!-- v v OK all is internal --> +<!-- Though asmentioned by SpotBugs: "a PreparedStatement, is more efficient" --> + <Match> + <Class name="org.apache.ofbiz.entity.util.SequenceUtil" /> + <Method name="SequenceBank" /> + <Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.jdbc.DatabaseUtil" /> + <Method name="createTable" /> + <Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.util.SequenceUtil$SequenceBank" /> + <Method name="fillBank" /> + <Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE" /> + </Match> +<!-- ^ ^ OK all is internal --> + + +<!-- v v OK all is internal (as long as not proved otherwise...)--> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="partialSelect"/> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="select" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="selectByMultiRelation" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="selectCountByCondition" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="selectListIteratorByCondition" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="singleInsert" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="customUpdate" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="updateByCondition" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.entity.datasource.GenericDAO" /> + <Method name="singleUpdate" /> + <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" /> + </Match> +<!-- ^ ^ OK all is internal (as long as not proved otherwise...)--> + +<!-- v v not a problem, false positive --> + <Match> + <Class name="org.apache.ofbiz.product.product.ProductSearchSession" /> + <Method name="makeSearchParametersString" /> + <Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT" /> + </Match> + <Match> + <Class name="org.apache.ofbiz.product.imagemanagement.FrameImage" /> + <Method name="previewFrameImage" /> + <Bug pattern="PT_RELATIVE_PATH_TRAVERSAL" /> + </Match> +<!-- ^ ^ not a problem, false positive --> + + + </FindBugsFilter>