Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-6113 Short-circuit sending of notifications when there are no s…
…ubscribers
- Loading branch information
Simon Brandhof
committed
Feb 2, 2015
1 parent
8430a7f
commit 7bcccf0
Showing
33 changed files
with
908 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...nar-server/src/main/java/org/sonar/server/issue/notification/IssueChangeNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,91 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.issue.notification; | |||
|
|||
import org.sonar.api.component.Component; | |||
import org.sonar.api.issue.internal.DefaultIssue; | |||
import org.sonar.api.issue.internal.FieldDiffs; | |||
import org.sonar.api.notifications.Notification; | |||
|
|||
import javax.annotation.Nullable; | |||
|
|||
import java.io.Serializable; | |||
import java.util.Map; | |||
|
|||
public class IssueChangeNotification extends Notification { | |||
|
|||
public static final String TYPE = "issue-changes"; | |||
|
|||
public IssueChangeNotification() { | |||
super(TYPE); | |||
} | |||
|
|||
public IssueChangeNotification setIssue(DefaultIssue issue) { | |||
setFieldValue("key", issue.key()); | |||
setFieldValue("reporter", issue.reporter()); | |||
setFieldValue("assignee", issue.assignee()); | |||
setFieldValue("message", issue.message()); | |||
setFieldValue("componentKey", issue.componentKey()); | |||
FieldDiffs currentChange = issue.currentChange(); | |||
if (currentChange != null) { | |||
for (Map.Entry<String, FieldDiffs.Diff> entry : currentChange.diffs().entrySet()) { | |||
String type = entry.getKey(); | |||
FieldDiffs.Diff diff = entry.getValue(); | |||
Serializable newValue = diff.newValue(); | |||
Serializable oldValue = diff.oldValue(); | |||
setFieldValue("old." + type, oldValue != null ? oldValue.toString() : null); | |||
setFieldValue("new." + type, newValue != null ? newValue.toString() : null); | |||
} | |||
} | |||
return this; | |||
} | |||
|
|||
public IssueChangeNotification setProject(Component project) { | |||
setFieldValue("projectName", project.longName()); | |||
setFieldValue("projectKey", project.key()); | |||
return this; | |||
} | |||
|
|||
public IssueChangeNotification setComponent(Component component) { | |||
setFieldValue("componentName", component.longName()); | |||
return this; | |||
} | |||
|
|||
public IssueChangeNotification setChangeAuthorLogin(@Nullable String s) { | |||
if (s != null) { | |||
setFieldValue("changeAuthor", s); | |||
} | |||
return this; | |||
} | |||
|
|||
public IssueChangeNotification setRuleName(@Nullable String s) { | |||
if (s != null) { | |||
setFieldValue("ruleName", s); | |||
} | |||
return this; | |||
} | |||
|
|||
public IssueChangeNotification setComment(@Nullable String s) { | |||
if (s != null) { | |||
setFieldValue("comment", s); | |||
} | |||
return this; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.