[opencms-dev] Using CMS to programmatically publish files

Brett Beaumont brett.beaumont at sytec.co.nz
Thu Aug 11 04:11:08 CEST 2005


All,

I'm running OpenCMS 5.0 for one of our clients. We have implemented separate sites as different root level folders. However, since different groups of people manage the different sites, we have run into an issue with the publishing and exporting processes. I can't make everyone admins, because then they get rights on each other's sites, and I can't use projects because the system allows you to copy any file into your project. 

The ideal solution would be for the "site1" people to be able to publish and export their site, and for the "site2" people to be able to publish and export theirs. To do this, I've started down the line of writing a basic JSP that will switch to Admin rights and publish "site1". 

I've got some base level code working as below. I haven't tested it too much, but it seems to publish okay as long as everything is already unlocked. If files are locked, then those get left unpublished (which is ideal), but they get moved into the temporary publishing project (which is destroyed at the end of the publishing process, leaving the files locked in an unexisting project). Ideally, I would like to publish all files or folders that are not locked. In terms of folders, I want to be able to publish unlocked folders, but ignore any of their locked children?

An alternative might be to try and publish everything, and then go through after the publish and tidy up the locks.

Otherwise, I might implement a solution where "site1" managers can only publish their site if everything is unlocked. It's not ideal, but it will help reduce the load on our super-admin.

Any help, or suggestions would be useful.

// Initialise
Configurations conf = new Configurations(new ExtendedProperties("/var/tomcat4/webapps/opencms/WEB-INF/config/opencms.properties"));
OpenCms m_openCms = new OpenCms(conf);
CmsObject m_cms = new CmsObject();

// Log in as Admin (may exceed normal users rights).
m_openCms.initUser(m_cms, null, null, I_CmsConstants.C_USER_ADMIN, I_CmsConstants.C_GROUP_ADMIN, 4, null);

// Publish
m_cms.publishResource("/site1/");

Regards,

Brett Beaumont 
Technical Consultant 
Sytec Resources Limited 

Phone	+64 4 473 5805
Fax 	+64 4 473 5812
Email 	<mailto:brett.beaumont at sytec.com>
WWW 	http://www.sytec.com

Important:  This electronic mail message and attachments (if any) are confidential and may be legally privileged.  If you are not the intended recipient please contact us immediately and destroy this message.  You may not legally copy, disclose, disseminate or use the contents in any way.  Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20050811/3a1ced6b/attachment.htm>


More information about the opencms-dev mailing list