@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { HashSet<String> newIgnoredWarnings = new HashSet<>(); for (Object key : json.keySet()) { String warningKey = key.toString(); if (!json.getBoolean(warningKey)) { newIgnoredWarnings.add(warningKey); } } this.ignoredWarnings = newIgnoredWarnings; this.save(); return true; } }
private boolean needToAddToCurrentView(StaplerRequest req) throws ServletException { String json = req.getParameter("json"); if (json != null && json.length() > 0) { // Submitted via UI JSONObject form = req.getSubmittedForm(); return form.has("addToCurrentView") && form.getBoolean("addToCurrentView"); } else { // Submitted via API return true; } }
/** * Installs a list of plugins from a JSON POST. * @param req The request object. * @return A JSON response that includes a "correlationId" in the "data" element. * That "correlationId" can then be used in calls to * {@link UpdateCenter#doInstallStatus(org.kohsuke.stapler.StaplerRequest)}. * @throws IOException Error reading JSON payload fro request. */ @RequirePOST @Restricted(DoNotUse.class) // WebOnly public HttpResponse doInstallPlugins(StaplerRequest req) throws IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); String payload = IOUtils.toString(req.getInputStream(), req.getCharacterEncoding()); JSONObject request = JSONObject.fromObject(payload); JSONArray pluginListJSON = request.getJSONArray("plugins"); List<String> plugins = new ArrayList<>(); for (int i = 0; i < pluginListJSON.size(); i++) { plugins.add(pluginListJSON.getString(i)); } UUID correlationId = UUID.randomUUID(); try { boolean dynamicLoad = request.getBoolean("dynamicLoad"); install(plugins, dynamicLoad, correlationId); JSONObject responseData = new JSONObject(); responseData.put("correlationId", correlationId.toString()); return hudson.util.HttpResponses.okJSON(responseData); } catch (Exception e) { return hudson.util.HttpResponses.errorJSON(e.getMessage()); } }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { connections = req.bindJSONToList(GitLabConnection.class, json.get("connections")); useAuthenticatedEndpoint = json.getBoolean("useAuthenticatedEndpoint"); refreshConnectionMap(); save(); return super.configure(req, json); }
protected boolean getParam(JSONObject params, String name, boolean defaultValue) { try { return params.getBoolean(name); } catch (Exception e) { return defaultValue; } }
@Override public PullRequestRebuildProperty newInstance(StaplerRequest req, JSONObject formData) throws FormException { return new PullRequestRebuildProperty(formData.getBoolean("buildPullRequestsFromSameRepo")); } }
@Override public JobUiProperty newInstance(final StaplerRequest req, final JSONObject formData) throws FormException { return new JobUiProperty(formData.getBoolean("newUi")); } }
@Override public BuildTagsProperty newInstance(final StaplerRequest req, final JSONObject formData) throws FormException { return new BuildTagsProperty(formData.getBoolean("shouldBuildTags")); } }
@Override public void fromJSON(JSONObject json) { fcb = json.getBoolean("fcb"); address = (byte) json.getInt("address"); } }
public void fromJSON(JSONObject jsonObject) { acceptRequests = jsonObject.getBoolean(ACCEPT_REQUESTS.getValue()); accessToken = jsonObject.getBoolean(ACCESS_TOKEN.getValue()); getCert = jsonObject.getBoolean(GET_CERT.getValue()); getClaims = jsonObject.getBoolean(GET_CLAIMS.getValue()); idToken = jsonObject.getBoolean(ID_TOKEN.getValue()); refreshToken = jsonObject.getBoolean(REFRESH_TOKEN.getValue()); userInfo = jsonObject.getBoolean(USER_INFO.getValue()); }
@Override public void fromJSON(JSONObject json) { acd = json.getBoolean("acd"); dfc = json.getBoolean("dfc"); address = (byte) json.getInt("address"); error = GeneralApplicationErrorEnum.fromLabel(json.getString("error")); }
@Override public Publisher newInstance(StaplerRequest req, JSONObject formData) throws hudson.model.Descriptor.FormException { String testResults = formData.getString("testResults"); boolean ignoreBadSteps = formData.getBoolean("ignoreBadSteps"); LOGGER.fine("ignoreBadSteps = "+ ignoreBadSteps); return new CucumberTestResultArchiver(testResults, ignoreBadSteps); }
@Override public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException { return new BuildTrigger( formData.getString("childProjects"), formData.has("evenIfUnstable") && formData.getBoolean("evenIfUnstable")); }
@Override public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException { return new BuildTrigger( formData.getString("childProjects"), formData.has("evenIfUnstable") && formData.getBoolean("evenIfUnstable")); }
@Override public void fromJSON(JSONObject json) { fcb = json.getBoolean("fcb"); address = (byte) json.getInt("address"); JSONFactory.readDataBlocks(this, json); } }
@Override public void fromJSON(JSONObject json) { fcb = json.getBoolean("fcb"); address = (byte) json.getInt("address"); baudrate = json.getInt("baudrate"); } }
private boolean needToAddToCurrentView(StaplerRequest req) throws ServletException { String json = req.getParameter("json"); if (json != null && json.length() > 0) { // Submitted via UI JSONObject form = req.getSubmittedForm(); return form.has("addToCurrentView") && form.getBoolean("addToCurrentView"); } else { // Submitted via API return true; } }
public void FromJsonObject(JSONObject dict) throws LogException { setKey(dict.getString(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS_KEY)); setType(dict.getString(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS_TYPE)); if (type.equals("const")) { setConstStr(dict.getString(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS_CONST)); } setRegexBegin(dict.getString(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS_REGEXBEGIN)); setRegexContent(dict.getString(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS_REGEXBEGIN)); setAll(dict.getBoolean(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS_ALL)); }
public boolean needsBuild(final DynamicProject project) { if (this.payloadJson.has("ref") && this.payloadJson.getString("ref").startsWith("refs/tags/")) { return project.shouldBuildTags(); } if (isPullRequest()) { return shouldBuildPullRequest(); } return !this.payloadJson.getBoolean("deleted"); }
@Override public ApiResponse handleApiOptionAction(String name, JSONObject params) throws ApiException { if (ACTION_OPTION_USE_PROXY_CHAIN.equals(name)) { boolean enabled = params.getBoolean("Boolean"); if (enabled && (connectionParam.getProxyChainName() == null || connectionParam.getProxyChainName().isEmpty())) { return ApiResponseElement.FAIL; } connectionParam.setUseProxyChain(enabled); return ApiResponseElement.OK; } return super.handleApiOptionAction(name, params); }