}
public static void getHeaders( String dashboardContent, String dashboardType, boolean absolute, String root,
String scheme, boolean isDebugMode, OutputStream out ) throws Exception {
ICdfHeadersProvider cdfHeaders = CdfEngine.getEnvironment().getCdfHeadersProvider();
// Identify which extra JSs and CSSs to add to header, according to components being used
List<String> componentTypes = new ArrayList<String>( CdfConstants.DASHBOARD_COMPONENT_TYPES.length );
if ( dashboardContent != null ) {
componentTypes = new ArrayList<String>();
// search for component types in dashboardsContent (e.g. template.html)
for ( String[] componenType : CdfConstants.DASHBOARD_COMPONENT_TYPES ) {
// Screen Scrap to get component types from dashboardContent
if ( Pattern.compile( String.format( "type:\\s*[\"'](?i)%s[a-z]*[\"']", componenType[ 0 ] ) )
.matcher( dashboardContent ).find() ) {
componentTypes.add( componenType[ 1 ] );
}
}
}
if ( absolute ) {
String webRoot;
// some dashboards need full absolute urls
if( !StringUtils.isEmpty( root ) ) {
if ( root.contains( "/" ) ) {
// file paths are already absolute, which didn't happen before
root = root.substring( 0, root.indexOf( "/" ) );
}
webRoot = scheme + "://" + root;
} else {
webRoot = CdfEngine.getEnvironment().getPathProvider().getWebappContextRoot();
}
out.write( cdfHeaders.getHeaders( dashboardType, isDebugMode, webRoot, componentTypes )
.getBytes( CharsetHelper.getEncoding() ) );
} else {
out.write(
cdfHeaders.getHeaders( dashboardType, isDebugMode, componentTypes ).getBytes( CharsetHelper.getEncoding() ) );
}
}