svn commit: r1750520 - in /ofbiz/trunk/applications/product/src/org/ofbiz/product/category: SeoConfigUtil.java SeoContextFilter.java UrlRegexpContextFilter.java ftl/UrlRegexpTransform.java

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

svn commit: r1750520 - in /ofbiz/trunk/applications/product/src/org/ofbiz/product/category: SeoConfigUtil.java SeoContextFilter.java UrlRegexpContextFilter.java ftl/UrlRegexpTransform.java

Arun Patidar-4
Author: arunpatidar
Date: Tue Jun 28 14:22:31 2016
New Revision: 1750520

URL: http://svn.apache.org/viewvc?rev=1750520&view=rev
Log:
Applied patch from jira issue - OFBIZ-7426 - Enforce noninstantiability to SeoConfigUtil Class. Thanks Rishi Solanki and  Anurag Chandak for your contribution.

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoConfigUtil.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/UrlRegexpContextFilter.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/ftl/UrlRegexpTransform.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoConfigUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoConfigUtil.java?rev=1750520&r1=1750519&r2=1750520&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoConfigUtil.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoConfigUtil.java Tue Jun 28 14:22:31 2016
@@ -48,14 +48,14 @@ import org.xml.sax.SAXException;
  * SeoConfigUtil - SEO Configuration file utility.
  *
  */
