From 81ebb6284ee13616213de894fe4de12daadb1ece Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Sat, 11 Oct 2014 08:11:09 -0700 Subject: [PATCH 1/3] Change Jenkins to use a single consistent data-binding field. See also: https://github.com/stapler/stapler/pull/39 This commit includes several changes to accomodate the above change in Stapler (moving away from 'stapler-class'), as well as to make Jenkins consistently use this same JSON field (moving away from 'kind'). NOTE: Stapler will continue to accept 'stapler-class' for backwards compatibility, and similarly this plugin will continue to pass 'stapler-class' for plugins that have keyed off of it. --- core/src/main/java/hudson/model/Descriptor.java | 2 +- .../model/GlobalProjectNamingStrategyConfiguration.java | 2 +- .../hudson/slaves/DumbSlave/configure-entries.jelly | 6 ++++++ core/src/main/resources/lib/form/descriptorRadioList.jelly | 4 ++++ core/src/main/resources/lib/form/dropdownListBlock.jelly | 6 +++++- core/src/main/resources/lib/form/hetero-list.jelly | 3 ++- core/src/main/resources/lib/form/hetero-radio.jelly | 7 +++++-- 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index bb6eeb2126..18db9bb9e0 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -909,7 +909,7 @@ public abstract class Descriptor> implements Saveable { if (formData!=null) { for (Object o : JSONArray.fromObject(formData)) { JSONObject jo = (JSONObject)o; - String kind = jo.getString("kind"); + String kind = jo.getString("$class"); Descriptor d = find(descriptors, kind); if (d != null) { items.add(d.newInstance(req, jo)); diff --git a/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java b/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java index 616d3bd2fc..9289a23f1b 100644 --- a/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java @@ -44,7 +44,7 @@ public class GlobalProjectNamingStrategyConfiguration extends GlobalConfiguratio final JSONObject optJSONObject = json.optJSONObject("useProjectNamingStrategy"); if (optJSONObject != null) { final JSONObject strategyObject = optJSONObject.getJSONObject("namingStrategy"); - final String className = strategyObject.getString("stapler-class"); + final String className = strategyObject.getString("$class"); try { Class clazz = Class.forName(className, true, Jenkins.getInstance().getPluginManager().uberClassLoader); final ProjectNamingStrategy strategy = (ProjectNamingStrategy) req.bindJSON(clazz, strategyObject); diff --git a/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly b/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly index a2b3407af4..0ca78b7064 100644 --- a/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly +++ b/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly @@ -57,8 +57,12 @@ THE SOFTWARE. + + + + @@ -77,7 +81,9 @@ THE SOFTWARE. + + diff --git a/core/src/main/resources/lib/form/descriptorRadioList.jelly b/core/src/main/resources/lib/form/descriptorRadioList.jelly index 5193df8043..675f816c0b 100644 --- a/core/src/main/resources/lib/form/descriptorRadioList.jelly +++ b/core/src/main/resources/lib/form/descriptorRadioList.jelly @@ -54,7 +54,11 @@ THE SOFTWARE. + + + + diff --git a/core/src/main/resources/lib/form/dropdownListBlock.jelly b/core/src/main/resources/lib/form/dropdownListBlock.jelly index d06278a673..ba0d206675 100644 --- a/core/src/main/resources/lib/form/dropdownListBlock.jelly +++ b/core/src/main/resources/lib/form/dropdownListBlock.jelly @@ -52,7 +52,11 @@ THE SOFTWARE. - + + + + + diff --git a/core/src/main/resources/lib/form/hetero-list.jelly b/core/src/main/resources/lib/form/hetero-list.jelly index 985f687e3a..cc85d48448 100644 --- a/core/src/main/resources/lib/form/hetero-list.jelly +++ b/core/src/main/resources/lib/form/hetero-list.jelly @@ -93,12 +93,13 @@ THE SOFTWARE.
+ +
- diff --git a/core/src/main/resources/lib/form/hetero-radio.jelly b/core/src/main/resources/lib/form/hetero-radio.jelly index 027960f9f0..0bb8bca1ed 100644 --- a/core/src/main/resources/lib/form/hetero-radio.jelly +++ b/core/src/main/resources/lib/form/hetero-radio.jelly @@ -48,9 +48,12 @@ THE SOFTWARE. - + + - + + + From cef6b49058d2258ce9b7b87405ee453d5f0b8ceb Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Wed, 29 Oct 2014 12:28:28 -0700 Subject: [PATCH 2/3] Surface a new class-entry form tag for submitting the appropriate invisible $class form field --- .../slaves/DumbSlave/configure-entries.jelly | 14 +----- .../main/resources/lib/form/class-entry.jelly | 43 +++++++++++++++++++ .../lib/form/descriptorRadioList.jelly | 8 +--- .../lib/form/dropdownListBlock.jelly | 13 ++---- .../main/resources/lib/form/hetero-list.jelly | 4 +- .../resources/lib/form/hetero-radio.jelly | 9 +--- 6 files changed, 52 insertions(+), 39 deletions(-) create mode 100644 core/src/main/resources/lib/form/class-entry.jelly diff --git a/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly b/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly index 0ca78b7064..667e123f29 100644 --- a/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly +++ b/core/src/main/resources/hudson/slaves/DumbSlave/configure-entries.jelly @@ -56,13 +56,7 @@ THE SOFTWARE. - - - - - - - + @@ -80,11 +74,7 @@ THE SOFTWARE. - - - - - + diff --git a/core/src/main/resources/lib/form/class-entry.jelly b/core/src/main/resources/lib/form/class-entry.jelly new file mode 100644 index 0000000000..ab0bf16070 --- /dev/null +++ b/core/src/main/resources/lib/form/class-entry.jelly @@ -0,0 +1,43 @@ + + + + + Invisible <f:entry> type for embedding a descriptor's $class field. + + The describable class that we are instantiating via structured form submission. + + + The descriptor of the describable that we are instantiating via + structured form submission. Mutually exclusive with clazz. + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/resources/lib/form/descriptorRadioList.jelly b/core/src/main/resources/lib/form/descriptorRadioList.jelly index 675f816c0b..6e20b815e6 100644 --- a/core/src/main/resources/lib/form/descriptorRadioList.jelly +++ b/core/src/main/resources/lib/form/descriptorRadioList.jelly @@ -53,13 +53,7 @@ THE SOFTWARE. title="${d.displayName}" checked="${instance.descriptor==d}"> - - - - - - - + diff --git a/core/src/main/resources/lib/form/dropdownListBlock.jelly b/core/src/main/resources/lib/form/dropdownListBlock.jelly index ba0d206675..426c61fd41 100644 --- a/core/src/main/resources/lib/form/dropdownListBlock.jelly +++ b/core/src/main/resources/lib/form/dropdownListBlock.jelly @@ -50,15 +50,7 @@ THE SOFTWARE. - - - - - - - - - + @@ -69,6 +61,9 @@ THE SOFTWARE. + + +
diff --git a/core/src/main/resources/lib/form/hetero-list.jelly b/core/src/main/resources/lib/form/hetero-list.jelly index cc85d48448..0f969e2aba 100644 --- a/core/src/main/resources/lib/form/hetero-list.jelly +++ b/core/src/main/resources/lib/form/hetero-list.jelly @@ -91,11 +91,9 @@ THE SOFTWARE. +
- - -
diff --git a/core/src/main/resources/lib/form/hetero-radio.jelly b/core/src/main/resources/lib/form/hetero-radio.jelly index 0bb8bca1ed..45eee1e302 100644 --- a/core/src/main/resources/lib/form/hetero-radio.jelly +++ b/core/src/main/resources/lib/form/hetero-radio.jelly @@ -47,14 +47,7 @@ THE SOFTWARE. - - - - - - - - + From 4de46465153dae1a9e804c0d526c44d528f00fb4 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Sat, 1 Nov 2014 10:07:21 -0700 Subject: [PATCH 3/3] add back kind for backwards compatibility, until plugins can be staged onto $class --- core/src/main/java/hudson/model/Descriptor.java | 6 +++++- core/src/main/resources/lib/form/class-entry.jelly | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 18db9bb9e0..2b5bcef0cf 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -909,7 +909,11 @@ public abstract class Descriptor> implements Saveable { if (formData!=null) { for (Object o : JSONArray.fromObject(formData)) { JSONObject jo = (JSONObject)o; - String kind = jo.getString("$class"); + String kind = jo.optString("$class", null); + if (kind == null) { + // Legacy: Remove once plugins have been staged onto $class + kind = jo.getString("kind"); + } Descriptor d = find(descriptors, kind); if (d != null) { items.add(d.newInstance(req, jo)); diff --git a/core/src/main/resources/lib/form/class-entry.jelly b/core/src/main/resources/lib/form/class-entry.jelly index ab0bf16070..e03af3a754 100644 --- a/core/src/main/resources/lib/form/class-entry.jelly +++ b/core/src/main/resources/lib/form/class-entry.jelly @@ -38,6 +38,10 @@ THE SOFTWARE. + + + + \ No newline at end of file