private JSONArray copyAndSanitizeArray(JSONArray jsonArray) { JSONArray result = new JSONArray(); jsonArray.forEach(value -> result.add(copyAndSanitize(value)) ); return result; } }
/** * Like {@link #doInstallNecessaryPlugins(StaplerRequest)} but only checks if everything is installed * or if some plugins need updates or installation. * * This method runs without side-effect. I'm still requiring the ADMINISTER permission since * XML file can contain various external references and we don't configure parsers properly against * that. * * @since 1.483 */ @RequirePOST public JSONArray doPrevalidateConfig(StaplerRequest req) throws IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); JSONArray response = new JSONArray(); for (Map.Entry<String,VersionNumber> p : parseRequestedPlugins(req.getInputStream()).entrySet()) { PluginWrapper pw = getPlugin(p.getKey()); JSONObject j = new JSONObject() .accumulate("name", p.getKey()) .accumulate("version", p.getValue().toString()); if (pw == null) { // install new response.add(j.accumulate("mode", "missing")); } else if (pw.isOlderThan(p.getValue())) { // upgrade response.add(j.accumulate("mode", "old")); } // else already good } return response; }
dependencies.add(new JSONObject() .element("name", attrs[0]) .element("version", attrs[1])
/** * @param list the list of auth urls to serialize * @return {@code null} if {@code list} is null, empty, or contains only null objects; the JSON * array representation of {@code list} otherwise, with any null element stripped off. */ public static String toString(List<LayerIdentifierInfo> list) { if (list == null || list.isEmpty()) { return null; } JSONArray array = new JSONArray(); for (LayerIdentifierInfo id : list) { if (id == null) { continue; } JSONObject jsonId = new JSONObject(); jsonId.put(AUTHORITY, id.getAuthority()); jsonId.put(IDENTIFIER, id.getIdentifier()); array.add(jsonId); } if (array.size() == 0) { // list was made of only null objects? return null; } String serialized = array.toString(); return serialized; } }
/** * @param list the list of layer identifiers to serialize * @return {@code null} if {@code list} is null, empty or contains only null objects; the JSON * array representation of {@code list} otherwise, with any null element stripped off. */ public static String toString(List<AuthorityURLInfo> obj) { if (obj == null || obj.isEmpty()) { return null; } JSONArray array = new JSONArray(); for (AuthorityURLInfo auth : obj) { if (auth == null) { continue; } JSONObject jsonAuth = new JSONObject(); jsonAuth.put(NAME, auth.getName()); jsonAuth.put(HREF, auth.getHref()); array.add(jsonAuth); } if (array.size() == 0) { // list was made of only null objects? return null; } String serialized = array.toString(); return serialized; } }
@Override protected synchronized JSON data() { JSONArray r = new JSONArray(); for (User u : modified) { UserInfo i = users.get(u); JSONObject entry = new JSONObject(). accumulate("id", u.getId()). accumulate("fullName", u.getFullName()). accumulate("url", u.getUrl()). accumulate("avatar", i.avatar != null ? i.avatar : Stapler.getCurrentRequest().getContextPath() + Functions.getResourcePath() + "/images/" + iconSize + "/user.png"). accumulate("timeSortKey", i.getTimeSortKey()). accumulate("lastChangeTimeString", i.getLastChangeTimeString()); Job<?,?> p = i.getJob(); if (p != null) { entry.accumulate("projectUrl", p.getUrl()).accumulate("projectFullDisplayName", p.getFullDisplayName()); } r.add(entry); } modified.clear(); return r; }
@Override public JSONArray toJSON() { final JSONArray a = new JSONArray(); for (ModelASTValue argument: arguments) { a.add(argument.toJSON()); } return a; }
@Override public JSONArray toJSON() { final JSONArray a = new JSONArray(); for (ModelASTStage stage: stages) { a.add(stage.toJSON()); } return a; }
@Override public JSONArray toJSON() { final JSONArray a = new JSONArray(); for (Map.Entry<ModelASTKey, ModelASTValue> entry: arguments.entrySet()) { JSONObject o = new JSONObject(); o.accumulate("key", entry.getKey().toJSON()); o.accumulate("value", entry.getValue().toJSON()); a.add(o); } return a; }
@Override public JSONArray toJSON() { final JSONArray a = new JSONArray(); for (Map.Entry<ModelASTKey, ModelASTMethodArg> entry: variables.entrySet()) { JSONObject o = new JSONObject(); o.accumulate("key", entry.getKey().toJSON()); o.accumulate("value", entry.getValue().toJSON()); a.add(o); } return a; }
@Override public JSONArray toJSON() { final JSONArray a = new JSONArray(); for (Map.Entry<ModelASTKey, ModelASTEnvironmentValue> entry: variables.entrySet()) { JSONObject o = new JSONObject(); o.accumulate("key", entry.getKey().toJSON()); o.accumulate("value", entry.getValue().toJSON()); a.add(o); } return a; }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTStep child:children) { a.add(child.toJSON()); } return super.toJSON().accumulate("children", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTOption option : options) { a.add(option.toJSON()); } return new JSONObject().accumulate("options", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTBuildCondition condition: conditions) { a.add(condition.toJSON()); } return new JSONObject().accumulate("conditions", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTTrigger trigger: triggers) { a.add(trigger.toJSON()); } return new JSONObject().accumulate("triggers", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTBuildParameter parameter : parameters) { a.add(parameter.toJSON()); } return new JSONObject().accumulate("parameters", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTValue arg: args) { a.add(arg.toJSON()); } return new JSONObject().accumulate("name", name).accumulate("arguments", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTMethodArg arg: args) { a.add(arg.toJSON()); } return new JSONObject().accumulate("name", name).accumulate("arguments", a); }
@Override public JSONObject toJSON() { final JSONArray a = new JSONArray(); for (ModelASTStep step: steps) { a.add(step.toJSON()); } return new JSONObject().accumulate("name", name).accumulate("steps", a); }