*/
public Object processView(GenericMVCContext context)
{
// generate the content
JetspeedClearElement element = null;
String template = (String) context.get("template");
Log.info("VelocityViewProcessor - processing " + template);
try
{
if (-1 == template.indexOf(".vm"))
{
template = template + ".vm";
}
Log.info("VelocityViewProcessor - locating template - " +
((RunData) context.get("data")).toString() + template);
String templatePath = TemplateLocator.locatePortletTemplate(
(RunData) context.get("data"),
template);
// need to add cache support
Portlet portlet = (Portlet) context.get("portlet");
RunData rundata = (RunData) context.get("data");
long cachePeriod = -1;
AbstractPortlet abstractPortlet = null;
// STW: Safety net ;)
if(portlet instanceof AbstractPortlet)
{
abstractPortlet =(AbstractPortlet) portlet;
if(abstractPortlet.getExpirationMillis() != null)
{
cachePeriod = abstractPortlet.getExpirationMillis().longValue();
}
}
if (cachePeriod > 0 && abstractPortlet != null)
{
String s = TurbineVelocity.handleRequest(context, templatePath);
abstractPortlet.setExpirationMillis(
cachePeriod + System.currentTimeMillis());
element = new JetspeedClearElement(s);
}
else
{
TurbineVelocity.handleRequest(
context, templatePath, rundata.getOut());
}
}
catch (Exception e)
{
element = new JetspeedClearElement(e.toString());
Log.error("VelocityViewProcessor - had problems handling request - " + e);
e.printStackTrace();
}
TurbineVelocity.requestFinished(context);
if (element == null)
{
element = new JetspeedClearElement("");
}
return element;
}