aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-21 06:07:56 (EST)
committerWinston Prakash2011-12-01 20:46:48 (EST)
commitc3d5fe5d7ad09e47009415ee66c555a7a767b64b (patch)
tree8d741759e2cd7c8273df6b4b8f829f6aaa2f50f3
parent2ccdbacaddd4a0cce0e0c7a996235dcd95cdef59 (diff)
downloadorg.eclipse.hudson.core-c3d5fe5d7ad09e47009415ee66c555a7a767b64b.zip
org.eclipse.hudson.core-c3d5fe5d7ad09e47009415ee66c555a7a767b64b.tar.gz
org.eclipse.hudson.core-c3d5fe5d7ad09e47009415ee66c555a7a767b64b.tar.bz2
Add configurable ThreadLocal value in order to skip saving config during submit operation
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java46
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleProject.java19
2 files changed, 30 insertions, 35 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 3cb29ff..4259418 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -89,6 +89,7 @@ import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
+import org.apache.commons.lang3.StringUtils;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.stapler.ForwardToView;
@@ -259,6 +260,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
@Override
+ @SuppressWarnings({"unchecked"})
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
super.onLoad(parent, name);
@@ -321,6 +323,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return cleanWorkspaceRequired;
}
+ public void setCleanWorkspaceRequired(boolean cleanWorkspaceRequired) {
+ this.cleanWorkspaceRequired = cleanWorkspaceRequired;
+ }
+
/**
* If this project is configured to be always built on this node,
* return that {@link Node}. Otherwise null.
@@ -526,6 +532,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return scmCheckoutRetryCount !=null ? scmCheckoutRetryCount : Hudson.getInstance().getScmCheckoutRetryCount();
}
+ public void setScmCheckoutRetryCount(Integer scmCheckoutRetryCount) {
+ this.scmCheckoutRetryCount = scmCheckoutRetryCount;
+ }
+
// ugly name because of EL
public boolean getHasCustomQuietPeriod() {
return quietPeriod!=null;
@@ -903,10 +913,14 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* Overwrites the JDK setting.
*/
public void setJDK(JDK jdk) throws IOException {
- this.jdk = jdk.getName();
+ setJDK(jdk.getName());
save();
}
+ public void setJDK(String jdk) {
+ this.jdk = jdk;
+ }
+
public BuildAuthorizationToken getAuthToken() {
return authToken;
}
@@ -1670,22 +1684,15 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
super.submit(req,rsp);
- makeDisabled(req.getParameter("disable")!=null);
- setTemplateName(Util.fixEmptyAndTrim(req.getParameter("templateName")));
-
- jdk = req.getParameter("jdk");
- if(req.getParameter("hasCustomQuietPeriod")!=null) {
- quietPeriod = Integer.parseInt(req.getParameter("quiet_period"));
- } else {
- quietPeriod = null;
- }
- if(req.getParameter("hasCustomScmCheckoutRetryCount")!=null) {
- scmCheckoutRetryCount = Integer.parseInt(req.getParameter("scmCheckoutRetryCount"));
- } else {
- scmCheckoutRetryCount = null;
- }
- blockBuildWhenDownstreamBuilding = req.getParameter("blockBuildWhenDownstreamBuilding")!=null;
- blockBuildWhenUpstreamBuilding = req.getParameter("blockBuildWhenUpstreamBuilding")!=null;
+ makeDisabled(null != req.getParameter("disable"));
+ setTemplateName(StringUtils.trimToNull(req.getParameter("templateName")));
+ setJDK(req.getParameter("jdk"));
+ setQuietPeriod(null != req.getParameter("hasCustomQuietPeriod") ?
+ Integer.parseInt(req.getParameter("quiet_period")) : null);
+ setScmCheckoutRetryCount(null != req.getParameter("hasCustomScmCheckoutRetryCount")
+ ? Integer.parseInt(req.getParameter("scmCheckoutRetryCount")) : null);
+ setBlockBuildWhenDownstreamBuilding(null != req.getParameter("blockBuildWhenDownstreamBuilding"));
+ setBlockBuildWhenUpstreamBuilding(null != req.getParameter("blockBuildWhenUpstreamBuilding"));
if (req.getParameter("hasSlaveAffinity") != null) {
// New logic for handling whether this choice came from the dropdown or textfield.
@@ -1701,11 +1708,12 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
advancedAffinityChooser = false;
}
- cleanWorkspaceRequired = null != req.getParameter("cleanWorkspaceRequired");
+
+ setCleanWorkspaceRequired(null != req.getParameter("cleanWorkspaceRequired"));
canRoam = assignedNode==null;
- concurrentBuild = req.getSubmittedForm().has("concurrentBuild");
+ setConcurrentBuild(req.getSubmittedForm().has("concurrentBuild"));
authToken = BuildAuthorizationToken.create(req);
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
index efcf06b..9d80068 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
@@ -83,35 +83,22 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
*
* @param customWorkspace customWorkspace.
* @since 1.320
+ * @throws java.io.IOException exception if any.
*/
public void setCustomWorkspace(String customWorkspace) throws IOException {
- setCustomWorkspace(customWorkspace, true);
- }
-
- /**
- * Sets custom workspace,
- * @param customWorkspace workspace.
- * @param forceSave true to force save operation
- * @throws IOException if any.
- * @see #save()
- */
- private void setCustomWorkspace(String customWorkspace, boolean forceSave) throws IOException{
if (!(hasParentTemplate()
&& StringUtils.equalsIgnoreCase(getTemplate().getCustomWorkspace(), customWorkspace))) {
this.customWorkspace = customWorkspace;
} else {
this.customWorkspace = null;
}
- if (forceSave) {
- save();
- }
+ save();
}
@Override
protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException {
setCustomWorkspace(
- req.hasParameter("customWorkspace")? req.getParameter("customWorkspace.directory") : null,
- false);
+ req.hasParameter("customWorkspace")? req.getParameter("customWorkspace.directory") : null);
super.submit(req, rsp);
}