Jonathan Hawkins wrote:


I want to get a list of the portlets by name or id that are in the users profile, not a list of available portlets but only those that are currently configured in the portal for that user.

Any assistance appreciated.

Try somethin like this:

    public void doPerform(RunData data) throws Exception
    {
        Profile profile = ((JetspeedRunData) data).getCustomizedProfile();
        Portlets portlets = profile.getDocument().getPortlets();
        if (portlets == null)
        {
            return;
        }
        int count = 0;
        count = traverse(portlets, count);
        super.doPerform(data);

    }

    private int traverse(Portlets portlets, int count)
    {
        // First let's add all the Entries in the current level
        Iterator eItr = portlets.getEntriesIterator();
        while(eItr.hasNext())
        {
            Entry entry =  (Entry)eItr.next();

Portlet portlet = null;
try
{
portlet = PortletFactory.getPortlet(entry);
}
catch (Exception e)
{
log.error("Could not create portlet for entry " + entry.getId(), e);
continue;
}
if (portlet == null)
{
log.error("Could not create portlet for entry " + entry.getId());
continue;
}
}
//Now if there are child levels, drill down recursively
if(portlets.getPortletsCount() > 0)
{
Iterator pItr = portlets.getPortletsIterator();
while(pItr.hasNext())
{
Portlets childPortlets = (Portlets)pItr.next();
count += traverse(childPortlets, count);
}
}
return count;
}


--
David Sean Taylor
Bluesunrise Software
[EMAIL PROTECTED]
[office] +01 707 773 4646
[mobile] +01 707 529 9194

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to