{
throw new IllegalArgumentException("Portlet type and name not specified");
}
// get page root content fragment
ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
ContentFragmentImpl pageRootContentFragmentImpl = contentPageImpl.getPageRootContentFragment();
if ((pageRootContentFragmentImpl != null) && pageRootContentFragmentImpl.isLocked())
{
pageRootContentFragmentImpl = (ContentFragmentImpl)pageRootContentFragmentImpl.getNonTemplateLayoutFragment();
}
if ((pageRootContentFragmentImpl == null) || pageRootContentFragmentImpl.isLocked())
{
throw new IllegalArgumentException("Page root content fragment not found or is locked");
}
// retrieve current page or template and root fragment from page manager
BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
BaseFragmentElement rootFragment = pageOrTemplate.getRootFragment();
if (!(rootFragment instanceof Fragment))
{
throw new IllegalArgumentException("New fragment cannot be added to page root fragment");
}