public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException { if (form==null) return null; final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); final AtomicReference<BindInterceptor> old = new AtomicReference<>(); old.set(req.setBindListener(new BindInterceptor() { @Override public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { if (jsonForProperties != jsonSource) { return old.get().onConvert(targetType, targetTypeErasure, jsonSource); } try { DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList()); tmp.rebuild(req, jsonForProperties, NodeProperty.all()); return tmp.toList(); } catch (FormException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new IllegalArgumentException(e); } } })); try { return getDescriptor().newInstance(req, form); } finally { req.setBindListener(old.get()); } }
Data(JSONObject o) { this.sourceId = Util.intern((String)o.get("id")); JSONObject c = o.optJSONObject("core"); if (c!=null) { core = new Entry(sourceId, c, url);
T existing = get((D)d); String name = d.getJsonSafeClassName(); JSONObject o = json.optJSONObject(name);
@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; } }
UserProperty p = getProperty(d.clazz); JSONObject o = json.optJSONObject("userProperty" + (i++)); if (o != null) { if (p != null) {
/** * 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 }
JSONObject jsonProperties = json.optJSONObject("properties"); if (jsonProperties != null) { t.rebuild(req,jsonProperties,JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass()));
/** * The failed configurator may pass in additional information about the failure. */ public JSONObject getDetails() { return json.optJSONObject("cause"); }
/** * The failed configurator may pass in additional information about the failure. */ public JSONObject getDetails() { return json.optJSONObject("cause"); }
public JSONObject getProperty(String name) { return properties.optJSONObject(name); }
public JSONObject optJSONObject(String key) { return jsonObject.optJSONObject(key); }
@Override public JobProperty<?> newInstance( StaplerRequest req, JSONObject formData) throws Descriptor.FormException { JSONObject property = formData.optJSONObject("subProjectsJobProperty"); if (property == null) { return null; } String subProjects = property.getString("defaultSubProjects"); String hiddenProjects = property.getString("hiddenSubProjects"); return new SubProjectsJobProperty(subProjects, hiddenProjects); } }
@Override public JobProperty<?> newInstance( StaplerRequest req, JSONObject formData) throws Descriptor.FormException { JSONObject property = formData.optJSONObject("rebuildRedsJobProperty"); if (property == null) { return null; } int maxRetries = Integer.parseInt(property.getString("maxRetries")); return new RebuildRedsJobProperty(maxRetries); } }
public JSONObject optJSONObject(String arg0) { return getJSONObject().optJSONObject(arg0); } public long optLong(String arg0, long arg1) {
@CheckForNull public String getTag() { JSONObject data = getWebHookPayload().getData(); if (data != null) { JSONObject push_data = data.optJSONObject("push_data"); if (push_data != null) { return push_data.optString("tag"); } } return null; }
@CheckForNull public String getPusher() { JSONObject data = getWebHookPayload().getData(); if (data != null) { JSONObject push_data = data.optJSONObject("push_data"); if (push_data != null) { return push_data.optString("pusher"); } } return null; }
private static boolean isTrueCondition(JSONObject stats, JSONObject node, double purityThreshold, int trueIdx) { String nodeIdx = node.optString("id"); JSONArray nodeValues = stats.optJSONObject(nodeIdx).optJSONArray("counts"); double purity = ((double) nodeValues.optInt(trueIdx)) / stats.optJSONObject(nodeIdx).optInt("count"); return purity >= purityThreshold && node.optBoolean("value"); }
private Finding parseFinding(JSONObject json) { final Component component = parseComponent(json.getJSONObject("component")); final Vulnerability vulnerability = parseVulnerability(json.getJSONObject("vulnerability")); final Analysis analysis = parseAnalysis(json.optJSONObject("analysis")); final String matrix = StringUtils.trimToNull(json.getString("matrix")); return new Finding(component, vulnerability, analysis, matrix); }
/*package*/ void configure(StaplerRequest req, JSONObject c) throws Descriptor.FormException, IOException { // apply configuration conditions.rebuild(req,c.optJSONObject("conditions"), PromotionCondition.all()); buildSteps = (List)Descriptor.newInstancesFromHeteroList( req, c, "buildStep", (List) PromotionProcess.getAll()); icon = c.getString("icon"); if (c.optBoolean("hasAssignedLabel")) { assignedLabel = Util.fixEmptyAndTrim(c.optString("assignedLabelString")); } else { assignedLabel = null; } isVisible = c.getString("isVisible"); save(); }
@Override public void configure(StaplerRequest req, JSONObject formData) throws IOException, ServletException, Descriptor.FormException { super.configure(req, formData); port = formData.optInt("port", 4444); exclusionPatterns = formData.getString("exclusionPatterns"); hubLogLevel = formData.getString("hubLogLevel"); newSessionWaitTimeout = formData.optInt("newSessionWaitTimeout", -1); maxSession = formData.optInt("maxSession", 5); timeout = formData.optInt("timeout", 300000); browserTimeout = formData.optInt("browserTimeout", 0); throwOnCapabilityNotPresent = formData.getBoolean("throwOnCapabilityNotPresent"); hostnameResolver = req.bindJSON(HostnameResolver.class, formData.optJSONObject("hostnameResolver")); if (hostnameResolver == null) hostnameResolver = new JenkinsRootHostnameResolver(); save(); }