public static JsonNode getNode(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } return node.get(prop); }
private IndexerDefinitionBuilder getBuilderFromJson(byte [] jsonBytes, IndexerDefinitionBuilder baseBuilder) throws IndexerServerException { try { return baseBuilder == null ? IndexerDefinitionJsonSerDeser.INSTANCE.fromJsonBytes(jsonBytes) : IndexerDefinitionJsonSerDeser.INSTANCE.fromJsonBytes(jsonBytes, baseBuilder); } catch (JsonFormatException jfe) { // throw an IndexerException so we know it a client problem. throw new IndexerServerException(HttpServletResponse.SC_BAD_REQUEST, new IndexerFormatException("Unable to create indexer definition, "+ jfe.getMessage(), jfe)); } }
public static JsonNode getNode(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } return node.get(prop); }
public static ArrayNode getArray(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isArray()) { throw new JsonFormatException("Not an array property: " + prop); } return (ArrayNode) node.get(prop); }
public static byte[] getBinary(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } try { return node.get(prop).getBinaryValue(); } catch (IOException e) { throw new JsonFormatException("Error reading binary data in property " + prop, e); } }
public static ObjectNode getObject(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isObject()) { throw new JsonFormatException("Not an object property: " + prop); } return (ObjectNode) node.get(prop); }
public static ObjectNode getObject(JsonNode node, String prop, ObjectNode defaultValue) throws JsonFormatException { if (node.get(prop) == null) { return defaultValue; } if (!node.get(prop).isObject()) { throw new JsonFormatException("Not an object property: " + prop); } return (ObjectNode) node.get(prop); }
public static int getInt(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isInt()) { throw new JsonFormatException("Not an integer property: " + prop); } return node.get(prop).getIntValue(); }
public static ObjectNode getObject(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null || node.get(prop).isNull()) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isObject()) { throw new JsonFormatException("Not an object property: " + prop); } return (ObjectNode) node.get(prop); }
public static byte[] getBinary(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null || node.get(prop).isNull()) { throw new JsonFormatException("Missing required property: " + prop); } try { return node.get(prop).getBinaryValue(); } catch (IOException e) { throw new JsonFormatException("Error reading binary data in property " + prop, e); } }
public static String getString(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isTextual()) { throw new JsonFormatException("Not a string property: " + prop); } return node.get(prop).getTextValue(); }
public static byte[] getBinary(JsonNode node, String prop, byte[] defaultValue) throws JsonFormatException { if (node.get(prop) == null) { return defaultValue; } try { return node.get(prop).getBinaryValue(); } catch (IOException e) { throw new JsonFormatException("Error reading binary data in property " + prop, e); } }
public static ArrayNode getArray(JsonNode node, String prop, ArrayNode defaultValue) throws JsonFormatException { if (node.get(prop) == null) { return defaultValue; } if (!node.get(prop).isArray()) { throw new JsonFormatException("Not an array property: " + prop); } return (ArrayNode) node.get(prop); }
public static ArrayNode getArray(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null || node.get(prop).isNull()) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isArray()) { throw new JsonFormatException("Not an array property: " + prop); } return (ArrayNode) node.get(prop); }
public static long getLong(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isLong() && !node.get(prop).isInt()) { throw new JsonFormatException("Not an long property: " + prop); } return node.get(prop).getLongValue(); }
public static Boolean getBoolean(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (node.get(prop).isNull()) { return null; } if (!node.get(prop).isBoolean()) { throw new JsonFormatException("Not a boolean property: " + prop); } return node.get(prop).getBooleanValue(); }
public static Boolean getBoolean(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null) { throw new JsonFormatException("Missing required property: " + prop); } if (node.get(prop).isNull()) { return null; } if (!node.get(prop).isBoolean()) { throw new JsonFormatException("Not a boolean property: " + prop); } return node.get(prop).getBooleanValue(); }
public static byte[] getBinary(JsonNode node, String prop, byte[] defaultValue) throws JsonFormatException { if (node.get(prop) == null || node.get(prop).isNull()) { return defaultValue; } try { return node.get(prop).getBinaryValue(); } catch (IOException e) { throw new JsonFormatException("Error reading binary data in property " + prop, e); } }
public static String getString(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null || node.get(prop).isNull()) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isTextual()) { throw new JsonFormatException("Not a string property: " + prop); } return node.get(prop).getTextValue(); }
public static int getInt(JsonNode node, String prop) throws JsonFormatException { if (node.get(prop) == null || node.get(prop).isNull()) { throw new JsonFormatException("Missing required property: " + prop); } if (!node.get(prop).isInt()) { throw new JsonFormatException("Not an integer property: " + prop); } return node.get(prop).getIntValue(); }