AnsweredAssumed Answered

scheduler did not work

Question asked by patdab90 on Dec 30, 2013
Latest reply on Dec 30, 2013 by rjohnson
I created a scheduler as in the example on the Alfresco wiki page (http://wiki.alfresco.com/wiki/Scheduled_Actions) but it does not work. In final form it should delete documents older than 30 days and this cron and lucene query is only for test (it remove in every second all documents from folder test). I create it in simple amp module and I install it as in tutorial (http://docs.alfresco.com/4.1/index.jsp?topic=/com.alfresco.enterprise.doc/tasks/amp-install.html). My beans:


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

    </bean>

<!– Action –>
<bean id="deleteNodesActionBean"
    class="pl.consdata.eximee.spike.deletescheduler.DeleteNodeActionExecuter"
    parent="action-executer">
    <property name="nodeService">
        <ref bean="nodeService" />
    </property>
    <property name="transactionService">
        <ref bean="TransactionService" />
    </property>
</bean>

<!– Action Definition –>
<bean id="deletefilesActionDefinition"
    class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
    <property name="actionName">
        <value>deleteNodesActionBean</value>
    </property>
    <!– Required services and the FreeMarker template model –>
    <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>

<!– Scheduler –>
<bean id="addClassifiableAspectEveryTenMinutes"
    class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
    <property name="transactionMode">
        <value>ISOLATED_TRANSACTIONS</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>
    <!– QUERY –>
    <property name="queryTemplate">
        <value>PATH:"/app:company_home/cm:test/*"</value>
    </property>
    <property name="cronExpression">
        <value>0/1 * * * * ?</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>
    <!– Inject the scheduler - the trigger will be registered with this scheduler –>
    <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="deletefilesActionDefinition" />
    </property>
    <property name="transactionService">
        <ref bean="TransactionService" />
    </property>
    <property name="runAsUser">
        <value>System</value>
    </property>
</bean>



And my action code:



public class DeleteNodeActionExecuter extends ActionExecuterAbstractBase {

public static final String NAME = "deleteNodesActionBean";

private static final Logger LOGGER = LoggerFactory
        .getLogger(DeleteNodeActionExecuter.class);

private NodeService nodeService;

private TransactionService transactionService;

public void setNodeService(final NodeService nodeService) {
    this.nodeService = nodeService;
}

public void setTransactionService(TransactionService transactionService) {
    this.transactionService = transactionService;
}

@Override
protected void executeImpl(Action action, final NodeRef actionedUponNodeRef) {
    if (!nodeService.exists(actionedUponNodeRef)) {
        LOGGER.warn("< node does not exist!", action, actionedUponNodeRef);
        return;
    }
    transactionService.getRetryingTransactionHelper().doInTransaction(
            new RetryingTransactionCallback<Void>() {

                public Void execute() throws Throwable {
                    if (!nodeService.exists(actionedUponNodeRef)) {
                        // Node has gone away, skip
                        LOGGER.debug("Node has gone away, skip: "+ actionedUponNodeRef.getId());
                        return null;
                    }
                    LOGGER.debug("deleting node: "
                            + actionedUponNodeRef.getId());
                    nodeService.deleteNode(actionedUponNodeRef);
                    LOGGER.debug("node deleted");
                    return null;
                }
            });

}

@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {

}



Link to my questions on: http://stackoverflow.com/questions/20835031/alfresco-scheduler-did-not-work

Outcomes