* @exception Exception
*/
protected Profile mergeRoleProfiles(RunData data, Vector profiles)
throws Exception
{
Profile result = null;
// If merge feature is not turned on, return
// profile for the first role (if any)
if (!this.useRoleMerge)
{
if (profiles.size() > 0)
{
result = (Profile) profiles.get(0);
}
}
// Proceed with merging all profiles
else if (profiles.size() > 0)
{
try
{
// Create an empty portlet container
Portlets portlets = new PsmlPortlets();
Control control = new PsmlControl();
control.setName(this.rolemergeControl);
portlets.setControl(control);
Controller controller = new PsmlController();
controller.setName(this.rolemergeController);
portlets.setController(controller);
// Set the skin
Skin skin = new PsmlSkin();
skin.setName(PortalToolkit.getSkin((String) null).getName());
portlets.setSkin(skin);
String mediaType = null;
// Process each role profile
int paneCount = 0;
for (Iterator it = profiles.iterator(); it.hasNext();)
{
Profile roleProfile = (Profile) it.next();
mediaType =
mediaType == null
? roleProfile.getMediaType()
: mediaType;
Profile tmpProfile = (Profile) roleProfile.clone();
Portlets tmpPortlets =
tmpProfile.getDocument().getPortlets();
// If topmost control is a tab control, then add each tab to the container
Control paneControl = tmpPortlets.getControl();
if (paneControl != null
&& paneControl.getName().equals(this.rolemergeControl))