cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco 3.4 : SETTING UP A SCHEDULER THAT RUNS JS SCRIPT

rennajihi
Champ in-the-making
Champ in-the-making

Hello,
I'm trying to set up a scheduled action that executes a js script periodically, here is the scheduler :

<bean id="runSplitterScriptAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
<property name="actionName">
<value>script</value>
</property>
<property name="parameterTemplates">
<map>
<entry>
<key>
<value>script-ref</value>
</key>
<!-- element and value has to be on the same line -->
<value>selectSingleNode('workspace://SpacesStore', 'lucene','PATH:"/app:company_home/app:dictionary/app:scripts/cm:split_transaction.js"')</value>
</entry>
</map>
</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="runScript" 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>
<!-- A query is not being used, just set the path to company home, which 
results in one hit that we will run the script against -->
<property name="queryTemplate">
<value>PATH:"/app:company_home"</value>
</property>
<!-- Execute the check review period action at the end of every month. -->
<property name="cronExpression">
<value>0 0/10 * * * ?</value>
</property>
<property name="jobName">
<value>splitterJob</value>
</property>
<property name="jobGroup">
<value>splitterJobGroup</value>
</property>
<property name="triggerName">
<value>splitterJobTrigger</value>
</property>
<property name="triggerGroup">
<value>splitterJobTriggerGroup</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="runSplitterScriptAction" />
</property>
<property name="transactionService">
<ref bean="TransactionService" />
</property>
<property name="runAsUser">
<value>svc-alfresco</value>
</property>
</bean>

<bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
<property name="serviceRegistry">
<ref bean="ServiceRegistry" />
</property>
</bean>

This scheduler work fine on Alfresco 4.2.6 but not on our client version 3.4, no output on console (I can execute it manualy), how can I make a operational scheduler on 3.4 version ?

Note: I tried many different possibilities for value field, none worked :

<value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:split_transaction.js"')}</value>

<value>\$\{selectSingleNode('workspace://SpacesStore/', 'lucene', 'and PATH:"/app:company_home/app:dictionary/app:scripts/cm:split_transaction.js"' )\}</value>

<value>selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:split_transaction.js"' )}</value>

Any help would be appreciated.
thx

1 REPLY 1

rennajihi
Champ in-the-making
Champ in-the-making

Bug on 3.4 version https://issues.alfresco.com/jira/browse/ALF-9981 to avoid it : 

<value>#{"${"}selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/ cm:split_transaction.js"' )#{"}"}</value>