[opencms-dev] creating a file
Christoph P. Kukulies
kuku at physik.rwth-aachen.de
Wed Aug 27 20:38:26 CEST 2008
On Wed, Aug 27, 2008 at 06:24:16AM -0700, Roman Uhlig wrote:
>
> We use OpenCms.createResource() for that (e.g. automatically creating Google
> Sitemaps every night).
Funnily that's exactly what I'm trying to do, a Google sitemap :-)
Thanks.
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
> Looks like that:
>
> CmsObject cmso = ....
> String filename = ...
> String s_filecontent = ...
> ...
>
> cmso.getRequestContext().setCurrentProject(cmso.readProject("Offline"));
>
> if (cmso.existsResource(filename)) {
> cmso.lockResourceTemporary(filename);
> cmso.deleteResource(filename, CmsResource.DELETE_PRESERVE_SIBLINGS);
> if (cmso.existsResource(filename)) {
> cmso.unlockResource(filename);
> cmso.publishResource(filename);
> }
> }
> cmso.createResource(
> filename,
> OpenCms.getResourceManager().getResourceType("plain").getTypeId(),
> s_filecontent.getBytes(),
> new ArrayList()
> );
> cmso.unlockResource(filename);
> cmso.publishResource(filename);
>
> cmso.getRequestContext().setCurrentProject(cmso.readProject("Online"));
>
>
> This works also in the latest OpenCms 6 versions (publishResource is
> deprecated as of version 7).
>
> HTH,
> Roman
>
> --
> View this message in context: http://www.nabble.com/creating-a-file-tp19178157p19180880.html
> Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list