Author: jleroux
Date: Wed Sep 30 21:47:15 2015
New Revision: 1706162

URL: http://svn.apache.org/viewvc?rev=1706162&view=rev
Log:
While working on r1705329 I did not notice that OrderContentWrapper was not 
using the same scheme than other *ContentWrapper (implementing ContentWrapper 
interface). This fixes it

Modified:
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderContentWrapper.java

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderContentWrapper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderContentWrapper.java?rev=1706162&r1=1706161&r2=1706162&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderContentWrapper.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderContentWrapper.java
 Wed Sep 30 21:47:15 2015
@@ -29,10 +29,13 @@ import javax.servlet.http.HttpServletReq
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilCodec;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.content.content.ContentWorker;
+import org.ofbiz.content.content.ContentWrapper;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityQuery;
@@ -42,7 +45,7 @@ import org.ofbiz.service.LocalDispatcher
  * Order Content Worker: gets order content to display
  *
  */
-public class OrderContentWrapper {
+public class OrderContentWrapper implements ContentWrapper {
 
     public static final String module = OrderContentWrapper.class.getName();
     public static final String SEPARATOR = "::";    // cache key separator
@@ -72,23 +75,25 @@ public class OrderContentWrapper {
         this.mimeTypeId = "text/html";
     }
 
-    public String get(String orderContentTypeId) {
-        return getOrderContentAsText(order, orderContentTypeId, locale, 
mimeTypeId, order.getDelegator(), dispatcher);
+    public StringUtil.StringWrapper get(String orderContentTypeId, String 
encoderType) {
+        return StringUtil.makeStringWrapper(getOrderContentAsText(order, 
orderContentTypeId, locale, mimeTypeId, order.getDelegator(), dispatcher, 
encoderType));
     }
 
-    public static String getOrderContentAsText(GenericValue order, String 
orderContentTypeId, HttpServletRequest request) {
+    public static String getOrderContentAsText(GenericValue order, String 
orderContentTypeId, HttpServletRequest request, String encoderType) {
         LocalDispatcher dispatcher = (LocalDispatcher) 
request.getAttribute("dispatcher");
-        return getOrderContentAsText(order, orderContentTypeId, 
UtilHttp.getLocale(request), "text/html", order.getDelegator(), dispatcher);
+        return getOrderContentAsText(order, orderContentTypeId, 
UtilHttp.getLocale(request), "text/html", order.getDelegator(), dispatcher, 
encoderType);
     }
 
-    public static String getOrderContentAsText(GenericValue order, String 
orderContentTypeId, Locale locale, LocalDispatcher dispatcher) {
-        return getOrderContentAsText(order, orderContentTypeId, locale, null, 
null, dispatcher);
+    public static String getOrderContentAsText(GenericValue order, String 
orderContentTypeId, Locale locale, LocalDispatcher dispatcher, String 
encoderType) {
+        return getOrderContentAsText(order, orderContentTypeId, locale, null, 
null, dispatcher, encoderType);
     }
 
-    public static String getOrderContentAsText(GenericValue order, String 
orderContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, 
LocalDispatcher dispatcher) {
+    public static String getOrderContentAsText(GenericValue order, String 
orderContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, 
LocalDispatcher dispatcher, String encoderType) {
         /* 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.
          */
+        UtilCodec.SimpleEncoder encoder = UtilCodec.getEncoder(encoderType);
+
         String orderItemSeqId = (order.getEntityName().equals("OrderItem")? 
order.getString("orderItemSeqId"): "_NA_");
 
         String cacheKey = orderContentTypeId + SEPARATOR + locale + SEPARATOR 
+ mimeTypeId + SEPARATOR + order.get("orderId") + SEPARATOR + orderItemSeqId;
@@ -102,7 +107,7 @@ public class OrderContentWrapper {
             getOrderContentAsText(null, null, order, orderContentTypeId, 
locale, mimeTypeId, delegator, dispatcher, outWriter);
             String outString = outWriter.toString();
             if (outString.length() > 0) {
-                outString = orderContentCache.putIfAbsentAndGet(cacheKey, 
outString);
+                outString = orderContentCache.putIfAbsentAndGet(cacheKey, 
encoder.encode(outString));
             }
             return outString;
 


Reply via email to