public Page copyPage(Page source, String path)
throws NodeException
{
// create the new page and copy attributes
Page page = newPage(path);
page.setTitle(source.getTitle());
page.setShortTitle(source.getShortTitle());
page.setVersion(source.getVersion());
page.setDefaultDecorator(source.getDefaultDecorator(Fragment.LAYOUT), Fragment.LAYOUT);
page.setDefaultDecorator(source.getDefaultDecorator(Fragment.PORTLET), Fragment.PORTLET);
page.setSkin(source.getSkin());
page.setHidden(source.isHidden());
// copy locale specific metadata
page.getMetadata().copyFields(source.getMetadata().getFields());
// copy security constraints
SecurityConstraints srcSecurity = source.getSecurityConstraints();
if ((srcSecurity != null) && !srcSecurity.isEmpty())
{
SecurityConstraints copiedSecurity = copySecurityConstraints(PAGE_NODE_TYPE, srcSecurity);
page.setSecurityConstraints(copiedSecurity);
}
// copy menu definitions
List menus = source.getMenuDefinitions();
if (menus != null)
{
List copiedMenus = copyMenuDefinitions(PAGE_NODE_TYPE, menus);
page.setMenuDefinitions(copiedMenus);
}
// copy fragments
Fragment root = copyFragment(source.getRootFragment(), source.getRootFragment().getName());
page.setRootFragment(root);
return page;
}