// generic context stuff
context.put("skins", CustomizeSetAction.buildList(rundata, Registry.SKIN));
context.put("securitys", CustomizeSetAction.buildList(rundata, Registry.SECURITY));
// we should first retrieve the portlet to customize
Portlet p = ((JetspeedRunData)rundata).getCustomized();
context.put("action", "portlets.CustomizeAction");
PortletInstance instance = PersistenceManager.getInstance(p, rundata);
context.put("portlet_instance", PersistenceManager.getInstance(p, rundata));
if (p==null) return;
// retrieve the portlet parameters
PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET,p.getName());
// save the entry in the session
Vector params = new Vector();
Iterator i = entry.getParameterNames();
//System.out.println("==========================================");
while(i.hasNext())
{
String name = (String)i.next();
Parameter param = entry.getParameter(name);
// filter some "system" and hidden parameters
if ( (!param.isHidden()) && (name.charAt(0)!='_') )
{
// check the user role
if (JetspeedSecurity.checkPermission((JetspeedUser)rundata.getUser(), new PortalResource( entry, param), JetspeedSecurity.PERMISSION_CUSTOMIZE))
{
// Implementation of clone() is missing so we have do it "by hand"
Parameter clone = new BaseParameter();
clone.setName(param.getName());
clone.setTitle(param.getTitle());
clone.setDescription(param.getDescription());
clone.setType(param.getType());
if (instance.getAttribute(name, null) != null)
{
clone.setValue(instance.getAttribute(name));
//System.out.println("Adding value from instance [" + name + "] = [" + clone.getValue() + "]");
}
else if (p.getPortletConfig().getInitParameter(name) != null)
{
clone.setValue(p.getPortletConfig().getInitParameter(name));
//System.out.println("Adding value from init [" + name + "] = [" + clone.getValue() + "]");
}
else
{
clone.setValue(param.getValue());
//System.out.println("Adding value from registry [" + name + "] = [" + clone.getValue() + "]");
}
params.add(clone);
}
}
}
// get the customization state for this page
SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
customizationState.setAttribute("customize-parameters", params);
// populate the customizer context
context.put("parameters", params);
context.put("portlet", p);
context.put("customizer", portlet);
if (p.getPortletConfig().getSecurityRef() != null)
context.put("security_ref", p.getPortletConfig().getSecurityRef().getParent());
if (p.getPortletConfig().getSkin() != null)
context.put("current_skin", p.getPortletConfig().getPortletSkin().getName());
Profile profile = ((JetspeedRunData)rundata).getCustomizedProfile();
String currentTitle = profile.getDocument().getEntryById(p.getID()).getTitle();
if (currentTitle == null && p.getPortletConfig().getMetainfo() != null)
{
currentTitle = p.getPortletConfig().getMetainfo().getTitle();
}
context.put("current_title", currentTitle);
}