This is an automated email from the ASF dual-hosted git repository.

mbrohl pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 502c56b3d9fb6bb5daf86bff364597d3548a6b3c
Author: Michael Brohl <michael.br...@ecomify.de>
AuthorDate: Fri Feb 2 12:19:05 2024 +0100

    Implemented: Refactored the ContentWrapper implementations to use the
    central cache key separator (OFBIZ-10194)
---
 .../java/org/apache/ofbiz/content/content/ContentWrapper.java    | 5 +++--
 .../java/org/apache/ofbiz/order/order/OrderContentWrapper.java   | 7 +++----
 .../java/org/apache/ofbiz/party/content/PartyContentWrapper.java | 1 -
 .../apache/ofbiz/product/category/CategoryContentWrapper.java    | 6 +++---
 .../ofbiz/product/config/ProductConfigItemContentWrapper.java    | 6 +++---
 .../org/apache/ofbiz/product/product/ProductContentWrapper.java  | 9 ++++-----
 .../apache/ofbiz/product/product/ProductPromoContentWrapper.java | 7 +++----
 .../ofbiz/workeffort/content/WorkEffortContentWrapper.java       | 1 -
 8 files changed, 19 insertions(+), 23 deletions(-)

diff --git 
a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWrapper.java
 
b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWrapper.java
index 5a0db6df11..86b321e404 100644
--- 
a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWrapper.java
+++ 
b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWrapper.java
@@ -37,7 +37,8 @@ import org.apache.ofbiz.entity.util.EntityUtilProperties;
 
 public interface ContentWrapper {
 
-    String MDOULE = ContentWrapper.class.getName();
+    String MODULE = ContentWrapper.class.getName();
+    static final String CACHE_KEY_SEPARATOR = "::";
 
     StringUtil.StringWrapper get(String contentTypeId, String encoderType);
 
@@ -108,7 +109,7 @@ public interface ContentWrapper {
             if (encoder != null) {
                 value = encoder.sanitize(value, null);
             } else {
-                Debug.logWarning("Unknown encoderType %s for encoding content 
value!", MDOULE, encoderType);
+                Debug.logWarning("Unknown encoderType %s for encoding content 
value!", MODULE, encoderType);
             }
         }
         return value;
diff --git 
a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
 
b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
index 06e7ae347c..940bf47fb3 100644
--- 
a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
+++ 
b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java
@@ -48,7 +48,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public class OrderContentWrapper implements ContentWrapper {
 
     private static final String MODULE = OrderContentWrapper.class.getName();
-    private static final String SEPARATOR = "::";    // cache key separator
 
     private static final UtilCache<String, String> ORDER_CONTENT_CACHE = 
UtilCache.createUtilCache(
             "order.content.rendered", true); // use soft reference to free up 
memory if needed
@@ -106,11 +105,11 @@ public class OrderContentWrapper implements 
ContentWrapper {
          * there was no content to retrieve)
          */
         /* caching: there is one cache created, "order.content"  Each order's 
content is cached with a key of
-         * contentTypeId::locale::mimeType::orderId::orderItemSeqId, or 
whatever the SEPARATOR is defined above to be.
+         * contentTypeId::locale::mimeType::orderId::orderItemSeqId, or 
whatever the CACHE_KEY_SEPARATOR is defined above to be.
          */
 
-        String cacheKey = orderContentTypeId + SEPARATOR + locale + SEPARATOR 
+ mimeTypeId + SEPARATOR + order.get(
-                "orderId") + SEPARATOR + orderItemSeqId + SEPARATOR + 
encoderType + SEPARATOR + delegator;
+        String cacheKey = orderContentTypeId + CACHE_KEY_SEPARATOR + locale + 
CACHE_KEY_SEPARATOR + mimeTypeId + CACHE_KEY_SEPARATOR + order.get(
+                "orderId") + CACHE_KEY_SEPARATOR + orderItemSeqId + 
CACHE_KEY_SEPARATOR + encoderType + CACHE_KEY_SEPARATOR + delegator;
         String cachedValue = ORDER_CONTENT_CACHE.get(cacheKey);
         if (cachedValue != null || ORDER_CONTENT_CACHE.containsKey(cacheKey)) {
             return cachedValue;
diff --git 
a/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java
 
b/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java
index 6a6c526b61..8ee3e93548 100644
--- 
a/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java
+++ 
b/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java
@@ -52,7 +52,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public class PartyContentWrapper implements ContentWrapper {
 
     private static final String MODULE = PartyContentWrapper.class.getName();
-    public static final String CACHE_KEY_SEPARATOR = "::";
 
     private static final UtilCache<String, String> PARTY_CONTENT_CACHE = 
UtilCache.createUtilCache("party.content.rendered", true);
 
diff --git 
a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
 
b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
index a4d05c6bbf..529a1d9c87 100644
--- 
a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
+++ 
b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
@@ -48,7 +48,7 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public class CategoryContentWrapper implements ContentWrapper {
 
     private static final String MODULE = 
CategoryContentWrapper.class.getName();
-    public static final String SEPARATOR = "::";    // cache key separator
+
     private static final UtilCache<String, String> CATEGORY_CONTENT_CACHE = 
UtilCache.createUtilCache(
             "category.content.rendered", true); // use soft reference to free 
up memory if needed
 
@@ -105,9 +105,9 @@ public class CategoryContentWrapper implements 
ContentWrapper {
          * Look for a previously cached entry (may also be an entry with null 
value if
          * there was no content to retrieve)
          */
-        String cacheKey = prodCatContentTypeId + SEPARATOR + locale + 
SEPARATOR + mimeTypeId + SEPARATOR
+        String cacheKey = prodCatContentTypeId + CACHE_KEY_SEPARATOR + locale 
+ CACHE_KEY_SEPARATOR + mimeTypeId + CACHE_KEY_SEPARATOR
                 + productCategory.get("productCategoryId")
-                + SEPARATOR + encoderType + SEPARATOR + delegator;
+                + CACHE_KEY_SEPARATOR + encoderType + CACHE_KEY_SEPARATOR + 
delegator;
         String cachedValue = CATEGORY_CONTENT_CACHE.get(cacheKey);
         if (cachedValue != null || 
CATEGORY_CONTENT_CACHE.containsKey(cacheKey)) {
             return cachedValue;
diff --git 
a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java
 
b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java
index 08c97d947b..2100a45c57 100644
--- 
a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java
+++ 
b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java
@@ -50,7 +50,7 @@ import org.apache.ofbiz.service.ServiceContainer;
 public class ProductConfigItemContentWrapper implements ContentWrapper {
 
     private static final String MODULE = 
ProductConfigItemContentWrapper.class.getName();
-    public static final String SEPARATOR = "::";    // cache key separator
+
     private static final UtilCache<String, String> CONFIG_ITEM_CONTENT_CACHE = 
UtilCache.createUtilCache(
             "configItem.content.rendered", true); // use soft reference to 
free up memory if needed
 
@@ -136,8 +136,8 @@ public class ProductConfigItemContentWrapper implements 
ContentWrapper {
         /* Look for a previously cached entry (may also be an entry with null 
value if
          * there was no content to retrieve)
          */
-        String cacheKey = confItemContentTypeId + SEPARATOR + locale + 
SEPARATOR + mimeTypeId + SEPARATOR
-                + productConfigItem.get("configItemId") + SEPARATOR + 
encoderType + SEPARATOR + delegator;
+        String cacheKey = confItemContentTypeId + CACHE_KEY_SEPARATOR + locale 
+ CACHE_KEY_SEPARATOR + mimeTypeId + CACHE_KEY_SEPARATOR
+                + productConfigItem.get("configItemId") + CACHE_KEY_SEPARATOR 
+ encoderType + CACHE_KEY_SEPARATOR + delegator;
         String cachedValue = CONFIG_ITEM_CONTENT_CACHE.get(cacheKey);
         if (cachedValue != null || 
CONFIG_ITEM_CONTENT_CACHE.containsKey(cacheKey)) {
             return cachedValue;
diff --git 
a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java
 
b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java
index 243a811f77..473e5d4606 100644
--- 
a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java
+++ 
b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java
@@ -48,7 +48,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public class ProductContentWrapper implements ContentWrapper {
 
     private static final String MODULE = ProductContentWrapper.class.getName();
-    public static final String SEPARATOR = "::";    // cache key separator
 
     private static final UtilCache<String, String> PRODUCT_CONTENT_CACHE = 
UtilCache.createUtilCache("product.content.rendered", true);
 
@@ -109,12 +108,12 @@ public class ProductContentWrapper implements 
ContentWrapper {
          * Look for a previously cached entry (may also be an entry with null 
value if
          * there was no content to retrieve) caching: there is one cache 
created,
          * "product.content" Each product's content is cached with a key of
-         * contentTypeId::locale::mimeType::productId, or whatever the 
SEPARATOR is
+         * contentTypeId::locale::mimeType::productId, or whatever the 
CACHE_KEY_SEPARATOR is
          * defined above to be.
          */
-        String cacheKey = productContentTypeId + SEPARATOR + locale + 
SEPARATOR + mimeTypeId + SEPARATOR + product.get(
-                "productId") + SEPARATOR
-                + encoderType + SEPARATOR + delegator;
+        String cacheKey = productContentTypeId + CACHE_KEY_SEPARATOR + locale 
+ CACHE_KEY_SEPARATOR + mimeTypeId + CACHE_KEY_SEPARATOR + product.get(
+                "productId") + CACHE_KEY_SEPARATOR
+                + encoderType + CACHE_KEY_SEPARATOR + delegator;
         String cachedValue = PRODUCT_CONTENT_CACHE.get(cacheKey);
         if (cachedValue != null || 
PRODUCT_CONTENT_CACHE.containsKey(cacheKey)) {
             return cachedValue;
diff --git 
a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java
 
b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java
index 70fcfe69e1..b3ce91881a 100644
--- 
a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java
+++ 
b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java
@@ -53,7 +53,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public class ProductPromoContentWrapper implements ContentWrapper {
 
     private static final String MODULE = 
ProductPromoContentWrapper.class.getName();
-    public static final String SEPARATOR = "::";    // cache key separator
 
     private static final UtilCache<String, String> PRODUCT_PROMO_CONTENT_CACHE 
=
             UtilCache.createUtilCache("product.promo.content.rendered", true);
@@ -116,10 +115,10 @@ public class ProductPromoContentWrapper implements 
ContentWrapper {
          * there was no content to retrieve)
          */
         /* caching: there is one cache created, "product.promo.content"  Each 
productPromo's content is cached with a key of
-         * contentTypeId::locale::mimeType::productPromoId, or whatever the 
SEPARATOR is defined above to be.
+         * contentTypeId::locale::mimeType::productPromoId, or whatever the 
CACHE_KEY_SEPARATOR is defined above to be.
          */
-        String cacheKey = productPromoContentTypeId + SEPARATOR + locale + 
SEPARATOR + mimeTypeId + SEPARATOR + productPromo.get("productPromoId")
-                + SEPARATOR + encoderType + SEPARATOR + delegator;
+        String cacheKey = productPromoContentTypeId + CACHE_KEY_SEPARATOR + 
locale + CACHE_KEY_SEPARATOR + mimeTypeId + CACHE_KEY_SEPARATOR + 
productPromo.get("productPromoId")
+                + CACHE_KEY_SEPARATOR + encoderType + CACHE_KEY_SEPARATOR + 
delegator;
         String cachedValue = PRODUCT_PROMO_CONTENT_CACHE.get(cacheKey);
         if (cachedValue != null || 
PRODUCT_PROMO_CONTENT_CACHE.containsKey(cacheKey)) {
             return cachedValue;
diff --git 
a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java
 
b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java
index 566fb6137d..0305450c45 100644
--- 
a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java
+++ 
b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java
@@ -54,7 +54,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
 public class WorkEffortContentWrapper implements ContentWrapper {
 
     private static final String MODULE = 
WorkEffortContentWrapper.class.getName();
-    public static final String CACHE_KEY_SEPARATOR = "::";
 
     private static final UtilCache<String, String> WORK_EFFORT_CONTENT_CACHE = 
UtilCache.createUtilCache("workeffort.content.rendered", true);
 

Reply via email to