Search in sources :

Example 1 with TestConnectionResult

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());
    }
}
Also used : MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment) TestConnectionResult(com.evolveum.midpoint.studio.client.TestConnectionResult)

Example 2 with TestConnectionResult

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);
    }
}
Also used : ShowExceptionNotificationAction(com.evolveum.midpoint.studio.impl.ShowExceptionNotificationAction) ShowExceptionNotificationAction(com.evolveum.midpoint.studio.impl.ShowExceptionNotificationAction) NotificationAction(com.intellij.notification.NotificationAction) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) NotificationType(com.intellij.notification.NotificationType) TestConnectionResult(com.evolveum.midpoint.studio.client.TestConnectionResult)

Aggregations

TestConnectionResult (com.evolveum.midpoint.studio.client.TestConnectionResult)2 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)2 Environment (com.evolveum.midpoint.studio.impl.Environment)1 ShowExceptionNotificationAction (com.evolveum.midpoint.studio.impl.ShowExceptionNotificationAction)1 NotificationAction (com.intellij.notification.NotificationAction)1 NotificationType (com.intellij.notification.NotificationType)1