[opencms-dev] Scheduled Job

Aitor de la Puente aitor at dicampus.com
Mon May 1 16:04:18 CEST 2006


Hello.

I need to execute a file of my project in a scheduled job. This file is 
"/sites/default/myproject/myjobs/job.html". I have published it, and it works 
alright. It is neccesary to access to the file in the Offline mode. So I 
created a task:

-----------------------------------------------------------------
package com.myproject.myjobs;

import java.util.List;
import java.util.Map;

import org.opencms.file.CmsObject;
import org.opencms.file.collectors.I_CmsResourceCollector;
import org.opencms.flex.CmsFlexCache;
import org.opencms.flex.CmsFlexCacheConfiguration;
import org.opencms.loader.CmsJspLoader;
import org.opencms.main.OpenCms;

public class Job1 implements org.opencms.scheduler.I_CmsScheduledJob {

	public String launch(CmsObject arg0, Map arg1) throws Exception {
		
		CmsJspLoader crl = new CmsJspLoader();
		
        crl.setFlexCache( new CmsFlexCache( new 
CmsFlexCacheConfiguration() ) );
        
        crl.initConfiguration();
        
        I_CmsResourceCollector collector = 
OpenCms.getResourceManager().getContentCollector( "singleFile" );
        
        List m_collectorResult = collector.getResults (
        		arg0,
        		"singleFile",
        		"/sites/default/myproject/myjobs/job.html" ); 
			// also I have used "/myproject/myjobs/job.html"

        return "ok";
    }

}
-----------------------------------------------------------------

And I created a scheduled job in the "Scheduled Jobs Management":

Job settings.
Job name: Job 1
Java class: com.myproject.myjobs.Job1 
Cron expresion: 0 0/5 * * * ?
Active: X

Context info.
User name: Admin
Project: Offline


This job is executed every 5 minutes, but it doesn't realize the changes that 
it have to do. Nevertheless, if I accede to the file from workplace it works 
fine.

Where is the mistake?

Thaks.

-- 

Regards.

--
-- Aitor de la Puente
--



More information about the opencms-dev mailing list