package at.kugel.tool.buildtray;
import at.kugel.tool.buildtray.action.HtmlRegularExpressionActions;
import at.kugel.tool.buildtray.action.http.URLReader;
import at.kugel.tool.buildtray.config.MultiConfig;
import at.kugel.tool.buildtray.status.ConsoleStatus;
/**
* Loads the build server url with all settings for debug purposes.
*
* @author <a href="http://www.code-cop.org/">Peter Kofler</a>
*/
public final class CheckConfig {
public static void main(String[] args) {
handleEmptyArguments(args);
MultiConfig configs = new MultiConfig(args);
tryServerAccess(configs);
checkBuildStatus(configs);
}
private static void handleEmptyArguments(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java -cp BuildServerSystemTray.jar CheckConfig <path to config file, e.g. \"config/Hudson-1.2.properties\">");
System.exit(2);
}
}
private static void tryServerAccess(MultiConfig configs) {
System.out.println("checking server access...");
try {
String content = new URLReader(configs.getFirstConfig()).readPage();
System.out.println(content);
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
}
private static void checkBuildStatus(MultiConfig configs) {
System.out.println("checking build status...");
HtmlRegularExpressionActions actions = new HtmlRegularExpressionActions(configs);
actions.setStatusDisplay(new ConsoleStatus());
actions.refresh();
}
}