<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.6944.0">
<TITLE>Using CMS to programmatically publish files</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">All,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">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. </FONT></P>

<P><FONT SIZE=2 FACE="Arial">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". </FONT></P>

<P><FONT SIZE=2 FACE="Arial">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?</FONT></P>

<P><FONT SIZE=2 FACE="Arial">An alternative might be to try and publish everything, and then go through after the publish and tidy up the locks.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Any help, or suggestions would be useful.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">// Initialise</FONT>

<BR><FONT SIZE=2 FACE="Courier New">Configurations conf = new Configurations(new ExtendedProperties("/var/tomcat4/webapps/opencms/WEB-INF/config/opencms.properties"));</FONT></P>

<P><FONT SIZE=2 FACE="Courier New">OpenCms m_openCms = new OpenCms(conf);</FONT>

<BR><FONT SIZE=2 FACE="Courier New">CmsObject m_cms = new CmsObject();</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">// Log in as Admin (may exceed normal users rights).</FONT>

<BR><FONT SIZE=2 FACE="Courier New">m_openCms.initUser(m_cms, null, null, I_CmsConstants.C_USER_ADMIN, I_CmsConstants.C_GROUP_ADMIN, 4, null);</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">// Publish</FONT>

<BR><FONT SIZE=2 FACE="Courier New">m_cms.publishResource("/site1/");</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Regards,</FONT>
</P>

<P><SPAN LANG="en-us"><B><I><FONT SIZE=2 FACE="Arial">Brett Beaumont</FONT></I></B></SPAN><B><I><SPAN LANG="en-nz"></SPAN></I><SPAN LANG="en-nz"><FONT SIZE=2 FACE="Arial"></FONT></SPAN></B><SPAN LANG="en-nz"> </SPAN>

<BR><SPAN LANG="en-us"><I><FONT SIZE=1 FACE="Arial">T</FONT><FONT SIZE=2 FACE="Arial">echnical Consultant </FONT></I></SPAN>

<BR><SPAN LANG="en-us"><I><FONT SIZE=2 FACE="Arial">Sytec Resources Limited</FONT></I></SPAN><I><SPAN LANG="en-nz"><FONT SIZE=2 FACE="Arial"></FONT></SPAN></I><I><SPAN LANG="en-nz"><B></B></SPAN></I><SPAN LANG="en-nz"><B></B><B> </B></SPAN>
</P>

<P><SPAN LANG="en-nz"><I><FONT SIZE=1 FACE="Arial">Phone</FONT></I>   <FONT SIZE=1 FACE="Arial">+64 4 473 5805<BR>
</FONT><I><FONT SIZE=1 FACE="Arial">Fax</FONT></I><FONT SIZE=1 FACE="Arial">     +64 4 473 5812</FONT></SPAN>

<BR><SPAN LANG="en-nz"><I><FONT SIZE=1 FACE="Arial">Email</FONT></I><FONT SIZE=1 FACE="Arial">  <U> </U></FONT><U><FONT COLOR="#0000FF" SIZE=1 FACE="Arial"><<A HREF="mailto:brett.beaumont@sytec.com">mailto:brett.beaumont@sytec.com</A>></FONT></U></SPAN>

<BR><SPAN LANG="en-nz"><I><FONT SIZE=1 FACE="Arial">WWW</FONT></I><FONT SIZE=1 FACE="Arial">     <A HREF="http://www.sytec.com">http://www.sytec.com</A></FONT></SPAN>
</P>

<P><SPAN LANG="en-nz"><FONT SIZE=1 FACE="Arial">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.</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><B></B></SPAN><SPAN LANG="en-us"><B><I></I></B></SPAN><SPAN LANG="en-us"><B><I></I></B></SPAN></P>

</BODY>
</HTML>