Improved: Refactor ContentWorkerInterface methods signatures
(OFBIZ-9164)

While working on OFBIZ-6919 which was built on R13.07 I stumbled upon an issue 
due to r1652852 where Adrian improved the cacheKey in 
FormFactory.getFormFromLocation() by adding a delegator reference (Tenants). 

Actually I'm not even sure it was done at r1652852 because Adrian did not 
maintain the FormFactory svn history.

Anyway, to make a long story short I had to introduce a DispatchContext 
parameter when calling FormFactory.readFormDocument() when the code from 
R13.07 only passed a null.

This had an impact in the hierarchy tree because FormFactory.readFormDocument() 
was called in DataResourceWorker class, where the new code was called 
from renderDataResourceAsText(). 

So I instead of only passing a Delegator I decided to pass only a 
LocalDispatcher parameter in renderDataResourceAsText(), since we can get the 
Delegator  from the LocalDispatcher. Doing so it had an impact on the 
renderDataResourceAsText hierarchy tree ending in DataResourceWorkerInterface 
and all related.

I finally decided to apply the same "Change Method Signature" refactoring 
pattern (http://refactoring.com/catalog/addParameter.html) to all cases 
related to ContentWorkerInterface. No need to pass a delegator when you have 
LocalDispatcher!

Since last commit and revert I fixed 5 test failures and improved the code more,
 mostly formatting, comments, etc.

There are very ugly method signatures out there which still need refactoring,
but it's so much work...

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1777297 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java
index 1b13784..81065d6 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java
@@ -117,7 +117,7 @@
                 String sub = null;
                 try {
                     Map<String, Object> dummy = new HashMap<String, Object>();
-                    sub = ContentWorker.renderSubContentAsText(dispatcher, delegator, v.getString("contentId"), mapKey, dummy, locale, mimeTypeId, true);
+                    sub = ContentWorker.renderSubContentAsText(dispatcher, v.getString("contentId"), mapKey, dummy, locale, mimeTypeId, true);
                 } catch (GeneralException e) {
                     Debug.logError(e, module);
                 } catch (IOException e) {
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
index 7bde4f8..18db23a 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
@@ -105,7 +105,7 @@
                 writer = response.getWriter();
                 GenericValue webSiteContent = EntityQuery.use(delegator).from("WebSiteContent").where("webSiteId", webSiteId, "webSiteContentTypeId", "MAINTENANCE_PAGE").filterByDate().queryFirst();
                 if (webSiteContent != null) {
-                    ContentWorker.renderContentAsText(dispatcher, delegator, webSiteContent.getString("contentId"), writer, null, locale, "text/html", null, null, true);
+                    ContentWorker.renderContentAsText(dispatcher, webSiteContent.getString("contentId"), writer, null, locale, "text/html", null, null, true);
                     return "success";
                 } else {
                     request.setAttribute("_ERROR_MESSAGE_", "Not able to display maintenance page for [" + webSiteId + "]");
@@ -295,11 +295,11 @@
                     List<GenericValue> webAnalytics = EntityQuery.use(delegator).from("WebAnalyticsConfig").where("webSiteId", webSiteId).queryList();
                     // render
                     if (UtilValidate.isNotEmpty(webAnalytics) && hasErrorPage) {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, contentId, writer, templateMap, locale, "text/html", null, null, true, webAnalytics);
+                        ContentWorker.renderContentAsText(dispatcher, contentId, writer, templateMap, locale, "text/html", null, null, true, webAnalytics);
                     } else if (UtilValidate.isEmpty(mapKey)) {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, contentId, writer, templateMap, locale, "text/html", null, null, true);
+                        ContentWorker.renderContentAsText(dispatcher, contentId, writer, templateMap, locale, "text/html", null, null, true);
                     } else {
-                        ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, writer, mapKey, templateMap, locale, "text/html", true);
+                        ContentWorker.renderSubContentAsText(dispatcher, contentId, writer, mapKey, templateMap, locale, "text/html", true);
                     }
 
                 } catch (TemplateException e) {
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java
index 5867f5c..63705fe 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java
@@ -209,7 +209,7 @@
     public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, Delegator delegator, GenericValue content) {
         Map<String, Object> drContext = UtilMisc.<String, Object>toMap("content", content);
         try {
-            String contentText = DataResourceWorker.renderDataResourceAsText(delegator, drView.getString("dataResourceId"), drContext, null, null, false);
+            String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, drView.getString("dataResourceId"), drContext, null, null, false);
             for (int i = 0; i < weight; i++) {
                 strings.add(contentText);
             }
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
index 2664e05..a6f51fe 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java
@@ -99,9 +99,9 @@
         init();
     }
 
