/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. * @param config Submitted configuration for Radio List * @return new instance or {@code null} if none was selected in the radio list * @throws FormException Data submission error */ @CheckForNull public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
private FormValidation updateData(String json, boolean signatureCheck) throws IOException { dataTimestamp = System.currentTimeMillis(); JSONObject o = JSONObject.fromObject(json); try { int v = o.getInt("updateCenterVersion"); if (v != 1) { throw new IllegalArgumentException("Unrecognized update center version: " + v); } } catch (JSONException x) { throw new IllegalArgumentException("Could not find (numeric) updateCenterVersion in " + json, x); } if (signatureCheck) { FormValidation e = verifySignature(o); if (e.kind!=Kind.OK) { LOGGER.severe(e.toString()); return e; } } LOGGER.info("Obtained the latest update center data file for UpdateSource " + id); retryWindow = 0; getDataFile().write(json); data = new Data(o); return FormValidation.ok(); }
/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
@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 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"); } } }
/** * The index of the failed configurator in the request you sent. * * @see com.cloudbees.mtslaves.client.VirtualMachineSpec#configs */ public int getOrdinal() { return json.getInt("ordinal"); }
public void Deserialize(JSONObject obj) { shard = obj.getInt("shard"); checkPoint = obj.getString("checkpoint"); updateTime = obj.getLong("updateTime"); if (obj.containsKey("consumer")) { consumer = obj.getString("consumer"); } } @Override
@Override public SectionedViewSection newInstance(StaplerRequest req, JSONObject formData) throws FormException { int columns = formData.getInt("columns"); if (columns <= 0) throw new FormException("Columns must be a number greater than 0", "columns"); return (SectionedViewSection)req.bindJSON(getClass().getDeclaringClass(), formData); }
void processMacro(JSONObject data) { // FIXME: need to check parameters. // FIXME: need to check permissions. if ("callMacro".equalsIgnoreCase(data.getString("command"))) { Token token = findTokenFromId(data.getString("tokenId")); MacroButtonProperties macro = token.getMacro(data.getInt("macroIndex"), false); macro.executeMacro(token.getId()); } }
@Override public void fromJSON(JSONObject json) { fcb = JSONFactory.getBoolean(json, "fcb", false); address = JSONFactory.decodeHexByte(json, "address", (byte) 0); telegramType = TelegramType.fromLabel(json.getString("telegramType")); subTelegram = json.getInt("subTelegram"); }
/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
/** * Creates a new instance of a {@link Describable} from the structured form * submission data posted by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if (config.isNullObject()) { return null; // none was selected } int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(), config); }
/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
/** * Creates a new instance of a {@link Describable} * from the structured form submission data posted * by a radio button group. */ public T newInstanceFromRadioList(JSONObject config) throws FormException { if(config.isNullObject()) return null; // none was selected int idx = config.getInt("value"); return get(idx).newInstance(Stapler.getCurrentRequest(),config); }
@Test public void testViewParamsJsonGet() throws Exception { JSON json = getAsJSON( "wfs?service=WFS&request=GetFeature&typename=" + viewTypeName + "&version=1.1&viewparams=bool:true;name:name-f003&outputFormat=application/json"); // print(json); assertEquals(1, ((JSONObject) json).getInt("totalFeatures")); }
@Test public void testGetWithCountAndStartIndex0() throws Exception { JSONObject json = (JSONObject) getAsJSON( "wfs?request=GetFeature&typenames=cdf:Fifteen&version=1.1.0&service=wfs&maxFeatures=5&startIndex=0&outputFormat=JSON"); assertEquals(5, json.getJSONArray("features").size()); assertEquals(15, json.getInt("totalFeatures")); }
@Test public void testGetWithCountAndStartIndexMiddle() throws Exception { JSONObject json = (JSONObject) getAsJSON( "wfs?request=GetFeature&typenames=cdf:Fifteen&version=1.1.0&service=wfs&maxFeatures=5&startIndex=7&outputFormat=JSON"); assertEquals(5, json.getJSONArray("features").size()); assertEquals(15, json.getInt("totalFeatures")); }