Author: jleroux
Date: Sat May 25 14:08:48 2019 New Revision: 1859972 URL: http://svn.apache.org/viewvc?rev=1859972&view=rev Log: Fixed: Duplicate entries in paramWithSuffix (OFBIZ-11056) when using string-list-suffix attribute for service definition, invoke method (from associated event handler) will try to parse parameters from both request variable and rawParameterMap which was also built from request. So we end up with duplicates in resulting list. This behaviour seems to be introduced with OFBIZ-5048. Thanks: Samuel Trégouët for report and fix Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java?rev=1859972&r1=1859971&r2=1859972&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java Sat May 25 14:08:48 2019 @@ -161,13 +161,15 @@ public final class UtilHttp { paramMap.putAll(getPathInfoOnlyParameterMap(request, nameSet, onlyIncludeOrSkip)); + Map<String, Object> multiPartMap = new HashMap<>(); if (paramMap.size() == 0) { // nothing found in the parameters; maybe we read the stream instead - Map<String, Object> multiPartMap = getMultiPartParameterMap(request); + multiPartMap = getMultiPartParameterMap(request); if (UtilValidate.isNotEmpty(multiPartMap)) { paramMap.putAll(multiPartMap); } } + request.setAttribute("multiPartMap", multiPartMap); if (Debug.verboseOn()) { Debug.logVerbose("Made Request Parameter Map with [" + paramMap.size() + "] Entries", module); @@ -282,7 +284,6 @@ public final class UtilHttp { } } - return multiPartMap; } Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java?rev=1859972&r1=1859971&r2=1859972&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java Sat May 25 14:08:48 2019 @@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRes import javax.servlet.http.HttpSession; import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilHttp; import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.entity.Delegator; @@ -118,6 +119,8 @@ public class ServiceEventHandler impleme } Map<String, Object> rawParametersMap = UtilHttp.getCombinedMap(request); + Map<String, Object> multiPartMap = UtilGenerics.checkMap(request.getAttribute("multiPartMap")); + Set<String> urlOnlyParameterNames = UtilHttp.getUrlOnlyParameterMap(request).keySet(); // we have a service and the model; build the context @@ -136,15 +139,15 @@ public class ServiceEventHandler impleme Object value = null; if (UtilValidate.isNotEmpty(modelParam.stringMapPrefix)) { - Map<String, Object> paramMap = UtilHttp.makeParamMapWithPrefix(request, rawParametersMap, modelParam.stringMapPrefix, null); + Map<String, Object> paramMap = UtilHttp.makeParamMapWithPrefix(request, multiPartMap, modelParam.stringMapPrefix, null); value = paramMap; if (Debug.verboseOn()) Debug.logVerbose("Set [" + modelParam.name + "]: " + paramMap, module); } else if (UtilValidate.isNotEmpty(modelParam.stringListSuffix)) { - List<Object> paramList = UtilHttp.makeParamListWithSuffix(request, rawParametersMap, modelParam.stringListSuffix, null); + List<Object> paramList = UtilHttp.makeParamListWithSuffix(request, multiPartMap, modelParam.stringListSuffix, null); value = paramList; } else { // first check the multi-part map - value = rawParametersMap.get(name); + value = multiPartMap.get(name); // next check attributes; do this before parameters so that attribute which can be changed by code can override parameters which can't if (UtilValidate.isEmpty(value)) { |
Free forum by Nabble | Edit this page |