<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2995" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>You can export with a scheduled job and this code,
adapted to your needs and environment :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>For a module:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
String moduleName = "my.mod";</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // Module
resources<BR> List resList =
OpenCms.getModuleManager().getModule(moduleName)<BR>
.getResources();<BR> // Verify
resources<BR> ArrayList resListCopy = new
ArrayList();<BR> for (Iterator it =
resList.iterator(); it.hasNext();)
{<BR> String res = (String)
it.next();<BR> try
{<BR> if (res
!= null)
{<BR>
cms.readResource(res);<BR>
resListCopy.add(res);<BR>
}<BR> } catch (Exception e)
{<BR> //
Resource not available - Log it</FONT><FONT face=Arial
size=2><BR> }<BR>
}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> String[] resources =
new String[resListCopy.size()];</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> for (int i = 0; i
< resListCopy.size(); i++)
{<BR> resources[i] = (String)
resListCopy.get(i);<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> String moduleFile =
OpenCms.getSystemInfo()<BR>
.getAbsoluteRfsPathRelativeToWebInf("packages/modules/"
<BR>
+ moduleName + ".zip");<BR> File file = new
File(moduleFile);<BR> if (file.exists())
{<BR>
file.delete();<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
CmsModuleImportExportHandler moduleExportHandler = new
CmsModuleImportExportHandler();<BR>
moduleExportHandler.setFileName(moduleFile);<BR>
moduleExportHandler.setAdditionalResources(resources);<BR>
moduleExportHandler.setModuleName(moduleName.replace('\\',
'/'));<BR>
moduleExportHandler.setDescription("Module Export:
"<BR> +
moduleExportHandler.getModuleName());</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> //
Export<BR>
OpenCms.getImportExportManager().exportData(cms, moduleExportHandler,
report);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>For a site folder:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> String filePath =
OpenCms.getSystemInfo()<BR>
.getAbsoluteRfsPathRelativeToWebInf(<BR>
"packages/" + folderName + ".zip");</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> File file = new
File(filePath);<BR> if (file.exists())
{<BR>
file.delete();<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> List
resourcesToExport = new ArrayList();<BR>
resourcesToExport.add(folderName + "/");</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> CmsExport ce = new
CmsExport(cms, filePath, resourcesToExport,
false,<BR>
true, null, false, false, 0L, report, true);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I suppose that these are the corresponding
classes/methods to import.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Hope this helps,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Pere</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=vb@sharedvision.com href="mailto:vb@sharedvision.com">Michael von
Bodungen</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=opencms-dev@opencms.org
href="mailto:opencms-dev@opencms.org">opencms-dev@opencms.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, March 31, 2008 4:45
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [opencms-dev] Can the export of
a project and modules from one server and import to another server be
automated</DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR></DIV>
<DIV><SPAN class=219254214-31032008><FONT face=Arial size=2>We are using
OpenCms and we have a staging server and production server. The staging
server is where users make all content changes, rather than in
production. We would like to automate the export of the OpenCms project
and modules on staging and their import to OpenCms on the production
server.</FONT></SPAN></DIV>
<DIV><SPAN class=219254214-31032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=219254214-31032008><FONT face=Arial size=2>Looking at the
scheduler, I can't see any predefined jobs. Can anyone tell me if this
has been done - supply any suggestions?</FONT></SPAN></DIV>
<DIV><SPAN class=219254214-31032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=219254214-31032008><FONT face=Arial
size=2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=219254214-31032008><FONT face=Arial
size=2>Michael</FONT></SPAN></DIV>
<DIV><SPAN class=219254214-31032008></SPAN> </DIV>
<P>
<HR>
<P></P><BR>_______________________________________________<BR>This mail is
sent to you from the opencms-dev mailing list<BR>To change your list options,
or to unsubscribe from the list, please
visit<BR>http://lists.opencms.org/mailman/listinfo/opencms-dev</BLOCKQUOTE></BODY></HTML>