boolean debug = requestParams.hasParameter( MethodParams.DEBUG )
&& getRequestParameterAsString( MethodParams.DEBUG, "" ).equals( "true" );
String style = getRequestParameterAsString( MethodParams.STYLE, "" );
RenderApi renderer = new RenderApi();
long start = System.currentTimeMillis();
UUID uuid = CpfAuditHelper.startAudit( getPluginName(), filePath, getObjectName(),
this.userSession, this, requestParams );
if ( create ) {
String result = renderer.newDashboard( filePath, debug, true, getRequest(), getResponse() );
IOUtils.write( result, getResponse().getOutputStream() );
} else if ( edit ) {
//TODO: file to path
String result = renderer.edit( "", "", filePath, debug, true, getRequest(), getResponse() );
IOUtils.write( result, getResponse().getOutputStream() );
} else if ( resource ) {
// TODO review later if there is a viable solution to making resources being
// called via cde resources rest api (pentaho/plugin/pentaho-cdf-dd/api/resources?resource=)
// this has to take into consideration:
// 1 - token replacement (see cde-core#CdfRunJsDashboardWriteContext.replaceTokens())
// 2 - resources being called from other resources (ex: resource plugin-samples/template.css calls resource
// images/button-contact-png)
new ResourcesApi().getResource( pathParams.getStringParameter( MethodParams.COMMAND, "" ), getResponse() );
} else {
String result = renderer
.render( "", "", filePath, inferScheme, root, absolute, bypassCacheRead, debug, viewId, style, getRequest() );
getResponse().setContentType( MimeTypes.HTML );
IOUtils.write( result, getResponse().getOutputStream() );
getResponse().getOutputStream().flush();