protected void buildNormalContext(VelocityPortlet portlet,
Context context,
RunData rundata) throws Exception
{
JetspeedRunData jdata = (JetspeedRunData) rundata;
SessionState customizationState = jdata.getPageSessionState();
Profile profile = jdata.getCustomizedProfile();
String mediaType = profile.getMediaType ();
// set velocity variable of mediatype (displayed in the customizer menu)
context.put("mtype", profile.getMediaType());
// make the list of already used panes/portlets available through the 'runs' reference
context.put("runs", AutoProfile.getPortletList(rundata));
// we should first retrieve the portlet to customize
PortletSet set = (PortletSet) (jdata).getCustomized();
//identify the portlet submode and build the appropriate subt-template path
String mode = rundata.getParameters().getString("mode");
if (mode == null)
{
mode = (String) customizationState.getAttribute("customize-mode");
if ((mode == null) || (mode.equalsIgnoreCase("addset")) || (mode.equalsIgnoreCase("general")))
{
mode = "layout";
}
}
else
{
if ((mediaType.equalsIgnoreCase("wml")) && (!mode.equalsIgnoreCase("add")))
{
mode = "layout";
}
customizationState.setAttribute("customize-mode", mode);
}
String template = (String) context.get("template");
if (template != null)
{
int idx = template.lastIndexOf(".");
StringBuffer buffer = new StringBuffer(template);
if (idx > 0)
{
template = template.substring(0, idx);
}
buffer.append("-").append(mode).append(".vm");
template = TemplateLocator.locatePortletTemplate(rundata, buffer.toString());
context.put("feature", template);
}
if (set == null)
{
return;
}
// get the customization state for this page
String customizedPaneName = (String) customizationState.getAttribute("customize-paneName");
if (customizedPaneName == null)
{
customizedPaneName = "*";
}