-public class SeoConfigUtil {
+public final class SeoConfigUtil {
     private static final String module = SeoConfigUtil.class.getName();
     private static Perl5Compiler perlCompiler = new Perl5Compiler();
     private static boolean isInitialed = false;
     private static boolean categoryUrlEnabled = true;
     private static boolean categoryNameEnabled = false;
     private static String categoryUrlSuffix = null;
-    public static final String DEFAULT_REGEXP = "^.*/.*$";
+    private static final String DEFAULT_REGEXP = "^.*/.*$";
     private static Pattern regexpIfMatch = null;
     private static boolean useUrlRegexp = false;
     private static boolean jSessionIdAnonEnabled = false;
@@ -68,33 +68,35 @@ public class SeoConfigUtil {
     private static List<Pattern> userExceptionPatterns = null;
     private static Set<String> allowedContextPaths = null;
     private static Map<String, String> specialProductIds = null;
-    public static final String ELEMENT_REGEXPIFMATCH = "regexpifmatch";
-    public static final String ELEMENT_URL_CONFIG = "url-config";
-    public static final String ELEMENT_DESCRIPTION = "description";
-    public static final String ELEMENT_FORWARD = "forward";
-    public static final String ELEMENT_SEO = "seo";
-    public static final String ELEMENT_URLPATTERN = "url-pattern";
-    public static final String ELEMENT_REPLACEMENT = "replacement";
-    public static final String ELEMENT_RESPONSECODE = "responsecode";
-    public static final String ELEMENT_JSESSIONID = "jsessionid";
-    public static final String ELEMENT_ANONYMOUS = "anonymous";
-    public static final String ELEMENT_VALUE = "value";
-    public static final String ELEMENT_USER = "user";
-    public static final String ELEMENT_EXCEPTIONS = "exceptions";
-    public static final String ELEMENT_CHAR_FILTERS = "char-filters";
-    public static final String ELEMENT_CHAR_FILTER = "char-filter";
-    public static final String ELEMENT_CHARACTER_PATTERN = "character-pattern";
-    public static final String ELEMENT_CATEGORY_URL = "category-url";
-    public static final String ELEMENT_ALLOWED_CONTEXT_PATHS = "allowed-context-paths";
-    public static final String ELEMENT_CATEGORY_NAME = "category-name";
-    public static final String ELEMENT_CATEGORY_URL_SUFFIX = "category-url-suffix";
-    public static final String SEO_CONFIG_FILENAME = "SeoConfig.xml";
-    public static final int DEFAULT_RESPONSECODE = HttpServletResponse.SC_MOVED_PERMANENTLY;
-    public static final String DEFAULT_ANONYMOUS_VALUE = "disable";
-    public static final String DEFAULT_USER_VALUE = "disable";
-    public static final String DEFAULT_CATEGORY_URL_VALUE = "enable";
-    public static final String DEFAULT_CATEGORY_NAME_VALUE = "disable";
-    public static final String ALLOWED_CONTEXT_PATHS_SEPERATOR = ":";
+    private static final String ELEMENT_REGEXPIFMATCH = "regexpifmatch";
+    private static final String ELEMENT_URL_CONFIG = "url-config";
+    private static final String ELEMENT_DESCRIPTION = "description";
+    private static final String ELEMENT_FORWARD = "forward";
+    private static final String ELEMENT_SEO = "seo";
+    private static final String ELEMENT_URLPATTERN = "url-pattern";
+    private static final String ELEMENT_REPLACEMENT = "replacement";
+    private static final String ELEMENT_RESPONSECODE = "responsecode";
+    private static final String ELEMENT_JSESSIONID = "jsessionid";
+    private static final String ELEMENT_ANONYMOUS = "anonymous";
+    private static final String ELEMENT_VALUE = "value";
+    private static final String ELEMENT_USER = "user";
+    private static final String ELEMENT_EXCEPTIONS = "exceptions";
+    private static final String ELEMENT_CHAR_FILTERS = "char-filters";
+    private static final String ELEMENT_CHAR_FILTER = "char-filter";
+    private static final String ELEMENT_CHARACTER_PATTERN = "character-pattern";
+    private static final String ELEMENT_CATEGORY_URL = "category-url";
+    private static final String ELEMENT_ALLOWED_CONTEXT_PATHS = "allowed-context-paths";
+    private static final String ELEMENT_CATEGORY_NAME = "category-name";
+    private static final String ELEMENT_CATEGORY_URL_SUFFIX = "category-url-suffix";
+    private static final String SEO_CONFIG_FILENAME = "SeoConfig.xml";
+    private static final int DEFAULT_RESPONSECODE = HttpServletResponse.SC_MOVED_PERMANENTLY;
+    private static final String DEFAULT_ANONYMOUS_VALUE = "disable";
+    private static final String DEFAULT_USER_VALUE = "disable";
+    private static final String DEFAULT_CATEGORY_URL_VALUE = "enable";
+    private static final String DEFAULT_CATEGORY_NAME_VALUE = "disable";
+    private static final String ALLOWED_CONTEXT_PATHS_SEPERATOR = ":";
+
+    private SeoConfigUtil() {}
 
     /**
      * Initialize url regular express configuration.
@@ -532,4 +534,8 @@ public class SeoConfigUtil {
     public static String getSpecialProductId(String productId) {
         return specialProductIds.get(productId);
     }
+
+    public static int getDefaultResponseCode() {
+        return DEFAULT_RESPONSECODE;
+    }
 }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java?rev=1750520&r1=1750519&r2=1750520&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/SeoContextFilter.java Tue Jun 28 14:22:31 2016
@@ -276,7 +276,7 @@ public class SeoContextFilter extends Co
                         rd.forward(request, response);
                     } else {
                         // redirect with url change in browser
-                        httpResponse.setStatus(SeoConfigUtil.DEFAULT_RESPONSECODE);
+                        httpResponse.setStatus(SeoConfigUtil.getDefaultResponseCode());
                         httpResponse.setHeader("Location", redirectPath);
                     }
                 }
@@ -386,7 +386,7 @@ public class SeoContextFilter extends Co
 
         if (foundMatch) {
             if (responseCodeInt == null) {
-                response.setStatus(SeoConfigUtil.DEFAULT_RESPONSECODE);
+                response.setStatus(SeoConfigUtil.getDefaultResponseCode());
             } else {
                 response.setStatus(responseCodeInt.intValue());
             }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/UrlRegexpContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/UrlRegexpContextFilter.java?rev=1750520&r1=1750519&r2=1750520&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/UrlRegexpContextFilter.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/UrlRegexpContextFilter.java Tue Jun 28 14:22:31 2016
@@ -243,7 +243,7 @@ public class UrlRegexpContextFilter exte
                         rd.forward(request, response);
                     } else {
                         // redirect with url change in browser
-                        httpResponse.setStatus(SeoConfigUtil.DEFAULT_RESPONSECODE);
+                        httpResponse.setStatus(SeoConfigUtil.getDefaultResponseCode());
                         httpResponse.setHeader("Location", redirectPath);
                     }
                 }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/ftl/UrlRegexpTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/ftl/UrlRegexpTransform.java?rev=1750520&r1=1750519&r2=1750520&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/ftl/UrlRegexpTransform.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/ftl/UrlRegexpTransform.java Tue Jun 28 14:22:31 2016
@@ -218,7 +218,7 @@ public class UrlRegexpTransform implemen
         }
         if (foundMatch) {
             if (responseCodeInt == null) {
-                response.setStatus(SeoConfigUtil.DEFAULT_RESPONSECODE);
+                response.setStatus(SeoConfigUtil.getDefaultResponseCode());
             } else {
                 response.setStatus(responseCodeInt.intValue());
             }