From 492b4902d8f156146ac324c4342aae22c0adf18c Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Thu, 30 Oct 2014 13:57:26 -0700 Subject: [PATCH 1/2] Adjust my prior change to better utilize structured form submission to accomodate a plugins that are not using p:config-assignedLabel --- .../java/hudson/model/AbstractProject.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 1d431dbb9a..c178738a23 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -1815,6 +1815,7 @@ public abstract class AbstractProject

,R extends A if(req.hasParameter("customWorkspace.directory")) { // Workaround for JENKINS-25221 while plugins are being updated. + LOGGER.log(Level.WARNING, "label assignment is using legacy 'customWorkspace.directory'"); customWorkspace = Util.fixEmptyAndTrim(req.getParameter("customWorkspace.directory")); } else if(json.optBoolean("hasCustomWorkspace", json.has("customWorkspace"))) { customWorkspace = Util.fixEmptyAndTrim(json.optString("customWorkspace")); @@ -1828,7 +1829,11 @@ public abstract class AbstractProject

,R extends A else scmCheckoutStrategy = null; - if(json.optBoolean("hasSlaveAffinity", json.has("label"))) { + if(req.hasParameter("_.assignedLabelString")) { + // Workaround for JENKINS-25372 while plugin is being updated. + LOGGER.log(Level.WARNING, "label assignment is using legacy '_.assignedLabelString'"); + assignedNode = Util.fixEmptyAndTrim(req.getParameter("_.assignedLabelString")); + } else if(json.optBoolean("hasSlaveAffinity", json.has("label"))) { assignedNode = Util.fixEmptyAndTrim(json.optString("label")); } else { assignedNode = null; @@ -2026,6 +2031,14 @@ public abstract class AbstractProject

,R extends A return true; } + public FormValidation doCheckAssignedLabelString(@AncestorInPath AbstractProject project, + @QueryParameter String value) { + // Provide a legacy interface in case plugins are not going through p:config-assignedLabel + // see: JENKINS-25372 + LOGGER.log(Level.WARNING, "checking label via legacy '_.assignedLabelString'"); + return doCheckLabel(project, value); + } + public FormValidation doCheckLabel(@AncestorInPath AbstractProject project, @QueryParameter String value) { if (Util.fixEmpty(value)==null) @@ -2084,6 +2097,13 @@ public abstract class AbstractProject

,R extends A return candidates; } + public AutoCompletionCandidates doAutoCompleteAssignedLabelString(@QueryParameter String value) { + // Provide a legacy interface in case plugins are not going through p:config-assignedLabel + // see: JENKINS-25372 + LOGGER.log(Level.WARNING, "autocompleting label via legacy '_.assignedLabelString'"); + return doAutoCompleteLabel(value); + } + public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) { AutoCompletionCandidates c = new AutoCompletionCandidates(); Set

,R extends A return true; } + @Restricted(DoNotUse.class) public FormValidation doCheckAssignedLabelString(@AncestorInPath AbstractProject project, @QueryParameter String value) { // Provide a legacy interface in case plugins are not going through p:config-assignedLabel @@ -2097,6 +2099,7 @@ public abstract class AbstractProject

,R extends A return candidates; } + @Restricted(DoNotUse.class) public AutoCompletionCandidates doAutoCompleteAssignedLabelString(@QueryParameter String value) { // Provide a legacy interface in case plugins are not going through p:config-assignedLabel // see: JENKINS-25372