AnsweredAssumed Answered

Scheduled java script with parameter

Question asked by e-manuel on Sep 23, 2008
Latest reply on Sep 24, 2008 by e-manuel
Hi,

i have a java script, that needs a xml-configuration file to get informations.
I can start it in the webclient without problems.
I select the details of the XML-File. Then i go to "Run Action" and i select to execute a Script. Then i select the right script.js and everything works fine.

Now i want to use the "Scheduled Action" feature of Alfresco 2.1 Community.
I followed the Instructions on
http://wiki.alfresco.com/wiki/Scheduled_Actions
but i don't know, how to configure it to use the config-XML file.
i can start it without the xml file, but i have to start it with the configuration xml file.

what can i do???

this is my scheduled-action-services-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

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

        <bean id="runScriptAction" 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>
                    <value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/cm:FC_PLANUNG/cm:Admin/cm:FC_Deadline.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>
   
    <!–
   Run the script every minute - select the single node company home that is not used …
    –>
    <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>
        <property name="queryTemplate">
              <value>PATH:"/app:company_home"</value>
        </property>
        <property name="cronExpression">
            <value>50 * * * * ? *</value>
        </property>
        <property name="jobName">
            <value>jobD</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerD</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="runScriptAction"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean> 
</beans>

thank you and best regards!

Outcomes