*/
public void doSkin(RunData rundata, Context context)
{
// we should first retrieve the portlet to customize and its parameters
// definition
PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
try
{
String skin = rundata.getParameters().getString("skin");
Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
Portlets portlets = profile.getDocument().getPortletsById(set.getID());
// skin is neither null nor zero-length
if ((skin != null) && (skin.trim().length() > 0))
{
PortletSkin s = PortalToolkit.getSkin(skin);
if (s != null)
{
set.getPortletConfig().setPortletSkin(s);
Skin psmlSkin = portlets.getSkin();
if (psmlSkin == null)
{
portlets.setSkin(new PsmlSkin());
}
portlets.getSkin().setName(skin);
}
else
{
logger.warn("Unable to update skin for portlet set "
+ set.getID() + " because skin " + skin
+ " does not exist.");
return;
}
}
else
{
// skin is either null or zero-length
String custPortletSetID = portlets.getId();
String rootPortletSetID = profile.getRootSet().getID();
// set system default skin for root PSML element
if (custPortletSetID != null && rootPortletSetID != null &&
custPortletSetID.equals(rootPortletSetID))
{
// get system default skin
String defaultSkinName = JetspeedResources.getString("services.PortalToolkit.default.skin");
PortletSkin defaultSkin = PortalToolkit.getSkin(defaultSkinName);
if (defaultSkin != null)
{
set.getPortletConfig().setPortletSkin((PortletSkin) defaultSkin);
Skin psmlSkin = portlets.getSkin();
if (psmlSkin == null)
{
portlets.setSkin(new PsmlSkin());
}
portlets.getSkin().setName(defaultSkin.getName());
}
else
{
logger.warn("Unable to set default skin for root portlet set "
+ set.getID() + " because skin " + skin
+ " does not exist.");
return;
}
}
else
{
// By setting the skin to null, the parent's skin will be used.
set.getPortletConfig().setPortletSkin((PortletSkin) null);
portlets.setSkin(null);
}
}
}
catch (Exception e)