提交 45f9de0f 编写于 作者: K Kohsuke Kawaguchi

backward compatibility resurrection

上级 8d14efe3
......@@ -102,6 +102,10 @@ public class ParametersDefinitionProperty extends JobProperty<AbstractProject<?,
return (AbstractProject<?, ?>) owner;
}
public void _doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
_doBuild(req,rsp,TimeDuration.fromString(req.getParameter("delay")));
}
/**
* Interprets the form submission and schedules a build for a parameterized job.
*
......@@ -140,6 +144,10 @@ public class ParametersDefinitionProperty extends JobProperty<AbstractProject<?,
rsp.sendRedirect(".");
}
public void buildWithParameters(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
buildWithParameters(req,rsp,TimeDuration.fromString(req.getParameter("delay")));
}
public void buildWithParameters(StaplerRequest req, StaplerResponse rsp, TimeDuration delay) throws IOException, ServletException {
List<ParameterValue> values = new ArrayList<ParameterValue>();
for (ParameterDefinition d: parameterDefinitions) {
......
package jenkins.util;
import org.apache.commons.beanutils.Converter;
import org.kohsuke.stapler.QueryParameter;
import java.util.concurrent.TimeUnit;
......@@ -31,20 +32,26 @@ public class TimeDuration {
return t.convert(millis,TimeUnit.MILLISECONDS);
}
public static TimeDuration fromString(String delay) {
if (delay==null)
return null;
try {
// TODO: more unit handling
if(delay.endsWith("sec")) delay=delay.substring(0,delay.length()-3);
if(delay.endsWith("secs")) delay=delay.substring(0,delay.length()-4);
return new TimeDuration(Long.parseLong(delay));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid time duration value: "+delay);
}
}
public static class StaplerConverterImpl implements Converter {
public Object convert(Class type, Object value) {
if (value==null)
return null;
if (value instanceof String) {
String delay = (String)value;
try {
// TODO: more unit handling
if(delay.endsWith("sec")) delay=delay.substring(0,delay.length()-3);
if(delay.endsWith("secs")) delay=delay.substring(0,delay.length()-4);
return new TimeDuration(Long.parseLong(delay));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid time duration value: "+delay);
}
return fromString((String) value);
}
throw new UnsupportedOperationException();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册