}
public static Folder importFolder(PageManager castorPageManager, Folder srcFolder, String userName, String destination, boolean copyIds) throws JetspeedException
{
String newPath = "";
Folder dstFolder = lookupFolder(castorPageManager,srcFolder.getPath());
dstFolder = castorPageManager.copyFolder(srcFolder, getUserFolder(userName, true) + destination);
castorPageManager.updateFolder(dstFolder);
Iterator pages = srcFolder.getPages().iterator();
while (pages.hasNext())
{
Page srcPage = (Page) pages.next();
Page dstPage = lookupPage(castorPageManager,srcPage.getPath());
newPath = getUserFolder(userName, true) + destination + getRealPath(srcPage.getPath());
dstPage = castorPageManager.copyPage(srcPage, newPath, copyIds);
castorPageManager.updatePage(dstPage);
}
Iterator pageTemplates = srcFolder.getPageTemplates().iterator();
while (pageTemplates.hasNext())
{
PageTemplate srcPageTemplate = (PageTemplate) pageTemplates.next();
PageTemplate dstPageTemplate = lookupPageTemplate(castorPageManager,srcPageTemplate.getPath());
newPath = getUserFolder(userName, true) + destination + getRealPath(srcPageTemplate.getPath());
dstPageTemplate = castorPageManager.copyPageTemplate(srcPageTemplate, newPath, copyIds);
castorPageManager.updatePageTemplate(dstPageTemplate);
}
Iterator dynamicPages = srcFolder.getDynamicPages().iterator();
while (dynamicPages.hasNext())
{
DynamicPage srcDynamicPage = (DynamicPage) dynamicPages.next();
DynamicPage dstDynamicPage = lookupDynamicPage(castorPageManager,srcDynamicPage.getPath());
newPath = getUserFolder(userName, true) + destination + getRealPath(srcDynamicPage.getPath());
dstDynamicPage = castorPageManager.copyDynamicPage(srcDynamicPage, newPath, copyIds);
castorPageManager.updateDynamicPage(dstDynamicPage);
}
Iterator fragmentDefinitions = srcFolder.getFragmentDefinitions().iterator();
while (fragmentDefinitions.hasNext())
{
FragmentDefinition srcFragmentDefinition = (FragmentDefinition) fragmentDefinitions.next();
FragmentDefinition dstFragmentDefinition = lookupFragmentDefinition(castorPageManager,srcFragmentDefinition.getPath());
newPath = getUserFolder(userName, true) + destination + getRealPath(srcFragmentDefinition.getPath());
dstFragmentDefinition = castorPageManager.copyFragmentDefinition(srcFragmentDefinition, newPath, copyIds);
castorPageManager.updateFragmentDefinition(dstFragmentDefinition);
}
Iterator links = srcFolder.getLinks().iterator();
while (links.hasNext())
{
Link srcLink = (Link) links.next();
Link dstLink = lookupLink(castorPageManager,srcLink.getPath());
newPath = getUserFolder(userName, true) + destination + getRealPath(srcLink.getPath());
dstLink = castorPageManager.copyLink(srcLink, newPath);
castorPageManager.updateLink(dstLink);
}
Iterator folders = srcFolder.getFolders().iterator();
while (folders.hasNext())
{
Folder folder = (Folder) folders.next();
newPath = destination + getRealPath(folder.getPath());
importFolder(castorPageManager,folder, userName, newPath, copyIds);
}
return dstFolder;
}