if ( wcdfFilePath == null ) {
throw new IllegalArgumentException( "wcdfFilePath" );
}
// Figure out what dashboard we should be handling: load its wcdf descriptor.
DashboardWcdfDescriptor wcdf;
if ( !wcdfFilePath.isEmpty() && wcdfFilePath.endsWith( ".wcdf" ) ) {
try {
wcdf = DashboardWcdfDescriptor.load( wcdfFilePath );
} catch ( IOException ex ) {
// TODO: User has no permission to WCDF falls here?
throw new ThingWriteException( "While accessing the WCDF file.", ex );
}
if ( wcdf == null ) {
// Doesn't exist
// TODO: Explain or fix, why create a (totally) empty one?
wcdf = new DashboardWcdfDescriptor();
}
} else {
// We didn't receive a valid path. We're in preview mode.
// TODO: Support mobile preview mode (must remove dependency on setStyle())
wcdf = getPreviewWcdf( wcdfFilePath );
bypassCacheRead = true; // no cache for preview
}
if ( StringUtils.isNotEmpty( style ) ) {
wcdf.setStyle( style );
}
return this.getDashboardCdfRunJs( wcdf, options, bypassCacheRead );
}