[opencms-dev] Access Denied From Scheduled Task

Stephan Hartmann hartmann at waehrisch-feykes.de
Wed Jun 18 09:20:02 CEST 2003


Hello Jeffrey,

the task starts in the Online project where you cannot make any changes. You 
have to switch to an offline project. There is a tempfile project with id 3 
(this may change but you can read it from the registry).
You can set your active project by calling

cms.getRequestContext().setCurrentProject(3);

Bye,
Stephan


Am Mittwoch, 18. Juni 2003 00:46 schrieben Sie:

> > Hello:
>
> I have a class that deletes a new file and then creates a new file in its
> place. The code works when run as a jsp scriptlet. However, I modified it
> to run as a Scheduled Task and now I am getting access denied to the
> resource (can't lock the existing file, and can't create a new file after
> manually deleting the original file).
>
> Here is the line from scheduled tasks:
>
> 41 * * * * Admin Administrators com.opencms.modules.homepage.news.weather 1
>
> And here is the relevent code in my file:
>
>     public String launch(CmsObject cms, String param) throws IOException,
> CmsException {
>
> ..... omitted for brevity ...
>
>         try {
>             cms.lockResource("/weather.html");
>         // This fails with access denied
>         } catch (CmsException ex ) {
>            System.err.println(ex.toString());
>         } try {
>             cms.deleteResource("/weather.html");
>         try {
>             CmsResource myFile = cms.createResource("/weather/",
> "weather.html", "plain", null, data);
>
>             cms.unlockResource(myFile.getAbsolutePath());
>
>             cms.publishResource(myFile.getAbsolutePath());
>
>         } catch (CmsException ex ) {
>             System.err.println(ex.toString());
>             return "Failed to update the resource!";
>         }
>         return "Scheduler launched successfully!";
>     }
>
> I have set both the file and directory to be owned by guest and write
> permissions for everyone.
>
> Does anyone have any idea what's going wrong?
>
> FYI, my program pulls the current weather conditions in Washington, DC from
> the US Government Weather Service's web page, parses the html, and creates
> a file that can be included on  my home page. If anyone is interested in
> this, I'll be happy to make the code available. It can be easily modified
> for other US cities (I'm not sure about Europe, sorry guys!).
>
> Regards,
>
> Jeff

----------------------------------------
Content-Type: text/html; charset="ISO-8859-1"; name="Anhang: 1"
Content-Transfer-Encoding: quoted-printable
Content-Description: 
----------------------------------------



More information about the opencms-dev mailing list