{
throw new IllegalArgumentException("Fragment type not specified.");
}
// retrieve current page from page manager
ContentPageImpl contentPageImpl = (ContentPageImpl)contentPage;
BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
if (!(pageOrTemplate instanceof BasePageElement))
{
throw new IllegalArgumentException("Decorators only supported on pages.");
}
BasePageElement page = (BasePageElement)pageOrTemplate;
BaseConcretePageElement concretePage = ((page instanceof BaseConcretePageElement) ? (BaseConcretePageElement)page : null);
// check for edit permission
page.checkAccess(JetspeedActions.EDIT);
// update default decorator and page in page manager
boolean update = false;
decoratorName = (!Utils.isNull(decoratorName) ? decoratorName : null);
if (((decoratorName != null) && !decoratorName.equals(page.getDefaultDecorator(fragmentType)) ||
((decoratorName == null) && (page.getDefaultDecorator(fragmentType) != null))))
{
page.setDefaultDecorator(decoratorName, fragmentType);
update = true;
}
if (update)
{
updatePage(page);
}
// update content context
Map effectiveDefaultDecorators = new HashMap();
if (concretePage != null)
{
effectiveDefaultDecorators.put(Fragment.LAYOUT, concretePage.getEffectiveDefaultDecorator(Fragment.LAYOUT));
effectiveDefaultDecorators.put(Fragment.PORTLET, concretePage.getEffectiveDefaultDecorator(Fragment.PORTLET));
}
else
{
String layoutDefaultDecorator = page.getDefaultDecorator(Fragment.LAYOUT);
if (layoutDefaultDecorator != null)
{
effectiveDefaultDecorators.put(Fragment.LAYOUT, layoutDefaultDecorator);
}
String portletDefaultDecorator = page.getDefaultDecorator(Fragment.PORTLET);
if (portletDefaultDecorator != null)
{
effectiveDefaultDecorators.put(Fragment.PORTLET, portletDefaultDecorator);
}
}
contentPageImpl.setEffectiveDefaultDecorators(effectiveDefaultDecorators);
}
catch (Exception e)
{
throw new PageLayoutComponentException("Unexpected exception: "+e, e);
}