mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-21 15:55:40 +00:00
Switch the source of a number of AbstractProject config options from StaplerRequest to JSONObject.
This change shifts the way a number of form elements are accessed when handling AbstractProject's doConfigSubmit from using "req.getParameter(...)" style access to using JSON-style (structured form submission) access through "reg.getSubmittedForm()".
This commit is contained in:
1 parent
f5a245e95d
commit
873de8cd22
1 file changed
+31
-15
@@ -1789,24 +1789,38 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
super.submit(req,rsp);
|
||||
JSONObject json = req.getSubmittedForm();
|
||||
|
||||
makeDisabled(req.getParameter("disable")!=null);
|
||||
// "disable": {}
|
||||
makeDisabled(json.has("disable"));
|
||||
|
||||
jdk = req.getParameter("jdk");
|
||||
if(req.getParameter("hasCustomQuietPeriod")!=null) {
|
||||
quietPeriod = Integer.parseInt(req.getParameter("quiet_period"));
|
||||
jdk = json.optString("jdk", null);
|
||||
|
||||
// "hasCustomQuietPeriod": {"quiet_period": "3"}
|
||||
JSONObject customQuietPeriodJson = json.optJSONObject("hasCustomQuietPeriod");
|
||||
if(customQuietPeriodJson!=null && !customQuietPeriodJson.isNullObject()) {
|
||||
quietPeriod = customQuietPeriodJson.optInt("quiet_period");
|
||||
} else {
|
||||
quietPeriod = null;
|
||||
}
|
||||
if(req.getParameter("hasCustomScmCheckoutRetryCount")!=null) {
|
||||
scmCheckoutRetryCount = Integer.parseInt(req.getParameter("scmCheckoutRetryCount"));
|
||||
|
||||
// "hasCustomScmCheckoutRetryCount": {"scmCheckoutRetryCount": "12"}
|
||||
JSONObject customRetryJson = json.optJSONObject("hasCustomScmCheckoutRetryCount");
|
||||
if(customRetryJson!=null && !customRetryJson.isNullObject()) {
|
||||
scmCheckoutRetryCount = customRetryJson.optInt("scmCheckoutRetryCount");
|
||||
} else {
|
||||
scmCheckoutRetryCount = null;
|
||||
}
|
||||
blockBuildWhenDownstreamBuilding = req.getParameter("blockBuildWhenDownstreamBuilding")!=null;
|
||||
blockBuildWhenUpstreamBuilding = req.getParameter("blockBuildWhenUpstreamBuilding")!=null;
|
||||
|
||||
if(req.hasParameter("customWorkspace")) {
|
||||
customWorkspace = Util.fixEmptyAndTrim(req.getParameter("customWorkspace.directory"));
|
||||
// "blockBuildWhenDownstreamBuilding": {}
|
||||
blockBuildWhenDownstreamBuilding = json.has("blockBuildWhenDownstreamBuilding");
|
||||
|
||||
// "blockBuildWhenUpstreamBuilding": {}
|
||||
blockBuildWhenUpstreamBuilding = json.has("blockBuildWhenUpstreamBuilding");
|
||||
|
||||
// "customWorkspace": {"directory": "aaa"}
|
||||
JSONObject customWorkspaceJson = json.optJSONObject("customWorkspace");
|
||||
if(customWorkspace!=null && !customWorkspaceJson.isNullObject()) {
|
||||
customWorkspace = Util.fixEmptyAndTrim(
|
||||
customWorkspaceJson.optString("directory"));
|
||||
} else {
|
||||
customWorkspace = null;
|
||||
}
|
||||
@@ -1817,17 +1831,19 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
else
|
||||
scmCheckoutStrategy = null;
|
||||
|
||||
|
||||
if(req.getParameter("hasSlaveAffinity")!=null) {
|
||||
assignedNode = Util.fixEmptyAndTrim(req.getParameter("_.assignedLabelString"));
|
||||
|
||||
JSONObject slaveAffinity = json.getJSONObject("hasSlaveAffinity");
|
||||
if(slaveAffinity!=null && !slaveAffinity.isNullObject()) {
|
||||
assignedNode = Util.fixEmptyAndTrim(
|
||||
slaveAffinity.optString("assignedLabelString"));
|
||||
} else {
|
||||
assignedNode = null;
|
||||
}
|
||||
canRoam = assignedNode==null;
|
||||
|
||||
keepDependencies = req.getParameter("keepDependencies") != null;
|
||||
keepDependencies = json.has("keepDependencies");
|
||||
|
||||
concurrentBuild = req.getSubmittedForm().has("concurrentBuild");
|
||||
concurrentBuild = json.has("concurrentBuild");
|
||||
|
||||
authToken = BuildAuthorizationToken.create(req);
|
||||
|
||||
|
||||
Reference in new issue
Block a user