-    private ContentMapFacade(LocalDispatcher dispatcher, Delegator delegator, String contentId, Map<String, Object> context, Locale locale, String mimeTypeId, boolean cache) {
+    private ContentMapFacade(LocalDispatcher dispatcher, String contentId, Map<String, Object> context, Locale locale, String mimeTypeId, boolean cache) {
         this.dispatcher = dispatcher;
-        this.delegator = delegator;
+        this.delegator = dispatcher.getDelegator();
         this.contentId = contentId;
         this.context = context;
         this.locale = locale;
@@ -109,9 +109,9 @@
         this.cache = cache;
         try {
             if (cache) {
-                this.value = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
+                this.value = EntityQuery.use(this.delegator).from("Content").where("contentId", contentId).cache().queryOne();
             } else {
-                this.value = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
+                this.value = EntityQuery.use(this.delegator).from("Content").where("contentId", contentId).queryOne();
             }
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
@@ -254,13 +254,12 @@
                 // so we're only looking for a direct alias using contentId
                 if (webSiteId != null && delegator != null) {
                     try {
-                    	
                         GenericValue webSitePathAlias = EntityQuery.use(delegator).from("WebSitePathAlias")
-                                .where("mapKey", null,
-                                        "webSiteId", webSiteId,
-                                        "contentId", this.contentId)
+                                .where("mapKey", null, "webSiteId", webSiteId,"contentId", this.contentId)
                                 .orderBy("-fromDate")
-                                .cache().filterByDate().queryFirst();
+                                .cache()
+                                .filterByDate()
+                                .queryFirst();
                         if (webSitePathAlias != null) {
                             contentUri = webSitePathAlias.getString("pathAlias");
                         }
@@ -300,7 +299,7 @@
             }
             if (subs != null) {
                 for (GenericValue v: subs) {
-                    subContent.add(new ContentMapFacade(dispatcher, delegator, v.getString("contentId"), context, locale, mimeType, cache));
+                    subContent.add(new ContentMapFacade(dispatcher, v.getString("contentId"), context, locale, mimeType, cache));
                 }
             }
             return subContent;
@@ -339,7 +338,7 @@
         }
 
         try {
-            return ContentWorker.renderContentAsText(dispatcher, delegator, contentId, renderCtx, locale, mimeType, cache);
+            return ContentWorker.renderContentAsText(dispatcher, contentId, renderCtx, locale, mimeType, cache);
         } catch (GeneralException e) {
             Debug.logError(e, module);
             return e.toString();
@@ -432,7 +431,7 @@
                 Debug.logError(e, module);
             }
             if (content != null) {
-                return new ContentMapFacade(dispatcher, delegator, content.getString("contentId"), context, locale, mimeType, cache);
+                return new ContentMapFacade(dispatcher, content.getString("contentId"), context, locale, mimeType, cache);
             }
 
             return null;
@@ -471,7 +470,7 @@
                 Debug.logError(e, module);
             }
             if (sub != null) {
-                return new ContentMapFacade(dispatcher, delegator, sub.getString("contentId"), context, locale, mimeType, cache);
+                return new ContentMapFacade(dispatcher, sub.getString("contentId"), context, locale, mimeType, cache);
             }
 
             return null;
@@ -533,7 +532,7 @@
             } else if ("render".equalsIgnoreCase(name)) {
                 // render just the dataresource
                 try {
-                    return DataResourceWorker.renderDataResourceAsText(delegator, value.getString("dataResourceId"), context, locale, mimeType, cache);
+                    return DataResourceWorker.renderDataResourceAsText(dispatcher, delegator, value.getString("dataResourceId"), context, locale, mimeType, cache);
                 } catch (GeneralException e) {
                     Debug.logError(e, module);
                     return e.toString();
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java
index 2ea7c4c..f017a12 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java
@@ -846,7 +846,7 @@
         }
 
         try {
-            ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, outWriter, mapKey, templateContext, locale, mimeTypeId, true);
+            ContentWorker.renderSubContentAsText(dispatcher, contentId, outWriter, mapKey, templateContext, locale, mimeTypeId, true);
             out.write(outWriter.toString());
             results.put("textData", outWriter.toString());
         } catch (GeneralException e) {
@@ -896,7 +896,7 @@
         }
 
         try {
-            ContentWorker.renderContentAsText(dispatcher, delegator, contentId, outWriter, templateContext, locale, mimeTypeId, null, null, true);
+            ContentWorker.renderContentAsText(dispatcher, contentId, outWriter, templateContext, locale, mimeTypeId, null, null, true);
             if (out != null) out.write(outWriter.toString());
             results.put("textData", outWriter.toString());
         } catch (GeneralException e) {
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java
index 8f3df0c..049e6eb 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java
@@ -93,23 +93,23 @@
 
     // new rendering methods
     @Override
-    public void renderContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
-        renderContentAsText(dispatcher, delegator, contentId, out, templateContext, locale, mimeTypeId, null, null, cache);
+    public void renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+        renderContentAsText(dispatcher, contentId, out, templateContext, locale, mimeTypeId, null, null, cache);
     }
 
     @Override
-    public void renderSubContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
-        renderSubContentAsText(dispatcher, delegator, contentId, out, mapKey, templateContext, locale, mimeTypeId, cache);
+    public void renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+        renderSubContentAsText(dispatcher, contentId, out, mapKey, templateContext, locale, mimeTypeId, cache);
     }
 
     @Override
-    public String renderSubContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
-        return renderSubContentAsText(dispatcher, delegator, contentId, mapKey, templateContext, locale, mimeTypeId, cache);
+    public String renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+        return renderSubContentAsText(dispatcher, contentId, mapKey, templateContext, locale, mimeTypeId, cache);
     }
 
     @Override
-    public String renderContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
-        return renderContentAsText(dispatcher, delegator, contentId, templateContext, locale, mimeTypeId, cache);
+    public String renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+        return renderContentAsText(dispatcher, contentId, templateContext, locale, mimeTypeId, cache);
     }
 
     // -------------------------------------
@@ -183,10 +183,11 @@
         return content;
     }
 
-    public static void renderContentAsText(LocalDispatcher dispatcher, Delegator delegator, GenericValue content, Appendable out,
-            Map<String,Object>templateContext, Locale locale, String mimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
+    public static void renderContentAsText(LocalDispatcher dispatcher, GenericValue content, Appendable out, Map<String,Object>templateContext,
+            Locale locale, String mimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
         // if the content has a service attached run the service
 
+        Delegator delegator = dispatcher.getDelegator();
         String serviceName = content.getString("serviceName"); //Kept for backward compatibility
         GenericValue custMethod = null;
         if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) {
@@ -254,7 +255,7 @@
             facade.setIsDecorated(true);
             templateContext.put("decoratedContent", facade); // decorated content
             templateContext.put("thisContent", decFacade); // decorator content
-            ContentWorker.renderContentAsText(dispatcher, delegator, contentDecoratorId, out, templateContext, locale, mimeTypeId, null, null, cache);
+            ContentWorker.renderContentAsText(dispatcher, contentDecoratorId, out, templateContext, locale, mimeTypeId, null, null, cache);
         } else {
             // get the data resource info
             String templateDataResourceId = content.getString("templateDataResourceId");
@@ -276,16 +277,15 @@
                 }
                 
                 if (UtilValidate.isNotEmpty(webAnalytics)) {
-                    DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, mimeTypeId, cache, webAnalytics);
+                    DataResourceWorker.renderDataResourceAsText(dispatcher, delegator, dataResourceId, out, templateContext, locale, mimeTypeId, cache, webAnalytics);
                 } else {
-                    DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, mimeTypeId, cache);
+                    DataResourceWorker.renderDataResourceAsText(dispatcher, dataResourceId, out, templateContext, locale, mimeTypeId, cache);
                 }
 
             // there is a template; render the data and then the template
             } else {
                 Writer dataWriter = new StringWriter();
-                DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, dataWriter,
-                        templateContext, locale, mimeTypeId, cache);
+                DataResourceWorker.renderDataResourceAsText(dispatcher, dataResourceId, dataWriter, templateContext, locale, mimeTypeId, cache);
 
                 String textData = dataWriter.toString();
                 if (textData != null) {
@@ -326,53 +326,56 @@
                 }
 
                 // render the template
-                DataResourceWorker.renderDataResourceAsText(delegator, templateDataResourceId, out, templateContext, locale, mimeTypeId, cache);
+                DataResourceWorker.renderDataResourceAsText(dispatcher, templateDataResourceId, out, templateContext, locale, mimeTypeId, cache);
             }
         }
     }
 
