Author: mbrohl
Date: Wed Feb 14 16:11:06 2018
New Revision: 1824257

URL: http://svn.apache.org/viewvc?rev=1824257&view=rev
Log:
Improved: General refactoring and code improvements, package 
Package org.apache.ofbiz.product.category.ftl.
(OFBIZ-10138)

Thanks Julian Leichert for reporting and providing the patches.

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java?rev=1824257&r1=1824256&r2=1824257&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java
 Wed Feb 14 16:11:06 2018
@@ -26,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.UtilMisc;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.base.util.template.FreeMarkerWorker;
 import org.apache.ofbiz.entity.Delegator;
@@ -54,7 +53,7 @@ import org.apache.ofbiz.entity.util.Enti
 public class CatalogAltUrlSeoTransform implements TemplateTransformModel {
     public final static String module = CatalogUrlSeoTransform.class.getName();
 
-    public String getStringArg(Map args, String key) {
+    public String getStringArg(Map<?, ?> args, String key) {
         Object o = args.get(key);
         if (o instanceof SimpleScalar) {
             return ((SimpleScalar) o).getAsString();
@@ -68,17 +67,16 @@ public class CatalogAltUrlSeoTransform i
         return null;
     }
 
-    public boolean checkArg(Map args, String key, boolean defaultValue) {
+    public boolean checkArg(Map<?, ?> args, String key, boolean defaultValue) {
         if (!args.containsKey(key)) {
             return defaultValue;
-        } else {
-            Object o = args.get(key);
-            if (o instanceof SimpleScalar) {
-                SimpleScalar s = (SimpleScalar) o;
-                return "true".equalsIgnoreCase(s.getAsString());
-            }
-            return defaultValue;
         }
+        Object o = args.get(key);
+        if (o instanceof SimpleScalar) {
+            SimpleScalar s = (SimpleScalar) o;
+            return "true".equalsIgnoreCase(s.getAsString());
+        }
+        return defaultValue;
     }
 
     @Override
@@ -171,9 +169,7 @@ public class CatalogAltUrlSeoTransform i
                     } else {
                         out.write(buf.toString());
                     }
-                } catch (TemplateModelException e) {
-                    throw new IOException(e.getMessage());
-                } catch (GenericEntityException e) {
+                } catch (TemplateModelException | GenericEntityException e) {
                     throw new IOException(e.getMessage());
                 }
             }

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java?rev=1824257&r1=1824256&r2=1824257&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java
 Wed Feb 14 16:11:06 2018
@@ -65,7 +65,7 @@ import org.apache.ofbiz.entity.util.Enti
 
 public class CatalogUrlSeoTransform implements TemplateTransformModel {
     public final static String module = CatalogUrlSeoTransform.class.getName();
-    
+
     private static Map<String, String> categoryNameIdMap = null;
     private static Map<String, String> categoryIdNameMap = null;
     private static boolean categoryMapInitialed = false;
@@ -84,8 +84,8 @@ public class CatalogUrlSeoTransform impl
             Debug.logWarning(e1, module);
         }
     }
