Author: arunpatidar
Date: Tue Jun 28 14:27:18 2016 New Revision: 1750521 URL: http://svn.apache.org/viewvc?rev=1750521&view=rev Log: Applied patch from jira issue - OFBIZ-7428 - Enforce noninstantiability to WidgetContentWorker Class. Thanks Rishi Solanki and Pratik Kulshreshth for your contribution. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetContentWorker.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/MenuWrapTransform.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlMenuRendererImage.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetContentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetContentWorker.java?rev=1750521&r1=1750520&r2=1750521&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetContentWorker.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetContentWorker.java Tue Jun 28 14:27:18 2016 @@ -23,9 +23,12 @@ import org.ofbiz.base.util.Debug; /** * WidgetContentWorker Class */ -public class WidgetContentWorker { +public final class WidgetContentWorker { public static final String module = WidgetContentWorker.class.getName(); - public static ContentWorkerInterface contentWorker = null; + private static ContentWorkerInterface contentWorker = null; + + private WidgetContentWorker () {} + static { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); @@ -39,4 +42,8 @@ public class WidgetContentWorker { Debug.logError(e, "Could not pre-initialize dynamically loaded class: ", module); } } + + public static ContentWorkerInterface getContentWorker() { + return contentWorker; + } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/MenuWrapTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/MenuWrapTransform.java?rev=1750521&r1=1750520&r2=1750521&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/MenuWrapTransform.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/MenuWrapTransform.java Tue Jun 28 14:27:18 2016 @@ -98,8 +98,8 @@ public class MenuWrapTransform implement Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE :Boolean.FALSE; GenericValue val = null; try { - if (WidgetContentWorker.contentWorker != null) { - val = WidgetContentWorker.contentWorker.getCurrentContentExt(delegator, trail, userLogin, templateCtx, nullThruDatesOnly, contentAssocPredicateId); + if (WidgetContentWorker.getContentWorker() != null) { + val = WidgetContentWorker.getContentWorker().getCurrentContentExt(delegator, trail, userLogin, templateCtx, nullThruDatesOnly, contentAssocPredicateId); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } @@ -129,8 +129,8 @@ public class MenuWrapTransform implement } // This order is taken so that the mimeType can be overridden in the transform arguments. String mimeTypeId = null; - if (WidgetContentWorker.contentWorker != null) { - mimeTypeId = WidgetContentWorker.contentWorker.getMimeTypeIdExt(delegator, view, templateCtx); + if (WidgetContentWorker.getContentWorker() != null) { + mimeTypeId = WidgetContentWorker.getContentWorker().getMimeTypeIdExt(delegator, view, templateCtx); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlMenuRendererImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlMenuRendererImage.java?rev=1750521&r1=1750520&r2=1750521&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlMenuRendererImage.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlMenuRendererImage.java Tue Jun 28 14:27:18 2016 @@ -54,8 +54,8 @@ public class HtmlMenuRendererImage exten GenericValue webSitePublishPoint = null; //Debug.logInfo("in HtmlMenuRendererImage, contentId:" + contentId,""); try { - if (WidgetContentWorker.contentWorker != null) { - webSitePublishPoint = WidgetContentWorker.contentWorker.getWebSitePublishPointExt(delegator, contentId, false); + if (WidgetContentWorker.getContentWorker() != null) { + webSitePublishPoint = WidgetContentWorker.getContentWorker().getWebSitePublishPointExt(delegator, contentId, false); } else { Debug.logError("Not rendering image because can't get WebSitePublishPoint, not ContentWorker found.", module); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java?rev=1750521&r1=1750520&r2=1750521&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java Tue Jun 28 14:27:18 2016 @@ -715,8 +715,8 @@ public class HtmlScreenRenderer extends Debug.logError("Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.", module); } } else if (UtilValidate.isNotEmpty(expandedContentId)) { - if (WidgetContentWorker.contentWorker != null) { - renderedContent = WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, expandedContentId, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + renderedContent = WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, expandedContentId, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } @@ -730,8 +730,8 @@ public class HtmlScreenRenderer extends if (UtilValidate.isEmpty(renderedContent)) { String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { - if (WidgetContentWorker.contentWorker != null) { - WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } @@ -839,8 +839,8 @@ public class HtmlScreenRenderer extends contentContext.putAll(context); try { - if (WidgetContentWorker.contentWorker != null) { - renderedContent = WidgetContentWorker.contentWorker.renderSubContentAsTextExt(dispatcher, delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + renderedContent = WidgetContentWorker.getContentWorker().renderSubContentAsTextExt(dispatcher, delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); //Debug.logInfo("renderedContent=" + renderedContent, module); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); @@ -848,8 +848,8 @@ public class HtmlScreenRenderer extends if (UtilValidate.isEmpty(renderedContent)) { String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { - if (WidgetContentWorker.contentWorker != null) { - WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java?rev=1750521&r1=1750520&r2=1750521&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java Tue Jun 28 14:27:18 2016 @@ -393,8 +393,8 @@ public class MacroScreenRenderer impleme Debug.logError("Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.", module); } } else if (UtilValidate.isNotEmpty(expandedContentId)) { - if (WidgetContentWorker.contentWorker != null) { - renderedContent = WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, expandedContentId, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + renderedContent = WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, expandedContentId, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } @@ -408,8 +408,8 @@ public class MacroScreenRenderer impleme if (UtilValidate.isEmpty(renderedContent)) { String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { - if (WidgetContentWorker.contentWorker != null) { - WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } @@ -511,8 +511,8 @@ public class MacroScreenRenderer impleme contentContext.putAll(context); try { - if (WidgetContentWorker.contentWorker != null) { - renderedContent = WidgetContentWorker.contentWorker.renderSubContentAsTextExt(dispatcher, delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + renderedContent = WidgetContentWorker.getContentWorker().renderSubContentAsTextExt(dispatcher, delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); //Debug.logInfo("renderedContent=" + renderedContent, module); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); @@ -520,8 +520,8 @@ public class MacroScreenRenderer impleme if (UtilValidate.isEmpty(renderedContent)) { String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { - if (WidgetContentWorker.contentWorker != null) { - WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); + if (WidgetContentWorker.getContentWorker() != null) { + WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } |
Free forum by Nabble | Edit this page |