@Override public BuildTrigger newInstance(StaplerRequest req, JSONObject formData) throws FormException { String childProjectsString = formData.getString("childProjects").trim(); if (childProjectsString.endsWith(",")) { childProjectsString = childProjectsString.substring(0, childProjectsString.length() - 1).trim(); } return new BuildTrigger( childProjectsString, formData.optString("threshold", Result.SUCCESS.toString())); }
public WarningVersionRange(JSONObject o) { this.name = Util.fixEmpty(o.optString("name")); this.firstVersion = Util.intern(Util.fixEmpty(o.optString("firstVersion"))); this.lastVersion = Util.intern(Util.fixEmpty(o.optString("lastVersion"))); Pattern p; try { p = Pattern.compile(o.getString("pattern")); } catch (PatternSyntaxException ex) { LOGGER.log(Level.WARNING, "Failed to compile pattern '" + o.getString("pattern") + "', using '.*' instead", ex); p = Pattern.compile(".*"); } this.pattern = p; }
Entry(String sourceId, JSONObject o, String baseURL) { this.sourceId = sourceId; this.name = Util.intern(o.getString("name")); this.version = Util.intern(o.getString("version")); // Trim this to prevent issues when the other end used Base64.encodeBase64String that added newlines // to the end in old commons-codec. Not the case on updates.jenkins-ci.org, but let's be safe. this.sha1 = Util.fixEmptyAndTrim(o.optString("sha1")); this.sha256 = Util.fixEmptyAndTrim(o.optString("sha256")); this.sha512 = Util.fixEmptyAndTrim(o.optString("sha512")); String url = o.getString("url"); if (!URI.create(url).isAbsolute()) { if (baseURL == null) { throw new IllegalArgumentException("Cannot resolve " + url + " without a base URL"); } url = URI.create(baseURL).resolve(url).toString(); } this.url = url; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { String t = json.optString("pollingThreadCount",null); if (doCheckPollingThreadCount(t).kind != FormValidation.Kind.OK) { setPollingThreadCount(THREADS_DEFAULT); } else { setPollingThreadCount(Integer.parseInt(t)); } // Save configuration save(); return true; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { JSONArray monitors = json.optJSONArray("administrativeMonitor"); for (AdministrativeMonitor am : AdministrativeMonitor.all()) { try { boolean disable; if(monitors != null) { disable = !monitors.contains(am.id); }else { disable = !am.id.equals(json.optString("administrativeMonitor")); } am.disable(disable); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to process form submission for " + am.id, e); } } return true; }
SignatureOutputStream sos = new SignatureOutputStream(signature); String providedDigest = signatureJson.optString(digestEntry, null); if (providedDigest == null) { return FormValidation.warning("No '" + digestEntry + "' found"); String providedSignature = signatureJson.optString(signatureEntry, null); if (providedSignature == null) { return FormValidation.warning("No '" + signatureEntry + "' found");
@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"); } } }
getJob(), delay.getTimeInSeconds(), new ParametersAction(values), new CauseAction(new Cause.UserIdCause())); if (item!=null) { String url = formData.optString("redirectTo"); if (url==null || !Util.isSafeToRedirectTo(url)) // avoid open redirect url = req.getContextPath()+'/'+item.getUrl();
jdk = json.optString("jdk", null); customWorkspace = Util.fixEmptyAndTrim(req.getParameter("customWorkspace.directory")); } else if(json.optBoolean("hasCustomWorkspace", json.has("customWorkspace"))) { customWorkspace = Util.fixEmptyAndTrim(json.optString("customWorkspace")); } else { customWorkspace = null; assignedNode = Util.fixEmptyAndTrim(json.optString("label")); } else if(req.hasParameter("_.assignedLabelString")) {
setDisplayName(json.optString("displayNameOrNull"));
public String resolveSingleDirectoryEntryLabel(final String storedReference, final String directoryName, final boolean localize, String keySeparator, final boolean dbl10n, final String labelFieldName) { JSONObject obj = getSingleDirectoryEntry(storedReference, directoryName, localize, keySeparator, dbl10n, labelFieldName); if (obj == null) { return ""; } return obj.optString(SuggestConstants.LABEL); }
public String resolveUserReferenceLabel(final String storedReference, final boolean prefixed, final String firstLabelField, final String secondLabelField, final String thirdLabelField, final boolean hideFirstLabel, final boolean hideSecondLabel, final boolean hideThirdLabel, final boolean displayEmailInSuggestion, final boolean hideIcon) { JSONObject obj = getSingleUserReference(storedReference, prefixed, firstLabelField, secondLabelField, thirdLabelField, hideFirstLabel, hideSecondLabel, hideThirdLabel, displayEmailInSuggestion, hideIcon); if (obj == null) { return ""; } return obj.optString(SuggestConstants.LABEL); }
public static void computeUserGroupIcon(final JSONObject obj, final boolean hideIcon) { if (obj != null) { if (!hideIcon) { String userGroupType = obj.optString(TYPE_KEY_NAME); obj.element(DISPLAY_ICON, StringUtils.isNotBlank(userGroupType) && (userGroupType.equals(USER_TYPE) || userGroupType.equals(GROUP_TYPE))); } } }
@Override public BuildTrigger newInstance(StaplerRequest req, JSONObject formData) throws FormException { String childProjectsString = formData.getString("childProjects").trim(); if (childProjectsString.endsWith(",")) { childProjectsString = childProjectsString.substring(0, childProjectsString.length() - 1).trim(); } return new BuildTrigger( childProjectsString, formData.optString("threshold", Result.SUCCESS.toString())); }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { String t = json.optString("pollingThreadCount",null); if(t==null || t.length()==0) setPollingThreadCount(0); else setPollingThreadCount(Integer.parseInt(t)); // Save configuration save(); return true; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { String t = json.optString("pollingThreadCount", null); if (t == null || t.length() == 0) { setPollingThreadCount(0); } else { setPollingThreadCount(Integer.parseInt(t)); } // Save configuration save(); return true; }
public String startOnline() throws IOException { String uri = address + "api/active/receiver/start/"; LinkedList<Part> partsList = new LinkedList<>(); partsList.add(new StringPart("token", token)); partsList.add(new StringPart("projectKey", project)); partsList.add(new StringPart("title", title)); String[] res = multipartPost(partsList, uri, HttpStatus.SC_CREATED); JSONObject obj = JSONObject.fromObject(res[0]); return address + "gui/active/" + obj.optString("OnlineID", "N/A") + "/"; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { androidHome = json.optString("androidHome"); shouldInstallSdk = json.optBoolean("shouldInstallSdk", true); shouldKeepInWorkspace = json.optBoolean("shouldKeepInWorkspace", false); save(); return true; }