use of net.sourceforge.processdash.templates.DashPackage in project processdash by dtuma.
the class DashHelpBroker method createClassLoader.
/** Create a classloader for loading from the javahelp library */
private static ClassLoader createClassLoader() throws Exception {
// succeeds, we can just return our classloader.
try {
ClassLoader cl = DashHelpBroker.class.getClassLoader();
cl.loadClass(UTILS_CLASS_NAME);
return cl;
} catch (Throwable t) {
}
// Our classloader knows nothing about javahelp (the normal case).
// Attempt to find javahelp within a dashboard template add-on file.
DashPackage dashHelpPackage = TemplateLoader.getPackage("dashHelp");
if (dashHelpPackage == null)
throw new FileNotFoundException("Could not locate javahelp jarfile");
// We found javahelp. Use the URL of the resource we found to
// construct an appropriate classloader for loading javahelp classes.
File dashHelpFile = new File(dashHelpPackage.filename);
File dashHelpExt = new File(dashHelpFile.getParentFile(), "dashHelpExt.jar");
URL[] classPath = new URL[] { dashHelpFile.toURI().toURL(), dashHelpExt.toURI().toURL() };
return new URLClassLoader(classPath);
}
use of net.sourceforge.processdash.templates.DashPackage in project processdash by dtuma.
the class TeamStartBootstrap method initiateTemplateLoad.
/** Ask the dashboard to begin the process of loading a new template.
*
* @return null on success; else an error message describing the
* problem encountered.
*/
private String initiateTemplateLoad(String templateID, File templateFile, String continuationURI) {
String templatePath = templateFile.getPath();
String templateDir = templateFile.getParent();
// Check to ensure that the template is contained in a 'jar'
// or 'zip' file.
String suffix = templatePath.substring(templatePath.length() - 4).toLowerCase();
if (!suffix.equals(".jar") && !suffix.equals(".zip"))
return resources.getString("Errors.Only_Jar_Zip");
// Make certain the file can be found.
if (!templateFile.isFile())
return resources.getString("Errors.Cannot_Find_File");
// Make certain that access permissions allow us to read the file
if (!templateFile.canRead())
return resources.getString("Errors.Cannot_Read_File");
// Check to make certain the file is a valid dashboard package, and
// is compatible with this version of the dashboard.
boolean upgradeNeeded = true;
try {
DashPackage dashPackage = getDashPackageForFile(templateFile);
String currentDashVersion = (String) env.get(WebServer.PACKAGE_ENV_PREFIX + "pspdash");
if (dashPackage.isIncompatible(currentDashVersion)) {
String requiredVersion = dashPackage.requiresDashVersion;
if (requiredVersion.endsWith("+")) {
requiredVersion = requiredVersion.substring(0, requiredVersion.length() - 1);
return resources.format("Errors.Version_Mismatch.Need_Upgrade_FMT", requiredVersion, currentDashVersion);
} else {
return resources.format("Errors.Version_Mismatch.Exact_FMT", requiredVersion, currentDashVersion);
}
}
upgradeNeeded = upgradeIsNeeded(dashPackage);
} catch (InvalidDashPackage idp) {
return resources.getString("Errors.Invalid_Dash_Package");
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to read team process add-on", e);
return resources.getString("Errors.Cannot_Read_File");
}
// Initiate the loading of the template definition.
new TemplateLoadTask(templatePath, templateDir, upgradeNeeded);
return null;
}
use of net.sourceforge.processdash.templates.DashPackage in project processdash by dtuma.
the class TeamStartBootstrap method templateIsLoaded.
private boolean templateIsLoaded(String templateID, String packageID, String packageVersion, File templateJarfile, String continuationURI, boolean requireDirInSearchPath) {
// if we have no loaded template with the given ID, return false.
if (DashController.getTemplates().get(templateID) == null) {
logger.log(Level.FINER, "No template found with ID {0}", templateID);
return false;
}
// check to see if the continuation URI is a valid resource. If not,
// return false.
int pos = continuationURI.indexOf('?');
if (pos != -1)
continuationURI = continuationURI.substring(0, pos);
pos = continuationURI.indexOf('#');
if (pos != -1)
continuationURI = continuationURI.substring(0, pos);
logger.log(Level.FINER, "continuationURI={0}", continuationURI);
URL url = resolveURL(continuationURI);
logger.log(Level.FINER, "url={0}", url);
if (url == null)
return false;
// us a version number to compare against, check if we're up-to-date.
if (requireDirInSearchPath == false && StringUtils.hasValue(packageID) && StringUtils.hasValue(packageVersion) && upgradeIsNeeded(packageID, packageVersion) == false)
return true;
// that JAR could not be located or does not exist, return false.
if (templateJarfile == null || !templateJarfile.exists())
return false;
// directory containing the template JAR file.
if (requireDirInSearchPath) {
File templateJarDir = templateJarfile.getParentFile();
if (!TemplateLoader.templateSearchPathContainsDir(templateJarDir)) {
logger.log(Level.FINER, "The template search path does not " + "contain the directory {0}", templateJarDir);
return false;
}
}
// the process contained in the JAR file.
try {
DashPackage pkg = getDashPackageForFile(templateJarfile);
if (upgradeIsNeeded(pkg)) {
logger.log(Level.FINEST, "Our currently installed version of " + "the process JAR file is out of date.");
return false;
}
} catch (Exception e) {
logger.log(Level.WARNING, "Encountered error comparing process " + "version numbers", e);
return false;
}
// the template appears to be loaded, and meets all our criteria.
logger.finer("Template is loaded");
return true;
}
use of net.sourceforge.processdash.templates.DashPackage in project processdash by dtuma.
the class DisplayConfig method printUserConfig.
private void printUserConfig() {
boolean brief = parameters.containsKey("brief");
printRes("<HTML><HEAD><TITLE>${Title}</TITLE>");
double indentLeftMargin = brief ? 0.3 : 1;
out.print("<STYLE> .indent { margin-left: " + indentLeftMargin + "cm }");
if (brief) {
out.print("body { font-size: small }");
out.print("sup { font-size: small }");
}
out.print("</STYLE>");
out.print("<HEAD>");
out.print("<BODY>");
if (!brief) {
printRes("<H1>${Header}</H1>");
}
loadConfigurationInformation();
if (dataDirectory != null) {
out.print("<DIV>");
out.print(resources.getHTML(Settings.isPersonalMode() ? "Data_Dir_Header" : "Team_Config_Dir_Header"));
out.print("<PRE class='indent'>");
out.println(HTMLUtils.escapeEntities(dataDirectory.getPath()));
out.println(" </PRE></DIV>");
}
if (dataURL != null) {
out.print("<DIV>");
out.print(resources.getHTML(Settings.isPersonalMode() ? "Data_Url_Header" : "Team_Config_Url_Header"));
out.print("<PRE class='indent'>");
out.println(HTMLUtils.escapeEntities(dataURL));
out.println(" </PRE></DIV>");
}
if (installationDirectory != null) {
out.print("<DIV>");
out.print(resources.getHTML(Settings.isPersonalMode() ? "Install_Dir_Header" : "Team_Install_Dir_Header"));
out.print("<PRE class='indent'>");
out.println(HTMLUtils.escapeEntities(installationDirectory.getPath()));
out.println(" </PRE></DIV>");
}
if (appTemplateDirectory != null) {
printRes("<DIV>${App_Template_Dir_Header}");
out.print("<PRE class='indent'>");
out.println(HTMLUtils.escapeEntities(appTemplateDirectory.getPath()));
out.println(" </PRE></DIV>");
}
printRes("<DIV>${JVM_Header}");
out.print("<PRE class='indent'>");
out.println(HTMLUtils.escapeEntities(jvmInfo));
out.println(" </PRE></DIV>");
printRes("<DIV>${Add_On.Header}");
List<DashPackage> packages = TemplateLoader.getPackages();
if (packages == null || packages.size() < 2)
printRes("<PRE class='indent'><i>${Add_On.None}</i></PRE>");
else {
packages = new ArrayList(packages);
Collections.sort(packages, PACKAGE_SORTER);
printRes("<br> " + "<table border class='indent' cellpadding='5'><tr>" + "<th>${Add_On.Name}</th>" + "<th>${Add_On.Version}</th>");
// don't display the "location" column
if (!brief) {
printRes("<th>${Add_On.Filename}</th></tr>");
}
for (Iterator<DashPackage> i = packages.iterator(); i.hasNext(); ) {
DashPackage pkg = i.next();
if (DASHBOARD_PACKAGE_ID.equals(pkg.id))
continue;
out.print("<tr><td>");
out.print(HTMLUtils.escapeEntities(pkg.name));
out.print("</td><td>");
out.print(HTMLUtils.escapeEntities(pkg.version));
out.print("</td>");
if (!brief) {
out.print("<td>" + HTMLUtils.escapeEntities(cleanupFilename(pkg.filename)) + "</td>");
}
out.println("</tr>");
}
maybePrintCustomTranslationPackages(brief);
out.print("</TABLE>");
}
out.println("</DIV>");
// Showing a link to "more details" if we are in brief mode
if (brief) {
printRes("<p><a href=\"/control/showenv.class\">${More_Details}</a>" + " " + "<a href=\"/control/showConsole.class?trigger\">${Show_Log}</a></p>");
}
out.println("</BODY></HTML>");
}
use of net.sourceforge.processdash.templates.DashPackage in project processdash by dtuma.
the class DisplayConfig method loadConfigurationInformation.
private void loadConfigurationInformation() {
dataDirectory = null;
dataURL = null;
configFile = new File(DashController.getSettingsFileName());
WorkingDirectory workingDir = ((ProcessDashboard) getDashboardContext()).getWorkingDirectory();
if (workingDir instanceof BridgedWorkingDirectory) {
BridgedWorkingDirectory bwd = (BridgedWorkingDirectory) workingDir;
dataURL = bwd.getDescription();
dataDirectory = bwd.getTargetDirectory();
if (dataDirectory == null)
configFile = null;
else
configFile = new File(dataDirectory, configFile.getName());
} else if (workingDir instanceof LocalWorkingDirectory) {
LocalWorkingDirectory lwd = (LocalWorkingDirectory) workingDir;
dataDirectory = lwd.getTargetDirectory();
}
DashPackage dash = TemplateLoader.getPackage(DASHBOARD_PACKAGE_ID);
if (dash != null && StringUtils.hasValue(dash.filename)) {
File dashJar = new File(dash.filename);
installationDirectory = dashJar.getParentFile();
}
appTemplateDirectory = TemplateLoader.getApplicationTemplateDir();
jvmInfo = System.getProperty("java.vendor") + " JRE " + System.getProperty("java.version") + "; " + System.getProperty("os.name");
}
Aggregations