public static DashHierarchy loadTemplates(DataRepository data) {
LOAD_TEMPLATES_PERMISSION.checkPermission();
DashHierarchy templates = new DashHierarchy(null);
ProfTimer pt = new ProfTimer(TemplateLoader.class,
"TemplateLoader.loadTemplates");
URL[] roots = getTemplateURLs();
pt.click("Got template roots");
String templateDirURL;
for (int i=roots.length; i-- > 0; ) {
templateDirURL = roots[i].toString();
if (templateDirURL.startsWith("file:/")) {
/* If the /Templates directory exists as a local file
* somewhere, search through that directory for process
* templates.
*/
// strip "file:" from the beginning of the url.
String dirname = templateDirURL.substring(5);
dirname = HTMLUtils.urlDecode(dirname);
searchDirForTemplates(templates, dirname, data);
pt.click("searched dir '" + dirname + "' for templates");
} else {
/* If the /Templates directory found is in a jar somewhere,
* search through the jar for process templates.
*/
// Strip "jar:" from the beginning and the "!/Templates/"
// from the end of the URL.
String jarFileURL = templateDirURL.substring
(4, templateDirURL.indexOf('!'));
searchJarForTemplates(templates, jarFileURL, data);
pt.click("searched jar '" + jarFileURL + "' for templates");
}
}
generateRollupTemplates(templates, data);
createProcessRoot(templates);
pt.click("done loading templates");
return templates;
}