diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index f808928454a71..a7d74fcee4780 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -45,6 +45,7 @@ import hudson.model.AbstractModelObject; import hudson.model.AdministrativeMonitor; import hudson.model.Api; +import hudson.model.Descriptor; import hudson.model.DownloadService; import hudson.model.Failure; import hudson.model.ItemGroupMixIn; @@ -165,6 +166,7 @@ import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.interceptor.RequirePOST; +import org.kohsuke.stapler.verb.POST; import org.springframework.security.core.Authentication; import org.xml.sax.Attributes; import org.xml.sax.InputSource; @@ -1795,6 +1797,16 @@ public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOExcept return new HttpRedirect("advanced"); } + @POST + public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, ServletException { + Jenkins jenkins = Jenkins.get(); + jenkins.checkPermission(Jenkins.ADMINISTER); + + ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm()); + ProxyConfigurationManager.saveProxyConfiguration(pc); + return new HttpRedirect("advanced"); + } + interface PluginCopier { void copy(File target) throws Exception; @@ -2112,6 +2124,10 @@ protected String identifyPluginShortName(File t) { return FilenameUtils.getBaseName(t.getName()); // fall back to the base name of what's uploaded } + public Descriptor getProxyDescriptor() { + return Jenkins.get().getDescriptor(ProxyConfiguration.class); + } + /** * Prepares plugins for some expected XML configuration. * If the configuration (typically a job’s {@code config.xml}) diff --git a/core/src/main/java/hudson/ProxyConfigurationManager.java b/core/src/main/java/hudson/ProxyConfigurationManager.java index 834689c8085b4..42f890ca8422a 100644 --- a/core/src/main/java/hudson/ProxyConfigurationManager.java +++ b/core/src/main/java/hudson/ProxyConfigurationManager.java @@ -26,62 +26,38 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.Descriptor; -import hudson.model.ManagementLink; -import hudson.security.Permission; import java.io.IOException; -import javax.servlet.ServletException; +import jenkins.model.GlobalConfiguration; import jenkins.model.Jenkins; -import org.kohsuke.stapler.HttpRedirect; -import org.kohsuke.stapler.HttpResponse; +import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.verb.POST; @Extension -public class ProxyConfigurationManager extends ManagementLink { +public class ProxyConfigurationManager extends GlobalConfiguration { + @NonNull @Override public String getDisplayName() { return Messages.ProxyConfigurationManager_DisplayName(); } - @Override - public String getIconFileName() { - return "symbol-proxy"; - } - - @Override - public String getUrlName() { - return "proxyConfigurationManager"; - } - - @NonNull - @Override - public Category getCategory() { - return Category.CONFIGURATION; - } - - @NonNull - @Override - public Permission getRequiredPermission() { - return Jenkins.SYSTEM_READ; - } - - @Override - public String getDescription() { - return Messages.ProxyConfigurationManager_Description(); - } - public Descriptor getProxyDescriptor() { return Jenkins.get().getDescriptor(ProxyConfiguration.class); } + @Override + public boolean configure(StaplerRequest req, JSONObject json) throws FormException { + ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, json); + try { + saveProxyConfiguration(pc); + } catch (IOException e) { + throw new FormException(e.getMessage(), e, null); + } + return true; + } - @POST - public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, ServletException { + public static void saveProxyConfiguration(ProxyConfiguration pc) throws IOException { Jenkins jenkins = Jenkins.get(); - jenkins.checkPermission(Jenkins.ADMINISTER); - - ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm()); if (pc.name == null) { jenkins.proxy = null; ProxyConfiguration.getXmlFile().delete(); @@ -89,7 +65,6 @@ public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, Ser jenkins.proxy = pc; jenkins.proxy.save(); } - return new HttpRedirect(".."); } } diff --git a/core/src/main/resources/hudson/ProxyConfigurationManager/index.jelly b/core/src/main/resources/hudson/ProxyConfigurationManager/config.jelly similarity index 57% rename from core/src/main/resources/hudson/ProxyConfigurationManager/index.jelly rename to core/src/main/resources/hudson/ProxyConfigurationManager/config.jelly index b0b9d07f1b6be..9697244033440 100644 --- a/core/src/main/resources/hudson/ProxyConfigurationManager/index.jelly +++ b/core/src/main/resources/hudson/ProxyConfigurationManager/config.jelly @@ -25,26 +25,11 @@ THE SOFTWARE. - - - -
-
-

${%HTTP Proxy Configuration}

- - - - - - - - - - - - -
-
-
-
+ + + + + + +
diff --git a/war/src/main/resources/images/symbols/proxy.svg b/war/src/main/resources/images/symbols/proxy.svg deleted file mode 100644 index 11caac0148cfa..0000000000000 --- a/war/src/main/resources/images/symbols/proxy.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file