-    public static String renderContentAsText(LocalDispatcher dispatcher, Delegator delegator, String contentId, Map<String, Object> templateContext,
-            Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+    public static String renderContentAsText(LocalDispatcher dispatcher, String contentId, Map<String, Object> templateContext, Locale locale,
+            String mimeTypeId, boolean cache) throws GeneralException, IOException {
         Writer writer = new StringWriter();
-        renderContentAsText(dispatcher, delegator, contentId, writer, templateContext, locale, mimeTypeId, null, null, cache);
+        renderContentAsText(dispatcher, contentId, writer, templateContext, locale, mimeTypeId, null, null, cache);
         String rendered = writer.toString();
         // According to https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#XSS_Prevention_Rules_Summary
-        // Normally head should be protected by X-XSS-Protection Response Header by default
-        if ((rendered.contains("<script>")
+        // Normally head is protected by X-XSS-Protection Response Header by default
+        if (rendered.contains("<script>")
                 || rendered.contains("<!--")
                 || rendered.contains("<div")
                 || rendered.contains("<style>")
                 || rendered.contains("<span")
                 || rendered.contains("<input")
                 || rendered.contains("<iframe")
-                || rendered.contains("<a"))) {
+                || rendered.contains("<a")) {
             rendered = encoder.sanitize(rendered);
         }
         return rendered; 
     }
 
-    public static String renderContentAsText(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out,
-            Map<String, Object> templateContext, Locale locale, String mimeTypeId, String partyId, String roleTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
+    public static String renderContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext,
+            Locale locale, String mimeTypeId, String partyId, String roleTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
+        Delegator delegator = dispatcher.getDelegator();
         GenericValue content = ContentWorker.findContentForRendering(delegator, contentId, locale, partyId, roleTypeId, cache);
-        ContentWorker.renderContentAsText(dispatcher, delegator, content, out, templateContext, locale, mimeTypeId, cache, webAnalytics);
+        ContentWorker.renderContentAsText(dispatcher, content, out, templateContext, locale, mimeTypeId, cache, webAnalytics);
         return out.toString();
     }
 
-    public static void renderContentAsText(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out,
-            Map<String, Object> templateContext, Locale locale, String mimeTypeId, String partyId, String roleTypeId, boolean cache) throws GeneralException, IOException {
+    public static void renderContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext,
+            Locale locale, String mimeTypeId, String partyId, String roleTypeId, boolean cache) throws GeneralException, IOException {
+        Delegator delegator = dispatcher.getDelegator();
         GenericValue content = ContentWorker.findContentForRendering(delegator, contentId, locale, partyId, roleTypeId, cache);
-        ContentWorker.renderContentAsText(dispatcher, delegator, content, out, templateContext, locale, mimeTypeId, cache, null);
+        ContentWorker.renderContentAsText(dispatcher, content, out, templateContext, locale, mimeTypeId, cache, null);
     }
 
-    public static String renderSubContentAsText(LocalDispatcher dispatcher, Delegator delegator, String contentId, String mapKey, Map<String, Object> templateContext,
-            Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+    public static String renderSubContentAsText(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale,
+            String mimeTypeId, boolean cache) throws GeneralException, IOException {
         Writer writer = new StringWriter();
-        renderSubContentAsText(dispatcher, delegator, contentId, writer, mapKey, templateContext, locale, mimeTypeId, cache);
+        renderSubContentAsText(dispatcher, contentId, writer, mapKey, templateContext, locale, mimeTypeId, cache);
         return writer.toString();
     }
 
-    public static void renderSubContentAsText(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out, String mapKey,
-            Map<String,Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+    public static void renderSubContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String,Object> templateContext,
+            Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException {
+        Delegator delegator = dispatcher.getDelegator();
 
         // find the sub-content with matching mapKey
         List<EntityCondition> exprs = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId));
@@ -389,7 +392,7 @@
         } else {
             String subContentId = subContent.getString("contentIdTo");
             templateContext.put("mapKey", mapKey);
-            renderContentAsText(dispatcher, delegator, subContentId, out, templateContext, locale, mimeTypeId, null, null, cache);
+            renderContentAsText(dispatcher, subContentId, out, templateContext, locale, mimeTypeId, null, null, cache);
         }
     }
 
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
index 76e891e..eac98f2 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java
@@ -39,6 +39,7 @@
 import java.util.TreeMap;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
@@ -49,13 +50,13 @@
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.apache.tika.Tika;
 import org.apache.ofbiz.base.location.FlexibleLocation;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.FileUtil;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.StringUtil;
 import org.apache.ofbiz.base.util.StringUtil.StringWrapper;
+import org.apache.ofbiz.base.util.UtilCodec;
 import org.apache.ofbiz.base.util.UtilGenerics;
 import org.apache.ofbiz.base.util.UtilHttp;
 import org.apache.ofbiz.base.util.UtilIO;
@@ -71,15 +72,21 @@
 import org.apache.ofbiz.entity.Delegator;
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.model.ModelReader;
 import org.apache.ofbiz.entity.util.EntityQuery;
 import org.apache.ofbiz.entity.util.EntityUtilProperties;
 import org.apache.ofbiz.service.GenericServiceException;
 import org.apache.ofbiz.service.LocalDispatcher;
+import org.apache.ofbiz.widget.model.FormFactory;
+import org.apache.ofbiz.widget.model.ModelForm;
 import org.apache.ofbiz.widget.model.ModelScreen;
 import org.apache.ofbiz.widget.model.ScreenFactory;
+import org.apache.ofbiz.widget.renderer.FormRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
+import org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer;
 import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer;
+import org.apache.tika.Tika;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
@@ -92,6 +99,7 @@
 
     public static final String module = DataResourceWorker.class.getName();
     public static final String err_resource = "ContentErrorUiLabels";
+    private static final String formrenderer = UtilProperties.getPropertyValue("widget", "screen.formrenderer");
 
     /**
      * Traverses the DataCategory parent/child structure and put it in categoryNode. Returns non-null error string if there is an error.
@@ -584,21 +592,24 @@
         }
     }
 
-    public static String renderDataResourceAsText(Delegator delegator, String dataResourceId, Map<String, Object> templateContext,
+    public static String renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId, Map<String, Object> templateContext,
              Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
         Writer writer = new StringWriter();
-        renderDataResourceAsText(delegator, dataResourceId, writer, templateContext, locale, targetMimeTypeId, cache, null);
+        renderDataResourceAsText(dispatcher, delegator, dataResourceId, writer, templateContext, locale, targetMimeTypeId, cache, null);
         return writer.toString();
     }
 
-    public static String renderDataResourceAsText(Delegator delegator, String dataResourceId, Appendable out,
+    public static String renderDataResourceAsText(LocalDispatcher dispatcher, String dataResourceId, Appendable out,
             Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
-       renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, cache, null);
+       renderDataResourceAsText(dispatcher, null, dataResourceId, out, templateContext, locale, targetMimeTypeId, cache, null);
        return out.toString();
    }
 
-    public static void renderDataResourceAsText(Delegator delegator, String dataResourceId, Appendable out,
-            Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
+    public static void renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId,
+            Appendable out, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
+        if (delegator == null) {
+            delegator = dispatcher.getDelegator();
+        }
         if (dataResourceId == null) {
             throw new GeneralException("Cannot lookup data resource with for a null dataResourceId");
         }
@@ -1072,11 +1083,6 @@
 
     public String renderDataResourceAsTextExt(Delegator delegator, String dataResourceId, Map<String, Object> templateContext,
             Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
-        return renderDataResourceAsText(delegator, dataResourceId, templateContext, locale, targetMimeTypeId, cache);
-    }
-
-    public void renderDataResourceAsTextExt(Delegator delegator, String dataResourceId, Appendable out, Map<String, Object> templateContext,
-            Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
-        renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, cache);
+        return renderDataResourceAsText(null, delegator, dataResourceId, templateContext, locale, targetMimeTypeId, cache);
     }
 }
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java
index b8a7521..3d0dc4d 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java
@@ -488,7 +488,7 @@
         }
 
         Writer outWriter = new StringWriter();
-        DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, outWriter, templateContext, locale, mimeTypeId, true);
+        DataResourceWorker.renderDataResourceAsText(dctx.getDispatcher(), dataResourceId, outWriter, templateContext, locale, mimeTypeId, true);
         try {
             out.write(outWriter.toString());
             results.put("textData", outWriter.toString());
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java
index 30421c5..aac3004 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java
@@ -168,7 +168,7 @@
                     String mimeTypeId = (String)templateCtx.get("mimeTypeId");
                     Locale locale = null;
                     try {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
+                        ContentWorker.renderContentAsText(dispatcher, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
                     } catch (IOException e) {
                         Debug.logError(e, "Error rendering content" + e.getMessage(), module);
                         throw new IOException("Error rendering content" + e.toString());
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java
index dbca95d..cfb89f9 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java
@@ -192,7 +192,7 @@
                         templateRoot.put("context", templateContext);
 
                         try {
-                            ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, false);
+                            ContentWorker.renderContentAsText(dispatcher, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, false);
                         } catch (IOException e) {
                             Debug.logError(e, "Error rendering content" + e.getMessage(), module);
                             throw new IOException("Error rendering content" + e.toString());
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java
index 945ec6d..6948ea3 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java
@@ -241,7 +241,7 @@
                     if (locale == null) locale = Locale.getDefault();
                     String mimeTypeId = (String) templateCtx.get("mimeTypeId");
                     try {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
+                        ContentWorker.renderContentAsText(dispatcher, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
                     } catch (GeneralException e) {
                         Debug.logError(e, "Error rendering content", module);
                         throw new IOException("Error rendering content" + e.toString());
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
index 2ecafb2..b4efe96 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
@@ -93,10 +93,10 @@
                         String mapKey = (String)templateRoot.get("mapKey");
                         String contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId");
                         if (UtilValidate.isNotEmpty(mapKey) || UtilValidate.isNotEmpty(contentAssocTypeId)) {
-                            String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, mapKey, templateRoot, locale, mimeTypeId, true);
+                            String txt = ContentWorker.renderSubContentAsText(dispatcher, contentId, mapKey, templateRoot, locale, mimeTypeId, true);
                             out.write(txt);
                         } else if (contentId != null) {
-                            ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, null, null, true);
+                            ContentWorker.renderContentAsText(dispatcher, contentId, out, templateRoot, locale, mimeTypeId, null, null, true);
                         }
                     } catch (GeneralException e) {
                         String errMsg = "Error rendering thisContentId:" + (String)templateRoot.get("contentId") + " msg:" + e.toString();
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAsText.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAsText.java
index ebacd51..a3764c6 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAsText.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentAsText.java
@@ -129,7 +129,7 @@
                 }
                 FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues);
                     try {
-                        String txt = ContentWorker.renderContentAsText(dispatcher, delegator, thisContentId, templateRoot, locale, mimeTypeId, true);
+                        String txt = ContentWorker.renderContentAsText(dispatcher, thisContentId, templateRoot, locale, mimeTypeId, true);
                         if ("true".equals(xmlEscape)) {
                             txt = UtilFormatOut.encodeXmlValue(txt);
                         }
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java
index 2eb8cc9..c7594c1 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java
@@ -103,9 +103,9 @@
 
                     String mapKey = (String)templateRoot.get("mapKey");
                     if (UtilValidate.isEmpty(mapKey)) {
-                        txt = ContentWorker.renderContentAsText(dispatcher, delegator, thisContentId, templateRoot, locale, mimeTypeId, true);
+                        txt = ContentWorker.renderContentAsText(dispatcher, thisContentId, templateRoot, locale, mimeTypeId, true);
                     } else {
-                        txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, thisContentId, mapKey, templateRoot, locale, mimeTypeId, true);
+                        txt = ContentWorker.renderSubContentAsText(dispatcher, thisContentId, mapKey, templateRoot, locale, mimeTypeId, true);
                     }
                     if ("true".equals(xmlEscape)) {
                         txt = UtilFormatOut.encodeXmlValue(txt);
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java
index 8b826e4..108fc10 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java
@@ -122,7 +122,7 @@
 
                 FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues);
                 try {
-                    String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, thisContentId, thisMapKey, templateRoot, locale, mimeTypeId, true);
+                    String txt = ContentWorker.renderSubContentAsText(dispatcher, thisContentId, thisMapKey, templateRoot, locale, mimeTypeId, true);
                     if ("true".equals(xmlEscape)) {
                         txt = UtilFormatOut.encodeXmlValue(txt);
                     }
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java
index 4093ded..4333a0b 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java
@@ -161,7 +161,7 @@
                     String contentId = thisView.getString("contentId");
                     if (contentId != null) {
                         try {
-                            ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, null, null, true);
+                            ContentWorker.renderContentAsText(dispatcher, contentId, out, templateRoot, locale, mimeTypeId, null, null, true);
                         } catch (GeneralException e) {
                             Debug.logError(e, "Error rendering content", module);
                             throw new IOException("Error rendering thisView:" + thisView + " msg:" + e.toString());
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java
index 297bfd7..29f286b 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java
@@ -142,9 +142,9 @@
                 }
                 try {
                     if (subContentId != null) {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, subContentId, out, templateRoot, locale, mimeTypeId, null, null, false);
+                        ContentWorker.renderContentAsText(dispatcher, subContentId, out, templateRoot, locale, mimeTypeId, null, null, false);
                     } else {
-                        ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, out, mapKey, templateRoot, locale, mimeTypeId, false);
+                        ContentWorker.renderSubContentAsText(dispatcher, contentId, out, mapKey, templateRoot, locale, mimeTypeId, false);
                     }
                 } catch (GeneralException e) {
                     Debug.logError(e, "Error rendering content", module);
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java
index d669890..4d572aa 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java
@@ -209,7 +209,7 @@
                     if (locale == null)
                         locale = Locale.getDefault();
                     try {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
+                        ContentWorker.renderContentAsText(dispatcher, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
                     } catch (GeneralException e) {
                         Debug.logError(e, "Error rendering content", module);
                         throw new IOException("Error rendering content" + e.toString());
diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java
index 57602b9..bfb547b 100644
--- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java
+++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java
@@ -173,7 +173,7 @@
                     String mimeTypeId = (String)templateCtx.get("mimeTypeId");
                     Locale locale = null;
                     try {
-                        ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
+                        ContentWorker.renderContentAsText(dispatcher, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
                     } catch (IOException e) {
                         Debug.logError(e, "Error rendering content" + e.getMessage(), module);
                         throw new IOException("Error rendering content" + e.toString());
diff --git a/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy b/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy
index cbf45ea..36236df 100644
--- a/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy
+++ b/applications/order/groovyScripts/entry/cart/ShowPromotionDetails.groovy
@@ -25,7 +25,7 @@
 if (!productPromoId) productPromoId = parameters.productPromoId
 productPromo = from("ProductPromo").where("productPromoId", productPromoId).queryOne()
 
-promoAutoDescription = ProductPromoWorker.makeAutoDescription(productPromo, delegator, locale)
+promoAutoDescription = ProductPromoWorker.makeAutoDescription(productPromo, delegator, locale, request.getAttribute("dispatcher"))
 
 productPromoCategoryList = from("ProductPromoCategory").where("productPromoId", productPromoId).cache(true).queryList()
 productPromoCategoryIncludeList = EntityUtil.filterByAnd(productPromoCategoryList, [productPromoApplEnumId : "PPPA_INCLUDE"])
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 9111a78..e6c3bbd 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
@@ -157,7 +157,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("order", order);
             inContext.put("orderContent", orderContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, orderContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
+            ContentWorker.renderContentAsText(dispatcher, orderContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
         }
     }
 }
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
index eea6495..585f877 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java
@@ -1598,7 +1598,7 @@
         try {
             GenericValue response = EntityQuery.use(delegator).from("ReturnItemResponse").where("returnItemResponseId", responseId).queryOne();
             if (response == null) {
-            	 return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderReturnItemResponseNotFound", UtilMisc.toMap("errorMsg", errorMsg,"responseId", responseId), locale));
+                 return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderReturnItemResponseNotFound", UtilMisc.toMap("errorMsg", errorMsg,"responseId", responseId), locale));
             }
             BigDecimal responseAmount = response.getBigDecimal("responseAmount").setScale(decimals, rounding);
             String paymentId = response.getString("paymentId");
@@ -1818,7 +1818,7 @@
                                     newItem.set("itemDescription", orderItem.get("itemDescription"));
                                 } else {
                                     newItem.set("productId", refurbItem.get("productId"));
-                                    newItem.set("itemDescription", ProductContentWrapper.getProductContentAsText(refurbItem, "PRODUCT_NAME", locale, null, "html"));
+                                    newItem.set("itemDescription", ProductContentWrapper.getProductContentAsText(refurbItem, "PRODUCT_NAME", locale, dispatcher, "html"));
                                 }
                                 newItem.set("orderItemTypeId", orderItem.get("orderItemTypeId"));
                                 newItem.set("productFeatureId", orderItem.get("productFeatureId"));
@@ -1933,7 +1933,7 @@
                                                 newItem.set("productId", repairItemProduct.get("productId"));
                                                 // TODO: orderItemTypeId, prodCatalogId, productCategoryId
                                                 newItem.set("quantity", repairQuantity);
-                                                newItem.set("itemDescription", ProductContentWrapper.getProductContentAsText(repairItemProduct, "PRODUCT_NAME", locale, null, "html"));
+                                                newItem.set("itemDescription", ProductContentWrapper.getProductContentAsText(repairItemProduct, "PRODUCT_NAME", locale, dispatcher, "html"));
                                                 newItem.set("statusId", "ITEM_CREATED");
                                                 orderItems.add(newItem);
                                                 additionalItemTotal = additionalItemTotal.add(repairQuantity.multiply(repairUnitPrice));
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
index 23327a9..c81a0ae 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
@@ -68,8 +68,8 @@
 import org.apache.ofbiz.product.config.ProductConfigWrapper;
 import org.apache.ofbiz.product.product.ProductWorker;
 import org.apache.ofbiz.product.store.ProductStoreWorker;
-import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.GenericServiceException;
+import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ServiceUtil;
 
 /**
@@ -498,24 +498,23 @@
             Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, String prodCatalogId,
             ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
 
-       return addOrIncreaseItem(productId,selectedAmount,quantity,reservStart,reservLength,reservPersons,
-                       null,null,shipBeforeDate,shipAfterDate,features,attributes,prodCatalogId,
+       return addOrIncreaseItem(productId,selectedAmount,quantity,reservStart,reservLength,reservPersons, null,null,shipBeforeDate,shipAfterDate,features,attributes,prodCatalogId,
                 configWrapper,itemType,itemGroupNumber,parentProductId,dispatcher);
     }
 
     /** add rental (with accommodation) item to cart  */
     public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons,
-               String accommodationMapId, String accommodationSpotId,
-            Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, String prodCatalogId,
-            ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
+               String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, 
+               String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
             return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, features, attributes, null, prodCatalogId, configWrapper, itemType, itemGroupNumber, parentProductId, dispatcher);
     }
 
     /** add rental (with accommodation) item to cart and order item attributes*/
