[opencms-dev] creating a file

Christoph P. Kukulies kuku at physik.rwth-aachen.de
Thu Aug 28 17:01:42 CEST 2008


See between the lines...

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).
> 
> 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(), 


What else resourceTypeNames are there besides "plain"? Would a google
sitemap file have to be structured contents? Or a plain sitemap.xml file?

> 	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


--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de



More information about the opencms-dev mailing list