[opencms-dev] Problems and scheduled static export

Niklas Eklund niklas at curalia.se
Wed Jan 7 14:59:01 CET 2004


Hello,

This is two snippets of the hack in the cron job I used to get it working:

		String webappURL = null;
		String servletURL = null;
		try {
			String context = A_OpenCms.getOpenCmsContext();
			webappURL = context.substring(0, context.indexOf('/', 1));
			servletURL =
				context.endsWith("/")
					? context.substring(0, context.length() - 1)
					: context;
		} catch (RuntimeException e) {
			return "Context not set up yet, cannot continue";
		}

...
...
...

				// set up the necessary env
				CmsExportRequest dReq =
					new CmsExportRequest(webappURL, servletURL);
				CmsExportResponse dRes = new CmsExportResponse();
				CmsObject cmsForStaticExport =
					cms.getCmsObjectForStaticExport(dReq, dRes);
				// hmm, seems to work
				cmsForStaticExport.setLauncherManager(
					new CmsLauncherManager(null));

		 
cms.getRequestContext().setCurrentProject(I_CmsConstants.C_PROJECT_ONLINE_ID);

				CmsStaticExport staticExport =
					new CmsStaticExport(
						cmsForStaticExport,
						exportResources,
						true,
						new Vector(),
						new Vector(),
						null,
						new CmsShellReport());
			}

exportResources is a Vector with the absolute paths (String) to the 
resources you want to export. You will get a warning/error about 
something (can't remember about what, but it should work). Good luck!

Regards,

  Niklas

Jörg Herbst wrote:

> Hi,
> 
> I'm trying to implement a scheduled publishing of my project. I've 
> implemented a I_CmsCronJob Object for calling cms.publishProject. This 
> works fine and the project is published as I want.
> My problem is, the static export is not triggered. I guess there is no 
> RequestContext in CmsStaticExport  [Line 229] 
> (cms.getRequestContext().getRequest() != null), so the static export 
> branch is never processed.
> So I've tried to change the source, removing the if condition. Now I'm 
> running in problems of a missing Launcher object (NullPointerException).
> Has anybody successfully implemented a scheduled publishing including a 
> static file export yet and can give me some help?
> 
> Thanks
> Joerg
> 
> 
> _______________________________________________
> 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