-    
-    public String getStringArg(Map args, String key) {
+
+    public String getStringArg(Map<?, ?> args, String key) {
         Object o = args.get(key);
         if (o instanceof SimpleScalar) {
             return ((SimpleScalar) o).getAsString();
@@ -99,19 +99,19 @@ public class CatalogUrlSeoTransform impl
     public Writer getWriter(final Writer out, final Map args)
             throws TemplateModelException, IOException {
         final StringBuilder buf = new StringBuilder();
-        
+
         return new Writer(out) {
-            
+
             @Override
             public void write(char[] cbuf, int off, int len) throws 
IOException {
                 buf.append(cbuf, off, len);
             }
-            
+
             @Override
             public void flush() throws IOException {
                 out.flush();
             }
-            
+
             @Override
             public void close() throws IOException {
                 try {
@@ -122,7 +122,7 @@ public class CatalogUrlSeoTransform impl
                         String currentCategoryId = getStringArg(args, 
"currentCategoryId");
                         String previousCategoryId = getStringArg(args, 
"previousCategoryId");
                         HttpServletRequest request = (HttpServletRequest) 
req.getWrappedObject();
-                        
+
                         if (!isCategoryMapInitialed()) {
                             initCategoryMap(request);
                         }
@@ -145,51 +145,51 @@ public class CatalogUrlSeoTransform impl
             }
         };
     }
-    
+
     /**
      * Check whether the category map is initialed.
-     * 
+     *
      * @return a boolean value to indicate whether the category map has been 
initialized.
      */
     public static boolean isCategoryMapInitialed() {
         return categoryMapInitialed;
     }
-    
+
     /**
      * Get the category name/id map.
-     * 
+     *
      * @return the category name/id map
      */
     public static Map<String, String> getCategoryNameIdMap() {
         return categoryNameIdMap;
     }
-    
+
     /**
      * Get the category id/name map.
-     * 
+     *
      * @return the category id/name map
      */
     public static Map<String, String> getCategoryIdNameMap() {
         return categoryIdNameMap;
     }
-    
+
     /**
      * Initial category-name/category-id map.
      * Note: as a key, the category-name should be:
      *         1. ascii
      *         2. lower cased and use hyphen between the words.
      *       If not, the category id will be used.
-     * 
+     *
      */
     public static synchronized void initCategoryMap(HttpServletRequest 
request) {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         initCategoryMap(request, delegator);
     }
-    
+
     public static synchronized void initCategoryMap(HttpServletRequest 
request, Delegator delegator) {
         if (SeoConfigUtil.checkCategoryUrl()) {
-            categoryNameIdMap = new Hashtable<String, String>();
-            categoryIdNameMap = new Hashtable<String, String>();
+            categoryNameIdMap = new Hashtable<>();
+            categoryIdNameMap = new Hashtable<>();
             Perl5Matcher matcher = new Perl5Matcher();
 
             try {
@@ -239,7 +239,7 @@ public class CatalogUrlSeoTransform impl
 
     /**
      * Make product url according to the configurations.
-     * 
+     *
      * @return String a catalog url
      */
     public static String makeProductUrl(HttpServletRequest request, String 
productId, String currentCategoryId, String previousCategoryId) {
@@ -271,7 +271,9 @@ public class CatalogUrlSeoTransform impl
             trail = CategoryWorker.adjustTrail(trail, currentCategoryId, 
previousCategoryId);
             if (!SeoConfigUtil.isCategoryUrlEnabled(contextPath)) {
                 for (String trailCategoryId: trail) {
-                    if ("TOP".equals(trailCategoryId)) continue;
+                    if ("TOP".equals(trailCategoryId)) {
+                        continue;
+                    }
                     urlBuilder.append("/");
                     urlBuilder.append(trailCategoryId);
                 }
@@ -316,17 +318,17 @@ public class CatalogUrlSeoTransform impl
                 urlBuilder.append(productId);
             }
         }
-        
+
         if (!urlBuilder.toString().endsWith("/") && 
UtilValidate.isNotEmpty(SeoConfigUtil.getCategoryUrlSuffix())) {
             urlBuilder.append(SeoConfigUtil.getCategoryUrlSuffix());
         }
-        
+
         return urlBuilder.toString();
     }
 
     /**
      * Make category url according to the configurations.
-     * 
+     *
      * @return String a category url
      */
     public static String makeCategoryUrl(HttpServletRequest request, String 
currentCategoryId, String previousCategoryId, String viewSize, String 
viewIndex, String viewSort, String searchString) {
@@ -363,7 +365,7 @@ public class CatalogUrlSeoTransform impl
         if (!urlBuilder.toString().endsWith("/") && 
UtilValidate.isNotEmpty(SeoConfigUtil.getCategoryUrlSuffix())) {
             urlBuilder.append(SeoConfigUtil.getCategoryUrlSuffix());
         }
-        
+
         // append view index
         if (UtilValidate.isNotEmpty(viewIndex)) {
             if (!urlBuilder.toString().endsWith("?") && 
!urlBuilder.toString().endsWith("&")) {
@@ -395,13 +397,13 @@ public class CatalogUrlSeoTransform impl
         if (urlBuilder.toString().endsWith("&")) {
             return urlBuilder.toString().substring(0, 
urlBuilder.toString().length()-1);
         }
-        
+
         return urlBuilder.toString();
     }
 
     /**
      * Make product url according to the configurations.
-     * 
+     *
      * @return String a catalog url
      */
     public static String makeProductUrl(String contextPath, List<String> 
trail, String productId, String productName, String currentCategoryId, String 
previousCategoryId) {
@@ -420,7 +422,9 @@ public class CatalogUrlSeoTransform impl
             trail = CategoryWorker.adjustTrail(trail, currentCategoryId, 
previousCategoryId);
             if (!SeoConfigUtil.isCategoryUrlEnabled(contextPath)) {
                 for (String trailCategoryId: trail) {
-                    if ("TOP".equals(trailCategoryId)) continue;
+                    if ("TOP".equals(trailCategoryId)) {
+                        continue;
+                    }
                     urlBuilder.append("/");
                     urlBuilder.append(trailCategoryId);
                 }
@@ -450,17 +454,17 @@ public class CatalogUrlSeoTransform impl
             }
             urlBuilder.append(productId);
         }
-        
+
         if (!urlBuilder.toString().endsWith("/") && 
UtilValidate.isNotEmpty(SeoConfigUtil.getCategoryUrlSuffix())) {
             urlBuilder.append(SeoConfigUtil.getCategoryUrlSuffix());
         }
-        
+
         return urlBuilder.toString();
     }
 
     /**
      * Get a string lower cased and hyphen connected.
-     * 
+     *
      * @param name a String to be transformed
      * @return String nice name
      */
@@ -475,7 +479,7 @@ public class CatalogUrlSeoTransform impl
         }
         return niceName;
     }
-    
+
     public static boolean forwardProductUri(HttpServletRequest request, 
HttpServletResponse response, Delegator delegator) throws ServletException, 
IOException {
         return forwardProductUri(request, response, delegator, null);
     }
@@ -515,7 +519,7 @@ public class CatalogUrlSeoTransform impl
         if (pathInfo.startsWith("/" + CatalogUrlServlet.CATEGORY_REQUEST + 
"/")) {
             return forwardCategoryUri(request, response, delegator, 
controlServlet);
         }
-        
+
         String lastPathElement = pathElements.get(pathElements.size() - 1);
         String categoryId = null;
         String productId = null;
@@ -558,19 +562,18 @@ public class CatalogUrlSeoTransform impl
                     String tempProductId = urlElements.get(i);
                     while (i >= 0) {
                         try {
-                            List<EntityExpr> exprs = new 
LinkedList<EntityExpr>();
+                            List<EntityExpr> exprs = new LinkedList<>();
                             
exprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, 
lastPathElement));
                             
exprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, 
tempProductId));
                             List<GenericValue> products = 
delegator.findList("Product", EntityCondition.makeCondition(exprs, 
EntityOperator.OR), UtilMisc.toSet("productId", "productName"), null, null, 
true);
-                            
+
                             if (products != null && products.size() > 0) {
                                 if (products.size() == 1) {
                                     productId = 
products.get(0).getString("productId");
                                     break;
-                                } else {
-                                    productId = tempProductId;
-                                    break;
                                 }
+                                productId = tempProductId;
+                                break;
                             } else if (i > 0) {
                                 tempProductId = urlElements.get(i - 1) + 
URL_HYPHEN + tempProductId;
                             }
@@ -669,7 +672,7 @@ public class CatalogUrlSeoTransform impl
 
     /**
      * This is used when building product url in services.
-     * 
+     *
      * @param delegator
      * @param wrapper
      * @param prefix
@@ -703,7 +706,9 @@ public class CatalogUrlSeoTransform impl
             trail = CategoryWorker.adjustTrail(null, currentCategoryId, 
previousCategoryId);
             if (!SeoConfigUtil.isCategoryUrlEnabled(contextPath)) {
                 for (String trailCategoryId: trail) {
-                    if ("TOP".equals(trailCategoryId)) continue;
+                    if ("TOP".equals(trailCategoryId)) {
+                        continue;
+                    }
                     urlBuilder.append("/");
                     urlBuilder.append(trailCategoryId);
                 }
@@ -747,17 +752,17 @@ public class CatalogUrlSeoTransform impl
                 urlBuilder.append(productId);
             }
         }
-        
+
         if (!urlBuilder.toString().endsWith("/") && 
UtilValidate.isNotEmpty(SeoConfigUtil.getCategoryUrlSuffix())) {
             urlBuilder.append(SeoConfigUtil.getCategoryUrlSuffix());
         }
-        
+
         return urlBuilder.toString();
     }
 
     /**
      * This is used when building category url in services.
-     * 
+     *
      * @param delegator
      * @param wrapper
      * @param prefix
@@ -801,7 +806,7 @@ public class CatalogUrlSeoTransform impl
         if (!urlBuilder.toString().endsWith("/") && 
UtilValidate.isNotEmpty(SeoConfigUtil.getCategoryUrlSuffix())) {
             urlBuilder.append(SeoConfigUtil.getCategoryUrlSuffix());
         }
-        
+
         // append view index
         if (UtilValidate.isNotEmpty(viewIndex)) {
             if (!urlBuilder.toString().endsWith("?") && 
!urlBuilder.toString().endsWith("&")) {
@@ -833,7 +838,7 @@ public class CatalogUrlSeoTransform impl
         if (urlBuilder.toString().endsWith("&")) {
             return urlBuilder.toString().substring(0, 
urlBuilder.toString().length()-1);
         }
-        
+
         return urlBuilder.toString();
     }
 }

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java?rev=1824257&r1=1824256&r2=1824257&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java
 Wed Feb 14 16:11:06 2018
@@ -51,7 +51,7 @@ import freemarker.template.TemplateTrans
 public class OfbizCatalogAltUrlTransform implements TemplateTransformModel {
     public final static String module = 
OfbizCatalogUrlTransform.class.getName();
 
-    public String getStringArg(Map args, String key) {
+    public String getStringArg(Map<?, ?> args, String key) {
         Object o = args.get(key);
         if (o instanceof SimpleScalar) {
             return ((SimpleScalar) o).getAsString();
@@ -65,17 +65,16 @@ public class OfbizCatalogAltUrlTransform
         return null;
     }
 
-    public boolean checkArg(Map args, String key, boolean defaultValue) {
+    public boolean checkArg(Map<?, ?> args, String key, boolean defaultValue) {
         if (!args.containsKey(key)) {
             return defaultValue;
-        } else {
-            Object o = args.get(key);
-            if (o instanceof SimpleScalar) {
-                SimpleScalar s = (SimpleScalar) o;
-                return "true".equalsIgnoreCase(s.getAsString());
-            }
-            return defaultValue;
         }
+        Object o = args.get(key);
+        if (o instanceof SimpleScalar) {
+            SimpleScalar s = (SimpleScalar) o;
+            return "true".equalsIgnoreCase(s.getAsString());
+        }
+        return defaultValue;
     }
 
     @Override
@@ -86,17 +85,17 @@ public class OfbizCatalogAltUrlTransform
         final boolean secure = checkArg(args, "secure", false);
 
         return new Writer(out) {
-            
+
             @Override
             public void write(char[] cbuf, int off, int len) throws 
IOException {
                 buf.append(cbuf, off, len);
             }
-            
+
             @Override
             public void flush() throws IOException {
                 out.flush();
             }
-            
+
             @Override
             public void close() throws IOException {
                 try {
@@ -106,7 +105,7 @@ public class OfbizCatalogAltUrlTransform
                     String productCategoryId = getStringArg(args, 
"productCategoryId");
                     String productId = getStringArg(args, "productId");
                     String url = "";
-                    
+
                     Object prefix = env.getVariable("urlPrefix");
                     String viewSize = getStringArg(args, "viewSize");
                     String viewIndex = getStringArg(args, "viewIndex");
@@ -144,11 +143,7 @@ public class OfbizCatalogAltUrlTransform
                     } else {
                         out.write(buf.toString());
                     }
-                } catch (TemplateModelException e) {
-                    throw new IOException(e.getMessage());
-                } catch (GenericEntityException e) {
-                    throw new IOException(e.getMessage());
-                } catch (WebAppConfigurationException e) {
+                } catch (TemplateModelException |GenericEntityException | 
WebAppConfigurationException e) {
                     throw new IOException(e.getMessage());
                 }
             }

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java?rev=1824257&r1=1824256&r2=1824257&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java
 Wed Feb 14 16:11:06 2018
@@ -35,8 +35,8 @@ import freemarker.template.TemplateTrans
 
 public class OfbizCatalogUrlTransform implements TemplateTransformModel {
     public final static String module = 
OfbizCatalogUrlTransform.class.getName();
-    
-    public String getStringArg(Map args, String key) {
+
+    public String getStringArg(Map<?, ?> args, String key) {
         Object o = args.get(key);
         if (o instanceof SimpleScalar) {
             return ((SimpleScalar) o).getAsString();

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java?rev=1824257&r1=1824256&r2=1824257&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
 Wed Feb 14 16:11:06 2018
@@ -44,23 +44,22 @@ import freemarker.template.TemplateTrans
 
 /**
  * SeoTransform - Freemarker Transform for URLs (links)
- * 
+ *
  */
 public class SeoTransform implements TemplateTransformModel {
 
     private static final String module = SeoTransform.class.getName();
 
-    public boolean checkArg(Map args, String key, boolean defaultValue) {
+    public boolean checkArg(Map<?, ?> args, String key, boolean defaultValue) {
         if (!args.containsKey(key)) {
             return defaultValue;
-        } else {
-            Object o = args.get(key);
-            if (o instanceof SimpleScalar) {
-                SimpleScalar s = (SimpleScalar) o;
-                return "true".equalsIgnoreCase(s.getAsString());
-            }
-            return defaultValue;
         }
+        Object o = args.get(key);
+        if (o instanceof SimpleScalar) {
+            SimpleScalar s = (SimpleScalar) o;
+            return "true".equalsIgnoreCase(s.getAsString());
+        }
+        return defaultValue;
     }
 
     public Writer getWriter(final Writer out, Map args) {
@@ -128,10 +127,10 @@ public class SeoTransform implements Tem
 
     /**
      * Transform a url according to seo pattern regular expressions.
-     * 
+     *
      * @param url , String to do the seo transform
      * @param isAnon , boolean to indicate whether it's an anonymous visit.
-     * 
+     *
      * @return String, the transformed url.
      */
     public static String seoUrl(String url, boolean isAnon) {
@@ -150,18 +149,17 @@ public class SeoTransform implements Tem
                     } else {
                         if (SeoConfigUtil.isJSessionIdUserEnabled()) {
                             continue;
-                        } else {
-                            boolean foundException = false;
-                            for (int i = 0; i < 
SeoConfigUtil.getUserExceptionPatterns().size(); i++) {
-                                if (matcher.matches(url, 
SeoConfigUtil.getUserExceptionPatterns().get(i))) {
-                                    foundException = true;
-                                    break;
-                                }
-                            }
-                            if (foundException) {
-                                continue;
+                        }
+                        boolean foundException = false;
+                        for (int i = 0; i < 
SeoConfigUtil.getUserExceptionPatterns().size(); i++) {
+                            if (matcher.matches(url, 
SeoConfigUtil.getUserExceptionPatterns().get(i))) {
+                                foundException = true;
+                                break;
                             }
                         }
+                        if (foundException) {
+                            continue;
+                        }
                     }
                 }
                 String replacement = 
SeoConfigUtil.getSeoReplacements().get(key);
@@ -176,7 +174,9 @@ public class SeoTransform implements Tem
                 }
             }
             if (!foundMatch) {
-                if (Debug.verboseOn()) Debug.logVerbose("Can NOT find a seo 
transform pattern for this url: " + url, module);
+                if (Debug.verboseOn()) {
+                    Debug.logVerbose("Can NOT find a seo transform pattern for 
this url: " + url, module);
+                }
             }
         }
         return url;

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java?rev=1824257&r1=1824256&r2=1824257&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java
 Wed Feb 14 16:11:06 2018
@@ -44,23 +44,22 @@ import freemarker.template.TemplateTrans
 
 /**
  * UrlRegexpTransform - Freemarker Transform for Products URLs (links)
- * 
+ *
  */
 public class UrlRegexpTransform implements TemplateTransformModel {
 
     private static final String module = UrlRegexpTransform.class.getName();
 
-    public boolean checkArg(Map args, String key, boolean defaultValue) {
+    public boolean checkArg(Map<?, ?> args, String key, boolean defaultValue) {
         if (!args.containsKey(key)) {
             return defaultValue;
-        } else {
-            Object o = args.get(key);
-            if (o instanceof SimpleScalar) {
-                SimpleScalar s = (SimpleScalar) o;
-                return "true".equalsIgnoreCase(s.getAsString());
-            }
-            return defaultValue;
         }
+        Object o = args.get(key);
+        if (o instanceof SimpleScalar) {
+            SimpleScalar s = (SimpleScalar) o;
+            return "true".equalsIgnoreCase(s.getAsString());
+        }
+        return defaultValue;
     }
 
     public Writer getWriter(final Writer out, Map args) {
@@ -128,12 +127,12 @@ public class UrlRegexpTransform implemen
 
     /**
      * Transform a url according to seo pattern regular expressions.
-     * 
+     *
      * @param url
      *            , String to do the seo transform
      * @param isAnon
      *            , boolean to indicate whether it's an anonymous visit.
-     * 
+     *
      * @return String, the transformed url.
      */
     public static String seoUrl(String url, boolean isAnon) {
@@ -152,18 +151,17 @@ public class UrlRegexpTransform implemen
                     } else {
                         if (SeoConfigUtil.isJSessionIdUserEnabled()) {
                             continue;
-                        } else {
-                            boolean foundException = false;
-                            for (int i = 0; i < 
SeoConfigUtil.getUserExceptionPatterns().size(); i++) {
-                                if (matcher.matches(url, 
SeoConfigUtil.getUserExceptionPatterns().get(i))) {
-                                    foundException = true;
-                                    break;
-                                }
-                            }
-                            if (foundException) {
-                                continue;
+                        }
+                        boolean foundException = false;
+                        for (int i = 0; i < 
SeoConfigUtil.getUserExceptionPatterns().size(); i++) {
+                            if (matcher.matches(url, 
SeoConfigUtil.getUserExceptionPatterns().get(i))) {
+                                foundException = true;
+                                break;
                             }
                         }
+                        if (foundException) {
+                            continue;
+                        }
                     }
                 }
                 String replacement = 
SeoConfigUtil.getSeoReplacements().get(key);
@@ -178,7 +176,9 @@ public class UrlRegexpTransform implemen
                 }
             }
             if (!foundMatch) {
-                if (Debug.verboseOn()) Debug.logVerbose("Can NOT find a seo 
transform pattern for this url: " + url, module);
+                if (Debug.verboseOn()) {
+                    Debug.logVerbose("Can NOT find a seo transform pattern for 
this url: " + url, module);
+                }
             }
         }
         return url;
@@ -190,7 +190,7 @@ public class UrlRegexpTransform implemen
 
     /**
      * Forward a uri according to forward pattern regular expressions. Note: 
this is developed for Filter usage.
-     * 
+     *
      * @param uri
      *            String to reverse transform
      * @return String


Reply via email to