Author: jleroux
Date: Thu Jun 3 04:18:34 2010 New Revision: 950867 URL: http://svn.apache.org/viewvc?rev=950867&view=rev Log: "Applied fix from trunk for revision: 950866 " ------------------------------------------------------------------------ r950866 | jleroux | 2010-06-03 06:11:32 +0200 (jeu. 03 juin 2010) | 3 lignes A patch from Sumit Pandit "Issue in rendering Freemarker Template from String." (https://issues.apache.org/jira/browse/OFBIZ-3782) - OFBIZ-3782 With the help of Bob Morley (it was more a cache issue than what Sumit thought) ------------------------------------------------------------------------ Modified: ofbiz/branches/release10.04/ (props changed) ofbiz/branches/release10.04/applications/content/ofbiz-component.xml ofbiz/branches/release10.04/applications/content/servicedef/services_data.xml ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataServices.java ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Propchange: ofbiz/branches/release10.04/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jun 3 04:18:34 2010 @@ -1,3 +1,3 @@ /ofbiz/branches/addbirt:831210-885099,885686-886087 /ofbiz/branches/multitenant20100310:921280-927264 -/ofbiz/trunk:939988,939990,939999,940025,940053,940234,940248,940309,940401,940410,940425,940779,940815,940849,941007,941047,941109,941177,941199,941261,941440,941600,941999,942084,942406,942414,942671,942883-942884,943168,943271-943272,944614,944621,944623,944647,944669,944797,944895,945010,945018,945026,945118,945573,945578,945580,945582,945610,945619,945848,945852,945857,946061,946066,946073,946075,946080,946309,946313,946320,946322,946596,947004-947005,947392,947424,947679,947988,948017,948694,949174,949710,949844 +/ofbiz/trunk:939988,939990,939999,940025,940053,940234,940248,940309,940401,940410,940425,940779,940815,940849,941007,941047,941109,941177,941199,941261,941440,941600,941999,942084,942406,942414,942671,942883-942884,943168,943271-943272,944614,944621,944623,944647,944669,944797,944895,945010,945018,945026,945118,945573,945578,945580,945582,945610,945619,945848,945852,945857,946061,946066,946073,946075,946080,946309,946313,946320,946322,946596,947004-947005,947392,947424,947679,947988,948017,948694,949174,949710,949844,950866 Modified: ofbiz/branches/release10.04/applications/content/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/content/ofbiz-component.xml?rev=950867&r1=950866&r2=950867&view=diff ============================================================================== --- ofbiz/branches/release10.04/applications/content/ofbiz-component.xml (original) +++ ofbiz/branches/release10.04/applications/content/ofbiz-component.xml Thu Jun 3 04:18:34 2010 @@ -28,6 +28,7 @@ under the License. <classpath type="jar" location="lib/uno/*"/> <classpath type="jar" location="build/lib/*"/> <entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/> + <entity-resource type="eca" reader-name="main" loader="main" location="entitydef/eecas.xml"/> <entity-resource type="data" reader-name="seed" loader="main" location="data/ContentTypeData.xml"/> <entity-resource type="data" reader-name="seed" loader="main" location="data/ContentOperationData.xml"/> <entity-resource type="data" reader-name="seed" loader="main" location="data/MimeTypeData.xml"/> Modified: ofbiz/branches/release10.04/applications/content/servicedef/services_data.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/content/servicedef/services_data.xml?rev=950867&r1=950866&r2=950867&view=diff ============================================================================== --- ofbiz/branches/release10.04/applications/content/servicedef/services_data.xml (original) +++ ofbiz/branches/release10.04/applications/content/servicedef/services_data.xml Thu Jun 3 04:18:34 2010 @@ -252,4 +252,11 @@ <attribute mode="IN" name="rootDir" optional="true" type="String"/> </service> --> + + <!-- Cleared associated DataResource rendered cache from UtilCache. --> + <service name="clearAssociatedRenderCache" engine="java" auth="true" default-entity-name="DataResource" + location="org.ofbiz.content.data.DataServices" invoke="clearAssociatedRenderCache"> + <auto-attributes include="pk" mode="IN" /> + </service> + </services> \ No newline at end of file Modified: ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=950867&r1=950866&r2=950867&view=diff ============================================================================== --- ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Thu Jun 3 04:18:34 2010 @@ -557,6 +557,20 @@ public class DataResourceWorker impleme // DataResource rendering methods // ------------------------------------- + public static void clearAssociatedRenderCache(Delegator delegator, String dataResourceId) throws GeneralException { + if (dataResourceId == null) { + throw new GeneralException("Cannot clear dataResource related cache for a null dataResourceId"); + } + + GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + if (dataResource != null) { + String dataTemplateTypeId = dataResource.getString("dataTemplateTypeId"); + if ("FTL".equals(dataTemplateTypeId)) { + FreeMarkerWorker.clearTemplateFromCache("DataResource:" + dataResourceId); + } + } + } + public static String renderDataResourceAsText(Delegator delegator, String dataResourceId, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException { Writer writer = new StringWriter(); Modified: ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataServices.java?rev=950867&r1=950866&r2=950867&view=diff ============================================================================== --- ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataServices.java (original) +++ ofbiz/branches/release10.04/applications/content/src/org/ofbiz/content/data/DataServices.java Thu Jun 3 04:18:34 2010 @@ -54,6 +54,19 @@ public class DataServices { public static final String module = DataServices.class.getName(); + public static Map<String, Object> clearAssociatedRenderCache(DispatchContext dctx, Map<String, Object> context) { + Delegator delegator = dctx.getDelegator(); + String dataResourceId = (String) context.get("dataResourceId"); + try { + DataResourceWorker.clearAssociatedRenderCache(delegator, dataResourceId); + } catch (GeneralException e) { + String errMsg = "Unable to clear associated render cache with dataResourceId=" + dataResourceId; + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } + return ServiceUtil.returnSuccess(); + } + /** * A top-level service for creating a DataResource and ElectronicText together. */ Modified: ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=950867&r1=950866&r2=950867&view=diff ============================================================================== --- ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original) +++ ofbiz/branches/release10.04/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Thu Jun 3 04:18:34 2010 @@ -173,6 +173,12 @@ public class FreeMarkerWorker { renderTemplate(template, context, outWriter); } + public static void clearTemplateFromCache(String templateLocation) { + synchronized (cachedTemplates) { + cachedTemplates.remove(templateLocation); + } + } + public static Environment renderTemplateFromString(String templateString, String templateLocation, Map<String, Object> context, Appendable outWriter) throws TemplateException, IOException { Template template = cachedTemplates.get(templateLocation); if (template == null) { @@ -186,7 +192,6 @@ public class FreeMarkerWorker { } } } - return renderTemplate(template, context, outWriter); } |
Free forum by Nabble | Edit this page |