svn commit: r534735 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r534735 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java

jonesde
Author: jonesde
Date: Thu May  3 00:09:25 2007
New Revision: 534735

URL: http://svn.apache.org/viewvc?view=rev&rev=534735
Log:
Small change to better handle case where the list price range search parameter is not valid, ie is missing and underscore

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?view=diff&rev=534735&r1=534734&r2=534735
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Thu May  3 00:09:25 2007
@@ -471,6 +471,9 @@
         } else {
             request.setAttribute("processSearchParametersAlreadyRun", Boolean.TRUE);
         }
+        
+        Debug.logInfo("Processing Product Search parameters: " + parameters, module);
+        
         HttpSession session = request.getSession();
         boolean constraintsChanged = false;
         GenericValue productStore = ProductStoreWorker.getProductStore(request);
@@ -491,7 +494,7 @@
                 }
             }
         }
-
+        
         String prioritizeCategoryId = null;
         if (UtilValidate.isNotEmpty((String) parameters.get("PRIORITIZE_CATEGORY_ID"))) {
             prioritizeCategoryId = (String) parameters.get("PRIORITIZE_CATEGORY_ID");
@@ -681,8 +684,17 @@
         if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_RANGE")) || UtilValidate.isNotEmpty((String) parameters.get("S_LPR"))) {
             String listPriceRangeStr = (String) parameters.get("LIST_PRICE_RANGE");
             if (UtilValidate.isEmpty(listPriceRangeStr)) listPriceRangeStr = (String) parameters.get("S_LPR");
-            String listPriceLowStr = listPriceRangeStr.substring(0, listPriceRangeStr.indexOf("_"));
-            String listPriceHighStr = listPriceRangeStr.substring(listPriceRangeStr.indexOf("_") + 1);
+            int underscoreIndex = listPriceRangeStr.indexOf("_");
+            String listPriceLowStr;
+            String listPriceHighStr;
+            if (underscoreIndex >= 0) {
+                listPriceLowStr = listPriceRangeStr.substring(0, listPriceRangeStr.indexOf("_"));
+                listPriceHighStr = listPriceRangeStr.substring(listPriceRangeStr.indexOf("_") + 1);
+            } else {
+                // no underscore: assume it is a low range with no high range, ie the ending underscore was left off
+                listPriceLowStr = listPriceRangeStr;
+                listPriceHighStr = null;
+            }
 
             Double listPriceLow = null;
             Double listPriceHigh = null;