if (jobState.equalsIgnoreCase("available")) { log.debug("submitAndHandleJob() Job status is: " + jobState + ". returning output..."); output = jobInfo.getJSONObject("output"); } else if (jobState.equalsIgnoreCase("running") || jobState.equalsIgnoreCase("waiting")) { while (!jobState.equalsIgnoreCase("available")) { jobState = jobInfo.getString("state"); output = jobInfo.getJSONObject("output"); } else if (jobState.equalsIgnoreCase("error") || jobState.equalsIgnoreCase("cancelled")
} else { try { final JSONObject output = result.getJSONObject("data"); flowFile = session.write(flowFile, out -> out.write(output.toString().getBytes())); flowFile = session.putAttribute(flowFile, CoreAttributes.MIME_TYPE.key(), LivySessionService.APPLICATION_JSON);
public BadgerFishXMLStreamReader(JSONObject obj) throws JSONException, XMLStreamException { String rootName = (String) obj.keys().next(); this.node = new Node(null, rootName, obj.getJSONObject(rootName), CONVENTION); this.nodes = new FastStack(); nodes.push(node); event = START_DOCUMENT; }
hasMore = jsonObjectNext.getBoolean(KEY_HAS_MORE); if (jsonObjectNext.has(KEY_NEXT_PARENT) && jsonObjectNext.getJSONObject(KEY_NEXT_PARENT) .has(KEY_NEXT_URL)) { hasMoreNextUrl = jsonObjectNext.getJSONObject( KEY_NEXT_PARENT).getString(KEY_NEXT_URL);
@Nullable public static JSONObject getNestedOptionalObject(JSONObject json, final String... path) throws JSONException { for (int i = 0; i < path.length - 1; i++) { String s = path[i]; json = json.getJSONObject(s); } return json.optJSONObject(path[path.length - 1]); }
@Nullable public static JSONObject getNestedOptionalObject(JSONObject json, String... path) throws JSONException { for (int i = 0; i < path.length - 1; i++) { String s = path[i]; json = json.getJSONObject(s); } return json.optJSONObject(path[path.length - 1]); }
private Collection<Field> parseFields(JSONObject json) throws JSONException { ArrayList<Field> res = new ArrayList<Field>(json.length()); final Iterator<String> iterator = getStringKeys(json); while (iterator.hasNext()) { final String key = iterator.next(); if (SPECIAL_FIELDS.contains(key)) { continue; } res.add(fieldParser.parse(json.getJSONObject(key), key)); } return res; }
private String getFieldStringUnisex(final JSONObject json, final String attributeName) throws JSONException { final JSONObject fieldsJson = json.getJSONObject(FIELDS); final Object fieldJson = fieldsJson.get(attributeName); if (fieldJson instanceof JSONObject) { return ((JSONObject) fieldJson).getString(VALUE_ATTR); // pre 5.0 way } return fieldJson.toString(); // JIRA 5.0 way }
@Override public Map<String, CimFieldInfo> parse(JSONObject json) throws JSONException { final Map<String, CimFieldInfo> res = Maps.newHashMapWithExpectedSize(json.length()); final Iterator keysIterator = json.keys(); while (keysIterator.hasNext()) { final String id = (String) keysIterator.next(); res.put(id, parseIssueFieldInfo(json.getJSONObject(id), id)); } return res; }
sServiceDescriptor.setAuthorizeUrl(service.getString("authorizeUrl")); JSONObject rights = service.getJSONObject("rights");
private String getFieldStringValue(final JSONObject json, final String attributeName) throws JSONException { final JSONObject fieldsJson = json.getJSONObject(FIELDS); final Object summaryObject = fieldsJson.get(attributeName); if (summaryObject instanceof JSONObject) { // pre JIRA 5.0 way return ((JSONObject) summaryObject).getString(VALUE_ATTR); } if (summaryObject instanceof String) { // JIRA 5.0 way return (String) summaryObject; } throw new JSONException("Cannot parse [" + attributeName + "] from available fields"); }
private String getFieldStringValue(JSONObject json, String attributeName) throws JSONException { final JSONObject fieldsJson = json.getJSONObject(FIELDS); final Object summaryObject = fieldsJson.get(attributeName); if (summaryObject instanceof JSONObject) { // pre JIRA 5.0 way return ((JSONObject) summaryObject).getString(VALUE_ATTR); } if (summaryObject instanceof String) { // JIRA 5.0 way return (String) summaryObject; } throw new JSONException("Cannot parse [" + attributeName + "] from available fields"); }
@Override public Session parse(JSONObject json) throws JSONException { final URI userUri = JsonParseUtil.getSelfUri(json); final String username = json.getString("name"); final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo")); return new Session(userUri, username, loginInfo); } }
private void verifyQueueOrder(JSONObject json, String realOrder) throws Exception { String order = ""; if (!json.isNull("root")) { JSONObject root = json.getJSONObject("root"); order = root.getString("name") + "-" + getQueueOrder(root); } assertEquals("Order of queue is wrong", order.substring(0, order.length() - 1), realOrder); }
private void verifyNumberOfNodes(JSONObject allocation, int realValue) throws Exception { if (allocation.isNull("root")) { assertEquals("State of allocation is wrong", 0, realValue); } else { assertEquals("State of allocation is wrong", 1 + getNumberOfNodes(allocation.getJSONObject("root")), realValue); } }
private JSONObject getSubQueue(JSONObject queue, String subQueue) throws JSONException { JSONArray queues = queue.getJSONObject("queues").getJSONArray("queue"); for (int i=0; i<queues.length(); ++i) { checkResourcesUsed(queues.getJSONObject(i)); if (queues.getJSONObject(i).getString("queueName").equals(subQueue) ) { return queues.getJSONObject(i); } } return null; }
private void verifyReservationCount(int count) throws Exception { WebResource resource = constructWebResource(LIST_RESERVATION_PATH) .queryParam("queue", DEFAULT_QUEUE); JSONObject json = testListReservationHelper(resource); if (count == 1) { // If there are any number other than one reservation, this will throw. json.getJSONObject("reservations"); } else { JSONArray reservations = json.getJSONArray("reservations"); assertTrue(reservations.length() == count); } }
@Test public void testAM() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("mapreduce") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); verifyAMInfo(json.getJSONObject("info"), appContext); }
@Test public void testInfoDefault() throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("mapreduce") .path("info/").get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); verifyAMInfo(json.getJSONObject("info"), appContext); }
public void testSingleNodeHelper(String nodeid, RMNode nm, String media) throws JSONException, Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("nodes").path(nodeid).accept(media).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject info = json.getJSONObject("node"); verifyNodeInfo(info, nm); }