+    // TODO change method signature, this one is really scary, above are not bad too :/ !
     public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons,
-               String accommodationMapId, String accommodationSpotId,
-            Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, Map<String, String> orderItemAttributes, String prodCatalogId,
-            ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
+               String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, 
+               Object> attributes, Map<String, String> orderItemAttributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, 
+               String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
         if (isReadOnlyCart()) {
            throw new CartItemModifyException("Cart items cannot be changed");
         }
@@ -560,7 +559,7 @@
                     if (supplierProduct != null && supplierProduct.getBigDecimal("lastPrice") != null) {
                         sci.setSupplierProductId(supplierProduct.getString("supplierProductId"));
                         sci.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
-                        sci.setName(ShoppingCartItem.getPurchaseOrderItemDescription(sci.getProduct(), supplierProduct, this.getLocale()));
+                        sci.setName(ShoppingCartItem.getPurchaseOrderItemDescription(sci.getProduct(), supplierProduct, this.getLocale(), dispatcher));
                     } else {
                        throw new CartItemModifyException("SupplierProduct not found");
                     }
@@ -3668,7 +3667,7 @@
                 orderItem.set("shoppingListId", item.getShoppingListId());
                 orderItem.set("shoppingListItemSeqId", item.getShoppingListItemSeqId());
 
