mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9981 Due to Spring 3.0 SPEL running on FTL entries like ${foo} before they are passed as properties to beans, support an escaped form of \$\{foo\} which is un-escaped before being passed to the FreeMarker engine. Updates the template code for scheduled actions to un-escape, and the example action definitions to be escaped
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30551 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,7 +33,8 @@
|
|||||||
<key>
|
<key>
|
||||||
<value>{http://www.alfresco.org/model/content/1.0}categories</value>
|
<value>{http://www.alfresco.org/model/content/1.0}categories</value>
|
||||||
</key>
|
</key>
|
||||||
<value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/cm:generalclassifiable/cm:Languages/cm:English"' )}</value>
|
<!-- Note - FreeMarker ${..} entries must be escaped in Spring context files -->
|
||||||
|
<value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/cm:generalclassifiable/cm:Languages/cm:English"' )\}</value>
|
||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
@@ -95,19 +96,22 @@
|
|||||||
<key>
|
<key>
|
||||||
<value>destination-folder</value>
|
<value>destination-folder</value>
|
||||||
</key>
|
</key>
|
||||||
<value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home"' )}</value>
|
<!-- Note - FreeMarker ${..} entries must be escaped in Spring context files -->
|
||||||
|
<value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home"' )\}</value>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<key>
|
<key>
|
||||||
<value>assoc-type</value>
|
<value>assoc-type</value>
|
||||||
</key>
|
</key>
|
||||||
<value>${node.primaryParentAssoc.typeQName}</value>
|
<!-- Note - FreeMarker ${..} entries must be escaped in Spring context files -->
|
||||||
|
<value>\$\{node.primaryParentAssoc.typeQName\}</value>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<key>
|
<key>
|
||||||
<value>assoc-name</value>
|
<value>assoc-name</value>
|
||||||
</key>
|
</key>
|
||||||
<value>${node.primaryParentAssoc.QName}</value>
|
<!-- Note - FreeMarker ${..} entries must be escaped in Spring context files -->
|
||||||
|
<value>\$\{node.primaryParentAssoc.QName\}</value>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<key>
|
<key>
|
||||||
@@ -150,7 +154,8 @@
|
|||||||
<key>
|
<key>
|
||||||
<value>value</value>
|
<value>value</value>
|
||||||
</key>
|
</key>
|
||||||
<value>${today?string("yyyy-MM-dd'T'HH:mm:ss.sss'Z'")}</value>
|
<!-- Note - FreeMarker ${..} entries must be escaped in Spring context files -->
|
||||||
|
<value>\$\{today?string("yyyy-MM-dd'T'HH:mm:ss.sss'Z'")\}</value>
|
||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
@@ -402,7 +407,8 @@
|
|||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
<property name="queryTemplate">
|
<property name="queryTemplate">
|
||||||
<value>@cm\:created:${luceneDateRange(yesterday, "-P10Y")}</value>
|
<!-- Note - FreeMarker ${..} entries must be escaped in Spring context files -->
|
||||||
|
<value>@cm\:created:\$\{luceneDateRange(yesterday, "-P10Y")\}</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="cronExpression">
|
<property name="cronExpression">
|
||||||
<value>0 0/1 * * * ?</value>
|
<value>0 0/1 * * * ?</value>
|
||||||
|
@@ -36,6 +36,9 @@ import org.springframework.context.ApplicationContextAware;
|
|||||||
/**
|
/**
|
||||||
* This class defines the template used to build a single action.
|
* This class defines the template used to build a single action.
|
||||||
*
|
*
|
||||||
|
* Because SPEL will eat ${foo} or #{foo} in the template when specified in the XML,
|
||||||
|
* this will also accept \$\{foo\} or \#\{foo\} as well.
|
||||||
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
*/
|
*/
|
||||||
public class SimpleTemplateActionDefinition extends AbstractTemplateActionDefinition implements ApplicationContextAware
|
public class SimpleTemplateActionDefinition extends AbstractTemplateActionDefinition implements ApplicationContextAware
|
||||||
@@ -176,17 +179,30 @@ public class SimpleTemplateActionDefinition extends AbstractTemplateActionDefini
|
|||||||
// Go through the template definitions and set the values.
|
// Go through the template definitions and set the values.
|
||||||
for (String paramName : parameterTemplates.keySet())
|
for (String paramName : parameterTemplates.keySet())
|
||||||
{
|
{
|
||||||
// Transform the template
|
// Fetch the template. Need to de-escape things put in to work
|
||||||
|
// around it not being possible to disable SPEL for one bean
|
||||||
String template = parameterTemplates.get(paramName);
|
String template = parameterTemplates.get(paramName);
|
||||||
String stringValue = templateService.processTemplateString(getTemplateActionModelFactory()
|
if(template.contains("\\$\\{") || template.contains("\\#\\{"))
|
||||||
.getTemplateEngine(), template, getTemplateActionModelFactory().getModel(nodeRef));
|
{
|
||||||
|
template = template.replace("\\$\\{", "${");
|
||||||
|
template = template.replace("\\#\\{", "#{");
|
||||||
|
if(template.contains("\\}"))
|
||||||
|
{
|
||||||
|
template = template.replace("\\}", "}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transform the template
|
||||||
|
String stringValue = templateService.processTemplateString(
|
||||||
|
getTemplateActionModelFactory().getTemplateEngine(),
|
||||||
|
template, getTemplateActionModelFactory().getModel(nodeRef));
|
||||||
|
|
||||||
// Find the data type from the action defintion
|
// Find the data type from the action defintion
|
||||||
DataTypeDefinition dataTypeDef;
|
DataTypeDefinition dataTypeDef;
|
||||||
if (actionDefinition.getParameterDefintion(paramName) != null)
|
if (actionDefinition.getParameterDefintion(paramName) != null)
|
||||||
{
|
{
|
||||||
dataTypeDef = dictionaryService
|
dataTypeDef = dictionaryService.getDataType(
|
||||||
.getDataType(actionDefinition.getParameterDefintion(paramName).getType());
|
actionDefinition.getParameterDefintion(paramName).getType());
|
||||||
}
|
}
|
||||||
// Fall back to the DD using the property name of it is not defined
|
// Fall back to the DD using the property name of it is not defined
|
||||||
// This is sometimes used for setting a property to a value.
|
// This is sometimes used for setting a property to a value.
|
||||||
|
Reference in New Issue
Block a user