private static List<String> convertToList(ArrayNode values) { final List<String> result = new ArrayList<>(values.size()); values.forEach(jsonNode -> result.add(jsonNode.asText())); return result;
private static List<String> convertToList(ArrayNode values) { final List<String> result = new ArrayList<>(values.size()); values.forEach(jsonNode -> result.add(jsonNode.asText())); return result;
static List<URI> getRoles(JsonNode node) {
final List<URI> roles = new ArrayList<>();
if (node != null && node.isArray()) {
((ArrayNode) node).forEach(e -> {
roles.add(toUri(roleBase, e.asText()));
return roles;
@Override public T valueNonNull(JsonNode node) { if (!node.isArray()) { throw new IllegalArgumentException("Node is not an array: " + node.getNodeType().name()); T container = containerSupplier.get(); ArrayNode array = (ArrayNode) node; array.forEach(child -> container.add(elementConverter.value(child))); return container;
@Override public T valueNonNull(JsonNode node) { if (!node.isArray()) { throw new IllegalArgumentException("Node is not an array: " + node.getNodeType().name()); T container = containerSupplier.get(); ArrayNode array = (ArrayNode) node; array.forEach(child -> container.add(elementConverter.value(child))); return container;
/**
* Dequques all the currently pending callbacks.
* @return A list of all pending callbacks.
public List<Callback> pendingCallbacks() {
ObjectNode req = makeRequest("callbacks");
JsonNode resp = this.runtime.requestResponse(req);
JsonNode callbacksResp = resp.get("callbacks");
if (callbacksResp == null || !callbacksResp.isArray()) {
throw new JsiiException("Expecting a 'callbacks' key with an array in response");
ArrayNode callbacksArray = (ArrayNode) callbacksResp;
List<Callback> result = new ArrayList<>();
callbacksArray.forEach(node -> {
try {
result.add(STD_OM.treeToValue(node, Callback.class));
} catch (JsonProcessingException e) {
throw new JsiiException(e);
return result;
public Collection<OpenstackRouter> getRouters() {
Invocation.Builder builder = getClientBuilder(neutronUrl + PATH_ROUTERS);
String response = builder.accept(MediaType.APPLICATION_JSON_TYPE).
header(HEADER_AUTH_TOKEN, getToken()).get(String.class);
ObjectMapper mapper = new ObjectMapper();
List<OpenstackRouter> openstackRouters = Lists.newArrayList();
try {
ObjectNode node = (ObjectNode) mapper.readTree(response);
ArrayNode routerList = (ArrayNode) node.path(PATH_ROUTERS);
OpenstackRouterCodec openstackRouterCodec = new OpenstackRouterCodec();
routerList.forEach(r -> openstackRouters
.add(openstackRouterCodec.decode((ObjectNode) r, null)));
} catch (IOException e) {
log.warn("getRouters()", e);
log.debug("router response:" + response);
openstackRouters.forEach(r -> log.debug("router ID: {}", r.id()));
return openstackRouters;
JsonNode rootNode = JsonUtils.read(fileToLoad);
ArrayNode institutes = (ArrayNode) rootNode.get("institutes");
institutes.forEach(institute -> {
String sourceId = institute.get("id").isNull() ? null : institute.get("id").asText();
String orgType = null;
if (!institute.get("types").isNull()) {
((ArrayNode) institute.get("types")).forEach(x -> sj.add(x.textValue()));
orgType = sj.toString();
if (node.isArray()) {
ArrayNode array = (ArrayNode) node;
array.forEach(obj -> {
JsonNode branch = (JsonNode) obj;
SourceCodeBranch glBranch = new SourceCodeBranch();
if (node.isArray()) {
ArrayNode array = (ArrayNode) node;
array.forEach(obj -> {
JsonNode project = (JsonNode) obj;
int id = project.get("id").asInt();
/**
* Returns network information stored in Neutron.
* @return List of OpenstackNetwork
public Collection<OpenstackNetwork> getNetworks() {
Invocation.Builder builder = getClientBuilder(neutronUrl + URI_NETWORKS);
String response = builder.accept(MediaType.APPLICATION_JSON_TYPE).
header(HEADER_AUTH_TOKEN, getToken()).get(String.class);
log.debug("networks response:" + response);
ObjectMapper mapper = new ObjectMapper();
List<OpenstackNetwork> openstackNetworks = Lists.newArrayList();
try {
ObjectNode node = (ObjectNode) mapper.readTree(response);
ArrayNode networkList = (ArrayNode) node.path(PATH_NETWORKS);
OpenstackNetworkCodec networkCodec = new OpenstackNetworkCodec();
networkList.forEach(n -> openstackNetworks.add(networkCodec.decode((ObjectNode) n, null)));
} catch (IOException e) {
log.warn("getNetworks()", e);
openstackNetworks.removeAll(Collections.singleton(null));
openstackNetworks.forEach(n -> log.debug("network ID: {}", n.id()));
return openstackNetworks;
/**
* Returns Subnet information in Neutron.
* @return List of OpenstackSubnet
public Collection<OpenstackSubnet> getSubnets() {
Invocation.Builder builder = getClientBuilder(neutronUrl + URI_SUBNETS);
String response = builder.accept(MediaType.APPLICATION_JSON_TYPE).
header(HEADER_AUTH_TOKEN, getToken()).get(String.class);
ObjectMapper mapper = new ObjectMapper();
List<OpenstackSubnet> subnets = Lists.newArrayList();
try {
ObjectNode node = (ObjectNode) mapper.readTree(response);
ArrayNode subnetList = (ArrayNode) node.path(PATH_SUBNETS);
OpenstackSubnetCodec subnetCodec = new OpenstackSubnetCodec();
subnetList.forEach(s -> subnets.add(subnetCodec.decode((ObjectNode) s, null)));
} catch (IOException e) {
log.warn("getSubnets()", e);
log.debug("subnets response:" + response);
subnets.forEach(s -> log.debug("subnet ID: {}", s.id()));
return subnets;
List<Ip4Address> dnsList = Lists.newArrayList();
if (dnsNameservsers != null && !dnsNameservsers.isMissingNode()) {
dnsNameservsers.forEach(dns -> dnsList.add(Ip4Address.valueOf(dns.asText())));
if (node.isArray()) {
ArrayNode array = (ArrayNode) node;
array.forEach(obj -> {
JsonNode org = (JsonNode) obj;
int id = org.get("id").asInt();
/**
* Returns port information stored in Neutron.
* @return List of OpenstackPort
public Collection<OpenstackPort> getPorts() {
Invocation.Builder builder = getClientBuilder(neutronUrl + URI_PORTS);
String response = builder.accept(MediaType.APPLICATION_JSON_TYPE).
header(HEADER_AUTH_TOKEN, getToken()).get(String.class);
ObjectMapper mapper = new ObjectMapper();
List<OpenstackPort> openstackPorts = Lists.newArrayList();
try {
ObjectNode node = (ObjectNode) mapper.readTree(response);
ArrayNode portList = (ArrayNode) node.path(PATH_PORTS);
OpenstackPortCodec portCodec = new OpenstackPortCodec();
portList.forEach(p -> openstackPorts.add(portCodec.decode((ObjectNode) p, null)));
} catch (IOException e) {
log.warn("getPorts()", e);
log.debug("port response:" + response);
openstackPorts.forEach(n -> log.debug("port ID: {}", n.id()));
return openstackPorts;
ArrayNode securityGroupList = (ArrayNode) portInfo.path(SECURITY_GROUPS);
Collection<String> securityGroupIdList = Lists.newArrayList();
securityGroupList.forEach(securityGroup -> securityGroupIdList.add(securityGroup.asText()));
String deviceId = portInfo.path(DEVICE_ID).asText();
an.forEach(cn -> {
if (cn!=null && cn.isContainerNode() ) {
n.remove(name);
obj.withArray("scale_factors").forEach(
fnode -> service.addSize(new Size(service.getWidth() / fnode.asInt(),
service.getHeight() / fnode.asInt())));
obj.withArray("scale_factors").forEach(
fnode -> tinfo.addScaleFactor(fnode.asInt()));
if (obj.has("tile_height")) {
ImageApiProfile profile = new ImageApiProfile();
if (obj.has("formats")) {
obj.withArray("formats").forEach(
f -> profile.addFormat(ImageApiProfile.Format.valueOf(f.asText().toUpperCase())));