Permalink
Browse files

Merge pull request #2828 from sathiya-mit/master

[JENKINS-42852] - Jenkins Configuration Save Option
(cherry picked from commit 77804c1)
  • Loading branch information...
oleg-nenashev authored and olivergondza committed Apr 7, 2017
1 parent 6128459 commit ce7d2aec50bbf2a97dab256aee399e180754483e
@@ -27,6 +27,7 @@
import hudson.Extension; import hudson.Extension;
import hudson.model.AdministrativeMonitor; import hudson.model.AdministrativeMonitor;
import jenkins.model.GlobalConfiguration; import jenkins.model.GlobalConfiguration;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -41,9 +42,15 @@
public class AdministrativeMonitorsConfiguration extends GlobalConfiguration { public class AdministrativeMonitorsConfiguration extends GlobalConfiguration {
@Override @Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException { public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
JSONArray monitors = json.optJSONArray("administrativeMonitor");
for (AdministrativeMonitor am : AdministrativeMonitor.all()) { for (AdministrativeMonitor am : AdministrativeMonitor.all()) {
try { try {
boolean disable = !json.getJSONArray("administrativeMonitor").contains(am.id); boolean disable;
if(monitors != null) {
disable = !monitors.contains(am.id);
}else {
disable = !am.id.equals(json.optString("administrativeMonitor"));
}
am.disable(disable); am.disable(disable);
} catch (IOException e) { } catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to process form submission for " + am.id, e); LOGGER.log(Level.WARNING, "Failed to process form submission for " + am.id, e);

0 comments on commit ce7d2ae

Please sign in to comment.