svn commit: r1817616 - /ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/

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

svn commit: r1817616 - /ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/

mbrohl
Author: mbrohl
Date: Sat Dec  9 14:51:18 2017
New Revision: 1817616

URL: http://svn.apache.org/viewvc?rev=1817616&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.product.category.
(OFBIZ-9772)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ControlServlet.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoControlServlet.java

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java Sat Dec  9 14:51:18 2017
@@ -54,8 +54,9 @@ public class CatalogUrlFilter implements
     public static final String PRODUCT_REQUEST = "product";
     public static final String CATEGORY_REQUEST = "category";
     
-    protected static String defaultLocaleString = null;
-    protected static String redirectUrl = null;
+    private static String defaultLocaleString;
+    private static String redirectUrl;
+
 
     protected FilterConfig config;
 
@@ -73,8 +74,8 @@ public class CatalogUrlFilter implements
         // set initial parameters
         String initDefaultLocalesString = config.getInitParameter("defaultLocaleString");
         String initRedirectUrl = config.getInitParameter("redirectUrl");
-        defaultLocaleString = UtilValidate.isNotEmpty(initDefaultLocalesString) ? initDefaultLocalesString : "";
-        redirectUrl = UtilValidate.isNotEmpty(initRedirectUrl) ? initRedirectUrl : "";
+        setDefaultLocaleString(UtilValidate.isNotEmpty(initDefaultLocalesString) ? initDefaultLocalesString : "");
+        setRedirectUrl(UtilValidate.isNotEmpty(initRedirectUrl) ? initRedirectUrl : "");
         
         String pathInfo = httpRequest.getServletPath();
         if (UtilValidate.isNotEmpty(pathInfo)) {
@@ -341,7 +342,9 @@ public class CatalogUrlFilter implements
 
     }
 
