AW: [opencms-dev] scheduled task - publish "page" type resource
Thomas Joseph Olaes
thomas.olaes at gmail.com
Mon Aug 16 19:38:18 CEST 2004
Thanks for your reply, Markus.
Unfortunately, I'm now getting an NullPointerException thrown at:
I_CmsLauncher launcher =
cmsForStaticExport.getLauncherManager().getLauncher(launcherId);
I tried something similar to what you suggested, and it does the trick
up to this point.
I'm thinking "cmsForStaticExport.getLauncherManager()" is returning
null, and that's what's giving me my error. I'll continue to look at
this and try to figure out what's going on, but if you or anyone else
has figured this out already, it would be a real timesaver if I could
get an additional bone thrown my way.
Thanks again for your help, and in advance for any additional advice
you or anyone spares this thread.
-TJ
On Tue, 10 Aug 2004 08:43:48 +0200 (MEST), Markus Strickler
<mstrickler at gmx.de> wrote:
> Hi Thomas-
>
> I faced the same problem some weeks ago.
> What I did was patching com/opencms/file/CmsStaticExport.java like this
> (sorry for not attaching a patch, but our CVS is down right now...):
>
> }else {
> // this will be false if OpenCms is running from the CmsShell
> try{
> if (cms.getRequestContext().getRequest() != null) {
> m_servletUrl =
> cms.getRequestContext().getRequest().getServletUrl();
> m_webAppUrl =
> cms.getRequestContext().getRequest().getWebAppUrl();
> } else {
> String context = A_OpenCms.getOpenCmsContext();
>
> m_webAppUrl = context.substring(0, context.indexOf('/',
> 1));
> m_servletUrl = context.endsWith("/") ? context
> .substring(0, context.length() - 1) : context;
> }
>
> This should do the trick for publishing.
>
> Greetings,
>
> -markus
>
> >-----Ursprüngliche Nachricht-----
> >Von: opencms-dev-admin at opencms.org
> >[mailto:opencms-dev-admin at opencms.org] Im Auftrag von Thomas
> >Joseph Olaes
> >Gesendet: Dienstag, 10. August 2004 03:56
> >An: opencms-dev at opencms.org
> >Betreff: Re: [opencms-dev] scheduled task - publish "page"
> >type resource
> >
> >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
> >>
> >_______________________________________________
> >This mail is send to you from the opencms-dev mailing list
> >To change your list options, or to unsubscribe from the list,
> >please visit
> >http://mail.opencms.org/mailman/listinfo/opencms-dev
> >
> >
>
> --
> NEU: WLAN-Router für 0,- EUR* - auch für DSL-Wechsler!
> GMX DSL = supergünstig & kabellos http://www.gmx.net/de/go/dsl
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
More information about the opencms-dev
mailing list