private String[] getStringArrayProperty(ObjectNode node, String property) { ArrayNode arrayNode = JsonUtil.getArray(node, property, null); if (arrayNode == null) return null; else { List<String> strings = new ArrayList<String>(); for (JsonNode jsonNode : arrayNode) { strings.add(jsonNode.getValueAsText()); } return strings.toArray(new String[strings.size()]); } }
private BatchBuildInfo parseBatchBuildInfo(ObjectNode buildNode) { Map<String, String> jobs = new HashMap<String, String>(); ObjectNode jobsNode = JsonUtil.getObject(buildNode, "mapReduceJobTrackingUrls"); Iterator<String> it = jobsNode.getFieldNames(); while (it.hasNext()) { String key = it.next(); String value = JsonUtil.getString(jobsNode, key); jobs.put(key, value); } BatchBuildInfo batchBuildInfo = new BatchBuildInfo( JsonUtil.getLong(buildNode, "submitTime"), JsonUtil.getBoolean(buildNode, "finishedSuccessful"), jobs, getStringArrayProperty(buildNode, "batchIndexCliArguments")); return batchBuildInfo; }
public IndexerDefinitionBuilder fromJson(ObjectNode node, IndexerDefinitionBuilder indexerDefinitionBuilder) { String name = JsonUtil.getString(node, "name"); LifecycleState lifecycleState = LifecycleState.valueOf(JsonUtil.getString(node, "lifecycleState")); IncrementalIndexingState incrementalIndexingState = IncrementalIndexingState.valueOf(JsonUtil.getString(node, "incrementalIndexingState")); BatchIndexingState batchIndexingState = BatchIndexingState.valueOf(JsonUtil.getString(node, "batchIndexingState")); String queueSubscriptionId = JsonUtil.getString(node, "subscriptionId", null); long subscriptionTimestamp = JsonUtil.getLong(node, "subscriptionTimestamp", 0L); String indexerComponentFactory = JsonUtil.getString(node, "indexerComponentFactory", null); String connectionType = JsonUtil.getString(node, "connectionType", null); ObjectNode connectionParamsNode = JsonUtil.getObject(node, "connectionParams", null); Map<String, String> connectionParams = null; if (connectionParamsNode != null) { activeBatchBuild = parseBatchBuildInfo(JsonUtil.getObject(node, "activeBatchBuild")); lastBatchBuild = parseBatchBuildInfo(JsonUtil.getObject(node, "lastBatchBuild")); String[] defaultBatchIndexCliArguments = getStringArrayProperty(node, "defaultBatchIndexCliArguments"); int occVersion = JsonUtil.getInt(node, "occVersion");
private byte[] getByteArrayProperty(ObjectNode node, String property) { try { String string = JsonUtil.getString(node, property, null); if (string == null) return null; return Base64.decode(string); } catch (IOException e) { throw new RuntimeException(e); } }
public IndexerDefinitionBuilder fromJson(ObjectNode node, IndexerDefinitionBuilder indexerDefinitionBuilder) { String name = JsonUtil.getString(node, "name"); LifecycleState lifecycleState = LifecycleState.valueOf(JsonUtil.getString(node, "lifecycleState")); IncrementalIndexingState incrementalIndexingState = IncrementalIndexingState.valueOf(JsonUtil.getString(node, "incrementalIndexingState")); BatchIndexingState batchIndexingState = BatchIndexingState.valueOf(JsonUtil.getString(node, "batchIndexingState")); String queueSubscriptionId = JsonUtil.getString(node, "subscriptionId", null); long subscriptionTimestamp = JsonUtil.getLong(node, "subscriptionTimestamp", 0L); String indexerComponentFactory = JsonUtil.getString(node, "indexerComponentFactory", null); String connectionType = JsonUtil.getString(node, "connectionType", null); ObjectNode connectionParamsNode = JsonUtil.getObject(node, "connectionParams", null); Map<String, String> connectionParams = null; if (connectionParamsNode != null) { activeBatchBuild = parseBatchBuildInfo(JsonUtil.getObject(node, "activeBatchBuild")); lastBatchBuild = parseBatchBuildInfo(JsonUtil.getObject(node, "lastBatchBuild")); String[] defaultBatchIndexCliArguments = getStringArrayProperty(node, "defaultBatchIndexCliArguments"); int occVersion = JsonUtil.getInt(node, "occVersion");
public static String getResponse(byte [] json) { if (json == null) { return null; } ObjectNode node; try { node = (ObjectNode) new ObjectMapper().readTree(new ByteArrayInputStream(json)); } catch (IOException e) { throw new RuntimeException("Error parsing result JSON.", e); } return JsonUtil.getString(node, "result"); }
private BatchBuildInfo parseBatchBuildInfo(ObjectNode buildNode) { Map<String, String> jobs = new HashMap<String, String>(); ObjectNode jobsNode = JsonUtil.getObject(buildNode, "mapReduceJobTrackingUrls"); Iterator<String> it = jobsNode.getFieldNames(); while (it.hasNext()) { String key = it.next(); String value = JsonUtil.getString(jobsNode, key); jobs.put(key, value); } BatchBuildInfo batchBuildInfo = new BatchBuildInfo( JsonUtil.getLong(buildNode, "submitTime"), JsonUtil.getBoolean(buildNode, "finishedSuccessful"), jobs, getStringArrayProperty(buildNode, "batchIndexCliArguments")); return batchBuildInfo; }
private String[] getStringArrayProperty(ObjectNode node, String property) { ArrayNode arrayNode = JsonUtil.getArray(node, property, null); if (arrayNode == null) return null; else { List<String> strings = new ArrayList<String>(); for (JsonNode jsonNode : arrayNode) { strings.add(jsonNode.getValueAsText()); } return strings.toArray(new String[strings.size()]); } }
private byte[] getByteArrayProperty(ObjectNode node, String property) { try { String string = JsonUtil.getString(node, property, null); if (string == null) return null; return Base64.decode(string); } catch (IOException e) { throw new RuntimeException(e); } }
public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException { ArrayNode arrayNode = getArray(node, prop, null); if (arrayNode == null) { return defaultValue; } List<String> elements = new ArrayList<String>(); Iterator<JsonNode> elementItr = arrayNode.getElements(); while (elementItr.hasNext()) { elements.add(elementItr.next().getValueAsText()); } return elements; } }
public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException { ArrayNode arrayNode = getArray(node, prop, null); if (arrayNode == null || arrayNode.isNull()) { return defaultValue; } List<String> elements = new ArrayList<String>(); Iterator<JsonNode> elementItr = arrayNode.getElements(); while (elementItr.hasNext()) { elements.add(elementItr.next().getValueAsText()); } return elements; } }