use of com.evolveum.midpoint.studio.client.TestConnectionResult in project midpoint-studio by Evolveum.
the class EnvironmentEditorDialog method executeTestConnection.
private void executeTestConnection(Project project, JLabel testConnection) {
Environment env = new Environment();
populateEnvironment(env);
try {
MidPointClient client = new MidPointClient(project, env, settings);
TestConnectionResult result = client.testConnection();
if (result.success()) {
updateInAwtThread(ConsoleViewContentType.NORMAL_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), "Version: " + result.version() + ", revision: " + result.revision());
} else {
String msg = result.exception() != null ? result.exception().getMessage() : null;
updateInAwtThread(ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), msg);
}
} catch (Exception ex) {
LOG.error("Couldn't test connection", ex);
updateInAwtThread(ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), ex.getMessage());
}
}
use of com.evolveum.midpoint.studio.client.TestConnectionResult in project midpoint-studio by Evolveum.
the class TestConnectionAction method testConnection.
private void testConnection(Project project, Environment environment) {
try {
MidPointClient client = new MidPointClient(project, environment);
TestConnectionResult result = client.testConnection();
String status = result.success() ? "was successful" : "failed";
NotificationType type = result.success() ? NotificationType.INFORMATION : NotificationType.ERROR;
String versionInfo = "";
if (result.success()) {
versionInfo = " Version: " + result.version() + ", build: " + result.revision() + ".";
}
NotificationAction action = null;
if (result.exception() != null) {
action = new ShowExceptionNotificationAction("Connection test exception for '" + environment.getName() + "'", result.exception(), TestConnectionAction.class, environment);
}
MidPointUtils.publishNotification(project, NOTIFICATION_KEY, "Test connection", "Connection test for '" + environment.getName() + "' " + status + "." + versionInfo, type, action);
} catch (Exception ex) {
MidPointUtils.publishExceptionNotification(project, environment, TestConnectionAction.class, NOTIFICATION_KEY, "Connection test for '" + environment.getName() + "' failed with exception", ex);
}
}
Aggregations