Refine search
public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException { Jenkins j = Jenkins.getInstance(); j.checkPermission(Jenkins.ADMINISTER); if (json.has("useSecurity")) { JSONObject security = json.getJSONObject("useSecurity"); j.setDisableRememberMe(security.optBoolean("disableRememberMe", false)); j.setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm")); j.setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization")); if (json.has("markupFormatter")) { j.setMarkupFormatter(req.bindJSON(MarkupFormatter.class, json.getJSONObject("markupFormatter"))); } else { j.setMarkupFormatter(null); j.setSlaveAgentPort(new ServerTcpPort(json.getJSONObject("slaveAgentPort")).getPort()); } catch (IOException e) { throw new hudson.model.Descriptor.FormException(e, "slaveAgentPortType");
checkPermission(ADMINISTER); JSONObject json = req.getSubmittedForm(); if (json.has("use_security")) { useSecurity = true; JSONObject security = json.getJSONObject("use_security"); setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm")); setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization")); if (security.has("markupFormatter")) { markupFormatter = req.bindJSON(MarkupFormatter.class, security.getJSONObject("markupFormatter")); } else { markupFormatter = null; if (json.has("viewsTabBar")) { viewsTabBar = req.bindJSON(ViewsTabBar.class, json.getJSONObject("viewsTabBar")); } else { viewsTabBar = new DefaultViewsTabBar(); slaveAgentPort = Integer.parseInt(req.getParameter("slaveAgentPort")); } catch (NumberFormatException e) { throw new FormException(Messages.Hudson_BadPortNumber(req.getParameter("slaveAgentPort")), "slaveAgentPort");
@Override protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException { super.submit(req,rsp); JSONObject json = req.getSubmittedForm(); ignoreUpstreamChanges = !json.has("triggerByDependency"); allowedToTriggerDownstream = json.has("allowedToTriggerDownstream"); useUpstreamParameters = json.has("useUpstreamParameters"); ivyFilePattern = Util.fixEmptyAndTrim(json.getString("ivyFilePattern")); ivyFileExcludesPattern = Util.fixEmptyAndTrim(json.getString("ivyFileExcludesPattern")); JSONObject ivyBuilderTypeJson = json.getJSONObject("ivyBuilderType"); try { ivyBuilderType = (IvyBuilderType) req.bindJSON(Class.forName(ivyBuilderTypeJson.getString("stapler-class")), ivyBuilderTypeJson); } catch (ClassNotFoundException e) { throw new FormException("Error creating specified builder type.", e, "ivyBuilderType"); aggregatorStyleBuild = !req.hasParameter("perModuleBuild"); incrementalBuild = req.hasParameter("incrementalBuild"); if (incrementalBuild)
@Override public SectionedViewSection newInstance(StaplerRequest req, JSONObject formData) throws FormException { SectionedViewSection section = (SectionedViewSection)req.bindJSON(getClass().getDeclaringClass(), formData); if (formData.get("useincluderegex") != null) { JSONObject merp = formData.getJSONObject("useincluderegex"); section.includeRegex = Util.nullify(merp.getString("includeRegex")); try { section.includePattern = Pattern.compile(section.includeRegex); } catch (PatternSyntaxException e) { throw new FormException("Regular expression is invalid: " + e.getMessage(), e, "includeRegex"); ItemGroup<?> group = req.findAncestorObject(ItemGroup.class); if (group == null) { group = Jenkins.getInstance(); section.jobFilters.rebuildHetero(req, formData, ViewJobFilter.all(), "jobFilters"); } catch (IOException e) { throw new FormException("Error rebuilding list of view job filters.", e, "jobFilters");
/** * 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() + '/'); }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException { // for compatibility reasons, the actual value is stored in Jenkins Jenkins j = Jenkins.get(); final JSONObject optJSONObject = json.optJSONObject("useProjectNamingStrategy"); if (optJSONObject != null) { final JSONObject strategyObject = optJSONObject.getJSONObject("namingStrategy"); final String className = strategyObject.getString("$class"); try { Class clazz = Class.forName(className, true, j.getPluginManager().uberClassLoader); final ProjectNamingStrategy strategy = (ProjectNamingStrategy) req.bindJSON(clazz, strategyObject); j.setProjectNamingStrategy(strategy); } catch (ClassNotFoundException e) { throw new FormException(e, "namingStrategy"); } } if (j.getProjectNamingStrategy() == null) { j.setProjectNamingStrategy(DefaultProjectNamingStrategy.DEFAULT_NAMING_STRATEGY); } return true; } }
String[] channelsNames = req.getParameterValues("irc_publisher.channel.name"); String[] channelsPasswords = req.getParameterValues("irc_publisher.channel.password"); throw new FormException("Channel name must not be empty", "channel.name"); boolean notifyOnly = jchans != null ? jchans.get(i).getBoolean("notificationOnly") : false; targets.add(new GroupChatIMMessageTarget(channelsNames[i], password, notifyOnly)); String n = req.getParameter(getParamNames().getStrategy()); if (n == null) { n = PARAMETERVALUE_STRATEGY_DEFAULT; if (formData.has("matrixNotifier")) { String o = formData.getString("matrixNotifier"); matrixJobMultiplier = MatrixJobMultiplier.valueOf(o);
@Override public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException { // for compatibility reasons, the actual value is stored in Jenkins Jenkins j = Jenkins.getInstance(); final JSONObject optJSONObject = json.optJSONObject("useProjectNamingStrategy"); if (optJSONObject != null) { final JSONObject strategyObject = optJSONObject.getJSONObject("namingStrategy"); final String className = strategyObject.getString("$class"); try { Class clazz = Class.forName(className, true, Jenkins.getInstance().getPluginManager().uberClassLoader); final ProjectNamingStrategy strategy = (ProjectNamingStrategy) req.bindJSON(clazz, strategyObject); j.setProjectNamingStrategy(strategy); } catch (ClassNotFoundException e) { throw new FormException(e, "namingStrategy"); } } if (j.getProjectNamingStrategy() == null) { j.setProjectNamingStrategy(DefaultProjectNamingStrategy.DEFAULT_NAMING_STRATEGY); } 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; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { Jenkins j = Jenkins.get(); try { // for compatibility reasons, this value is stored in Jenkins String num = json.getString("numExecutors"); if (!num.matches("\\d+")) { throw new FormException(Messages.Hudson_Computer_IncorrectNumberOfExecutors(),"numExecutors"); } j.setNumExecutors(json.getInt("numExecutors")); if (req.hasParameter("master.mode")) j.setMode(Mode.valueOf(req.getParameter("master.mode"))); else j.setMode(Mode.NORMAL); j.setLabelString(json.optString("labelString", "")); return true; } catch (IOException e) { throw new FormException(e,"numExecutors"); } } }
private JobPropertyImpl(StaplerRequest req, JSONObject json) throws Descriptor.FormException, IOException { List<Ancestor> ancs = req.getAncestors(); final Object ancestor = ancs.get(ancs.size()-1).getObject(); if (ancestor instanceof AbstractProject) { owner = (AbstractProject)ancestor; } else if (ancestor == null) { throw new Descriptor.FormException("Cannot retrieve the ancestor item in the request", "owner"); } else { throw new Descriptor.FormException("Cannot create Promoted Builds Job Property for " + ancestor.getClass() + ". Currently the plugin supports instances of AbstractProject only." + ". Other job types are not supported, submit a bug to the plugin, which provides the job type" if(json.has("promotions")) json = json.getJSONObject("promotions"); for( Object o : JSONArray.fromObject(json.get("activeItems")) ) { JSONObject c = (JSONObject)o; String name = c.getString("name"); Hudson.checkGoodName(name); } catch (Failure f) { throw new Descriptor.FormException(f.getMessage(), name);
@Override public Publisher newInstance(StaplerRequest req, JSONObject formData) throws hudson.model.Descriptor.FormException { String testResults = formData.getString("testResults"); boolean keepLongStdio = formData.getBoolean("keepLongStdio"); DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>> testDataPublishers = new DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>>(Saveable.NOOP); try { testDataPublishers.rebuild(req, formData, TestDataPublisher.all()); } catch (IOException e) { throw new FormException(e, null); } return new JUnitResultArchiver(testResults, keepLongStdio, testDataPublishers); }
@Override protected void submit(StaplerRequest req) throws IOException, ServletException, FormException { String proxiedViewName = req.getSubmittedForm().getString("proxiedViewName"); if (Hudson.getInstance().getView(proxiedViewName) == null) { throw new FormException("Not an existing global view", "proxiedViewName"); } this.proxiedViewName = proxiedViewName; }
checkPermission(Permission.HUDSON_ADMINISTER); JSONObject json = req.getSubmittedForm(); if (json.has("use_security")) { useSecurity = true; JSONObject security = json.getJSONObject("use_security"); if (security.has("markupFormatter")) { markupFormatter = req.bindJSON(MarkupFormatter.class, security.getJSONObject("markupFormatter")); String v = req.getParameter("slaveAgentPortType"); if (!isUseSecurity() || v == null || v.equals("random")) { slaveAgentPort = 0; slaveAgentPort = Integer.parseInt(req.getParameter("slaveAgentPort")); } catch (NumberFormatException e) { throw new FormException(hudson.model.Messages.Hudson_BadPortNumber(req.getParameter("slaveAgentPort")), "slaveAgentPort");
enablePlugin = json.getBoolean("enablePlugin"); host = json.getString("host"); port = json.getInt("port"); throw new FormException("Unable to connect to Gearman server. " + "Please check the server connection settings and retry.", "host"); throw new FormException("Unable to connect to Gearman server. " + "Please check the server connection settings and retry.", "host"); req.bindJSON(this, json); save(); return true;
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { // for compatibility reasons, the actual value is stored in Jenkins Jenkins j = Jenkins.getInstance(); if (json.has("primaryView")) { final String viewName = json.getString("primaryView"); final View newPrimaryView = j.getView(viewName); if (newPrimaryView == null) { throw new FormException(Messages.GlobalDefaultViewConfiguration_ViewDoesNotExist(viewName), "primaryView"); } j.setPrimaryView(newPrimaryView); } else { // Fallback if the view is not specified j.setPrimaryView(j.getViews().iterator().next()); } return true; } }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { try { req.bindJSON(this, json); // stapler oddity, empty lists are not set on bean by "req.bindJSON(this, json)" this.releaseWebHookConfigurations = req.bindJSONToList(ReleaseWebHook.class, json.get("releaseWebHookConfigurations")); } catch (final Exception e) { final String message = "Configuration error: " + e.getMessage(); LOGGER.log(Level.WARNING, message, e); LOGGER.log(Level.FINE, "Form data: {}", json.toString()); throw new FormException(message, e, "team-configuration"); } save(); return true; }
@Override public boolean configure(final StaplerRequest req, final JSONObject formData) throws FormException { try { setColorMaps(req.bindJSONToList(AnsiColorMap.class, req.getSubmittedForm().get("colorMap")).toArray(new AnsiColorMap[1])); return true; } catch (ServletException e) { throw new FormException(e, ""); } }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { Jenkins j = Jenkins.getInstance(); try { // for compatibility reasons, this value is stored in Jenkins j.setNumExecutors(json.getInt("numExecutors")); if (req.hasParameter("master.mode")) j.setMode(Mode.valueOf(req.getParameter("master.mode"))); else j.setMode(Mode.NORMAL); j.setLabelString(json.optString("labelString", "")); return true; } catch (IOException e) { throw new FormException(e,"numExecutors"); } } }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { // for compatibility reasons, the actual value is stored in Jenkins Jenkins j = Jenkins.get(); if (json.has("primaryView")) { final String viewName = json.getString("primaryView"); final View newPrimaryView = j.getView(viewName); if (newPrimaryView == null) { throw new FormException(Messages.GlobalDefaultViewConfiguration_ViewDoesNotExist(viewName), "primaryView"); } j.setPrimaryView(newPrimaryView); } else { // Fallback if the view is not specified j.setPrimaryView(j.getViews().iterator().next()); } return true; } }