// generate content page
BaseConcretePageElement concretePage = ((pageOrTemplate instanceof BaseConcretePageElement) ? (BaseConcretePageElement)pageOrTemplate : null);
DynamicPage dynamicPage = ((pageOrTemplate instanceof DynamicPage) ? (DynamicPage)pageOrTemplate : null);
FragmentDefinition fragmentDefinition = (((concretePage == null) && (pageOrTemplate instanceof FragmentDefinition)) ? (FragmentDefinition)pageOrTemplate : null);
String contentPageId = pageOrTemplate.getId();
ContentPageImpl contentPageImpl = new ContentPageImpl(this, contentPageId, pageOrTemplate, pageTemplate, fragmentDefinitions);
// set/merge page attributes
mergeContentPageAttributes(contentPageImpl, pageOrTemplate);
contentPageImpl.setName(pageOrTemplate.getName());
contentPageImpl.setPath(pageOrTemplate.getPath());
contentPageImpl.setUrl(pageOrTemplate.getUrl());
contentPageImpl.setHidden(pageOrTemplate.isHidden());
// merge template attributes
mergeContentPageAttributes(contentPageImpl, pageTemplate);
// set effective default detectors from merged default
// decorators or inherit page effective default decorators
Map effectiveDefaultDecorators = null;
String effectiveLayoutDefaultDecorator = contentPageImpl.getDefaultDecorator(Fragment.LAYOUT);
if (effectiveLayoutDefaultDecorator == null)
{
if (concretePage != null)
{
effectiveLayoutDefaultDecorator = concretePage.getEffectiveDefaultDecorator(Fragment.LAYOUT);
}
else if (pageOrTemplate.getParent() != null)
{
effectiveLayoutDefaultDecorator = ((Folder)pageOrTemplate.getParent()).getEffectiveDefaultDecorator(Fragment.LAYOUT);
}
}
if (effectiveLayoutDefaultDecorator != null)
{
if (effectiveDefaultDecorators == null)
{
effectiveDefaultDecorators = new HashMap();
}
effectiveDefaultDecorators.put(Fragment.LAYOUT, effectiveLayoutDefaultDecorator);
}
String effectivePortletDefaultDecorator = contentPageImpl.getDefaultDecorator(Fragment.PORTLET);
if (effectivePortletDefaultDecorator == null)
{
if (concretePage != null)
{
effectivePortletDefaultDecorator = concretePage.getEffectiveDefaultDecorator(Fragment.PORTLET);
}
else if (pageOrTemplate.getParent() != null)
{
effectiveLayoutDefaultDecorator = ((Folder)pageOrTemplate.getParent()).getEffectiveDefaultDecorator(Fragment.PORTLET);
}
}
if (effectivePortletDefaultDecorator != null)
{
if (effectiveDefaultDecorators == null)
{
effectiveDefaultDecorators = new HashMap();
}
effectiveDefaultDecorators.put(Fragment.PORTLET, effectivePortletDefaultDecorator);
}
contentPageImpl.setEffectiveDefaultDecorators(effectiveDefaultDecorators);
if (dynamicPage != null)
{
contentPageImpl.setContentType(dynamicPage.getContentType());
contentPageImpl.setInheritable(dynamicPage.isInheritable());
}
if (fragmentDefinition != null)
{
contentPageImpl.setDefId(fragmentDefinition.getDefId());
}
log.debug("PageLayoutComponentImpl.newContentPage(): construct ContentPage: id="+contentPageImpl.getId()+", path="+contentPageImpl.getPath());
// generate root and nested content fragments
BaseFragmentsElement definition = null;
BaseFragmentElement rootFragment = null;
boolean rootTemplate = false;
if (pageTemplate != null)
{
definition = pageTemplate;
rootFragment = definition.getRootFragment();
rootTemplate = true;
}
if (rootFragment == null)
{
definition = pageOrTemplate;
rootFragment = definition.getRootFragment();
}
if (rootFragment != null)
{
// generate content page/fragment hierarchy for page
ContentFragmentImpl rootContentFragmentImpl = newContentFragment(null, pageOrTemplate, fragmentDefinitions, definition, rootFragment, rootTemplate);
// ensure that page/fragment hierarchy root is a layout
// portlet by generating a transient locked parent
// layout fragment if necessary
if (!rootContentFragmentImpl.getType().equals(ContentFragment.LAYOUT))
{
ContentFragmentImpl layoutContentFragmentImpl = newContentFragment("", pageOrTemplate, null, null, null, null, rootTemplate, true);
layoutContentFragmentImpl.setType(ContentFragment.LAYOUT);
layoutContentFragmentImpl.setName(defaultLayoutPortletName);
layoutContentFragmentImpl.getFragments().add(rootContentFragmentImpl);
rootContentFragmentImpl = layoutContentFragmentImpl;
}
// save content page/fragment hierarchy
contentPageImpl.setRootFragment(rootContentFragmentImpl);
}
log.debug("PageLayoutComponentImpl.newContentPage(): constructed ContentPage: id="+contentPageImpl.getId());
return contentPageImpl;
}