You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ar...@apache.org on 2016/07/02 05:56:47 UTC

svn commit: r1751026 - in /ofbiz/trunk: applications/accounting/src/org/ofbiz/accounting/ applications/order/src/org/ofbiz/order/shoppingcart/ framework/base/src/org/ofbiz/base/util/ framework/webapp/src/org/ofbiz/webapp/event/ specialpurpose/ebaystore...

Author: arunpatidar
Date: Sat Jul  2 05:56:47 2016
New Revision: 1751026

URL: http://svn.apache.org/viewvc?rev=1751026&view=rev
Log:
Applied patch from jira issue - OFBIZ-7589 - Enforce noninstantiability to UtilHttp class. Thanks Rishi Solanki and  Rohit Koushal for your contribution.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java?rev=1751026&r1=1751025&r2=1751026&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java Sat Jul  2 05:56:47 2016
@@ -55,7 +55,7 @@ public static String createReconcileAcco
     // The number of multi form rows is retrieved
     int rowCount = UtilHttp.getMultiFormRowCount(ctx);
     for (int i = 0; i < rowCount; i++) {  //for calculating amount per glAccountId
-        String suffix = UtilHttp.MULTI_ROW_DELIMITER + i;
+        String suffix = UtilHttp.getMultiRowDelimiter() + i;
         isSelected = (ctx.containsKey("_rowSubmit" + suffix) && "Y".equalsIgnoreCase((String)ctx.get("_rowSubmit" + suffix)));
         if (!isSelected) {
             continue;
@@ -95,7 +95,7 @@ public static String createReconcileAcco
     String glReconciliationId = (String) glReconResult.get("glReconciliationId");
     String reconciledAmount;
     for (int i = 0; i < rowCount; i++) {
-        String suffix = UtilHttp.MULTI_ROW_DELIMITER + i;
+        String suffix = UtilHttp.getMultiRowDelimiter() + i;
         isSelected = (ctx.containsKey("_rowSubmit" + suffix) && "Y".equalsIgnoreCase((String)ctx.get("_rowSubmit" + suffix)));
         if (!isSelected) {
             continue;

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1751026&r1=1751025&r2=1751026&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Sat Jul  2 05:56:47 2016
@@ -1799,7 +1799,7 @@ public class ShoppingCartEvents {
         } else {
             for (int i = 0; i < rowCount; i++) {
                 controlDirective = null;                // re-initialize each time
-                String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i;        // current suffix after each field id
+                String thisSuffix = UtilHttp.getMultiRowDelimiter() + i;        // current suffix after each field id
 
                 // get the productId
                 if (paramMap.containsKey("productId" + thisSuffix)) {
@@ -2012,7 +2012,7 @@ public class ShoppingCartEvents {
             Debug.logWarning("No rows to process, as rowCount = " + rowCount, module);
         } else {
             for (int i = 0; i < rowCount; i++) {
-                String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i;
+                String thisSuffix = UtilHttp.getMultiRowDelimiter() + i;
                 if (paramMap.containsKey("productId" + thisSuffix)) {
                     productId = (String) paramMap.remove("productId" + thisSuffix);
                 }

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=1751026&r1=1751025&r2=1751026&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Sat Jul  2 05:56:47 2016
@@ -508,7 +508,7 @@ public class ShoppingCartHelper {
             String productId = null;
             String quantStr = null;
             String requirementId = null;
-            String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i;
+            String thisSuffix = UtilHttp.getMultiRowDelimiter() + i;
             boolean rowSelected = (!context.containsKey("_rowSubmit" + thisSuffix))? false :
                     "Y".equalsIgnoreCase((String)context.get("_rowSubmit" + thisSuffix));
 

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=1751026&r1=1751025&r2=1751026&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Sat Jul  2 05:56:47 2016
@@ -66,18 +66,20 @@ import com.ibm.icu.util.Calendar;
 /**
  * HttpUtil - Misc HTTP Utility Functions
  */
-public class UtilHttp {
+public final class UtilHttp {
 
     public static final String module = UtilHttp.class.getName();
 
-    public static final String MULTI_ROW_DELIMITER = "_o_";
-    public static final String ROW_SUBMIT_PREFIX = "_rowSubmit_o_";
-    public static final String COMPOSITE_DELIMITER = "_c_";
-    public static final int MULTI_ROW_DELIMITER_LENGTH = MULTI_ROW_DELIMITER.length();
-    public static final int ROW_SUBMIT_PREFIX_LENGTH = ROW_SUBMIT_PREFIX.length();
-    public static final int COMPOSITE_DELIMITER_LENGTH = COMPOSITE_DELIMITER.length();
+    private static final String MULTI_ROW_DELIMITER = "_o_";
+    private static final String ROW_SUBMIT_PREFIX = "_rowSubmit_o_";
+    private static final String COMPOSITE_DELIMITER = "_c_";
+    private static final int MULTI_ROW_DELIMITER_LENGTH = MULTI_ROW_DELIMITER.length();
+    private static final int ROW_SUBMIT_PREFIX_LENGTH = ROW_SUBMIT_PREFIX.length();
+    private static final int COMPOSITE_DELIMITER_LENGTH = COMPOSITE_DELIMITER.length();
 
-    public static final String SESSION_KEY_TIMEZONE = "timeZone";
+    private static final String SESSION_KEY_TIMEZONE = "timeZone";
+
+    private UtilHttp () {}
 
     /**
      * Create a combined map from servlet context, session, attributes and parameters
@@ -1470,4 +1472,11 @@ public class UtilHttp {
         }
     }
 
+    public static String getMultiRowDelimiter() {
+        return MULTI_ROW_DELIMITER;
+    }
+
+    public static String getRowSubmitPrefix() {
+        return ROW_SUBMIT_PREFIX;
+    }
 }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java?rev=1751026&r1=1751025&r2=1751026&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java Sat Jul  2 05:56:47 2016
@@ -190,14 +190,14 @@ public class ServiceMultiEventHandler im
 
             // now loop throw the rows and prepare/invoke the service for each
             for (int i = 0; i < rowCount; i++) {
-                String curSuffix = UtilHttp.MULTI_ROW_DELIMITER + i;
+                String curSuffix = UtilHttp.getMultiRowDelimiter() + i;
                 boolean rowSelected = false;
-                if (UtilValidate.isNotEmpty(request.getAttribute(UtilHttp.ROW_SUBMIT_PREFIX + i))) {
-                    rowSelected = request.getAttribute(UtilHttp.ROW_SUBMIT_PREFIX + i) == null ? false :
-                    "Y".equalsIgnoreCase((String)request.getAttribute(UtilHttp.ROW_SUBMIT_PREFIX + i));
+                if (UtilValidate.isNotEmpty(request.getAttribute(UtilHttp.getRowSubmitPrefix() + i))) {
+                    rowSelected = request.getAttribute(UtilHttp.getRowSubmitPrefix() + i) == null ? false :
+                    "Y".equalsIgnoreCase((String)request.getAttribute(UtilHttp.getRowSubmitPrefix() + i));
                 } else {
-                    rowSelected = request.getParameter(UtilHttp.ROW_SUBMIT_PREFIX + i) == null ? false :
-                    "Y".equalsIgnoreCase(request.getParameter(UtilHttp.ROW_SUBMIT_PREFIX + i));
+                    rowSelected = request.getParameter(UtilHttp.getRowSubmitPrefix() + i) == null ? false :
+                    "Y".equalsIgnoreCase(request.getParameter(UtilHttp.getRowSubmitPrefix() + i));
                 }
 
                 // make sure we are to process this row

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java?rev=1751026&r1=1751025&r2=1751026&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java Sat Jul  2 05:56:47 2016
@@ -650,7 +650,7 @@ public class EbayEvents {
         int rowCount = UtilHttp.getMultiFormRowCount(paramMap);
         if (rowCount > 1) {
             for (int i = 0; i < rowCount; i++) {
-                String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i;        // current suffix after each field id
+                String thisSuffix = UtilHttp.getMultiRowDelimiter() + i;        // current suffix after each field id
                 // get the NameSpecifics
                 if (paramMap.containsKey("nameValueListType" + thisSuffix)) {
                     nameValueListType = (String) paramMap.remove("nameValueListType" + thisSuffix);