Author: mthl
Date: Fri Jul 19 14:34:03 2019 New Revision: 1863404 URL: http://svn.apache.org/viewvc?rev=1863404&view=rev Log: Improved: Use ‘HttpServletRequest#getParameterMap’ when possible It is better to avoid using obsolete ‘Enumeration’ class when possible so the calls to ‘HttpServletRequest#getParameterNames’ has been replaced by ‘HttpServletRequest#getParameterMap’. Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1863404&r1=1863403&r2=1863404&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java Fri Jul 19 14:34:03 2019 @@ -22,7 +22,6 @@ import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -311,13 +310,11 @@ public class ShoppingCartEvents { if ("VV_FEATURETREE".equals(ProductWorker.getProductVirtualVariantMethod(delegator, productId))) { // get the selected features. List<String> selectedFeatures = new LinkedList<>(); - Enumeration<String> paramNames = UtilGenerics.cast(request.getParameterNames()); - while (paramNames.hasMoreElements()) { - String paramName = paramNames.nextElement(); - if (paramName.startsWith("FT")) { - selectedFeatures.add(request.getParameterValues(paramName)[0]); + request.getParameterMap().forEach((name, values) -> { + if (name.startsWith("FT")) { + selectedFeatures.add(values[0]); } - } + }); // check if features are selected if (UtilValidate.isEmpty(selectedFeatures)) { Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java?rev=1863404&r1=1863403&r2=1863404&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java Fri Jul 19 14:34:03 2019 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.apache.ofbiz.product.config; -import java.util.Enumeration; import java.util.LinkedList; import java.util.List; import java.util.Locale; @@ -27,7 +26,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; 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.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; @@ -151,13 +149,12 @@ public final class ProductConfigWorker { if ("VV_FEATURETREE".equals(ProductWorker.getProductVirtualVariantMethod((Delegator)request.getAttribute("delegator"), selectedProductId))) { // get the selected features List<String> selectedFeatures = new LinkedList<>(); - Enumeration<String> paramNames = UtilGenerics.cast(request.getParameterNames()); - while (paramNames.hasMoreElements()) { - String paramName = paramNames.nextElement(); - if (paramName.startsWith("FT" + k + "_" + cnt + "_" + variantIndex)) { - selectedFeatures.add(request.getParameterValues(paramName)[0]); + String prefix = "FT" + k + "_" + cnt + "_" + variantIndex; + request.getParameterMap().forEach((name, values) -> { + if (name.startsWith(prefix)) { + selectedFeatures.add(values[0]); } - } + }); // check if features are selected if (UtilValidate.isEmpty(selectedFeatures)) { Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java?rev=1863404&r1=1863403&r2=1863404&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java Fri Jul 19 14:34:03 2019 @@ -361,11 +361,9 @@ public class ControlServlet extends Http if (Debug.verboseOn()) Debug.logVerbose("--- End Request Headers: ---", module); if (Debug.verboseOn()) Debug.logVerbose("--- Start Request Parameters: ---", module); - Enumeration<String> paramNames = UtilGenerics.cast(request.getParameterNames()); - while (paramNames.hasMoreElements()) { - String paramName = paramNames.nextElement(); - Debug.logVerbose(paramName + ":" + request.getParameter(paramName), module); - } + request.getParameterMap().forEach((name, values) -> { + Debug.logVerbose(name + ":" + values, module); + }); if (Debug.verboseOn()) Debug.logVerbose("--- End Request Parameters: ---", module); if (Debug.verboseOn()) Debug.logVerbose("--- Start Request Attributes: ---", module); |
Free forum by Nabble | Edit this page |