[opencms-dev] Scheduled task

Samuel Shum Hiu Yeung (FS) sshum at frontline.com.sg
Wed Mar 5 12:49:34 CET 2003


Thanks Andreas,

Now I have successfully run the scheduled task to publish a project.
But while trying to synchronize a folder, I got the following exception.

[05.03.2003 19:41:10] <opencms_cronscheduler> Error running job for
com.opencms.core.CmsCronEntry{41 * * * * Admin Administrators
sg.com.frontline.cms.ScheduleSync /user_projects/samuel_folder/} Error:
com.opencms.core.CmsException: 2 Not found. Detailed error:
[com.opencms.file.CmsSynchronize] /user_projects/samuel_folder/.
 at
com.opencms.file.CmsSynchronize.synchronizeServer(CmsSynchronize.java:154)
 at com.opencms.file.CmsSynchronize.<init>(CmsSynchronize.java:121)
 at com.opencms.file.CmsObject.syncFolder(CmsObject.java:3785)
 at sg.com.frontline.rapid.cms.ScheduleSync.launch(ScheduleSync.java:18)
 at com.opencms.core.CmsCronScheduleJob.run(CmsCronScheduleJob.java:68)

My confusion is mainly on the Foldername to be passed to the method
syncFolder(Foldername).
Shall it be the system file path or the virtual file path? I tried both put
both throw me some Not Found exception.

Thanks,
Samuel

----- Original Message -----
From: "Andreas Zahner" <A.Zahner at alkacon.com>
To: <opencms-dev at www.opencms.org>
Sent: Wednesday, March 05, 2003 4:24 PM
Subject: AW: [opencms-dev] Scheduled task


Samuel,

you can publish a project by using the method publishProject() of the
CmsObject, e.g. "cms.publishProject(ProjectId);". All you need to know
in the launch() method is the project ID of your project, which you can
pass as a parameter from the Backoffice and then cast to int. You can
easily get the project ID by viewing the source code of the head frame
of the OpenCms workplace.

For synchronization, use the method syncFolder(Foldername) of the
CmsObject.

Regards,

Andreas Zahner
Alkacon Software - The OpenCms Experts
http://www.alkacon.com


-----Ursprüngliche Nachricht-----
Von: owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org] Im Auftrag von Samuel Shum
Hiu Yeung (FS)
Gesendet: Mittwoch, 5. März 2003 03:11
An: opencms-dev at www.opencms.org
Betreff: Re: [opencms-dev] Scheduled task


Thanks Andrea,

I am actually trying to write a scheduled task to do publishing and/or
synchonization the website contents daily, e.g. for news publishing. So
I am looking for the API that is to be called for publishing from the
cronjob class. And I guess it shall be
com.opencms.workplace.CmsAdminProjectPublish
or CmsAdminPublishProjectThread
But it requires parameters like the CmsObject, projectId, CmsSession
etc..., which may not be intuitive to be constructed in the cronjob
class.

Does anyone who has done this before? Or already there is such feature
in Opencms?

Thanks for the guidance,
Samuel

----- Original Message -----
From: "Andreas Zahner" <A.Zahner at alkacon.com>
To: <opencms-dev at www.opencms.org>
Sent: Tuesday, March 04, 2003 8:26 PM
Subject: AW: [opencms-dev] Scheduled task


Samuel,

you can use "Scheduled tasks" to run special tasks in OpenCms, e.g. send
a Newsletter every month, check something every 30 minutes etc.

In the OpenCms backoffice, you have to enter the following information
(separated by a space): Minute, hour, day, month, day of week, user,
group, java class, parameter.

An example for the backoffice entry:
"6 12 * * * Admin Administrators your.package.ClassName aParam" runs
your class every day at 12.06 am as user Admin in the Administrators
group. Further examples for adjusting the time: "5 12 * * 0" runs your
class every Monday at 12.05, "30 11 24 12 *" runs your class every year
on December, 24th at 11.30

Your Java class has to implement the class I_CmsCronJob (package
com.opencms.core) and provide a method "launch" which will be executed.

Example:
/**
 * This method is called by the scheduler.<p>
 *
 * @param CmsObject the Cms object
 * @param parameter the parameters entered in the backoffice
 * @return String String that is written to the opencms log
*/
public String launch(CmsObject cms, String parameter) throws
IOException, CmsException { // enter your code here!! return "Scheduler
launched successfully!"; }

Now you should be able to create your own scheduled tasks.

Regards,

Andreas Zahner
Alkacon Software - The OpenCms Experts
http://www.alkacon.com

-----Ursprüngliche Nachricht-----
Von: owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org] Im Auftrag von Samuel Shum
Hiu Yeung (FS)
Gesendet: Dienstag, 4. März 2003 11:09
An: opencms-dev at www.opencms.org
Betreff: [opencms-dev] Scheduled task


Hi,

I think Scheduled Task is a new feature in opencms 5.0.
Can anyone provide me an example or some kind of writeup on how to use
it? Or please direct me to a place that I can get the information on
using it?

Thanks so much,
Samuel




More information about the opencms-dev mailing list