Skip to content
Permalink
Browse files

Fix for https://issues.jenkins-ci.org/browse/JENKINS-35289

  • Loading branch information...
davidvanlaatum committed Jun 4, 2016
1 parent 989e6dd commit 5fd4108a221c8dea63f192302ba467b6dd6d9eaf
@@ -23,6 +23,7 @@
*/
package hudson.plugins.emailext.plugins.content;

import hudson.ExtensionList;
import hudson.FilePath;
import hudson.Plugin;
import hudson.model.AbstractBuild;
@@ -36,7 +37,6 @@
import java.io.IOException;
import java.io.InputStream;

import hudson.plugins.emailext.ExtendedEmailPublisherDescriptor;
import jenkins.model.Jenkins;

import org.apache.commons.io.FilenameUtils;
@@ -45,8 +45,6 @@
import org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro;
import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException;

import java.io.*;

/**
*
* @author acearl
@@ -71,8 +69,8 @@ public boolean acceptsMacroName(String macroName) {
public static File scriptsFolder() {
return new File(Jenkins.getActiveInstance().getRootDir(), EMAIL_TEMPLATES_DIRECTORY);
}
protected abstract ConfigProvider getConfigProvider();

protected abstract Class<? extends ConfigProvider> getProviderClass();

@Override
public boolean hasNestedContent() {
@@ -137,7 +135,8 @@ private InputStream getManagedFile(String fileName) {
Plugin plugin = Jenkins.getActiveInstance().getPlugin("config-file-provider");
if (plugin != null) {
Config config = null;
ConfigProvider provider = getConfigProvider();
ExtensionList<ConfigProvider> providers = ConfigProvider.all();
ConfigProvider provider = providers.get(getProviderClass ());
for (Config c : provider.getAllConfigs()) {
if (c.name.equalsIgnoreCase(fileName) && provider.isResponsibleFor(c.id)) {
config = c;
@@ -50,15 +50,11 @@ public String evaluate(AbstractBuild<?, ?> build, TaskListener listener, String
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}

@Override
protected ConfigProvider getConfigProvider() {
if(configProvider == null) {
ExtensionList<ConfigProvider> providers = ConfigProvider.all();
configProvider = providers.get(JellyTemplateConfigProvider.class);
}
return (ConfigProvider)configProvider;
protected Class<? extends ConfigProvider> getProviderClass() {
return JellyTemplateConfigProvider.class;
}

private String renderContent(AbstractBuild<?, ?> build, InputStream inputStream, TaskListener listener)
@@ -84,12 +84,8 @@ public String evaluate(AbstractBuild<?, ?> context, TaskListener listener, Strin
}

@Override
protected synchronized ConfigProvider getConfigProvider() {
if(configProvider == null) {
ExtensionList<ConfigProvider> providers = ConfigProvider.all();
configProvider = providers.get(GroovyTemplateConfigProvider.class);
}
return (ConfigProvider)configProvider;
protected Class<? extends ConfigProvider> getProviderClass () {
return GroovyTemplateConfigProvider.class;
}

/**
@@ -52,14 +52,9 @@ public String evaluate(AbstractBuild<?, ?> build, TaskListener listener, String
}
return result;
}

@Override
protected ConfigProvider getConfigProvider() {
if(configProvider == null) {
ExtensionList<ConfigProvider> providers = ConfigProvider.all();
configProvider = providers.get(CustomConfigProvider.class);
}
return (ConfigProvider)configProvider;

protected Class<? extends ConfigProvider> getProviderClass() {
return CustomConfigProvider.class;
}

@Override

0 comments on commit 5fd4108

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