/** * Create a response containing the supplied "data". * @param data The data. */ JSONObjectResponse(@Nonnull Map<?,?> data) { this(); this.jsonObject.put("data", JSONObject.fromObject(data)); }
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 void addJSONTokenIntoMap(Map<String, JSONObject> tokenMap, JSONObject tokenData) { String uuid = tokenData.getString("tokenUuid"); tokenMap.put(uuid, tokenData); }
/** * {@inheritDoc} * * @return * null to avoid setting an instance of {@link JobProperty} to the target project (or just use {@link OptionalJobProperty}) */ @Override public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException { // JobPropertyDescriptors are bit different in that we allow them even without any user-visible configuration parameter, // so replace the lack of form data by an empty one. if(formData.isNullObject()) formData=new JSONObject(); return super.newInstance(req, formData); }
/** * Create a response containing the supplied "data". * @param data The data. */ JSONObjectResponse(@Nonnull JSONObject data) { this(); this.jsonObject.put("data", data); }
public T newInstanceFromRadioList(JSONObject parent, String name) throws FormException { return newInstanceFromRadioList(parent.getJSONObject(name)); }
/** * Creates an instance of {@link RepositoryBrowser} from a form submission. * * @since 1.227 */ public static <T extends RepositoryBrowser> T createInstance(Class<T> type, StaplerRequest req, JSONObject parent, String fieldName) throws FormException { JSONObject o = (JSONObject)parent.get(fieldName); if(o==null) return null; return req.bindJSON(type,o); } }
/** * Create an empty "ok" response. */ JSONObjectResponse() { this.jsonObject = new JSONObject(); status("ok"); }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType(Flavor.JSON.contentType); PrintWriter w = rsp.getWriter(); JSONArray.fromObject(this).write(w); } }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { try { // for compatibility reasons, this value is stored in Jenkins Jenkins.get().setScmCheckoutRetryCount(json.getInt("scmCheckoutRetryCount")); return true; } catch (IOException e) { throw new FormException(e,"quietPeriod"); } catch (JSONException e) { throw new FormException(e.getMessage(), "quietPeriod"); } } }
@Override protected synchronized JSON data() { JSONArray d = JSONArray.fromObject(results); results.clear(); return d; }
@Override public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException { return formData.optBoolean("specified") ? super.newInstance(req, formData) : null; }
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); }
/** * Create a response containing the supplied "data". * @param data The data. */ JSONObjectResponse(@Nonnull JSONArray data) { this(); this.jsonObject.put("data", data); }
@Override public UserProperty newInstance(StaplerRequest req, JSONObject formData) throws FormException { return new UserSearchProperty(formData.optBoolean("insensitiveSearch")); }
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 @Nonnull JSONObjectResponse status(@Nonnull String status) { this.jsonObject.put("status", status); return this; }