private JsonNode getPointer(String pointer, ObjectNode rootNode) { return pointer != null ? rootNode.at(pointer) : rootNode; }
int getStatusCode() { return metadataNode.at("/statusCode").asInt(HttpStatus.SC_OK); }
String getReasonString() { return metadataNode.at("/reason").asText("Not Found"); }
String getSources() { return metadataNode.at("/sources").toString(); }
String getGeneratedDate() { return metadataNode.at("/generated").asText(); }
public static ObjectNode resolveSchemaForReference(final ObjectNode json, final String title, final String reference) { final ObjectNode dereferenced = (ObjectNode) json.at(reference.substring(1)); return createJsonSchema(title, dereferenced); }
public static ObjectNode resolveSchemaForReference(final ObjectNode json, final String title, final String reference) { final ObjectNode dereferenced = (ObjectNode) json.at(reference.substring(1)); return createJsonSchema(title, dereferenced); }
int getExpirySeconds() { if (!metadataNode.has("expires")) { return (int)TimeUnit.DAYS.toSeconds(365); } String expiryDate = metadataNode.at("/expires").asText(); return CacheDateUtils.getSecondsUntil(expiryDate); }
@Override public <O> ConfigObject<O> getAsConfigObject(String pointer, TypeToken<O> type) { JsonNode node = pointer != null ? rootNode.at(pointer) : rootNode; if (node.isMissingNode()) { node = emptyNode; } try { JavaType javaType = objectMapper.getTypeFactory().constructType(type.getType()); O value = objectMapper.readValue(new TreeTraversingParser(node, objectMapper), javaType); return new DefaultConfigObject<>(pointer, type, value); } catch (IOException ex) { throw Exceptions.uncheck(ex); } }
/** * Gets the content of the key recursively as a JsonObject * @param path root path (i.e. /path1/path2) * @param etcdClient EtcdClient * @return JsonNode * @throws IOException * @throws EtcdAuthenticationException * @throws TimeoutException * @throws EtcdException */ public static JsonNode getAsJson(String path, EtcdClient etcdClient) throws IOException, EtcdAuthenticationException, TimeoutException, EtcdException { EtcdKeyGetRequest etcdKeyGetRequest = etcdClient.get(path).recursive(); EtcdKeysResponse dataTree = etcdKeyGetRequest.send().get(); ObjectNode jNode = JsonNodeFactory.instance.objectNode(); if (dataTree.getNode().getNodes().isEmpty()) { iterateOverNodes(jNode, dataTree.getNode()); } else { for (EtcdNode node : dataTree.getNode().getNodes()) { iterateOverNodes(jNode, node); } } return dotNotationToStandardJson(jNode.at(path)); }