Author: deepak Date: Mon Nov 13 06:26:53 2017 New Revision: 1815059 URL: http://svn.apache.org/viewvc?rev=1815059&view=rev Log: Fixed: Content related changes needs OFBiz server restart (OFBIZ-9922) DataResourceWorker call the FreeMarkerWorker.renderTemplateFromString if dataTemplateTypeId is FTL, and pass the dataResource.lastUpdatedStamp to update the ftl cache. But if you use ftl file as objectInfo so dataResource.lastUpdatedStamp will not change if you update the ftl file
Thanks Suraj Khurana for reporting the issue. Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java?rev=1815059&r1=1815058&r2=1815059&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java Mon Nov 13 06:26:53 2017 @@ -57,6 +57,7 @@ import org.apache.ofbiz.base.util.Genera 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.UtilDateTime; import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilHttp; import org.apache.ofbiz.base.util.UtilIO; @@ -674,7 +675,17 @@ public class DataResourceWorker impleme // render the FTL template boolean useTemplateCache = cache && !UtilProperties.getPropertyAsBoolean("content", "disable.ftl.template.cache", false); - Timestamp lastUpdatedStamp = dataResource.getTimestamp("lastUpdatedStamp"); + //Do not use dataResource.lastUpdatedStamp for dataResource template caching as it may use ftl file or electronicText + // If dataResource using ftl file use nowTimestamp to avoid freemarker caching + Timestamp lastUpdatedStamp = UtilDateTime.nowTimestamp(); + //If dataResource is type of ELECTRONIC_TEXT then only use the lastUpdatedStamp of electronicText entity for freemarker caching + if ("ELECTRONIC_TEXT".equals(dataResource.getString("dataResourceTypeId"))) { + GenericValue electronicText = dataResource.getRelatedOne("ElectronicText", true); + if (electronicText != null) { + lastUpdatedStamp = electronicText.getTimestamp("lastUpdatedStamp"); + } + } + FreeMarkerWorker.renderTemplateFromString("delegator:" + delegator.getDelegatorName() + ":DataResource:" + dataResourceId, templateText, templateContext, out, lastUpdatedStamp.getTime(), useTemplateCache); } catch (TemplateException e) { throw new GeneralException("Error rendering FTL template", e);