* @exception Exception
*/
protected Profile mergeGroupProfiles(RunData data, Vector profiles)
throws Exception
{
Profile result = null;
// If merge feature is not turned on, return
// profile for the first group (if any)
if (this.useGroupMerge == false)
{
if (profiles.size() > 0)
{
result = (Profile) profiles.get(0);
}
}
// Proceed with merging all profiles
else if (profiles.size() > 0)
{
// Sort the profiles by group name (Jetspeed should come out on top if all other
// group names are lower case
// TODO: Need to figure out a better method of controlling the tab sequence
Collections.sort(profiles, new Comparator()
{
public int compare(Object o1, Object o2)
{
Profile e1 = (Profile) o1;
Profile e2 = (Profile) o2;
Comparable v1 = (Comparable) e1.getGroupName();
Comparable v2 = (Comparable) e2.getGroupName();
return v1.compareTo(v2);
}
});
try
{
// Create an empty portlet container
Portlets portlets = new PsmlPortlets();
Control control = new PsmlControl();
control.setName(this.groupmergeControl);
portlets.setControl(control);
Controller controller = new PsmlController();
controller.setName(this.groupmergeController);
portlets.setController(controller);
// Set title
portlets.setTitle("Home Page");
// Set the skin
Skin skin = new PsmlSkin();
skin.setName(PortalToolkit.getSkin((String) null).getName());
portlets.setSkin(skin);
// Set top level security ref
if (groupmergeSecurityref != null)
{
SecurityEntry entry =
(SecurityEntry) Registry.getEntry(
Registry.SECURITY,
groupmergeSecurityref);
if (entry != null)
{
SecurityReference ref = new BaseSecurityReference();
ref.setParent(entry.getName());
portlets.setSecurityRef(ref);
}
}
String mediaType = null;
// Process each group profile
int paneCount = 0;
for (Iterator it = profiles.iterator(); it.hasNext();)
{
Profile groupProfile = (Profile) it.next();
mediaType =
mediaType == null
? groupProfile.getMediaType()
: mediaType;
Profile tmpProfile = (Profile) groupProfile.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.groupmergeControl))