-                orderItem.set("itemDescription", item.getName());
+                orderItem.set("itemDescription", item.getName(dispatcher));
                 orderItem.set("comments", item.getItemComment());
                 orderItem.set("estimatedDeliveryDate", item.getDesiredDeliveryDate());
                 orderItem.set("correspondingPoId", this.getPoNumber());
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
index 75ea1c7..1fc2c5d 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java
@@ -803,7 +803,7 @@
                                         oldQuantity = item.getQuantity();
                                         if (oldQuantity.compareTo(quantity) != 0) {
                                             // save the old description and price, in case the user wants to change those as well
-                                            oldDescription = item.getName();
+                                            oldDescription = item.getName(this.dispatcher);
                                             oldPrice = item.getBasePrice();
 
                                             if (UtilValidate.isNotEmpty(item.getProductId())) {
@@ -824,7 +824,7 @@
                                                     item.setSupplierProductId(supplierProduct.getString("supplierProductId"));
                                                     item.setQuantity(quantity, dispatcher, this.cart);
                                                     item.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
-                                                    item.setName(ShoppingCartItem.getPurchaseOrderItemDescription(item.getProduct(), supplierProduct, cart.getLocale()));
+                                                    item.setName(ShoppingCartItem.getPurchaseOrderItemDescription(item.getProduct(), supplierProduct, cart.getLocale(), dispatcher));
                                                 }
                                             } else {
                                                 item.setQuantity(quantity, dispatcher, this.cart);
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java
index 5153b23..1480cc3 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java
@@ -249,7 +249,7 @@
         // if supplierProduct has no supplierProductName, use the regular supplierProductId
         if (supplierProduct != null) {
             newItem.setSupplierProductId(supplierProduct.getString("supplierProductId"));
-            newItem.setName(getPurchaseOrderItemDescription(product, supplierProduct, cart.getLocale()));
+            newItem.setName(getPurchaseOrderItemDescription(product, supplierProduct, cart.getLocale(), dispatcher));
             newItem.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
         } else {
             newItem.setName(product.getString("internalName"));
@@ -691,16 +691,24 @@
     /** Cannot create shopping cart item with no parameters */
     protected ShoppingCartItem() {}
 
-    /** Creates new ShoppingCartItem object. */
+    /** Creates new ShoppingCartItem object. 
+     * @deprecated Use {@link #ShoppingCartItem(GenericValue,Map<String, GenericValue>,Map<String, Object>,String,Locale,String,ShoppingCart.ShoppingCartItemGroup,LocalDispatcher)} instead*/
     protected ShoppingCartItem(GenericValue product, Map<String, GenericValue> additionalProductFeatureAndAppls, Map<String, Object> attributes, String prodCatalogId, Locale locale, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup) {
+        this(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, locale, itemType, itemGroup, null);
+    }
+
+    /** Creates new ShoppingCartItem object. 
+     * @param dispatcher TODO*/
+    protected ShoppingCartItem(GenericValue product, Map<String, GenericValue> additionalProductFeatureAndAppls, Map<String, Object> attributes, String prodCatalogId, Locale locale, 
+            String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher) {
         this(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, locale, itemType, itemGroup, null);
          if (product != null) {
-            String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale, null, "html");
+            String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale, dispatcher, "html");
             // if the productName is null or empty, see if there is an associated virtual product and get the productName of that product
             if (UtilValidate.isEmpty(productName)) {
                 GenericValue parentProduct = this.getParentProduct();
                 if (parentProduct != null) {
-                    productName = ProductContentWrapper.getProductContentAsText(parentProduct, "PRODUCT_NAME", this.locale, null, "html");
+                    productName = ProductContentWrapper.getProductContentAsText(parentProduct, "PRODUCT_NAME", this.locale, dispatcher, "html");
                 }
             }
 
@@ -982,14 +990,14 @@
         return inventoryAvailable;
     }
 
-    protected void setQuantity(BigDecimal quantity, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps, boolean resetShipGroup, boolean updateProductPrice, boolean skipInventoryChecks) throws CartItemModifyException {
+    protected void setQuantity(BigDecimal quantity, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps, boolean resetShipGroup,
+            boolean updateProductPrice, boolean skipInventoryChecks) throws CartItemModifyException {
         if (this.quantity.compareTo(quantity) == 0) {
             return;
         }
 
         if (this.isPromo) {
-            Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", this.getName(),
-                                            "productId",   productId);
+            Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", this.getName(dispatcher), "productId", productId);
             String excMsg = UtilProperties.getMessage(resource, "OrderCannotChangeQuantityInPromotion", messageMap , cart.getLocale());
             throw new CartItemModifyException(excMsg);
         }
@@ -1001,9 +1009,8 @@
             // check inventory if new quantity is greater than old quantity; don't worry about inventory getting pulled out from under, that will be handled at checkout time
             if (_product != null && quantity.compareTo(this.quantity) > 0) {
                 if (!isInventoryAvailableOrNotRequired(quantity, productStoreId, dispatcher)) {
-                    Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("requestedQuantity", UtilFormatOut.formatQuantity(quantity.doubleValue()),
-                                                    "productName",       this.getName(),
-                                                    "productId",         productId);
+                    Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("requestedQuantity", UtilFormatOut.formatQuantity(quantity.doubleValue()), 
+                            "productName",this.getName(dispatcher), "productId", productId);
                     String excMsg = UtilProperties.getMessage(resource, "OrderDoNotHaveEnoughProducts", messageMap , cart.getLocale());
                     Debug.logWarning(excMsg, module);
                     throw new CartItemModifyException(excMsg);
@@ -1661,23 +1668,30 @@
         this.locale = locale;
     }
 
-    /** Set the item's name. */
+    /** Set the item's description. */
     public void setName(String itemName) {
         this.itemDescription = itemName;
     }
-    /** Returns the item's name. */
+    /** Returns the item's description. 
+    * @deprecated use getName(LocalDispatcher dispatcher) 
+    **/
     public String getName() {
+        return itemDescription;
+    }
+    
+    /** Returns the item's description or PRODUCT_NAME from content. */
+    public String getName(LocalDispatcher dispatcher) {
        if (itemDescription != null) {
           return itemDescription;
        } else {
         GenericValue product = getProduct();
         if (product != null) {
-            String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale, null, "html");
+            String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale, dispatcher, "html");
             // if the productName is null or empty, see if there is an associated virtual product and get the productName of that product
             if (UtilValidate.isEmpty(productName)) {
                 GenericValue parentProduct = this.getParentProduct();
                 if (parentProduct != null) {
-                    productName = ProductContentWrapper.getProductContentAsText(parentProduct, "PRODUCT_NAME", this.locale, null, "html");
+                    productName = ProductContentWrapper.getProductContentAsText(parentProduct, "PRODUCT_NAME", this.locale, dispatcher, "html");
                 }
             }
             if (productName == null) {
@@ -1692,17 +1706,17 @@
     }
 
     /** Returns the item's description. */
-    public String getDescription() {
+    public String getDescription(LocalDispatcher dispatcher) {
         GenericValue product = getProduct();
 
         if (product != null) {
-            String description = ProductContentWrapper.getProductContentAsText(product, "DESCRIPTION", this.locale, null, "html");
+            String description = ProductContentWrapper.getProductContentAsText(product, "DESCRIPTION", this.locale, dispatcher, "html");
 
             // if the description is null or empty, see if there is an associated virtual product and get the description of that product
             if (UtilValidate.isEmpty(description)) {
                 GenericValue parentProduct = this.getParentProduct();
                 if (parentProduct != null) {
-                    description = ProductContentWrapper.getProductContentAsText(parentProduct, "DESCRIPTION", this.locale, null, "html");
+                    description = ProductContentWrapper.getProductContentAsText(parentProduct, "DESCRIPTION", this.locale, dispatcher, "html");
                 }
             }
 
@@ -2492,7 +2506,7 @@
         return newItems;
     }
 
-    public static String getPurchaseOrderItemDescription(GenericValue product, GenericValue supplierProduct, Locale locale) {
+    public static String getPurchaseOrderItemDescription(GenericValue product, GenericValue supplierProduct, Locale locale, LocalDispatcher dispatcher) {
 
         String itemDescription = null;
 
@@ -2501,7 +2515,7 @@
         }
 
         if (UtilValidate.isEmpty(itemDescription)) {
-            itemDescription = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", locale, null, "html");
+            itemDescription = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", locale, dispatcher, "html");
         }
 
         return itemDescription;
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
index 53f3439..73cd600 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
@@ -658,7 +658,7 @@
         }
     }
 
-    public static String makeAutoDescription(GenericValue productPromo, Delegator delegator, Locale locale) throws GenericEntityException {
+    public static String makeAutoDescription(GenericValue productPromo, Delegator delegator, Locale locale, LocalDispatcher dispatcher) throws GenericEntityException {
         if (productPromo == null) {
             return "";
         }
@@ -672,7 +672,7 @@
 
             List<GenericValue> productPromoConds = EntityQuery.use(delegator).from("ProductPromoCond").where("productPromoId", productPromo.get("productPromoId")).orderBy("productPromoCondSeqId").cache(true).queryList();
             productPromoConds = EntityUtil.filterByAnd(productPromoConds, UtilMisc.toMap("productPromoRuleId", productPromoRule.get("productPromoRuleId")));
-            // using the other method to consolodate cache entries because the same cache is used elsewhere: List productPromoConds = productPromoRule.getRelated("ProductPromoCond", null, UtilMisc.toList("productPromoCondSeqId"), true);
+            // using the other method to consolidate cache entries because the same cache is used elsewhere: List productPromoConds = productPromoRule.getRelated("ProductPromoCond", null, UtilMisc.toList("productPromoCondSeqId"), true);
             Iterator<GenericValue> productPromoCondIter = UtilMisc.toIterator(productPromoConds);
             while (productPromoCondIter != null && productPromoCondIter.hasNext()) {
                 GenericValue productPromoCond = productPromoCondIter.next();
@@ -723,7 +723,7 @@
                 if (UtilValidate.isEmpty(messageContext.get("partyId"))) messageContext.put("partyId", "any");
                 GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
                 if (product != null) {
-                    messageContext.put("productName", ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", locale, null, "html"));
+                    messageContext.put("productName", ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", locale, dispatcher, "html"));
                 }
 
                 String msgProp = UtilProperties.getMessage("ProductPromoUiLabels", "ProductPromoAction." + productPromoAction.getString("productPromoActionEnumId"), messageContext, locale);
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 e02cdaa..984acb0 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
@@ -217,7 +217,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("party", party);
             inContext.put("partyContent", partyContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
+            ContentWorker.renderContentAsText(dispatcher, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
             return;
         }
         
@@ -271,7 +271,7 @@
                 Map<String, Object> inContext = new HashMap<String, Object>();
                 inContext.put("party", party);
                 inContext.put("partyContent", partyContent);
-                ContentWorker.renderContentAsText(dispatcher, delegator, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false);
+                ContentWorker.renderContentAsText(dispatcher, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false);
                 contentList.add(outWriter.toString());
             }
         }
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 c685252..8bc9d70 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
@@ -169,7 +169,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("productCategory", productCategory);
             inContext.put("categoryContent", categoryContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, categoryContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
+            ContentWorker.renderContentAsText(dispatcher, categoryContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
             return;
         }
         
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 a3adcee..415b182 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
@@ -177,7 +177,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("productConfigItem", productConfigItem);
             inContext.put("productConfigItemContent", productConfigItemContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
+            ContentWorker.renderContentAsText(dispatcher, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache);
             return;
         }
         
diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java
index 57c272f..c2cfee7 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java
@@ -211,7 +211,7 @@
     public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, Delegator delegator, GenericValue product) {
         Map<String, Object> drContext = UtilMisc.<String, Object>toMap("product", product);
         try {
-            String contentText = DataResourceWorker.renderDataResourceAsText(delegator, drView.getString("dataResourceId"), drContext, null, null, false);
+            String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, drView.getString("dataResourceId"), drContext, null, null, false);
             for (int i = 0; i < weight; i++) {
                 strings.add(contentText);
             }
@@ -227,7 +227,7 @@
             int weight = 1;
 
             try {
-            	Delegator delegator = value.getDelegator();
+                Delegator delegator = value.getDelegator();
                 weight = EntityUtilProperties.getPropertyAsInteger("prodsearch", "index.weight." + value.getEntityName() + "." + fieldName, 1).intValue();
             } catch (Exception e) {
                 Debug.logWarning("Could not parse weight number: " + e.toString(), module);
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 b8990a9..0911ec4 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
@@ -173,7 +173,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("product", product);
             inContext.put("productContent", productContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, productContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache);
+            ContentWorker.renderContentAsText(dispatcher, productContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache);
             return;
         }
 
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 e273b85..5fcc368 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
@@ -180,7 +180,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("productPromo", productPromo);
             inContext.put("productPromoContent", productPromoContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, productPromoContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache);
+            ContentWorker.renderContentAsText(dispatcher, productPromoContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache);
             return;
         }
         
diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java
index f84ecd6..28d282e 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java
@@ -258,7 +258,7 @@
             inContext.put("postalCode", shipToAddress.getString("postalCode"));
         }
         try {
-            ContentWorker.renderContentAsText(dispatcher, delegator, templateName, outWriter, inContext, locale, "text/plain", null, null, false);
+            ContentWorker.renderContentAsText(dispatcher, templateName, outWriter, inContext, locale, "text/plain", null, null, false);
         } catch (Exception e) {
             Debug.logError(e, "Cannot get DHL Estimate: Failed to render DHL XML Request.", module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
@@ -753,7 +753,7 @@
             inContext.put("notifyEmailAddress", recipientEmail);
 
             try {
-                ContentWorker.renderContentAsText(dispatcher, delegator, templateName, outWriter, inContext, locale, "text/plain", null, null, false);
+                ContentWorker.renderContentAsText(dispatcher, templateName, outWriter, inContext, locale, "text/plain", null, null, false);
             } catch (Exception e) {
                 Debug.logError(e, "Cannot confirm DHL shipment: Failed to render DHL XML Request.", module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
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 b6eb9f2..975ecfe 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
@@ -305,7 +305,7 @@
             Map<String, Object> inContext = new HashMap<String, Object>();
             inContext.put("workEffort", workEffort);
             inContext.put("workEffortContent", workEffortContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false);
+            ContentWorker.renderContentAsText(dispatcher, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false);
             return;
         }
         
@@ -341,7 +341,7 @@
                 Map<String, Object> inContext = new HashMap<String, Object>();
                 inContext.put("workEffort", workEffort);
                 inContext.put("workEffortContent", workEffortContent);
-                ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false);
+                ContentWorker.renderContentAsText(dispatcher, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false);
                 contentList.add(outWriter.toString());
             }
         }
diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java
index 61d434f..5fc7329 100644
--- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java
+++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java
@@ -124,7 +124,7 @@
     public static void addWeightedDataResourceString(GenericValue dataResource, int weight, List<String> strings, Delegator delegator, GenericValue workEffort) {
         Map<String, Object> workEffortCtx = UtilMisc.<String, Object>toMap("workEffort", workEffort);
         try {
-            String contentText = DataResourceWorker.renderDataResourceAsText(delegator, dataResource.getString("dataResourceId"), workEffortCtx, null, null, false);
+            String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, dataResource.getString("dataResourceId"), workEffortCtx, null, null, false);
             for (int i = 0; i < weight; i++) {
                 strings.add(contentText);
             }
@@ -135,7 +135,7 @@
         }
     }
     public static void addWeightedKeywordSourceString(GenericValue value, String fieldName, List<String> strings) {
-    	Delegator delegator = value.getDelegator();
+        Delegator delegator = value.getDelegator();
         if (value.getString(fieldName) != null) {
             int weight = 1;
 
diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/content/ContentWorkerInterface.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/content/ContentWorkerInterface.java
index e027408..034ab11 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/content/ContentWorkerInterface.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/content/ContentWorkerInterface.java
@@ -40,9 +40,9 @@
     public String getMimeTypeIdExt(Delegator delegator, GenericValue view, Map<String, Object> ctx);
 
     // new rendering methods
-    public void renderContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
-    public String renderContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
+    public void renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
+    public String renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
 
-    public void renderSubContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
-    public String renderSubContentAsTextExt(LocalDispatcher dispatcher, Delegator delegator, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
+    public void renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
+    public String renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
 }
diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/content/DataResourceWorkerInterface.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/content/DataResourceWorkerInterface.java
index 3ad3cb9..3d521f1 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/content/DataResourceWorkerInterface.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/content/DataResourceWorkerInterface.java
@@ -31,7 +31,4 @@
 public interface DataResourceWorkerInterface {
     public String renderDataResourceAsTextExt(Delegator delegator, String dataResourceId, Map<String, Object> templateContext,
             Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException;
-
-    public void renderDataResourceAsTextExt(Delegator delegator, String dataResourceId, Appendable out, Map<String, Object> templateContext,
-            Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException;
 }
diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java
index 0fe77d6..437e22b 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java
@@ -394,7 +394,7 @@
                 }
             } else if (UtilValidate.isNotEmpty(expandedContentId)) {
                 if (WidgetContentWorker.getContentWorker() != null) {
-                    renderedContent = WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, expandedContentId, contentContext, locale, mimeTypeId, true);
+                    renderedContent = WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, expandedContentId, contentContext, locale, mimeTypeId, true);
                 } else {
                     Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module);
                 }
@@ -409,7 +409,7 @@
                 String editRequest = content.getEditRequest(context);
                 if (UtilValidate.isNotEmpty(editRequest)) {
                     if (WidgetContentWorker.getContentWorker() != null) {
-                        WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true);
+                        WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true);
                     } else {
                         Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module);
                     }
@@ -512,7 +512,7 @@
 
          try {
              if (WidgetContentWorker.getContentWorker() != null) {
-                 renderedContent = WidgetContentWorker.getContentWorker().renderSubContentAsTextExt(dispatcher, delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true);
+                 renderedContent = WidgetContentWorker.getContentWorker().renderSubContentAsTextExt(dispatcher, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true);
                  //Debug.logInfo("renderedContent=" + renderedContent, module);
              } else {
                  Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module);
@@ -521,7 +521,7 @@
                  String editRequest = content.getEditRequest(context);
                  if (UtilValidate.isNotEmpty(editRequest)) {
                      if (WidgetContentWorker.getContentWorker() != null) {
-                         WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true);
+                         WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true);
                      } else {
                          Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module);
                      }
diff --git a/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ContentDocument.java b/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ContentDocument.java
index 0e522ba..c2a902f 100644
--- a/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ContentDocument.java
+++ b/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ContentDocument.java
@@ -126,7 +126,7 @@
         }
         String text;
         try {
-            text = ContentWorker.renderContentAsText(dispatcher, content.getDelegator(), contentId, null, locale, mimeTypeId, true);
+            text = ContentWorker.renderContentAsText(dispatcher, contentId, null, locale, mimeTypeId, true);
         } catch (GeneralException e) {
             Debug.logError(e, module);
             return false;
diff --git a/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java b/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java
index dc592a7..d0267eb 100644
--- a/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java
+++ b/specialpurpose/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java
@@ -18,6 +18,20 @@
  *******************************************************************************/
 package org.apache.ofbiz.content.search;
 
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.DoublePoint;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.LongPoint;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.Term;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilDateTime;
@@ -32,22 +46,6 @@
 import org.apache.ofbiz.entity.util.EntityQuery;
 import org.apache.ofbiz.entity.util.EntityUtil;
 import org.apache.ofbiz.entity.util.EntityUtilProperties;
-import org.apache.lucene.document.Document;
-//import org.apache.lucene.document.DoubleField;
-import org.apache.lucene.document.DoublePoint;
-import org.apache.lucene.document.Field;
-//import org.apache.lucene.document.LongField;
-import org.apache.lucene.document.LongPoint;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.Term;
-
-import java.io.IOException;
-import java.sql.Timestamp;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 
 public class ProductDocument implements LuceneDocument {
     private static final String module = ProductDocument.class.getName();
@@ -207,7 +205,7 @@
                         }
                         try {
                             Map<String, Object> drContext = UtilMisc.<String, Object>toMap("product", product);
-                            String contentText = DataResourceWorker.renderDataResourceAsText(delegator, productContentAndInfo.getString("dataResourceId"), drContext, null, null, false);
+                            String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, productContentAndInfo.getString("dataResourceId"), drContext, null, null, false);
                             this.addTextFieldByWeight(doc, "content", contentText, null, weight, false, "fullText", delegator);
                         } catch (IOException e1) {
                             Debug.logError(e1, "Error getting content text to index", module);