Skip to content
Permalink
Browse files

[FIXED JENKINS-10935]

  • Loading branch information...
jacob_robertson
jacob_robertson committed Sep 8, 2011
1 parent 88732ba commit ed1940328e697cc0f1fa211f6b968e477f52a627
@@ -2,6 +2,7 @@

import hudson.model.AbstractProject;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.TopLevelItem;
import hudson.tasks.Publisher;
import hudson.util.DescribableList;
@@ -12,7 +13,7 @@

public abstract class AbstractEmailValuesProvider implements PluginHelperTestable {

@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings("unchecked")
public List<String> getValues(TopLevelItem item) {
List<String> values = new ArrayList<String>();
if (item instanceof AbstractProject) {
@@ -28,6 +29,9 @@
return values;
}

protected abstract Descriptor<Publisher> getDescriptor();
@SuppressWarnings("unchecked")
protected Descriptor<Publisher> getDescriptor() {
return Hudson.getInstance().getDescriptor(getPluginTesterClass());
}
protected abstract String getValue(Publisher publisher);
}
@@ -1,15 +1,10 @@
package hudson.views;

import hudson.model.Descriptor;
import hudson.tasks.Mailer;
import hudson.tasks.Publisher;

public class CoreEmailValuesProvider extends AbstractEmailValuesProvider {

@Override
protected Descriptor<Publisher> getDescriptor() {
return Mailer.descriptor();
}
@Override
protected String getValue(Publisher publisher) {
Mailer mailer = (Mailer) publisher;
@@ -1,15 +1,10 @@
package hudson.views;

import hudson.model.Descriptor;
import hudson.plugins.emailext.ExtendedEmailPublisher;
import hudson.tasks.Publisher;

public class EmailExtValuesProvider extends AbstractEmailValuesProvider {

@Override
protected Descriptor<Publisher> getDescriptor() {
return ExtendedEmailPublisher.DESCRIPTOR;
}
@Override
protected String getValue(Publisher publisher) {
ExtendedEmailPublisher mailer = (ExtendedEmailPublisher) publisher;
@@ -70,7 +70,7 @@ protected boolean matches(TopLevelItem item) {
@SuppressWarnings("unchecked")
@Override
protected boolean runMatches(Run run) {
User user = Hudson.getInstance().getMe();
User user = getUser();
if (matchUserFullName) {
String userName = normalize(user.getFullName());
if (runMatches(userName, true, run)) {
@@ -85,6 +85,17 @@ protected boolean runMatches(Run run) {
}
return false;
}
private User getUser() {
try {
return Hudson.getInstance().getMe();
} catch (Exception e) {
try {
return Hudson.getInstance().getUser(Hudson.ANONYMOUS.getName());
} catch (Exception e2) {
return null;
}
}
}
@SuppressWarnings("unchecked")
public boolean runMatches(String userName, boolean matchAgainstFullName, Run run) {
if (matchScmChanges) {
@@ -125,7 +136,7 @@ public String normalize(String userName) {
}

public boolean matchesEmail(TopLevelItem item) {
User user = Hudson.getInstance().getMe();
User user = getUser();
if (matchUserFullName) {
String userName = normalize(user.getFullName());
if (matchesEmail(item, userName)) {

0 comments on commit ed19403

Please sign in to comment.
You can’t perform that action at this time.