You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Michael Rothrock <mi...@michaelrothrock.com> on 2003/09/18 23:15:58 UTC

Getting a Portlet instance entry

Ok, I'm trying to get an instance of a Portlet object so I can check
permissions like so:

JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(), portlet,
"view")

I'm doing this in left.jsp, so I need to generate the instance by name.
After much trial and error, I've discovered a method that works (querying
the profiles, iterating through trying to get portlets by name).

There really must be a better way, and I'm hoping that someone can make a
suggestion.

Here's what I'm doing now:

    QueryLocator qLoc = new QueryLocator(QueryLocator.QUERY_ROLE);
    qLoc.setRoleByName("user");
    qLoc.setUser((JetspeedUser) data.getUser());
    Portlet portlet = null;
    Iterator i = Profiler.query(qLoc);
    while (i.hasNext()) {
        Profile profile = (Profile) i.next();
        if (profile.getRootSet().getPortletByName("files") != null) {
            String name =
profile.getRootSet().getPortletByName("files").getName();
            if (name.equalsIgnoreCase("files")) {
                portlet = profile.getRootSet().getPortletByName("files");
                break;
            }
        }
    }

Ugly, especially in JSP.

Any ideas?


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org