Context context = TurbineVelocity.getContext(rundata);
context.put( "data", rundata);
TurbineVelocity.getContext(rundata).put("jetspeed", new org.apache.jetspeed.util.template.JetspeedTool(rundata));
ConcreteElement result = null;
String controlName = rundata.getParameters().getString("previewedControlName");
String portletName = rundata.getParameters().getString("previewedPortletName");
if ( portletName == null )
{
JetspeedLink jsLink = null;
try
{
jsLink = JetspeedLinkFactory.getInstance(rundata);
rundata.setRedirectURI(
jsLink.setUser(
rundata.getUser().getUserName(), "default.psml")
.addPathInfo("template", "Customize")
.addPathInfo("media-type", "html")
.toString()
);
JetspeedLinkFactory.putInstance(jsLink);
jsLink = null;
return new JetspeedClearElement("");
} catch (Exception e)
{
Log.error(e);
rundata.setScreenTemplate("Home");
return new JetspeedClearElement("");
}
//return new JetspeedClearElement("You must specify portlet to preview using [previewedPortletName] parameter");
}
Portlet portlet = null;
try
{
portlet = PortletFactory.getPortlet(portletName, "PreviewPortlet");
PortletControl control = controlName == null ? PortalToolkit.getControl((String)null) :
PortalToolkit.getControl(controlName);
control = null;
if ( control != null )
{
JetspeedRunData jdata = (JetspeedRunData)rundata;
// Use the profile's skin
//portlet.getPortletConfig().setSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
control.setPortlet(portlet);
control.init();
result = control.getContent(rundata);
}
else if ( portlet != null )
{
result = portlet.getContent(rundata);
}
if ( result != null && !result.toString().equals("") )
{
/*String html = result.toString();
String currentURL = rundata.getRequest().getRequestURI();
Log.debug("PreviewPortlet: currentURL = " + currentURL + " reader value = " + html);
PreviewRewriter rewriter = new PreviewRewriter(currentURL, currentURL , currentURL, portletName);