aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-05-30 11:13:00 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-05-30 11:13:10 +0200
commit7652deb6f19e3bc4ed062a34f3a04b47cd89fbfe (patch)
tree096f09af8b6d0b3f2029e2d45cd3e4205d0c3958 /sonar-core
parentecfb38dbf57f93e8c05789bef2ccdbaac307714c (diff)
downloadsonarqube-7652deb6f19e3bc4ed062a34f3a04b47cd89fbfe.tar.gz
sonarqube-7652deb6f19e3bc4ed062a34f3a04b47cd89fbfe.zip
Fix some quality flaws
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java
index b57f001b3da..0fc2debfc09 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java
@@ -30,6 +30,7 @@ import org.sonar.api.rules.Rule;
import org.sonar.api.utils.DateUtils;
import org.sonar.core.i18n.RuleI18nManager;
+import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Map;
@@ -58,31 +59,36 @@ public class IssueNotifications implements BatchComponent, ServerComponent {
return notification;
}
+ @CheckForNull
public Notification sendChanges(DefaultIssue issue, IssueChangeContext context, IssueQueryResult queryResult) {
return sendChanges(issue, context, queryResult.rule(issue), queryResult.project(issue), queryResult.component(issue));
}
+ @CheckForNull
public Notification sendChanges(DefaultIssue issue, IssueChangeContext context, Rule rule, Component project, @Nullable Component component) {
- Notification notification = newNotification(project, "issue-changes");
- notification.setFieldValue("key", issue.key());
- notification.setFieldValue("changeAuthor", context.login());
- notification.setFieldValue("reporter", issue.reporter());
- notification.setFieldValue("assignee", issue.assignee());
- notification.setFieldValue("message", issue.message());
- notification.setFieldValue("ruleName", ruleName(rule));
- notification.setFieldValue("componentKey", issue.componentKey());
- if (component != null) {
- notification.setFieldValue("componentName", component.name());
- }
+ if (issue.diffs() != null) {
+ Notification notification = newNotification(project, "issue-changes");
+ notification.setFieldValue("key", issue.key());
+ notification.setFieldValue("changeAuthor", context.login());
+ notification.setFieldValue("reporter", issue.reporter());
+ notification.setFieldValue("assignee", issue.assignee());
+ notification.setFieldValue("message", issue.message());
+ notification.setFieldValue("ruleName", ruleName(rule));
+ notification.setFieldValue("componentKey", issue.componentKey());
+ if (component != null) {
+ notification.setFieldValue("componentName", component.name());
+ }
- for (Map.Entry<String, FieldDiffs.Diff> entry : issue.diffs().diffs().entrySet()) {
- String type = entry.getKey();
- FieldDiffs.Diff diff = entry.getValue();
- notification.setFieldValue("old." + type, diff.oldValue() != null ? diff.oldValue().toString() : null);
- notification.setFieldValue("new." + type, diff.newValue() != null ? diff.newValue().toString() : null);
+ for (Map.Entry<String, FieldDiffs.Diff> entry : issue.diffs().diffs().entrySet()) {
+ String type = entry.getKey();
+ FieldDiffs.Diff diff = entry.getValue();
+ notification.setFieldValue("old." + type, diff.oldValue() != null ? diff.oldValue().toString() : null);
+ notification.setFieldValue("new." + type, diff.newValue() != null ? diff.newValue().toString() : null);
+ }
+ notificationsManager.scheduleForSending(notification);
+ return notification;
}
- notificationsManager.scheduleForSending(notification);
- return notification;
+ return null;
}
private String ruleName(@Nullable Rule rule) {