/** * @deprecated * Use {@link StaplerRequest#getSubmittedForm()}. Since 1.238. */ @Deprecated public static JSONObject get(StaplerRequest req) throws ServletException { return req.getSubmittedForm(); } /**
private boolean needToAddToCurrentView(StaplerRequest req) throws ServletException { String json = req.getParameter("json"); if (json != null && json.length() > 0) { // Submitted via UI JSONObject form = req.getSubmittedForm(); return form.has("addToCurrentView") && form.getBoolean("addToCurrentView"); } else { // Submitted via API return true; } }
@Override protected void submit(StaplerRequest req) throws IOException, ServletException, FormException { String proxiedViewName = req.getSubmittedForm().getString("proxiedViewName"); if (Jenkins.getInstance().getView(proxiedViewName) == null) { throw new FormException("Not an existing global view", "proxiedViewName"); } this.proxiedViewName = proxiedViewName; }
protected final <T extends Describable<T>> List<T> buildDescribable(StaplerRequest req, List<? extends Descriptor<T>> descriptors) throws FormException, ServletException { JSONObject data = req.getSubmittedForm(); List<T> r = new Vector<T>(); for (Descriptor<T> d : descriptors) { String safeName = d.getJsonSafeClassName(); if (req.getParameter(safeName) != null) { T instance = d.newInstance(req, data.getJSONObject(safeName)); r.add(instance); } } return r; }
public static SettingsProvider parseSettingsProvider(StaplerRequest req) throws Descriptor.FormException, ServletException { JSONObject settings = req.getSubmittedForm().getJSONObject("settings"); if (settings == null) { return new DefaultSettingsProvider(); } return req.bindJSON(SettingsProvider.class, settings); }
public static GlobalSettingsProvider parseSettingsProvider(StaplerRequest req) throws Descriptor.FormException, ServletException { JSONObject settings = req.getSubmittedForm().getJSONObject("globalSettings"); if (settings == null) { return new DefaultGlobalSettingsProvider(); } return req.bindJSON(GlobalSettingsProvider.class, settings); }
@RequirePOST public synchronized void doConfigure(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException { boolean result = configure(req, req.getSubmittedForm()); LOGGER.log(Level.FINE, "tools saved: "+result); FormApply.success(req.getContextPath() + "/manage").generateResponse(req, rsp, null); }
/** * Accepts the update to the node configuration. */ @RequirePOST public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Jenkins.ADMINISTER); properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); this.description = req.getSubmittedForm().getString("description"); updateTransientActions(); save(); FormApply.success(".").generateResponse(req, rsp, null); }
@RequirePOST public @Nonnull HttpResponse doConfigSubmit( StaplerRequest req ) throws IOException, ServletException, FormException { checkPermission(UPDATE); try (BulkChange bc = new BulkChange(this)) { JSONObject json = req.getSubmittedForm(); submit(json); bc.commit(); } return FormApply.success("."); }
/** * Accepts the update to the node configuration. */ @RequirePOST public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { checkPermission(CONFIGURE); String proposedName = Util.fixEmptyAndTrim(req.getSubmittedForm().getString("name")); Jenkins.checkGoodName(proposedName); Node node = getNode(); if (node == null) { throw new ServletException("No such node " + nodeName); } if ((!proposedName.equals(nodeName)) && Jenkins.getActiveInstance().getNode(proposedName) != null) { throw new FormException(Messages.ComputerSet_SlaveAlreadyExists(proposedName), "name"); } String nExecutors = req.getSubmittedForm().getString("numExecutors"); if (StringUtils.isBlank(nExecutors) || Integer.parseInt(nExecutors)<=0) { throw new FormException(Messages.Slave_InvalidConfig_Executors(nodeName), "numExecutors"); } Node result = node.reconfigure(req, req.getSubmittedForm()); Jenkins.getInstance().getNodesObject().replaceNode(this.getNode(), result); // take the user back to the agent top page. rsp.sendRedirect2("../" + result.getNodeName() + '/'); }
/** * Parses {@link SCM} configuration from the submitted form. * * @param target * The project for which this SCM is configured to. */ @SuppressWarnings("deprecation") public static SCM parseSCM(StaplerRequest req, AbstractProject target) throws FormException, ServletException { SCM scm = SCM.all().newInstanceFromRadioList(req.getSubmittedForm().getJSONObject("scm")); if (scm == null) { scm = new NullSCM(); // JENKINS-36043 workaround for AbstractMultiBranchProject.submit } scm.getDescriptor().generation++; return scm; }
/** * Accepts submission from the configuration page. */ @RequirePOST public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { JSONObject src = req.getSubmittedForm(); String newName = src.getString("name"), redirect = "."; XmlFile oldFile = null; if(!name.equals(newName)) { Jenkins.checkGoodName(newName); oldFile = getConfigFile(); // rename getParent().logRecorders.remove(name); this.name = newName; getParent().logRecorders.put(name,this); redirect = "../" + Util.rawEncode(newName) + '/'; } List<Target> newTargets = req.bindJSONToList(Target.class, src.get("targets")); for (Target t : newTargets) t.enable(); targets.replaceBy(newTargets); save(); if (oldFile!=null) oldFile.delete(); rsp.sendRedirect2(redirect); }
@RequirePOST public synchronized void doConfigure(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException { // for compatibility reasons, the actual value is stored in Jenkins BulkChange bc = new BulkChange(Jenkins.getInstance()); try{ boolean result = configure(req, req.getSubmittedForm()); LOGGER.log(Level.FINE, "security saved: "+result); Jenkins.getInstance().save(); FormApply.success(req.getContextPath()+"/manage").generateResponse(req, rsp, null); } finally { bc.commit(); } }
/** * Really creates a new agent. */ @RequirePOST public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Computer.CREATE); String fixedName = Util.fixEmptyAndTrim(name); checkName(fixedName); JSONObject formData = req.getSubmittedForm(); formData.put("name", fixedName); // TODO type is probably NodeDescriptor.id but confirm Node result = NodeDescriptor.all().find(type).newInstance(req, formData); app.addNode(result); // take the user back to the agent list top page rsp.sendRedirect2("."); }
@RequirePOST public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, ServletException { Jenkins jenkins = Jenkins.getInstance(); jenkins.checkPermission(CONFIGURE_UPDATECENTER); ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm()); if (pc.name==null) { jenkins.proxy = null; ProxyConfiguration.getXmlFile().delete(); } else { jenkins.proxy = pc; jenkins.proxy.save(); } return new HttpRedirect("advanced"); }
@Override protected void submit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { super.submit(req,rsp); JSONObject json = req.getSubmittedForm(); getBuildWrappersList().rebuild(req,json, BuildWrappers.getFor(this)); getBuildersList().rebuildHetero(req,json, Builder.all(), "builder"); getPublishersList().rebuildHetero(req, json, Publisher.all(), "publisher"); }
/** * Accepts submission from the node configuration page. */ @RequirePOST public synchronized void doConfigExecutorsSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { checkPermission(ADMINISTER); BulkChange bc = new BulkChange(this); try { JSONObject json = req.getSubmittedForm(); ExtensionList.lookupSingleton(MasterBuildConfiguration.class).configure(req,json); getNodeProperties().rebuild(req, json.optJSONObject("nodeProperties"), NodeProperty.all()); } finally { bc.commit(); } updateComputerList(); rsp.sendRedirect(req.getContextPath()+'/'+toComputer().getUrl()); // back to the computer page }
/** * Accepts submission from the configuration page. */ @RequirePOST public synchronized HttpResponse doConfigSubmit( StaplerRequest req) throws IOException, ServletException, FormException { BulkChange bc = new BulkChange(MONITORS_OWNER); try { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); monitors.rebuild(req,req.getSubmittedForm(),getNodeMonitorDescriptors()); // add in the rest of instances are ignored instances for (Descriptor<NodeMonitor> d : NodeMonitor.all()) if(monitors.get(d)==null) { NodeMonitor i = createDefaultInstance(d, true); if(i!=null) monitors.add(i); } // recompute the data for (NodeMonitor nm : monitors) { nm.triggerUpdate(); } return FormApply.success("."); } finally { bc.commit(); } }
/** * Accepts submission from the configuration page. * * Subtypes should override the {@link #submit(StaplerRequest)} method. */ @RequirePOST public final synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { checkPermission(CONFIGURE); submit(req); description = Util.nullify(req.getParameter("description")); filterExecutors = req.getParameter("filterExecutors") != null; filterQueue = req.getParameter("filterQueue") != null; rename(req.getParameter("name")); getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); save(); FormApply.success("../" + Util.rawEncode(name)).generateResponse(req,rsp,this); }
/** * Accepts submission from the configuration page. */ @RequirePOST public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { BulkChange bc = new BulkChange(this); try { checkPermission(ADMINISTER); JSONObject json = req.getSubmittedForm(); systemMessage = Util.nullify(req.getParameter("system_message")); boolean result = true; for (Descriptor<?> d : Functions.getSortedDescriptorsForGlobalConfigUnclassified()) result &= configureDescriptor(req,json,d); save(); updateComputerList(); if(result) FormApply.success(req.getContextPath()+'/').generateResponse(req, rsp, null); else FormApply.success("configure").generateResponse(req, rsp, null); // back to config } finally { bc.commit(); } }