*/
public ConcreteElement getPortletFromRegistry(RunData data)
{
ConcreteElement result = null;
Portlet p = null;
String portletName = data.getParameters().getString("p");
String controlName = data.getParameters().getString("c");
try
{
// Retrieve registry entry
PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, portletName);
// Verify security for the parameter
boolean canAccess = JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(),
new PortalResource(entry),
JetspeedSecurity.PERMISSION_CUSTOMIZE);
if (canAccess)
{
// Always set portlet id to "preview" so each preview request gets it from the cache.
// At least, I think that's how it works.
p = PortletFactory.getPortlet(portletName, "preview");
PortletControl control = controlName == null ? PortalToolkit.getControl((String) null)
: PortalToolkit.getControl(controlName);
if (control != null)
{
JetspeedRunData jdata = (JetspeedRunData) rundata;
// Use the profile's skin
p.getPortletConfig().setPortletSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
control.setPortlet(p);
control.init();
result = control.getContent(rundata);
}
else if (p != null)
{
result = p.getContent(rundata);
}
}
else
{
result = new JetspeedClearElement(Localization.getString(data, "SECURITY_NO_ACCESS_TO_PORTLET"));