/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. * @param parent JSON, which contains the configuration entry for the radio list * @param name Name of the configuration entry for the radio list * @return new instance or {@code null} if none was selected in the radio list * @throws FormException Data submission error */ @CheckForNull public T newInstanceFromRadioList(JSONObject parent, String name) throws FormException { return newInstanceFromRadioList(parent.getJSONObject(name)); }
public T newInstanceFromRadioList(JSONObject parent, String name) throws FormException { return newInstanceFromRadioList(parent.getJSONObject(name)); }
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); }
FormValidation warning = null; JSONObject signature = o.getJSONObject("signature"); if (signature.isNullObject()) { return FormValidation.error("No signature block found in "+name);
private boolean configureDescriptor(StaplerRequest req, JSONObject json, Descriptor<?> d) throws FormException { // collapse the structure to remain backward compatible with the JSON structure before 1. String name = d.getJsonSafeClassName(); JSONObject js = json.has(name) ? json.getJSONObject(name) : new JSONObject(); // if it doesn't have the property, the method returns invalid null object. json.putAll(js); return d.configure(req, js); }
private boolean configureDescriptor(StaplerRequest req, JSONObject json, Descriptor<?> d) throws FormException { // collapse the structure to remain backward compatible with the JSON structure before 1. String name = d.getJsonSafeClassName(); JSONObject js = json.has(name) ? json.getJSONObject(name) : new JSONObject(); // if it doesn't have the property, the method returns invalid null object. json.putAll(js); return d.configure(req, js); }
private boolean configureDescriptor(StaplerRequest req, JSONObject json, Descriptor<?> d) throws Descriptor.FormException { String name = d.getJsonSafeClassName(); JSONObject js = json.has(name) ? json.getJSONObject(name) : new JSONObject(); // if it doesn't have the property, the method returns invalid null object. json.putAll(js); return d.configure(req, js); }
private JSONObject getPluginVersions(UpdateSite updateSite) { // TODO use jenkins-core API for this once UpdateSite offers. try { return pluginVersions.get(updateSite.getId(), () -> { final File file = new File(Jenkins.getInstance().getRootDir(), "updates/" + updateSite.getId() + "plugin-versions.json"); boolean needUpdate = !file.exists() || System.currentTimeMillis() - file.lastModified() > TimeUnit.DAYS.toMillis(1); if (needUpdate) { final URI metadata = new URI(updateSite.getUrl()).resolve("./plugin-versions.json"); try (InputStream is = ProxyConfiguration.open(metadata.toURL()).getInputStream()) { FileUtils.copyInputStreamToFile(is, file); } catch (IOException e) { logger.log(Level.WARNING, "Failed to download plugin-versions metadata from " + updateSite.getUrl(), e); } } try { return JSONObject.fromObject(FileUtils.readFileToString(file)).getJSONObject("plugins"); } catch (IOException e) { return null; } }); } catch (ExecutionException e) { return null; } }
/** * 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; }
for(Map.Entry<String,JSONObject> e : (Set<Map.Entry<String,JSONObject>>)o.getJSONObject("plugins").entrySet()) { Plugin p = new Plugin(sourceId, e.getValue());
@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("myViewsTabBar")) { j.setMyViewsTabBar(req.bindJSON(MyViewsTabBar.class,json.getJSONObject("myViewsTabBar"))); } else { j.setMyViewsTabBar(new DefaultMyViewsTabBar()); } 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.get(); if (json.has("viewsTabBar")) { j.setViewsTabBar(req.bindJSON(ViewsTabBar.class,json.getJSONObject("viewsTabBar"))); } else { j.setViewsTabBar(new DefaultViewsTabBar()); } return true; } }
@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; } }
@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("csrf")) { JSONObject csrf = json.getJSONObject("csrf"); j.setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer")); } else { j.setCrumbIssuer(null); } return true; } }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { try { Jenkins j = Jenkins.get(); JSONObject np = json.getJSONObject("globalNodeProperties"); if (!np.isNullObject()) { j.getGlobalNodeProperties().rebuild(req, np, NodeProperty.for_(j)); } return true; } catch (IOException e) { throw new FormException(e,"globalNodeProperties"); } } }
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.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");
final JSONObject plugin = versions.getJSONObject(p.shortname); if (plugin == null) { throw new ConfiguratorException("update site " + p.site + " isn't hosting plugin " + p.shortname); final JSONObject version = plugin.getJSONObject(p.version); if (version == null) { throw new ConfiguratorException("update site " + p.site + " isn't hosting plugin " + p.shortname + " version " + p.version);
json.getJSONObject("scmCheckoutStrategy")); else scmCheckoutStrategy = null;