AW: [opencms-dev] Scheduled task

Andreas Zahner A.Zahner at alkacon.com
Wed Mar 5 13:31:32 CET 2003


Samuel,

I didn't try this, but I think there are two possible reasons for your
exception. First, the resource does not exist (I assume you checked
that), and second, the system is in the Online project while
synchronizing. So you have to change the current project to an existing
offline project before synchronizing your folders.

You can do that as follows:
CmsProject myProject = cms.getRequestContext().currentProject();
int oldProjectId = myProject.getId();
cms.getRequestContext().setCurrentProject(anOfflineProjectId);
cms.syncFolder("/absolute/path/to/your/folder/");
cms.getRequestContext().setCurrentProject(oldProjectId);

Be sure that the resources are present in the VFS of OpenCms! I hope
this helps.

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 12:50
An: opencms-dev at www.opencms.org
Betreff: Re: [opencms-dev] Scheduled task


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:15
4)
 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





More information about the opencms-dev mailing list