hasMoreNextUrl = null; if (jsonObjectNext.has(KEY_HAS_MORE)) { 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);
sServiceDescriptor.setReadRevision(rights.has("readRevision") && rights.getBoolean("readRevision")); sServiceDescriptor.setReadExtendedData(rights.has("readExtendedData") ? rights.getString("readExtendedData") : null); sServiceDescriptor.setWriteRevision(rights.has("writeRevision") && rights.getBoolean("writeRevision")); sServiceDescriptor.setWriteExtendedData(rights.has("writeExtendedData") ? rights.getString("writeExtendedData") : null); sServiceDescriptors.add(sServiceDescriptor);
public static int tryGetInt(JSONObject jsonObject, String key, int defaultValue) throws JSONException { if (jsonObject.has(key)) { return jsonObject.getInt(key); } return defaultValue; }
static Iterable<String> parseExpandos(final JSONObject json) throws JSONException { if (json.has("expand")) { final String expando = json.getString("expand"); return Splitter.on(',').split(expando); } else { return Collections.emptyList(); } }
@Nullable public static String tryGetString(JSONObject jsonObject, String key) throws JSONException { if (jsonObject.has(key)) { return jsonObject.getString(key); } return null; }
public static Optional<JSONArray> getOptionalArray(final JSONObject jsonObject, final String attributeName) throws JSONException { return jsonObject.has(attributeName) ? Optional.of(jsonObject.getJSONArray(attributeName)) : Optional.<JSONArray>absent(); }
public static Optional<JSONArray> getOptionalArray(final JSONObject jsonObject, final String attributeName) throws JSONException { return jsonObject.has(attributeName) ? Optional.of(jsonObject.getJSONArray(attributeName)) : Optional.<JSONArray>absent(); }
private ContainerLogFileInfo generatePerContainerLogFileInfoFromJSON( JSONObject meta) throws JSONException { String fileName = meta.has("fileName") ? meta.getString("fileName") : "N/A"; String fileSize = meta.has("fileSize") ? meta.getString("fileSize") : "N/A"; String lastModificationTime = meta.has("lastModifiedTime") ? meta.getString("lastModifiedTime") : "N/A"; return new ContainerLogFileInfo(fileName, fileSize, lastModificationTime); }
public void injectErrorIfExistSilently(JSONObject jsonObj) throws JSONException { if (jsonObj.has("error")) { errorType = fromString(jsonObj.getString("error")); } if (jsonObj.has("error_description")) { errorDescription = jsonObj.getString("error_description"); } if (jsonObj.has("error_uri")) { errorUri = jsonObj.getString("error_uri"); } }
public Address(JSONObject jObj) throws JSONException { _publicIp = Ip.parse(jObj.getString(JSON_KEY_PUBLIC_IP)); _instanceId = jObj.has(JSON_KEY_INSTANCE_ID) ? jObj.getString(JSON_KEY_INSTANCE_ID) : null; _privateIp = jObj.has(JSON_KEY_PRIVATE_IP_ADDRESS) ? Ip.parse(jObj.getString(JSON_KEY_PRIVATE_IP_ADDRESS)) : null; // TODO: not sure what other information we need to pull }
private JSONObject getFieldUnisex(JSONObject json, String attributeName) throws JSONException { final JSONObject fieldsJson = json.getJSONObject(FIELDS); final JSONObject fieldJson = fieldsJson.getJSONObject(attributeName); if (fieldJson.has(VALUE_ATTR)) { return fieldJson.getJSONObject(VALUE_ATTR); // pre 5.0 way } else { return fieldJson; // JIRA 5.0 way } }
private JSONObject getFieldUnisex(JSONObject json, String attributeName) throws JSONException { final JSONObject fieldsJson = json.getJSONObject(FIELDS); final JSONObject fieldJson = fieldsJson.getJSONObject(attributeName); if (fieldJson.has(VALUE_ATTR)) { return fieldJson.getJSONObject(VALUE_ATTR); // pre 5.0 way } else { return fieldJson; // JIRA 5.0 way } }
@VisibleForTesting public String getNodeHttpAddressFromRMWebString(ContainerLogsRequest request) throws ClientHandlerException, UniformInterfaceException, JSONException { if (request.getNodeId() == null || request.getNodeId().isEmpty()) { return null; } JSONObject nodeInfo = YarnWebServiceUtils .getNodeInfoFromRMWebService(getConf(), request.getNodeId()) .getJSONObject("node"); return nodeInfo.has("nodeHTTPAddress") ? nodeInfo.getString("nodeHTTPAddress") : null; }
private Property updateProperty( Property property, JSONObject jsonItem ) throws RepositoryException, JSONException { String propertyName = property.getName(); String jsonPropertyName = jsonItem.has(propertyName) ? propertyName : propertyName + BASE64_ENCODING_SUFFIX; Node node = property.getParent(); setPropertyOnNode(node, jsonPropertyName, jsonItem.get(jsonPropertyName)); return property; }
@Override public ChangelogGroup parse(JSONObject json) throws JSONException { final DateTime created = JsonParseUtil.parseDateTime(json, "created"); final BasicUser author = json.has("author") ? JsonParseUtil.parseBasicUser(json.getJSONObject("author")) : null; final Collection<ChangelogItem> items = JsonParseUtil.parseJsonArray(json.getJSONArray("items"), changelogItemJsonParser); return new ChangelogGroup(author, created, items); } }
public static DelegationToken getDelegationTokenFromJson(JSONObject json) throws JSONException { DelegationToken ret = new DelegationToken(); if (json.has("token")) { ret.setToken(json.getString("token")); } else if (json.has("expiration-time")) { ret.setNextExpirationTime(json.getLong("expiration-time")); } return ret; }
private void verifyResourcesContainDefaultResourceTypes(JSONObject queue, Set<String> resourceCategories) throws JSONException { for (String resourceCategory : resourceCategories) { boolean hasResourceCategory = queue.has(resourceCategory); assertTrue("Queue " + queue + " does not have resource category key: " + resourceCategory, hasResourceCategory); verifyResourceContainsDefaultResourceTypes( queue.getJSONObject(resourceCategory)); } }
private void verifyResourcesContainCustomResourceTypes(JSONObject queue, Set<String> resourceCategories) throws JSONException { for (String resourceCategory : resourceCategories) { assertTrue("Queue " + queue + " does not have resource category key: " + resourceCategory, queue.has(resourceCategory)); verifyResourceContainsAllCustomResourceTypes( queue.getJSONObject(resourceCategory)); } }
@Override public Field parse(final JSONObject jsonObject) throws JSONException { final String id = jsonObject.getString("id"); final String name = jsonObject.getString("name"); final Boolean orderable = jsonObject.getBoolean("orderable"); final Boolean navigable = jsonObject.getBoolean("navigable"); final Boolean searchable = jsonObject.getBoolean("searchable"); final FieldType custom = jsonObject.getBoolean("custom") ? FieldType.CUSTOM : FieldType.JIRA; final FieldSchema schema = jsonObject.has("schema") ? schemaJsonParser.parse(jsonObject.getJSONObject("schema")) : null; return new Field(id, name, custom, orderable, navigable, searchable, schema); }