[opencms-dev] scheduled task - publish "page" type resource

Thomas Joseph Olaes thomas.olaes at gmail.com
Tue Aug 10 03:56:01 CEST 2004


Alright, I think I figured out why my scheduled task wasn't working.

Line 229 and 230 in com/opencms/file/CmsStaticExport.java (OpenCMS 5.0.1)

...
[229]        }else if (cms.getRequestContext().getRequest() != null) {
[230]            // this will be false if OpenCms is running from the CmsShell
...

since I doubt cms.getRequestContext().getRequest() will return
something other than null when run as a scheduled task, I guess I
flunk this test.

How does one go about publishing *and* exporting a resource from
within a scheduled task?

-TJ

On Mon, 9 Aug 2004 14:26:44 -0700, Thomas Joseph Olaes
<thomas.olaes at gmail.com> wrote:
> Hello list,
> 
> I've been trying to find an answer to my problem for a few hours now
> and have been scouring the source code and google to no avail...
> 
> let's say I have a file in the VFS called:
> 
> "/test.html"
> 
> and I have a scheduled task that has the following in launch():
> 
> // set project to offlineproject
> ...
> 
> cmsobject.lockResource("/test.html");
> // read /test.html in the VFS
> ...
> 
> // do stuff to /test.html in the VFS
> ...
> 
> // save the content to /test.html in the VFS
> ...
> cmsobject.touch("/test.html");
> cmsobject.unlockResource("/test.html");
> cmsobject.publishResource("/test.html");
> 
> I'm pretty much doing the above, and when I publish the resource in my
> scheduled task it looks like the resource is published in the DB, and
> I even get the output in the Tomcat command console:
> 
> ...
> Publishing /system/bodies/sites/site1/index.html
> Publishing /sites/site1/index.html
> ------ Checking filesystem links ...
> ------ .. filesystem link check finished
> ...
> 
> The above is actual text from the output of doing the command
> cmsobject.publishResource(sResourceName);
> 
> I'm really at a loss here. I notice when I do a normal publish through
> the OpenCMS app, I see:
> 
> Publishing resource ...
> Publishing /sites/site1/test1.html
> Publishing /system/bodies/sites/site1/test1.html
> Static export, number of starting links is: 2
> Exporting /sites/site1/test1.html
> Skipping /system/bodies/sites/site1/test1.html
> ... static export finished
> Checking filesystem links ...
> .. filesystem link check finished
> ... the resource has been published
> 
> It looks to me I'm missing this section involving the static export...
> but when I look at the file
> com/opencms/workspace/CmsPublishResourceThread.java in the source code
> all I see is
> 
> (line 60)
> m_report.println(m_report.key("report.publish_resource_begin"),
> I_CmsReport.C_FORMAT_HEADLINE);
> (line 61)            m_cms.publishResource(m_resourceName, false, m_report);
> (line 62)
> m_report.println(m_report.key("report.publish_resource_end"),
> I_CmsReport.C_FORMAT_HEADLINE);
> 
> where m_cms is a CmsObject acquired through the Servlet interface. the
> lines 60 and 62 just print out: "Publishing resource ..." and "... the
> resource has been published", so I expected if I just did
> publishResource(sResourceName) which actually maps to
> publishResource(sResourceName, false, new CmsShellReport()), which
> looks similar enough to me...
> 
> Maybe I'm missing something set within the cmsobject? There's a bunch
> of different variables and stuff that I've skimmed over and I know
> there's one thing here that's so obvious but I can't see it right now.
> I even checked cmsobject.getStaticExportProperties().isStaticExportEnabled()
> to see if it was passing as true and it was, so that whole code inside
> that if statement (CmsObject.java, lines 2445-2473) is running.
> 
> So to summarize: I can't get cmsobject.publishResource(String
> resourceName); to work from within a scheduled task.
> 
> Thanks in advance for any help given to me, I tried putting up as
> detailed information above as I could and the steps I've taken so far
> to try to resolve this if it helps any.
> 
> -TJ
>



More information about the opencms-dev mailing list