Scheduled Actions Alfresco 4.2f

cancel
Showing results for 
Search instead for 
Did you mean: 
ruben_arjonilla
Member II

Scheduled Actions Alfresco 4.2f

Buenos días,

Recientemente hemos actualizado alfresco de la versión 4.0.e a la 4.2.f y nos hemos dado cuenta de que los Scheduled Jobs que teníamos programados no se ejecutan.

que cambios hay que realizar para que funcione en alfresco 4.2.f?

os pongo el fichero de configuración que utilizábamos hasta ahora (basado en la mini-guia encontrada en este mismo foro https://forums.alfresco.com/es/forum/extender-o-cambiar-alfresco/mini-gu%C3%ADa-scheduled-actions-06... )

este es el código del fichero que tenemos en {alf_dir}/tomcat/shared/classes/alfresco/extension/custom-job-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="jobXXX" class="org.springframework.scheduling.quartz.JobDetailBean">
      <property name="jobClass" value="com.xxx.scheduledJobs.CronXXX"/>
      <property name="jobDataAsMap">
         <map>
            <entry key="transactionService" value-ref="transactionService"/>
            <entry key="authenticationComponent" value-ref="authenticationComponent"/>
            <entry key="nodeService" value-ref="nodeService"/>
            <entry key="contentService" value-ref="contentService"/>
         </map>
      </property>
   </bean>
   
   <!– Definición del trigger –>
   <bean id="cronXXXTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
      <property name="jobDetail" ref="jobXXX"/>
      <property name="cronExpression" value="0 0 02 * * ?"/>
   </bean>
   
   <!– Listamos el trigger en la factory para arrancarlo –>
   <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
      <property name="triggers">
         <list>
            <ref bean="cronXXXTrigger"/>
         </list>
      </property>
   </bean>
</beans>


lo que hacemos con este job, es llamar a un JAVA que realiza una serie de acciones cada día a las 2 de la mañana.

He estado buscando información por internet, y creo que este formato ha cambiado ( https://wiki.alfresco.com/wiki/Scheduled_Actions ), ya que lo que sale en la web no se parece en nada a lo que tenia hasta la versión anterior.

He probado a cambiar el nombre del fichero "custom-job-context.xml" a "scheduled-action-services-context.xml", que es el que viene en la versión 4.2.f "scheduled-action-services-context.xml.sample".

os pongo también este último fichero "scheduled-action-services-context.xml.sample"

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

<beans>
   
    <!–
    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>
   
    <!–
    An example action template that defines an action to add the generalclassifiable aspect to all nodes that do not have
    and add a category defined by path.   
    –>
    <bean id="addClassifiableAspectAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>add-features</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>aspect-name</value>
                    </key>
                    <value>{http://www.alfresco.org/model/content/1.0}generalclassifiable</value>
                </entry>
               
                <entry>
                    <key>
                        <value>{http://www.alfresco.org/model/content/1.0}categories</value>
                    </key>
                    <value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/cm:generalclassifiable/cm:Languages/cm:English"' )}</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>
   
    <!–
    An example action template that removes an aspect from all those nodes that have the aspect.
    –>
    <bean id="removeClassifiableAspectAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>remove-features</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>aspect-name</value>
                    </key>
                    <value>{http://www.alfresco.org/model/content/1.0}generalclassifiable</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>
   
    <!–
    An example that copies the tutorial node into the company home space
    –>
    <bean id="copyAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>copy</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>destination-folder</value>
                    </key>
                    <value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home"' )}</value>
                </entry>
                <entry>
                    <key>
                        <value>assoc-type</value>
                    </key>
                    <value>${node.primaryParentAssoc.typeQName}</value>
                </entry>
                <entry>
                    <key>
                        <value>assoc-name</value>
                    </key>
                    <value>${node.primaryParentAssoc.QName}</value>
                </entry>
                <entry>
                    <key>
                        <value>deep-copy</value>
                    </key>
                    <value>false</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>
   
    <!–
    An example that sets the created date to now
    –>
    <bean id="setCreatedDateAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>set-property-value</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>property</value>
                    </key>
                    <value>{http://www.alfresco.org/model/content/1.0}created</value>
                </entry>
                <entry>
                    <key>
                        <value>value</value>
                    </key>
                    <value>${today?string("yyyy-MM-dd'T'HH:mm:ss.sss'Z'")}</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>
   
    <!–
    Compound action example …
    –>
   
    <bean id="compositeAction" class="org.alfresco.repo.action.scheduled.CompositeTemplateActionDefinition">
        <property name="actionService">
            <ref bean="ActionService"/>
        </property>
        <property name="templateService">
            <ref bean="TemplateService"/>
        </property>
        <property name="templateActionDefinitions">
            <list>
                <ref bean="copyAction"/>
                <ref bean="setCreatedDateAction"/>
            </list>
        </property>
    </bean>
   
    <!– ONE_TRANSACTION    ISOLATED_TRANSACTIONS      UNTIL_FIRST_FAILURE –>
   
    <!–
    Define a job for adding the classified aspect to nodes.
    –>
    <bean id="addClassifiableAspectEveryTenMinutes" 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>PATH:"//\*" -ASPECT:"{http://www.alfresco.org/model/content/1.0}generalclassifiable"</value>
        </property>
        <property name="cronExpression">
            <value>0 50 * * * ?</value>
        </property>
        <property name="jobName">
            <value>jobA</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerA</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="addClassifiableAspectAction"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
    <!–
    Define a job to remove an aspect.
    –>
    <bean id="removeClassifiableAspectEveryTenMinutes" 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>ASPECT:"{http://www.alfresco.org/model/content/1.0}generalclassifiable"</value>
        </property>
        <property name="cronExpression">
            <value>0 55 * * * ?</value>
        </property>
        <property name="jobName">
            <value>jobB</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerB</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="removeClassifiableAspectAction"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
    <!–
    Define a job to remove an aspect.
    –>
    <bean id="copyTutorialEveryTenMinutes" 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/*//*" +TEXT:"tutorial"</value>
        </property>
        <property name="cronExpression">
            <value>0 40 * * * ?</value>
        </property>
        <property name="jobName">
            <value>jobC</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerC</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="copyAction"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
    <!–
    Find content created yesterday in the previous 10 years:-
    set the created date to today and copy to the company home 
    –>
    <bean id="makeStuffCreatedRecentlyCreatedNow" 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>@cm\:created:${luceneDateRange(yesterday, "-P10Y")}</value>
        </property>
        <property name="cronExpression">
            <value>0 0/1 * * * ?</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="compositeAction"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
</beans>


Si alguien me puede ayudar le estaría muy agradecido.

Gracias de antemano
2 Replies
angelborroy
Alfresco Employee

Re: Scheduled Actions Alfresco 4.2f

Todo lo que describes es correcto y debería funcionar. Colocar el
custom-job-context.xml
en la carpeta "extension" es suficiente.

Supongo que el problema es que no habéis recompilado vuestra clase
com.xxx.scheduledJobs.CronXXX
para la nueva versión de Alfresco o que está arrojando alguna excepción no controlada. En cualquier caso, el cron está bien definido y debería estar activo.
Hyland Developer Evangelist
ruben_arjonilla
Member II

Re: Scheduled Actions Alfresco 4.2f

Gracias por tu respuesta.

Nos olvidamos de recompilar nuestro JAVA con los ".jar" de la nueva versión.

Queda solucionado