Search in sources :

Example 1 with ShowExceptionNotificationAction

use of com.evolveum.midpoint.studio.impl.ShowExceptionNotificationAction 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)1 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)1 ShowExceptionNotificationAction (com.evolveum.midpoint.studio.impl.ShowExceptionNotificationAction)1 NotificationAction (com.intellij.notification.NotificationAction)1 NotificationType (com.intellij.notification.NotificationType)1