diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index f105e83d..adbac86f 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,5 +1,5 @@
Version 0.13.11
- *
+ * #84 Handle connection exceptions
Version 0.13.10
* #253 [Feature Request] Log in progress
diff --git a/includes/pluginChanges.html b/includes/pluginChanges.html
index 17db8558..fd45cd3e 100644
--- a/includes/pluginChanges.html
+++ b/includes/pluginChanges.html
@@ -1,6 +1,10 @@
0.13.11
-
+ - #84 Handle connection exceptions
+ RSS change: Use Notification system. First failed build will shown as warning in Notification Group 'Jenkins Notification'
+ instead as balloon over Build Status Summary widget.
+
+
0.13.10
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/security/AuthenticationException.java b/src/main/java/org/codinjutsu/tools/jenkins/exception/AuthenticationException.java
similarity index 87%
rename from src/main/java/org/codinjutsu/tools/jenkins/security/AuthenticationException.java
rename to src/main/java/org/codinjutsu/tools/jenkins/exception/AuthenticationException.java
index df93b80b..d189d6f8 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/security/AuthenticationException.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/exception/AuthenticationException.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.codinjutsu.tools.jenkins.security;
+package org.codinjutsu.tools.jenkins.exception;
-public class AuthenticationException extends RuntimeException {
+public class AuthenticationException extends JenkinsPluginRuntimeException {
private final String responseBody;
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/exception/ConfigurationException.java b/src/main/java/org/codinjutsu/tools/jenkins/exception/ConfigurationException.java
index e7321921..23499d7f 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/exception/ConfigurationException.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/exception/ConfigurationException.java
@@ -18,7 +18,7 @@
import org.jetbrains.annotations.NotNull;
-public class ConfigurationException extends RuntimeException {
+public class ConfigurationException extends JenkinsPluginRuntimeException {
public ConfigurationException(String message) {
super(message);
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/exception/JenkinsPluginRuntimeException.java b/src/main/java/org/codinjutsu/tools/jenkins/exception/JenkinsPluginRuntimeException.java
new file mode 100644
index 00000000..b4d239c8
--- /dev/null
+++ b/src/main/java/org/codinjutsu/tools/jenkins/exception/JenkinsPluginRuntimeException.java
@@ -0,0 +1,12 @@
+package org.codinjutsu.tools.jenkins.exception;
+
+public class JenkinsPluginRuntimeException extends RuntimeException {
+
+ public JenkinsPluginRuntimeException(String message) {
+ super(message);
+ }
+
+ public JenkinsPluginRuntimeException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+}
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/exception/NoJobFoundException.java b/src/main/java/org/codinjutsu/tools/jenkins/exception/NoJobFoundException.java
index 11b27e53..4c6cc464 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/exception/NoJobFoundException.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/exception/NoJobFoundException.java
@@ -22,7 +22,7 @@
import java.text.MessageFormat;
-public class NoJobFoundException extends RuntimeException {
+public class NoJobFoundException extends JenkinsPluginRuntimeException {
public NoJobFoundException(@NotNull Job job) {
super(createMessage(job));
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java
index 7e467396..45f4b163 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java
@@ -24,22 +24,15 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.MessageType;
-import com.intellij.openapi.ui.popup.Balloon;
-import com.intellij.openapi.ui.popup.BalloonBuilder;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.ui.awt.RelativePoint;
import org.codinjutsu.tools.jenkins.JenkinsAppSettings;
import org.codinjutsu.tools.jenkins.JobTracker;
-import org.codinjutsu.tools.jenkins.exception.ConfigurationException;
+import org.codinjutsu.tools.jenkins.exception.JenkinsPluginRuntimeException;
import org.codinjutsu.tools.jenkins.model.Build;
import org.codinjutsu.tools.jenkins.model.BuildStatusEnum;
import org.codinjutsu.tools.jenkins.util.GuiUtil;
-import org.codinjutsu.tools.jenkins.view.JenkinsWidget;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.awt.*;
-import java.util.List;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -85,6 +78,7 @@ public void initScheduledJobs() {
}
}
+ @SuppressWarnings({"java:S3824", "java:S3398"})
private Map loadAndReturnNewLatestBuilds() {
final Map latestBuildMap = requestManager.loadJenkinsRssLatestBuilds(jenkinsAppSettings);
final Map newBuildMap = new HashMap<>();
@@ -106,6 +100,7 @@ private Map loadAndReturnNewLatestBuilds() {
return newBuildMap;
}
+ @SuppressWarnings("java:S3398")
private void sendNotificationForEachBuild(List buildToSortByDateDescending) {
for (Build build : buildToSortByDateDescending) {
BuildStatusEnum status = build.getStatus();
@@ -118,11 +113,13 @@ private void sendNotificationForEachBuild(List buildToSortByDateDescendin
notificationType = NotificationType.WARNING;
}
NotificationGroupManager.getInstance().getNotificationGroup("Jenkins Rss")
- .createNotification("", buildMessage(build), notificationType, NotificationListener.URL_OPENING_LISTENER)
+ .createNotification("", buildMessage(build), notificationType,
+ NotificationListener.URL_OPENING_LISTENER)
.notify(project);
}
}
+ @SuppressWarnings("java:S3398")
private List sortByDateDescending(Map finishedBuilds) {
final List buildToSortByDateDescending = new ArrayList<>(finishedBuilds.values());
@@ -130,23 +127,19 @@ private List sortByDateDescending(Map finishedBuilds) {
return buildToSortByDateDescending;
}
- private void displayTheFirstFailedBuildInABalloon(Map.Entry firstFailedBuild) {
+ @SuppressWarnings("java:S3398")
+ private void notifyFirstFailedBuild(Map.Entry firstFailedBuild) {
if (firstFailedBuild != null) {
final String jobName = firstFailedBuild.getKey();
final Build build = firstFailedBuild.getValue();
final String message = Optional.ofNullable(build.getFullDisplayName())
.orElseGet(() -> jobName + build.getDisplayNumber()) + ": FAILED";
- displayErrorMessageInABalloon(message);
+ JenkinsNotifier.getInstance(project).notify(message, NotificationType.WARNING);
}
}
- private void displayErrorMessageInABalloon(String message) {
- BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, MessageType.ERROR, null);
- final Balloon balloon = balloonBuilder.setFadeoutTime(TimeUnit.SECONDS.toMillis(1)).createBalloon();
- GuiUtil.runInSwingThread(() -> balloon.show(new RelativePoint(JenkinsWidget.getInstance(project).getComponent(),
- new Point(0, 0)), Balloon.Position.above));
- }
-
+ @SuppressWarnings("java:S3398")
+ @Nullable
private Map.Entry getFirstFailedBuild(Map finishedBuilds) {
for (Map.Entry buildByJobName : finishedBuilds.entrySet()) {
Build build = buildByJobName.getValue();
@@ -186,8 +179,8 @@ public void run(@NotNull ProgressIndicator indicator) {
final Map finishedBuilds;
try {
finishedBuilds = loadAndReturnNewLatestBuilds();
- } catch (ConfigurationException ex) {
- displayErrorMessageInABalloon(ex.getMessage());
+ } catch (JenkinsPluginRuntimeException ex) {
+ JenkinsNotifier.getInstance(project).error(ex.getMessage());
return;
}
if (!shouldDisplayResult || finishedBuilds.isEmpty()) {
@@ -195,10 +188,8 @@ public void run(@NotNull ProgressIndicator indicator) {
}
JobTracker.getInstance().onNewFinishedBuilds(finishedBuilds);
-
sendNotificationForEachBuild(sortByDateDescending(finishedBuilds));
-
- displayTheFirstFailedBuildInABalloon(getFirstFailedBuild(finishedBuilds));
+ notifyFirstFailedBuild(getFirstFailedBuild(finishedBuilds));
}
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/security/BasicSecurityClient.java b/src/main/java/org/codinjutsu/tools/jenkins/security/BasicSecurityClient.java
index 19bc03a4..0cab0665 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/security/BasicSecurityClient.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/security/BasicSecurityClient.java
@@ -21,6 +21,7 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpHeaders;
+import org.codinjutsu.tools.jenkins.exception.AuthenticationException;
import org.codinjutsu.tools.jenkins.exception.ConfigurationException;
import org.codinjutsu.tools.jenkins.util.IOUtils;
import org.jetbrains.annotations.Nullable;
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/security/DefaultSecurityClient.java b/src/main/java/org/codinjutsu/tools/jenkins/security/DefaultSecurityClient.java
index 3b1dbc2f..2dca08de 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/security/DefaultSecurityClient.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/security/DefaultSecurityClient.java
@@ -26,6 +26,7 @@
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpHeaders;
+import org.codinjutsu.tools.jenkins.exception.AuthenticationException;
import org.codinjutsu.tools.jenkins.exception.ConfigurationException;
import org.codinjutsu.tools.jenkins.model.FileParameter;
import org.codinjutsu.tools.jenkins.model.RequestData;
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java
index 07fe08c9..6c466d80 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java
@@ -33,7 +33,7 @@
import org.codinjutsu.tools.jenkins.JenkinsSettings;
import org.codinjutsu.tools.jenkins.JenkinsTree;
import org.codinjutsu.tools.jenkins.JenkinsTreeState;
-import org.codinjutsu.tools.jenkins.exception.ConfigurationException;
+import org.codinjutsu.tools.jenkins.exception.JenkinsPluginRuntimeException;
import org.codinjutsu.tools.jenkins.logic.*;
import org.codinjutsu.tools.jenkins.model.*;
import org.codinjutsu.tools.jenkins.util.CollectionUtil;
@@ -476,7 +476,7 @@ public void run(@NotNull ProgressIndicator indicator) {
}
currentSelectedView = viewToLoad;
loadJobs();
- } catch (ConfigurationException ex) {
+ } catch (JenkinsPluginRuntimeException ex) {
notifyErrorJenkinsToolWindow(ex.getMessage());
} finally {
setTreeBusy(false);
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java
index 5cdee2b9..2ccb7f2d 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java
@@ -24,10 +24,10 @@
import org.apache.commons.lang.StringUtils;
import org.codinjutsu.tools.jenkins.JenkinsAppSettings;
import org.codinjutsu.tools.jenkins.JenkinsSettings;
+import org.codinjutsu.tools.jenkins.exception.AuthenticationException;
import org.codinjutsu.tools.jenkins.exception.ConfigurationException;
import org.codinjutsu.tools.jenkins.logic.ConfigurationValidator;
import org.codinjutsu.tools.jenkins.logic.RequestManager;
-import org.codinjutsu.tools.jenkins.security.AuthenticationException;
import org.codinjutsu.tools.jenkins.security.JenkinsVersion;
import org.codinjutsu.tools.jenkins.util.GuiUtil;
import org.codinjutsu.tools.jenkins.view.annotation.FormValidator;
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/action/LogToolWindow.java b/src/main/java/org/codinjutsu/tools/jenkins/view/action/LogToolWindow.java
index 8455e435..a97accc4 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/view/action/LogToolWindow.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/view/action/LogToolWindow.java
@@ -17,7 +17,7 @@
import com.intellij.openapi.wm.ToolWindowManager;
import com.offbytwo.jenkins.helper.BuildConsoleStreamListener;
import lombok.Value;
-import org.codinjutsu.tools.jenkins.exception.NoJobFoundException;
+import org.codinjutsu.tools.jenkins.exception.JenkinsPluginRuntimeException;
import org.codinjutsu.tools.jenkins.logic.RequestManager;
import org.codinjutsu.tools.jenkins.model.Build;
import org.codinjutsu.tools.jenkins.model.BuildType;
@@ -60,7 +60,7 @@ public void run(@NotNull ProgressIndicator indicator) {
try {
final RequestManager requestManager = browserPanel.getJenkinsManager();
requestManager.loadConsoleTextFor(job, buildType, processHandler);
- } catch (NoJobFoundException e) {
+ } catch (JenkinsPluginRuntimeException e) {
browserPanel.notifyErrorJenkinsToolWindow(e.getMessage());
}
}
@@ -91,9 +91,7 @@ private static JComponent createConsolePanel(ConsoleView view, ActionGroup actio
}
private static ActionToolbar createToolbar(ActionGroup actions) {
- final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(
- ActionPlaces.UNKNOWN, actions, false);
- return actionToolbar;
+ return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actions, false);
}
private void showInToolWindow(ShowLogConsoleView showLogConsoleView, String tabName) {
@@ -161,7 +159,6 @@ public ShowLogRunDescriptor(@Nullable ExecutionConsole executionConsole,
}
public void init() {
- //setContentToolWindowId(TOOL_WINDOW_ID);
setActivateToolWindowWhenAdded(true);
setAutoFocusContent(true);
}
diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/action/results/JobTestResultsHandler.java b/src/main/java/org/codinjutsu/tools/jenkins/view/action/results/JobTestResultsHandler.java
index 25afbfb3..c713b161 100644
--- a/src/main/java/org/codinjutsu/tools/jenkins/view/action/results/JobTestResultsHandler.java
+++ b/src/main/java/org/codinjutsu/tools/jenkins/view/action/results/JobTestResultsHandler.java
@@ -13,7 +13,7 @@
import com.offbytwo.jenkins.model.TestResult;
import com.offbytwo.jenkins.model.TestSuites;
import jetbrains.buildServer.messages.serviceMessages.TestFailed;
-import org.codinjutsu.tools.jenkins.exception.NoJobFoundException;
+import org.codinjutsu.tools.jenkins.exception.JenkinsPluginRuntimeException;
import org.codinjutsu.tools.jenkins.logic.RequestManager;
import org.codinjutsu.tools.jenkins.model.Job;
import org.codinjutsu.tools.jenkins.view.BrowserPanel;
@@ -43,7 +43,7 @@ class JobTestResultsHandler {
: Arrays.stream(clazz.getMethods())
.filter(m -> method.equals(m.getName()))
.findFirst()
- .map(m -> (PsiElement) m)
+ .map(PsiElement.class::cast)
.orElse(clazz);
return clazz == null ? Collections.emptyList() : Collections.singletonList(new PsiLocation<>(element));
@@ -56,7 +56,7 @@ void handle() {
try {
List testResults = RequestManager.getInstance(project).loadTestResultsFor(job);
testResults.forEach(this::handleTestResult);
- } catch (NoJobFoundException e) {
+ } catch (JenkinsPluginRuntimeException e) {
browserPanel.notifyErrorJenkinsToolWindow(e.getMessage());
}
testEventsProcessor.onFinishTesting();
diff --git a/src/test/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanelTest.java b/src/test/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanelTest.java
index ffd2f8a4..cb5598fd 100644
--- a/src/test/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanelTest.java
+++ b/src/test/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanelTest.java
@@ -18,16 +18,6 @@
import org.codinjutsu.tools.jenkins.JenkinsAppSettings;
import org.codinjutsu.tools.jenkins.JenkinsSettings;
-import org.codinjutsu.tools.jenkins.exception.ConfigurationException;
-import org.codinjutsu.tools.jenkins.logic.RequestManager;
-import org.codinjutsu.tools.jenkins.security.AuthenticationException;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import static org.codinjutsu.tools.jenkins.JenkinsAppSettings.DEFAULT_BUILD_DELAY;
-import static org.codinjutsu.tools.jenkins.JenkinsAppSettings.DUMMY_JENKINS_SERVER_URL;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doThrow;
public class ConfigurationPanelTest {