提交 1aa8302d 编写于 作者: K kohsuke

structured form functionality is moved to stapler.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11043 71c3de6d-444a-0410-be80-ed276b4c234a
上级 c156dad5
......@@ -291,7 +291,7 @@
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
<version>1.79</version>
<version>1.80</version>
</dependency>
<dependency>
<!-- until the next rev of stapler picks up localizer 1.5 -->
......@@ -480,12 +480,6 @@
<artifactId>txw2</artifactId>
<version>20070624</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>json-lib</artifactId>
<version>2.1</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
......
......@@ -18,27 +18,14 @@ import java.util.Collections;
* @author Kohsuke Kawaguchi
*/
public class StructuredForm {
/**
* @deprecated
* Use {@link StaplerRequest#getSubmittedForm()}. Since 1.238.
*/
public static JSONObject get(StaplerRequest req) {
JSONObject o = (JSONObject)req.getAttribute(StructuredForm.class.getName());
if(o==null) {
String p = req.getParameter("json");
if(p==null) {
// no data submitted
try {
StaplerResponse rsp = Stapler.getCurrentResponse();
rsp.sendError(SC_BAD_REQUEST,"This page expects a form submission");
rsp.getWriter().close();
throw new Error("This page expects a form submission");
} catch (IOException e) {
throw new Error(e);
}
}
o = JSONObject.fromObject(p);
req.setAttribute(StructuredForm.class.getName(),o);
}
return o;
return req.getSubmittedForm();
}
/**
* Retrieves the property of the given object and returns it as a list of {@link JSONObject}.
*
......
......@@ -2,7 +2,6 @@ package hudson.matrix;
import hudson.CopyOnWrite;
import hudson.FilePath;
import hudson.StructuredForm;
import hudson.XmlFile;
import hudson.model.AbstractProject;
import hudson.model.Action;
......@@ -446,7 +445,7 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
newAxes.add(Axis.parsePrefixed(req,"label"));
this.axes = newAxes;
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
buildWrappers.rebuild(req, json, BuildWrappers.getFor(this), "wrapper");
builders.rebuildHetero(req, json, BuildStep.BUILDERS, "builder");
......
......@@ -2,7 +2,6 @@ package hudson.maven;
import hudson.CopyOnWrite;
import hudson.FilePath;
import hudson.StructuredForm;
import hudson.Util;
import hudson.Functions;
import hudson.maven.reporters.MavenMailer;
......@@ -391,7 +390,7 @@ public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBui
protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
super.submit(req, rsp);
reporters.rebuild(req,StructuredForm.get(req),MavenReporters.getConfigurableList(),"reporter");
reporters.rebuild(req, req.getSubmittedForm(),MavenReporters.getConfigurableList(),"reporter");
goals = Util.fixEmpty(req.getParameter("goals").trim());
......
......@@ -532,7 +532,7 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
aggregatorStyleBuild = !req.hasParameter("maven.perModuleBuild");
usePrivateRepository = req.hasParameter("maven.usePrivateRepository");
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
reporters.rebuild(req,json,MavenReporters.getConfigurableList(),"reporter");
publishers.rebuild(req,json,BuildStepDescriptor.filter(BuildStep.PUBLISHERS,this.getClass()),"publisher");
buildWrappers.rebuild(req,json,BuildWrappers.getFor(this),"wrapper");
......
......@@ -4,7 +4,6 @@ import hudson.AbortException;
import hudson.FeedAdapter;
import hudson.FilePath;
import hudson.Launcher;
import hudson.StructuredForm;
import hudson.maven.MavenModule;
import hudson.model.Descriptor.FormException;
import hudson.model.Fingerprint.RangeSet;
......@@ -946,7 +945,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
protected final <T extends Describable<T>> List<T> buildDescribable(StaplerRequest req, List<? extends Descriptor<T>> descriptors, String prefix)
throws FormException {
JSONObject data = StructuredForm.get(req);
JSONObject data = req.getSubmittedForm();
List<T> r = new Vector<T>();
for( int i=0; i< descriptors.size(); i++ ) {
String name = prefix + i;
......
......@@ -1478,7 +1478,7 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
req.setCharacterEncoding("UTF-8");
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
// keep using 'useSecurity' field as the main configuration setting
// until we get the new security implementation working
......@@ -1580,7 +1580,7 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
public synchronized void doConfigExecutorsSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(ADMINISTER);
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
numExecutors = Integer.parseInt(req.getParameter("numExecutors"));
if(req.hasParameter("master.mode"))
......
......@@ -2,7 +2,6 @@ package hudson.model;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import hudson.ExtensionPoint;
import hudson.StructuredForm;
import hudson.Util;
import hudson.XmlFile;
import hudson.model.Descriptor.FormException;
......@@ -813,7 +812,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
try {
properties.clear();
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
if (req.getParameter("logrotate") != null)
logRotator = LogRotator.DESCRIPTOR.newInstance(req,json.getJSONObject("logrotate"));
......@@ -856,7 +855,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
PrintWriter pw = new PrintWriter(sw);
pw
.println("Failed to parse form data. Please report this probelm as a bug");
pw.println("JSON=" + StructuredForm.get(req));
pw.println("JSON=" + req.getSubmittedForm());
pw.println();
e.printStackTrace(pw);
......
package hudson.model;
import hudson.StructuredForm;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -62,7 +60,7 @@ public class ParametersDefinitionProperty extends JobProperty<AbstractProject<?,
List<ParameterValue> values = new ArrayList<ParameterValue>();
JSONObject formData = StructuredForm.get(req);
JSONObject formData = req.getSubmittedForm();
JSONArray a = JSONArray.fromObject(formData.get("parameter"));
for (Object o : a) {
......
package hudson.model;
import hudson.StructuredForm;
import hudson.Util;
import hudson.model.Descriptor.FormException;
import hudson.tasks.BuildStep;
......@@ -158,7 +157,7 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
super.submit(req,rsp);
req.setCharacterEncoding("UTF-8");
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
buildWrappers.rebuild(req,json, BuildWrappers.getFor(this), "wrapper");
builders.rebuildHetero(req,json, BuildStep.BUILDERS, "builder");
......
......@@ -3,7 +3,6 @@ package hudson.model;
import com.thoughtworks.xstream.XStream;
import hudson.CopyOnWrite;
import hudson.FeedAdapter;
import hudson.StructuredForm;
import hudson.Util;
import hudson.XmlFile;
import hudson.model.Descriptor.FormException;
......@@ -386,7 +385,7 @@ public class User extends AbstractModelObject implements AccessControlled {
fullName = req.getParameter("fullName");
description = req.getParameter("description");
JSONObject json = StructuredForm.get(req);
JSONObject json = req.getSubmittedForm();
List<UserProperty> props = new ArrayList<UserProperty>();
int i=0;
......
......@@ -2,7 +2,6 @@ package hudson.scm;
import hudson.model.Descriptor;
import hudson.model.Descriptor.FormException;
import hudson.StructuredForm;
import java.util.List;
......@@ -34,6 +33,6 @@ public class SCMS {
int scmidx = Integer.parseInt(scm);
SCMDescriptor<?> d = SCMS.get(scmidx);
d.generation++;
return d.newInstance(req,StructuredForm.get(req).getJSONObject("scm"));
return d.newInstance(req, req.getSubmittedForm().getJSONObject("scm"));
}
}
......@@ -2,7 +2,6 @@ package hudson.tasks;
import hudson.CopyOnWrite;
import hudson.Launcher;
import hudson.StructuredForm;
import hudson.Util;
import hudson.FilePath;
import hudson.EnvVars;
......@@ -263,7 +262,7 @@ public class Ant extends Builder {
public boolean configure(StaplerRequest req) {
installations = req.bindJSONToList(
AntInstallation.class,StructuredForm.get(req).get("ant")).toArray(new AntInstallation[0]);
AntInstallation.class, req.getSubmittedForm().get("ant")).toArray(new AntInstallation[0]);
save();
return true;
}
......
......@@ -7,7 +7,6 @@ import hudson.Launcher;
import hudson.Launcher.LocalLauncher;
import hudson.Util;
import hudson.EnvVars;
import hudson.StructuredForm;
import hudson.maven.MavenEmbedder;
import hudson.maven.MavenUtil;
import hudson.maven.RedeployPublisher;
......@@ -227,7 +226,7 @@ public class Maven extends Builder {
}
public boolean configure(StaplerRequest req) {
this.installations = req.bindJSONToList(MavenInstallation.class,StructuredForm.get(req).get("maven"))
this.installations = req.bindJSONToList(MavenInstallation.class, req.getSubmittedForm().get("maven"))
.toArray(new MavenInstallation[0]);
save();
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册