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/06/28 14:36:05 UTC

svn commit: r1750525 - /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java

Author: arunpatidar
Date: Tue Jun 28 14:36:05 2016
New Revision: 1750525

URL: http://svn.apache.org/viewvc?rev=1750525&view=rev
Log:
Applied patch from jira issue - OFBIZ-7433 - Enforce noninstantiability to UtilCacheEvents Class. Thanks Rahul Singh for your contribution.

Modified:
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java?rev=1750525&r1=1750524&r2=1750525&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/UtilCacheEvents.java Tue Jun 28 14:36:05 2016
@@ -34,9 +34,11 @@ import org.ofbiz.security.Security;
 /**
  * Contains events for the UtilCache class; must be external to access security resources
  */
-public class UtilCacheEvents {
+public final class UtilCacheEvents {
 
-    public static final String err_resource = "WebtoolsErrorUiLabels";
+    private static final String err_resource = "WebtoolsErrorUiLabels";
+
+    private UtilCacheEvents() {}
 
     /** An HTTP WebEvent handler the specified element from the specified cache
      * @param request The HTTP request object for the current JSP or Servlet request.
@@ -49,21 +51,21 @@ public class UtilCacheEvents {
 
         Security security = (Security) request.getAttribute("security");
         if (!security.hasPermission("UTIL_CACHE_EDIT", request.getSession())) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
         String name = request.getParameter("UTIL_CACHE_NAME");
         if (name == null) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCacheEvents.noCacheNameSpecified", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCacheEvents.noCacheNameSpecified", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
         String numString = request.getParameter("UTIL_CACHE_ELEMENT_NUMBER");
 
         if (numString == null) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCacheEvents.noElementNumberSpecified", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCacheEvents.noElementNumberSpecified", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", "");
             return "error";
         }
@@ -95,15 +97,15 @@ public class UtilCacheEvents {
 
             if (key != null) {
                 utilCache.remove(key);
-                errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.removeElementWithKey", UtilMisc.toMap("key", key.toString()), locale) + ".";
+                errMsg = UtilProperties.getMessage(err_resource, "utilCache.removeElementWithKey", UtilMisc.toMap("key", key.toString()), locale) + ".";
                 request.setAttribute("_EVENT_MESSAGE_", errMsg);
             } else {
-                errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotRemoveElementNumber", UtilMisc.toMap("name", name, "numString", numString), locale) + ".";
+                errMsg = UtilProperties.getMessage(err_resource, "utilCache.couldNotRemoveElementNumber", UtilMisc.toMap("name", name, "numString", numString), locale) + ".";
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
         } else {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotRemoveElement", UtilMisc.toMap("name", name), locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCache.couldNotRemoveElement", UtilMisc.toMap("name", name), locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
@@ -121,7 +123,7 @@ public class UtilCacheEvents {
 
         Security security = (Security) request.getAttribute("security");
         if (!security.hasPermission("UTIL_CACHE_EDIT", request.getSession())) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
@@ -129,7 +131,7 @@ public class UtilCacheEvents {
         String name = request.getParameter("UTIL_CACHE_NAME");
 
         if (name == null) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotClearCache", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCache.couldNotClearCache", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
@@ -137,10 +139,10 @@ public class UtilCacheEvents {
 
         if (utilCache != null) {
             utilCache.clear();
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.clearCache", UtilMisc.toMap("name", name), locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCache.clearCache", UtilMisc.toMap("name", name), locale) + ".";
             request.setAttribute("_EVENT_MESSAGE_", errMsg);
         } else {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotClearCacheNotFoundName", UtilMisc.toMap("name", name), locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCache.couldNotClearCacheNotFoundName", UtilMisc.toMap("name", name), locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
@@ -158,13 +160,13 @@ public class UtilCacheEvents {
 
         Security security = (Security) request.getAttribute("security");
         if (!security.hasPermission("UTIL_CACHE_EDIT", request.getSession())) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
         UtilCache.clearAllCaches();
-        errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.clearAllCaches", locale);
+        errMsg = UtilProperties.getMessage(err_resource, "utilCache.clearAllCaches", locale);
         request.setAttribute("_EVENT_MESSAGE_", errMsg + " (" + UtilDateTime.nowDateString("yyyy-MM-dd HH:mm:ss")  + ").");
         return "success";
     }
@@ -180,7 +182,7 @@ public class UtilCacheEvents {
 
         Security security = (Security) request.getAttribute("security");
         if (!security.hasPermission("UTIL_CACHE_EDIT", request.getSession())) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCacheEvents.permissionEdit", locale) + ".";
             request.setAttribute("_EVENT_MESSAGE_", errMsg);
             return "error";
         }
@@ -188,7 +190,7 @@ public class UtilCacheEvents {
         String name = request.getParameter("UTIL_CACHE_NAME");
 
         if (name == null) {
-            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotUpdateCacheSetting", locale) + ".";
+            errMsg = UtilProperties.getMessage(err_resource, "utilCache.couldNotUpdateCacheSetting", locale) + ".";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }