return context;
}
private Folder processFolder(Folder srcFolder, PageManager dest, Context context) throws JetspeedException
{
Folder dstFolder = lookupFolder(dest, srcFolder.getPath());
if (null != dstFolder)
{
if (context.overwriteFolders)
{
context.logger.info("overwriting folder " + srcFolder.getPath());
dest.removeFolder(dstFolder);
dstFolder = dest.copyFolder(srcFolder, srcFolder.getPath());
dest.updateFolder(dstFolder);
context.folderCount++;
}
else
{
context.logger.info("skipping folder " + srcFolder.getPath());
}
}
else
{
context.logger.info("processing new folder " + srcFolder.getPath());
dstFolder = dest.copyFolder(srcFolder, srcFolder.getPath());
dest.updateFolder(dstFolder);
context.folderCount++;
}
Iterator pages = srcFolder.getPages().iterator();
while (pages.hasNext())
{
Page srcPage = (Page) pages.next();
Page dstPage = lookupPage(dest, srcPage.getPath());
if (null != dstPage)
{
if (context.overwritePages)
{
context.logger.info("overwriting page " + srcPage.getPath());
dest.removePage(dstPage);
dstPage = dest.copyPage(srcPage, srcPage.getPath(), true);
dest.updatePage(dstPage);
context.pageCount++;
}
else
{
context.logger.info("skipping page " + srcPage.getPath());
}
}
else
{
context.logger.info("processing new page " + srcPage.getPath());
dstPage = dest.copyPage(srcPage, srcPage.getPath(), true);
dest.updatePage(dstPage);
context.pageCount++;
}
}
Iterator pageTemplates = srcFolder.getPageTemplates().iterator();
while (pageTemplates.hasNext())
{
PageTemplate srcPageTemplate = (PageTemplate) pageTemplates.next();
PageTemplate dstPageTemplate = lookupPageTemplate(dest, srcPageTemplate.getPath());
if (null != dstPageTemplate)
{
if (context.overwritePages)
{
context.logger.info("overwriting page template " + srcPageTemplate.getPath());
dest.removePageTemplate(dstPageTemplate);
dstPageTemplate = dest.copyPageTemplate(srcPageTemplate, srcPageTemplate.getPath(), true);
dest.updatePageTemplate(dstPageTemplate);
context.pageCount++;
}
else
{
context.logger.info("skipping page template " + srcPageTemplate.getPath());
}
}
else
{
context.logger.info("processing new page template " + srcPageTemplate.getPath());
dstPageTemplate = dest.copyPageTemplate(srcPageTemplate, srcPageTemplate.getPath(), true);
dest.updatePageTemplate(dstPageTemplate);
context.pageCount++;
}
}
Iterator dynamicPages = srcFolder.getDynamicPages().iterator();
while (dynamicPages.hasNext())
{
DynamicPage srcDynamicPage = (DynamicPage) dynamicPages.next();
DynamicPage dstDynamicPage = lookupDynamicPage(dest, srcDynamicPage.getPath());
if (null != dstDynamicPage)
{
if (context.overwritePages)
{
context.logger.info("overwriting dynamic page " + srcDynamicPage.getPath());
dest.removeDynamicPage(dstDynamicPage);
dstDynamicPage = dest.copyDynamicPage(srcDynamicPage, srcDynamicPage.getPath(), true);
dest.updateDynamicPage(dstDynamicPage);
context.pageCount++;
}
else
{
context.logger.info("skipping dynamic page " + srcDynamicPage.getPath());
}
}
else
{
context.logger.info("processing new dynamic page " + srcDynamicPage.getPath());
dstDynamicPage = dest.copyDynamicPage(srcDynamicPage, srcDynamicPage.getPath(), true);
dest.updateDynamicPage(dstDynamicPage);
context.pageCount++;
}
}
Iterator fragmentDefinitions = srcFolder.getFragmentDefinitions().iterator();
while (fragmentDefinitions.hasNext())
{
FragmentDefinition srcFragmentDefinition = (FragmentDefinition) fragmentDefinitions.next();
FragmentDefinition dstFragmentDefinition = lookupFragmentDefinition(dest, srcFragmentDefinition.getPath());
if (null != dstFragmentDefinition)
{
if (context.overwritePages)
{
context.logger.info("overwriting fragment definition " + srcFragmentDefinition.getPath());
dest.removeFragmentDefinition(dstFragmentDefinition);
dstFragmentDefinition = dest.copyFragmentDefinition(srcFragmentDefinition, srcFragmentDefinition.getPath(), true);
dest.updateFragmentDefinition(dstFragmentDefinition);
context.pageCount++;
}
else
{
context.logger.info("skipping fragment definition " + srcFragmentDefinition.getPath());
}
}
else
{
context.logger.info("processing fragment definition " + srcFragmentDefinition.getPath());
dstFragmentDefinition = dest.copyFragmentDefinition(srcFragmentDefinition, srcFragmentDefinition.getPath(), true);
dest.updateFragmentDefinition(dstFragmentDefinition);
context.pageCount++;
}
}
Iterator links = srcFolder.getLinks().iterator();
while (links.hasNext())
{
Link srcLink = (Link) links.next();
Link dstLink = lookupLink(dest, srcLink.getPath());
if (null != dstLink)
{
if (context.overwritePages)
{
context.logger.info("overwriting link " + srcLink.getPath());
dest.removeLink(dstLink);
dstLink = dest.copyLink(srcLink, srcLink.getPath());
dest.updateLink(dstLink);
context.linkCount++;
}
else
{
context.logger.info("skipping link " + srcLink.getPath());
}
}
else
{
context.logger.info("processing new link " + srcLink.getPath());
dstLink = dest.copyLink(srcLink, srcLink.getPath());
dest.updateLink(dstLink);
context.linkCount++;
}
}
Iterator folders = srcFolder.getFolders().iterator();
while (folders.hasNext())
{
Folder folder = (Folder) folders.next();
processFolder(folder, dest, context);
}
return dstFolder;
}