提交 10b20952 编写于 作者: K kohsuke

collapse the structure to remain backward compatible with the JSON structure before 1.238.

Updated Ant and Maven to use the newer style, but there are plugins out there that expect older
form submission format.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11151 71c3de6d-444a-0410-be80-ed276b4c234a
上级 39c15f8d
...@@ -1544,10 +1544,10 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node, ...@@ -1544,10 +1544,10 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
boolean result = true; boolean result = true;
for( Descriptor<Builder> d : BuildStep.BUILDERS ) for( Descriptor<Builder> d : BuildStep.BUILDERS )
result &= d.configure(req,json.getJSONObject(d.getJsonSafeClassName())); result &= configureDescriptor(req,json,d);
for( Descriptor<Publisher> d : BuildStep.PUBLISHERS ) for( Descriptor<Publisher> d : BuildStep.PUBLISHERS )
result &= d.configure(req,json.getJSONObject(d.getJsonSafeClassName())); result &= configureDescriptor(req,json,d);
for( Descriptor<BuildWrapper> d : BuildWrappers.WRAPPERS ) for( Descriptor<BuildWrapper> d : BuildWrappers.WRAPPERS )
result &= d.configure(req); result &= d.configure(req);
...@@ -1574,6 +1574,13 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node, ...@@ -1574,6 +1574,13 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
} }
} }
private boolean configureDescriptor(StaplerRequest req, JSONObject json, Descriptor<?> d) throws FormException {
// collapse the structure to remain backward compatible with the JSON structure before 1.238
JSONObject js = json.getJSONObject(d.getJsonSafeClassName());
json.putAll(js);
return d.configure(req, js);
}
/** /**
* Accepts submission from the configuration page. * Accepts submission from the configuration page.
*/ */
......
...@@ -260,9 +260,10 @@ public class Ant extends Builder { ...@@ -260,9 +260,10 @@ public class Ant extends Builder {
return installations; return installations;
} }
public boolean configure(StaplerRequest req) { @Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
installations = req.bindJSONToList( installations = req.bindJSONToList(
AntInstallation.class, req.getSubmittedForm().get("ant")).toArray(new AntInstallation[0]); AntInstallation.class, json.get("ant")).toArray(new AntInstallation[0]);
save(); save();
return true; return true;
} }
......
...@@ -225,9 +225,9 @@ public class Maven extends Builder { ...@@ -225,9 +225,9 @@ public class Maven extends Builder {
return installations; return installations;
} }
public boolean configure(StaplerRequest req) { @Override
this.installations = req.bindJSONToList(MavenInstallation.class, req.getSubmittedForm().get("maven")) public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
.toArray(new MavenInstallation[0]); this.installations = req.bindJSONToList(MavenInstallation.class, json.get("maven")).toArray(new MavenInstallation[0]);
save(); save();
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册