mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)
51903 to 54309 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
https://issues.alfresco.com/jira/browse/MNT-8776
|
||||
|
||||
Cronjob sending emails fails when <20> System <20> is used, it causes FTL model.person=null when sending mails
|
||||
|
||||
To reproduce, configure a <20> CronScheduledQueryBasedTemplateActionDefinition <20>
|
||||
<bean id="createNewsEachWeek" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
|
||||
<property name="transactionMode">
|
||||
<value>UNTIL_FIRST_FAILURE</value>
|
||||
</property>
|
||||
..
|
||||
<property name="queryTemplate">
|
||||
<value>+TYPE:"cm:folder" +@cm\:name:"Gepubliceerd"</value>
|
||||
</property>
|
||||
..
|
||||
<property name="runAsUser">
|
||||
<value>System</value>
|
||||
</property>
|
||||
</bean>
|
||||
You need a script called by CronScheduledQueryBasedTemplateActionDefinition that execute the MailAcionExecuter :
|
||||
function notifyIntranetGroup(content) {
|
||||
if(SENT_NOTIFICATION_EMAILS == true) {
|
||||
var mail = actions.create("mail");
|
||||
mail.parameters.to = SENT_NOTIFICATION_ADRESS;
|
||||
mail.parameters.subject = "[INFO][NEW][NEWS] " + content.properties["cm:name"];
|
||||
mail.parameters.text = "Een nieuw nieuwsbericht werd toegevoegd.";
|
||||
var notificationTemplate = search.luceneSearch("@cm
|
||||
:name:'notify_new_document_email.ftl'");
|
||||
if(notificationTemplate.length >= 1) {
|
||||
if(notificationTemplate[0].name == "notify_new_document_email.ftl")
|
||||
{ mail.parameters.template = notificationTemplate[0]; }
|
||||
}
|
||||
mail.execute(content);
|
||||
}
|
||||
}
|
||||
THE FTL notify_new_document_email.ftl must exist as well in your repo.
|
||||
--------------------------------------
|
||||
A new document '$
|
||||
{document.name}
|
||||
', is available in the '$
|
||||
{space.name}
|
||||
' space, it was added by $
|
||||
{person.properties.firstName}
|
||||
<#if person.properties.lastName?exists> $
|
||||
{person.properties.lastName}
|
||||
</#if>.
|
15
source/test-resources/alfresco/scripts/email/mail_test.js
Normal file
15
source/test-resources/alfresco/scripts/email/mail_test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
function notifyIntranetGroup(content) {
|
||||
var mail = actions.create("mail");
|
||||
mail.parameters.to = "wasa@alfresco.com";
|
||||
mail.parameters.subject = "[INFO][NEW][NEWS] " + content.properties["cm:name"];
|
||||
mail.parameters.text = "Een nieuw nieuwsbericht werd toegevoegd.";
|
||||
var notificationTemplate = search.luceneSearch("@cm\\:name:'notify_new_document_email.ftl'");
|
||||
if(notificationTemplate.length >= 1) {
|
||||
if(notificationTemplate[0].name == "notify_new_document_email.ftl")
|
||||
{ mail.parameters.template = notificationTemplate[0]; }
|
||||
}
|
||||
mail.execute(content);
|
||||
}
|
||||
|
||||
var content = search.luceneSearch("@cm\\:name:'cronjob_test.txt'")[0];
|
||||
notifyIntranetGroup(content);
|
@@ -0,0 +1,4 @@
|
||||
A new document '${document.name}', is available in the '${space.name}' space, it was added by ${person.properties.firstName}
|
||||
<#if person.properties.lastName?exists>
|
||||
${person.properties.lastName}
|
||||
</#if>
|
@@ -0,0 +1,98 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<import resource="classpath:alfresco/application-context.xml" />
|
||||
|
||||
<!--
|
||||
Define the model factory used to generate object models suitable for use with freemarker templates.
|
||||
-->
|
||||
<bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
|
||||
<property name="serviceRegistry">
|
||||
<ref bean="ServiceRegistry"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="scriptAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
|
||||
<property name="actionName">
|
||||
<value>script</value>
|
||||
</property>
|
||||
<property name="parameterTemplates">
|
||||
<null/>
|
||||
</property>
|
||||
<property name="templateActionModelFactory">
|
||||
<ref bean="templateActionModelFactory"/>
|
||||
</property>
|
||||
<property name="dictionaryService">
|
||||
<ref bean="DictionaryService"/>
|
||||
</property>
|
||||
<property name="actionService">
|
||||
<ref bean="ActionService"/>
|
||||
</property>
|
||||
<property name="templateService">
|
||||
<ref bean="TemplateService"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="createNewsEachWeek" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
|
||||
<property name="transactionMode">
|
||||
<value>UNTIL_FIRST_FAILURE</value>
|
||||
</property>
|
||||
<property name="compensatingActionMode">
|
||||
<value>IGNORE</value>
|
||||
</property>
|
||||
<property name="searchService">
|
||||
<ref bean="SearchService"/>
|
||||
</property>
|
||||
<property name="templateService">
|
||||
<ref bean="TemplateService"/>
|
||||
</property>
|
||||
<property name="queryLanguage">
|
||||
<value>lucene</value>
|
||||
</property>
|
||||
<property name="stores">
|
||||
<list>
|
||||
<value>workspace://SpacesStore</value>
|
||||
</list>
|
||||
</property>
|
||||
<!-- Find all nodes that do not have the aspect -->
|
||||
<property name="queryTemplate">
|
||||
<value>+TYPE:"cm:folder" +@cm\:name:"Gepubliceerd"</value>
|
||||
</property>
|
||||
<property name="cronExpression">
|
||||
<value>0 50 * * * ?</value>
|
||||
</property>
|
||||
<property name="jobName">
|
||||
<value>jobE</value>
|
||||
</property>
|
||||
<property name="jobGroup">
|
||||
<value>jobGroup</value>
|
||||
</property>
|
||||
<property name="triggerName">
|
||||
<value>triggerE</value>
|
||||
</property>
|
||||
<property name="triggerGroup">
|
||||
<value>triggerGroup</value>
|
||||
</property>
|
||||
<property name="scheduler">
|
||||
<ref bean="schedulerFactory"/>
|
||||
</property>
|
||||
<property name="actionService">
|
||||
<ref bean="ActionService"/>
|
||||
</property>
|
||||
<property name="templateActionModelFactory">
|
||||
<ref bean="templateActionModelFactory"/>
|
||||
</property>
|
||||
<property name="templateActionDefinition">
|
||||
<ref bean="scriptAction"/>
|
||||
</property>
|
||||
<property name="transactionService">
|
||||
<ref bean="TransactionService"/>
|
||||
</property>
|
||||
<property name="runAsUser">
|
||||
<value>System</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
Reference in New Issue
Block a user