-    public static String makeCategoryUrl(HttpServletRequest request, String previousCategoryId, String productCategoryId, String productId, String viewSize, String viewIndex, String viewSort, String searchString) {
+    public static String makeCategoryUrl(HttpServletRequest request, String previousCategoryId,
+            String productCategoryId, String productId, String viewSize, String viewIndex, String viewSort,
+            String searchString) {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         try {
             GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne();
@@ -415,7 +418,7 @@ public class CatalogUrlFilter implements
         return url;
     }
     
-    public static String makeProductUrl(HttpServletRequest request, String previousCategoryId, String productCategoryId, String productId) {
+    public static String makeProductUrl(HttpServletRequest request, String previousCategoryId, String productCategoryId,String productId) {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         String url = null;
         try {
@@ -456,4 +459,20 @@ public class CatalogUrlFilter implements
         }
         return url;
     }
+
+    public static String getDefaultLocaleString() {
+        return defaultLocaleString;
+    }
+
+    public static void setDefaultLocaleString(String defaultLocaleString) {
+        CatalogUrlFilter.defaultLocaleString = defaultLocaleString;
+    }
+
+    public static String getRedirectUrl() {
+        return redirectUrl;
+    }
+
+    public static void setRedirectUrl(String redirectUrl) {
+        CatalogUrlFilter.redirectUrl = redirectUrl;
+    }
 }

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java Sat Dec  9 14:51:18 2017
@@ -37,8 +37,8 @@ public class CatalogUrlSeoFilter extends
 
     public final static String module = CatalogUrlSeoFilter.class.getName();
 
-    protected static String defaultLocaleString = null;
-    protected static String redirectUrl = null;
+    protected String defaultLocaleString = null;
+    protected String redirectUrl = null;
 
     /**
      * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
@@ -62,7 +62,7 @@ public class CatalogUrlSeoFilter extends
 
         // set the ServletContext in the request for future use
         httpRequest.setAttribute("servletContext", config.getServletContext());
-        if (CatalogUrlSeoTransform.forwardUri(httpRequest, httpResponse, delegator, ControlServlet.controlServlet)) {
+        if (CatalogUrlSeoTransform.forwardUri(httpRequest, httpResponse, delegator, ControlServlet.getControlServlet())) {
             return;
         }
         super.doFilter(httpRequest, httpResponse, chain);

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java Sat Dec  9 14:51:18 2017
@@ -23,7 +23,6 @@ import java.util.LinkedList;
 import java.util.List;
 
 import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -54,13 +53,6 @@ public class CatalogUrlServlet extends H
         super();
     }
 
-    /**
-     * @see javax.servlet.http.HttpServlet#init(javax.servlet.ServletConfig)
-     */
-    @Override
-    public void init(ServletConfig config) throws ServletException {
-        super.init(config);
-    }
 
     /**
      * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
@@ -154,13 +146,6 @@ public class CatalogUrlServlet extends H
         }
     }
 
-    /**
-     * @see javax.servlet.http.HttpServlet#destroy()
-     */
-    @Override
-    public void destroy() {
-        super.destroy();
-    }
 
     public static String makeCatalogUrl(HttpServletRequest request, String productId, String currentCategoryId, String previousCategoryId) {
         StringBuilder urlBuilder = new StringBuilder();

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java Sat Dec  9 14:51:18 2017
@@ -111,9 +111,7 @@ public class CategoryContentWrapper impl
                 outString = outString == null? "" : outString;
             }
             outString = encoder.sanitize(outString, null);
-            if (categoryContentCache != null) {
-                categoryContentCache.put(cacheKey, outString);
-            }
+            categoryContentCache.put(cacheKey, outString);
             return outString;
         } catch (GeneralException e) {
             Debug.logError(e, "Error rendering CategoryContent, inserting empty String", module);

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java Sat Dec  9 14:51:18 2017
@@ -237,16 +237,16 @@ public class CategoryServices {
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
         int viewIndex = 0;
         try {
-            viewIndex = Integer.valueOf((String) context.get("viewIndexString")).intValue();
+            viewIndex = Integer.parseInt((String) context.get("viewIndexString"));
         } catch (Exception e) {
             viewIndex = 0;
         }
 
         int viewSize = defaultViewSize;
         try {
-            viewSize = Integer.valueOf((String) context.get("viewSizeString")).intValue();
-        } catch (Exception e) {
-            viewSize = defaultViewSize;
+            viewSize = Integer.parseInt((String) context.get("viewSizeString"));
+        } catch (NumberFormatException e) {
+            Debug.logError(e.getMessage(), module);
         }
 
         GenericValue productCategory = null;

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java Sat Dec  9 14:51:18 2017
@@ -405,9 +405,7 @@ public final class CategoryWorker {
             CategoryContentWrapper catContentWrapper = new CategoryContentWrapper(cat, request);
             catContentWrappers.put(productCategoryId, catContentWrapper);
             List<GenericValue> subCat = getRelatedCategoriesRet(request, "subCatList", productCategoryId, true);
-            if (subCat != null) {
-                getCategoryContentWrappers(catContentWrappers, subCat, request);
-            }
+            getCategoryContentWrappers(catContentWrappers, subCat, request);
         }
     }
     

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ControlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ControlServlet.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ControlServlet.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ControlServlet.java Sat Dec  9 14:51:18 2017
@@ -32,9 +32,9 @@ public class ControlServlet extends org.
 
     public static final String module = ControlServlet.class.getName();
 
-    protected static String defaultPage = null;
-    protected static String pageNotFound = null;
-    protected static String controlServlet = null;
+    private static String defaultPage = null;
+    private static String pageNotFound = null;
+    private static String controlServlet = null;
 
     public ControlServlet() {
         super();
@@ -47,22 +47,47 @@ public class ControlServlet extends org.
         super.init(config);
 
         ServletContext context = this.getServletContext();
-        if (UtilValidate.isEmpty(defaultPage)) {
-            defaultPage = context.getInitParameter("defaultPage");
+        if (UtilValidate.isEmpty(getDefaultPage())) {
+            setDefaultPage(context.getInitParameter("defaultPage"));
         }
-        if (UtilValidate.isEmpty(defaultPage)) {
-            defaultPage = "/main";
+        if (UtilValidate.isEmpty(getDefaultPage())) {
+            setDefaultPage("/main");
         }
-        if (UtilValidate.isEmpty(pageNotFound)) {
-            pageNotFound = context.getInitParameter("pageNotFound");
+        if (UtilValidate.isEmpty(getPageNotFound())) {
+            setPageNotFound(context.getInitParameter("pageNotFound"));
         }
-        if (UtilValidate.isEmpty(pageNotFound)) {
-            pageNotFound = "/pagenotfound";
+        if (UtilValidate.isEmpty(getPageNotFound())) {
+            setPageNotFound("/pagenotfound");
         }
 
-        if (defaultPage.startsWith("/") && defaultPage.lastIndexOf("/") > 0) {
-            controlServlet = defaultPage.substring(1);
-            controlServlet = controlServlet.substring(0, controlServlet.indexOf("/"));
+        if (getDefaultPage().startsWith("/") && getDefaultPage().lastIndexOf('/') > 0) {
+            setControlServlet(getDefaultPage().substring(1));
+            setControlServlet(getControlServlet().substring(0, getControlServlet().indexOf('/')));
         }
     }
+
+    public static String getDefaultPage() {
+        return defaultPage;
+    }
+
+    public static void setDefaultPage(String defaultPage) {
+        ControlServlet.defaultPage = defaultPage;
+    }
+
+    public static String getPageNotFound() {
+        return pageNotFound;
+    }
+
+    public static void setPageNotFound(String pageNotFound) {
+        ControlServlet.pageNotFound = pageNotFound;
+    }
+
+    public static String getControlServlet() {
+        return controlServlet;
+    }
+
+    public static void setControlServlet(String controlServlet) {
+        ControlServlet.controlServlet = controlServlet;
+    }
+
 }

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java Sat Dec  9 14:51:18 2017
@@ -52,14 +52,6 @@ public class SeoCatalogUrlServlet extend
     }
 
     /**
-     * @see javax.servlet.http.HttpServlet#init(javax.servlet.ServletConfig)
-     */
-    @Override
-    public void init(ServletConfig config) throws ServletException {
-        super.init(config);
-    }
-
-    /**
      * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
      */
     @Override
@@ -139,18 +131,11 @@ public class SeoCatalogUrlServlet extend
             request.setAttribute("productId", productId);
         }
 
-        RequestDispatcher rd = request.getRequestDispatcher("/" + (UtilValidate.isEmpty(SeoControlServlet.controlServlet) ? "" : (SeoControlServlet.controlServlet + "/"))
+        RequestDispatcher rd = request.getRequestDispatcher("/" + (UtilValidate.isEmpty(SeoControlServlet.getControlServlet()) ? "" : (SeoControlServlet.getControlServlet() + "/"))
                 + (productId != null ? PRODUCT_REQUEST : CATEGORY_REQUEST));
         rd.forward(request, response);
     }
 
-    /**
-     * @see javax.servlet.http.HttpServlet#destroy()
-     */
-    @Override
-    public void destroy() {
-        super.destroy();
-    }
 
     public static String makeCatalogUrl(HttpServletRequest request, String productId, String currentCategoryId, String previousCategoryId) {
         StringBuilder urlBuilder = new StringBuilder();

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java Sat Dec  9 14:51:18 2017
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
@@ -231,7 +232,8 @@ public final class SeoConfigUtil {
             try {
                 NodeList configs = rootElement.getElementsByTagName(ELEMENT_URL_CONFIG);
                 Debug.logInfo("Parsing " + ELEMENT_URL_CONFIG, module);
-                for (int j = 0; j < configs.getLength(); j++) {
+                int length = configs.getLength();
+                for (int j = 0; j < length; j++) {
                     Element config = (Element) configs.item(j);
                     String urlpattern = UtilXml.childElementValue(config, ELEMENT_URLPATTERN, null);
                     if (UtilValidate.isEmpty(urlpattern)) {
@@ -289,7 +291,8 @@ public final class SeoConfigUtil {
                 NodeList nameFilterNodes = rootElement
                         .getElementsByTagName(ELEMENT_CHAR_FILTER);
                 Debug.logInfo("Parsing " + ELEMENT_CHAR_FILTER + ": ", module);
-                for (int i = 0; i < nameFilterNodes.getLength(); i++) {
+                int length = nameFilterNodes.getLength();
+                for (int i = 0; i < length; i++) {
                     Element element = (Element) nameFilterNodes.item(i);
                     String charaterPattern = UtilXml.childElementValue(element, ELEMENT_CHARACTER_PATTERN, null);
                     String replacement = UtilXml.childElementValue(element, ELEMENT_REPLACEMENT, null);
@@ -507,17 +510,17 @@ public final class SeoConfigUtil {
      */
     @Deprecated
     public static boolean addSpecialProductId(String productId) throws Exception {
-        if (productId.toLowerCase().equals(productId) || productId.toUpperCase().equals(productId)) {
+        if (productId.toLowerCase(Locale.getDefault()).equals(productId) || productId.toUpperCase(Locale.getDefault()).equals(productId)) {
             return false;
         }
-        if (isSpecialProductId(productId.toLowerCase())) {
+        if (isSpecialProductId(productId.toLowerCase(Locale.getDefault()))) {
             if (specialProductIds.containsValue(productId)) {
                 return true;
             } else {
                 throw new Exception("This product Id cannot be lower cased for SEO URL purpose: " + productId);
             }
         }
-        specialProductIds.put(productId.toLowerCase(), productId);
+        specialProductIds.put(productId.toLowerCase(Locale.getDefault()), productId);
         return true;
     }
     

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java Sat Dec  9 14:51:18 2017
@@ -43,8 +43,8 @@ import org.apache.ofbiz.entity.util.Enti
 
 public class SeoContentUrlFilter implements Filter {
     public final static String module = SeoContentUrlFilter.class.getName();
-    protected static String defaultLocaleString = null;
-    protected static String redirectUrl = null;
+    protected static final String defaultLocaleString = null;
+    protected static final String redirectUrl = null;
     private FilterConfig config;
 
     @Override
@@ -61,7 +61,7 @@ public class SeoContentUrlFilter impleme
         String urlContentId = null;
         String pathInfo = UtilHttp.getFullRequestUrl(httpRequest);
         if (UtilValidate.isNotEmpty(pathInfo)) {
-            String alternativeUrl = pathInfo.substring(pathInfo.lastIndexOf("/"));
+            String alternativeUrl = pathInfo.substring(pathInfo.lastIndexOf('/'));
             if (alternativeUrl.endsWith("-content")) {
                 try {
                     List<GenericValue> contentDataResourceViews = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("drObjectInfo", alternativeUrl), null, false);
@@ -81,8 +81,8 @@ public class SeoContentUrlFilter impleme
             }
             if (UtilValidate.isNotEmpty(urlContentId)) {
                 StringBuilder urlBuilder = new StringBuilder();
-                if (UtilValidate.isNotEmpty(SeoControlServlet.controlServlet)) {
-                    urlBuilder.append("/" + SeoControlServlet.controlServlet);
+                if (UtilValidate.isNotEmpty(SeoControlServlet.getControlServlet())) {
+                    urlBuilder.append("/" + SeoControlServlet.getControlServlet());
                 }
                 urlBuilder.append("/" + config.getInitParameter("viewRequest") + "?contentId=" + urlContentId);
 

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java Sat Dec  9 14:51:18 2017
@@ -25,7 +25,9 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import javax.servlet.Filter;
@@ -57,7 +59,7 @@ public class SeoContextFilter implements
 
     public static final String module = SeoContextFilter.class.getName();
 
-    protected Set<String> WebServlets = new HashSet<>();
+    protected Set<String> webServlets = new HashSet<>();
     private FilterConfig config;
     private String allowedPaths = "";
     private String redirectPath = "";
@@ -74,13 +76,13 @@ public class SeoContextFilter implements
         }
 
         Map<String, ? extends ServletRegistration> servletRegistrations = config.getServletContext().getServletRegistrations();
-        for (String key : servletRegistrations.keySet()) {
-            Collection<String> servlets = servletRegistrations.get(key).getMappings();
+        for (Entry<String, ? extends ServletRegistration> entry : servletRegistrations.entrySet()) {
+            Collection<String> servlets = entry.getValue().getMappings();
             for (String servlet : servlets) {
                 if (servlet.endsWith("/*")) {
                     servlet = servlet.substring(0, servlet.length() - 2);
-                    if (UtilValidate.isNotEmpty(servlet) && !WebServlets.contains(servlet)) {
-                        WebServlets.add(servlet);
+                    if (UtilValidate.isNotEmpty(servlet) && !webServlets.contains(servlet)) {
+                        webServlets.add(servlet);
                     }
                 }
             }
@@ -118,18 +120,18 @@ public class SeoContextFilter implements
         if (httpRequest.getAttribute(ControlFilter.FORWARDED_FROM_SERVLET) == null) {
             requestPath = httpRequest.getServletPath();
             if (requestPath == null) requestPath = "";
-            if (requestPath.lastIndexOf("/") > 0) {
-                if (requestPath.indexOf("/") == 0) {
-                    requestPath = "/" + requestPath.substring(1, requestPath.indexOf("/", 1));
+            if (requestPath.lastIndexOf('/') > 0) {
+                if (requestPath.indexOf('/') == 0) {
+                    requestPath = '/' + requestPath.substring(1, requestPath.indexOf('/', 1));
                 } else {
-                    requestPath = requestPath.substring(1, requestPath.indexOf("/"));
+                    requestPath = requestPath.substring(1, requestPath.indexOf('/'));
                 }
             }
 
             String requestInfo = httpRequest.getServletPath();
             if (requestInfo == null) requestInfo = "";
-            if (requestInfo.lastIndexOf("/") >= 0) {
-                requestInfo = requestInfo.substring(0, requestInfo.lastIndexOf("/")) + "/*";
+            if (requestInfo.lastIndexOf('/') >= 0) {
+                requestInfo = requestInfo.substring(0, requestInfo.lastIndexOf('/')) + "/*";
             }
 
             StringBuilder contextUriBuffer = new StringBuilder();
@@ -161,7 +163,7 @@ public class SeoContextFilter implements
                 if (redirectPath == null) {
                     if (UtilValidate.isEmpty(viewName)) {
                         // redirect without any url change in browser
-                        RequestDispatcher rd = request.getRequestDispatcher(SeoControlServlet.defaultPage);
+                        RequestDispatcher rd = request.getRequestDispatcher(SeoControlServlet.getDefaultPage());
                         rd.forward(request, response);
                     } else {
                         int error = 404;
@@ -178,7 +180,7 @@ public class SeoContextFilter implements
                     }
                 } else {
                     filterMessage = filterMessage + " (" + redirectPath + ")";
-                    if (!redirectPath.toLowerCase().startsWith("http")) {
+                    if (!redirectPath.toLowerCase(Locale.getDefault()).startsWith("http")) {
                         redirectPath = httpRequest.getContextPath() + redirectPath;
                     }
                     // httpResponse.sendRedirect(redirectPath);
@@ -196,7 +198,7 @@ public class SeoContextFilter implements
                 return;
             } else if ((allowedPathList.contains(requestPath) || allowedPathList.contains(requestInfo) || allowedPathList.contains(httpRequest.getServletPath())
                     || allowedPathList.contains(requestUri) || allowedPathList.contains("/" + viewName))
-                    && !WebServlets.contains(httpRequest.getServletPath())) {
+                    && !webServlets.contains(httpRequest.getServletPath())) {
                 request.setAttribute(SeoControlServlet.REQUEST_IN_ALLOW_LIST, Boolean.TRUE);
             }
         }

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoControlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoControlServlet.java?rev=1817616&r1=1817615&r2=1817616&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoControlServlet.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoControlServlet.java Sat Dec  9 14:51:18 2017
@@ -20,6 +20,7 @@ package org.apache.ofbiz.product.categor
 
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.util.Locale;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -40,8 +41,8 @@ public class SeoControlServlet extends C
 
     public static final String module = SeoControlServlet.class.getName();
 
-    protected static String defaultPage = null;
-    protected static String controlServlet = null;
+    private static String defaultPage = null;
+    private static String controlServlet = null;
     
     public static final String REQUEST_IN_ALLOW_LIST = "_REQUEST_IN_ALLOW_LIST_";
 
@@ -56,16 +57,16 @@ public class SeoControlServlet extends C
         super.init(config);
 
         ServletContext context = this.getServletContext();
-        if (UtilValidate.isEmpty(defaultPage)) {
-            defaultPage = context.getInitParameter("defaultPage");
+        if (UtilValidate.isEmpty(SeoControlServlet.getDefaultPage())) {
+            setDefaultPage(context.getInitParameter("defaultPage"));
         }
-        if (UtilValidate.isEmpty(defaultPage)) {
-            defaultPage = "/main";
+        if (UtilValidate.isEmpty(getDefaultPage())) {
+            setDefaultPage("/main");
         }
 
-        if (defaultPage.startsWith("/") && defaultPage.lastIndexOf("/") > 0) {
-            controlServlet = defaultPage.substring(1);
-            controlServlet = controlServlet.substring(0, controlServlet.indexOf("/"));
+        if (getDefaultPage().startsWith("/") && getDefaultPage().lastIndexOf('/') > 0) {
+            setControlServlet(getDefaultPage().substring(1));
+            setControlServlet(getControlServlet().substring(0, getControlServlet().indexOf('/')));
         }
 
         SeoConfigUtil.init();
@@ -74,7 +75,7 @@ public class SeoControlServlet extends C
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  String uri = URLEncoder.encode(request.getRequestURI(), "UTF-8");
         if (request.getAttribute(REQUEST_IN_ALLOW_LIST) != null || request.getAttribute("_jsp_" + uri) != null) {
-            if (request.getRequestURI().toLowerCase().endsWith(".jsp") || request.getRequestURI().toLowerCase().endsWith(".jspx") ) {
+            if (request.getRequestURI().toLowerCase(Locale.getDefault()).endsWith(".jsp") || request.getRequestURI().toLowerCase(Locale.getDefault()).endsWith(".jspx") ) {
                 JspServlet jspServlet = new JspServlet();
                 jspServlet.init(this.getServletConfig());
                 jspServlet.service(request, response);
@@ -87,4 +88,21 @@ public class SeoControlServlet extends C
         }
         super.doGet(request, response);
     }
+
+    public static String getDefaultPage() {
+        return defaultPage;
+    }
+
+    public static void setDefaultPage(String defaultPage) {
+        SeoControlServlet.defaultPage = defaultPage;
+    }
+
+    public static String getControlServlet() {
+        return controlServlet;
+    }
+
+    public static void setControlServlet(String controlServlet) {
+        SeoControlServlet.controlServlet = controlServlet;
+    }
+
 }