Removing json package dependency due to licensing issues
Change-Id: Iabd2f0343ca42a1956c1f7c6e471d8e141d29bc7
diff --git a/apps/artemis/BUILD b/apps/artemis/BUILD
index 763a535..10692dd 100755
--- a/apps/artemis/BUILD
+++ b/apps/artemis/BUILD
@@ -3,7 +3,7 @@
"@okio//jar",
"@commons_net//jar",
"@io_socket_client//jar",
- "@json//jar",
+ "@minimal_json//jar",
"@engine_io_client//jar",
"@io_netty_netty//jar",
"@io_netty_netty_transport//jar",
@@ -18,7 +18,7 @@
BUNDLES = [
"@commons_net//jar",
"@io_socket_client//jar",
- "@json//jar",
+ "@minimal_json//jar",
"@engine_io_client//jar",
"//apps/artemis:onos-apps-artemis",
"//apps/routing-api:onos-apps-routing-api",
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/ArtemisPacketProcessor.java b/apps/artemis/src/main/java/org/onosproject/artemis/ArtemisPacketProcessor.java
index d4cae92..ce2be24 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/ArtemisPacketProcessor.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/ArtemisPacketProcessor.java
@@ -16,7 +16,7 @@
package org.onosproject.artemis;
import io.netty.channel.ChannelHandlerContext;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
import org.onosproject.artemis.impl.objects.ArtemisMessage;
/**
@@ -37,5 +37,5 @@
*
* @param msg BGP Update message
*/
- void processMonitorPacket(JSONObject msg);
+ void processMonitorPacket(JsonObject msg);
}
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisConfig.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisConfig.java
index 9d188dd..813ad16 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisConfig.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisConfig.java
@@ -19,8 +19,7 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.collect.Streams;
-import org.json.JSONArray;
-import org.json.JSONException;
+import com.eclipsesource.json.JsonArray;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onosproject.core.ApplicationId;
@@ -392,15 +391,11 @@
* <code>50</code> friendly anycaster announcing our prefix
* <code>100+i</code> BGP hijack type i (0 <= i <=2)
*/
- int checkPath(JSONArray path) {
+ int checkPath(JsonArray path) {
// TODO add MOAS check
ArrayList<Integer> asnPath = new ArrayList<>();
- for (int i = 0; i < path.length(); i++) {
- try {
- asnPath.add(path.getInt(i));
- } catch (JSONException e) {
- log.warn("checkPath", e);
- }
+ for (int i = 0; i < path.size(); i++) {
+ asnPath.add(path.get(i).asInt());
}
// reverse the list to get path starting from origin
Collections.reverse(asnPath);
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDeaggregatorImpl.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDeaggregatorImpl.java
index a26ae30..8d61e9a 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDeaggregatorImpl.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDeaggregatorImpl.java
@@ -23,7 +23,7 @@
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.CharsetUtil;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.TpPort;
@@ -415,7 +415,7 @@
}
@Override
- public void processMonitorPacket(JSONObject msg) {
+ public void processMonitorPacket(JsonObject msg) {
}
}
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDetectorImpl.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDetectorImpl.java
index 02f9cd2..205df9e 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDetectorImpl.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisDetectorImpl.java
@@ -16,10 +16,8 @@
package org.onosproject.artemis.impl;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
+import com.eclipsesource.json.JsonArray;
import org.onlab.packet.IpPrefix;
import org.onosproject.artemis.ArtemisDetector;
import org.onosproject.artemis.ArtemisEventListener;
@@ -70,30 +68,26 @@
void handleArtemisEvent(ArtemisEvent event) {
// If an instance was deactivated, check whether we need to roll back the upgrade.
if (event.type().equals(ArtemisEvent.Type.BGPUPDATE_ADDED)) {
- JSONObject take = (JSONObject) event.subject();
+ JsonObject take = (JsonObject) event.subject();
log.info("Received information about monitored prefix " + take.toString());
artemisService.getConfig().ifPresent(config ->
config.monitoredPrefixes().forEach(artemisPrefix -> {
- try {
- IpPrefix prefix = artemisPrefix.prefix(), receivedPrefix;
+ IpPrefix prefix = artemisPrefix.prefix(), receivedPrefix;
- receivedPrefix = IpPrefix.valueOf(take.getString("prefix"));
+ receivedPrefix = IpPrefix.valueOf(take.get("prefix").asString());
- if (prefix.contains(receivedPrefix)) {
- JSONArray path = take.getJSONArray("path");
+ if (prefix.contains(receivedPrefix)) {
+ JsonArray path = take.get("path").asArray();
- int state = artemisPrefix.checkPath(path);
- if (state >= 100) {
- log.info("BGP Hijack detected; pushing prefix for hijack Deaggregation");
- eventDispatcher.post(new ArtemisEvent(ArtemisEvent.Type.HIJACK_ADDED,
- receivedPrefix));
- } else {
- log.info("BGP Update is legit");
- }
+ int state = artemisPrefix.checkPath(path);
+ if (state >= 100) {
+ log.info("BGP Hijack detected; pushing prefix for hijack Deaggregation");
+ eventDispatcher.post(new ArtemisEvent(ArtemisEvent.Type.HIJACK_ADDED,
+ receivedPrefix));
+ } else {
+ log.info("BGP Update is legit");
}
- } catch (JSONException e) {
- log.error(ExceptionUtils.getFullStackTrace(e));
}
})
);
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisMonitorImpl.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisMonitorImpl.java
index b050448..14eb3d4 100755
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisMonitorImpl.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/ArtemisMonitorImpl.java
@@ -17,7 +17,7 @@
import com.google.common.collect.Sets;
import io.netty.channel.ChannelHandlerContext;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
import org.onlab.packet.IpPrefix;
import org.onosproject.artemis.ArtemisMonitor;
import org.onosproject.artemis.ArtemisPacketProcessor;
@@ -79,7 +79,7 @@
}
@Override
- public void processMonitorPacket(JSONObject msg) {
+ public void processMonitorPacket(JsonObject msg) {
// TODO: in future maybe store the BGP Update message and propagate it to the cluster instead of Events
eventDispatcher.post(new ArtemisEvent(ArtemisEvent.Type.BGPUPDATE_ADDED, msg));
}
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/ExaBgpMonitors.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/ExaBgpMonitors.java
index d645360..fd0e9c1 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/ExaBgpMonitors.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/ExaBgpMonitors.java
@@ -17,8 +17,7 @@
import io.socket.client.IO;
import io.socket.client.Socket;
-import org.json.JSONException;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
import org.onlab.packet.IpPrefix;
import org.onosproject.artemis.ArtemisPacketProcessor;
import org.onosproject.artemis.Monitors;
@@ -48,14 +47,10 @@
* socket.io onConnect event handler.
*/
private void onConnect() {
- try {
- JSONObject parameters = new JSONObject();
- parameters.put("prefix", this.prefix);
+ JsonObject parameters = new JsonObject();
+ parameters.set("prefix", this.prefix.toString());
- socket.emit("exa_subscribe", parameters);
- } catch (JSONException e) {
- log.warn("onConenct()", e);
- }
+ socket.emit("exa_subscribe", parameters);
}
/**
@@ -64,10 +59,8 @@
* @param args exabgp message
*/
private void onExaMessage(Object[] args) {
- JSONObject message = (JSONObject) args[0];
-
- try {
- if (message.getString("type").equals("A")) {
+ JsonObject message = (JsonObject) args[0];
+ if (message.get("type").asString().equals("A")) {
// Example of BGP Update message:
// {
// "path":[65001],
@@ -87,9 +80,6 @@
// Append synchronized message to message list in memory.
packetProcessor.processMonitorPacket(message);
}
- } catch (JSONException e) {
- log.warn("onExaMessage()", e);
- }
}
@Override
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/RipeMonitors.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/RipeMonitors.java
index 52025c9..b083083 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/RipeMonitors.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/monitors/RipeMonitors.java
@@ -17,8 +17,7 @@
import io.socket.client.IO;
import io.socket.client.Socket;
-import org.json.JSONException;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
import org.onlab.packet.IpPrefix;
import org.onosproject.artemis.ArtemisPacketProcessor;
import org.onosproject.artemis.Monitors;
@@ -48,22 +47,18 @@
* socket.io onConnect event handler.
*/
private void onConnect() {
- try {
- socket.emit("ping");
+ socket.emit("ping");
- JSONObject parameters = new JSONObject();
- parameters.put("origin", (Object) null);
- parameters.put("type", (Object) null);
- parameters.put("moreSpecific", true);
- parameters.put("lessSpecific", false);
- parameters.put("peer", (Object) null);
- parameters.put("host", this.host);
- parameters.put("prefix", this.prefix);
+ JsonObject parameters = new JsonObject();
+ parameters.set("origin", "");
+ parameters.set("type", "");
+ parameters.set("moreSpecific", true);
+ parameters.set("lessSpecific", false);
+ parameters.set("peer", "");
+ parameters.set("host", this.host);
+ parameters.set("prefix", this.prefix.toString());
- socket.emit("ris_subscribe", parameters);
- } catch (JSONException e) {
- log.warn("onConnect()", e);
- }
+ socket.emit("ris_subscribe", parameters);
}
@Override
@@ -83,34 +78,31 @@
* @param args RIS message
*/
private void onRisMessage(Object[] args) {
- try {
- JSONObject message = (JSONObject) args[0];
- if (message.getString("type").equals("A")) {
- // Example of BGP Update message:
- // {
- // "timestamp":1488044022.97,
- // "prefix":"101.1.46.0/24",
- // "host":"rrc21",
- // "next_hop":"37.49.236.246",
- // "peer":"37.49.236.246",
- // "path":[2613,25091,9318,9524],
- // "type":"A"
- // }
+ JsonObject message = (JsonObject) args[0];
+ if (message.get("type").asString().equals("A")) {
+ // Example of BGP Update message:
+ // {
+ // "timestamp":1488044022.97,
+ // "prefix":"101.1.46.0/24",
+ // "host":"rrc21",
+ // "next_hop":"37.49.236.246",
+ // "peer":"37.49.236.246",
+ // "path":[2613,25091,9318,9524],
+ // "type":"A"
+ // }
- // We want to keep only prefix and path in memory.
- message.remove("community");
- message.remove("timestamp");
- message.remove("next_hop");
- message.remove("peer");
- message.remove("type");
- message.remove("host");
+ // We want to keep only prefix and path in memory.
+ message.remove("community");
+ message.remove("timestamp");
+ message.remove("next_hop");
+ message.remove("peer");
+ message.remove("type");
+ message.remove("host");
- // Append synchronized message to message list in memory.
- packetProcessor.processMonitorPacket(message);
- }
- } catch (JSONException e) {
- log.error("onRisMessage()", e);
+ // Append synchronized message to message list in memory.
+ packetProcessor.processMonitorPacket(message);
}
+
socket.emit("ping");
}
diff --git a/apps/k8s-networking/BUILD b/apps/k8s-networking/BUILD
index a876bb7..c03a3b9 100644
--- a/apps/k8s-networking/BUILD
+++ b/apps/k8s-networking/BUILD
@@ -3,7 +3,7 @@
"//apps/k8s-networking/app:onos-apps-k8s-networking-app",
"@commons_net//jar",
"@jersey_client//jar",
- "@json//jar",
+ "@minimal_json//jar",
"@k8s_client//jar",
"@k8s_model//jar",
"@k8s_model_common//jar",
diff --git a/apps/k8s-networking/app/BUILD b/apps/k8s-networking/app/BUILD
index 05510a3..c57afc3 100644
--- a/apps/k8s-networking/app/BUILD
+++ b/apps/k8s-networking/app/BUILD
@@ -6,7 +6,7 @@
"//apps/k8s-networking/api:onos-apps-k8s-networking-api",
"@commons_net//jar",
"@jersey_client//jar",
- "@json//jar",
+ "@minimal_json//jar",
"@k8s_client//jar",
"@k8s_model//jar",
"@k8s_model_common//jar",
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sOpenstackIntegrationHandler.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sOpenstackIntegrationHandler.java
index a631c62..0a1c5de 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sOpenstackIntegrationHandler.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/K8sOpenstackIntegrationHandler.java
@@ -16,8 +16,7 @@
package org.onosproject.k8snetworking.impl;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.json.JSONException;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonObject;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.LeadershipService;
import org.onosproject.cluster.NodeId;
@@ -129,20 +128,15 @@
String jsonString = "";
- try {
- jsonString = new JSONObject()
- .put(K8S_NODE_IP, k8sNodeIp)
- .put(POD_GW_IP, gatewayIp)
- .put(POD_CIDR, podCidr)
- .put(SERVICE_CIDR, SERVICE_IP_CIDR_DEFAULT)
- .put(OS_K8S_INT_PORT_NAME, osK8sIntPortName)
- .put(K8S_INT_OS_PORT_MAC, k8sIntOsPortMac)
- .toString();
- log.info("push integration configuration {}", jsonString);
- } catch (JSONException e) {
- log.error("Failed to generate JSON string");
- return;
- }
+ jsonString = new JsonObject()
+ .set(K8S_NODE_IP, k8sNodeIp)
+ .set(POD_GW_IP, gatewayIp)
+ .set(POD_CIDR, podCidr)
+ .set(SERVICE_CIDR, SERVICE_IP_CIDR_DEFAULT)
+ .set(OS_K8S_INT_PORT_NAME, osK8sIntPortName)
+ .set(K8S_INT_OS_PORT_MAC, k8sIntOsPortMac)
+ .toString();
+ log.info("push integration configuration {}", jsonString);
HttpAuthenticationFeature feature =
HttpAuthenticationFeature.basic(ONOS_USERNAME, ONOS_PASSWORD);
@@ -169,17 +163,12 @@
String jsonString = "";
- try {
- jsonString = new JSONObject()
- .put(K8S_NODE_IP, k8sNodeIp)
- .put(SERVICE_CIDR, SERVICE_IP_CIDR_DEFAULT)
- .put(OS_K8S_EXT_PORT_NAME, osK8sExtPortName)
- .toString();
- log.info("push integration configuration {}", jsonString);
- } catch (JSONException e) {
- log.error("Failed to generate JSON string");
- return;
- }
+ jsonString = new JsonObject()
+ .set(K8S_NODE_IP, k8sNodeIp)
+ .set(SERVICE_CIDR, SERVICE_IP_CIDR_DEFAULT)
+ .set(OS_K8S_EXT_PORT_NAME, osK8sExtPortName)
+ .toString();
+ log.info("push integration configuration {}", jsonString);
HttpAuthenticationFeature feature =
HttpAuthenticationFeature.basic(ONOS_USERNAME, ONOS_PASSWORD);
diff --git a/apps/kubevirt-networking/BUILD b/apps/kubevirt-networking/BUILD
index ec4607d..13bdcb7 100644
--- a/apps/kubevirt-networking/BUILD
+++ b/apps/kubevirt-networking/BUILD
@@ -1,4 +1,5 @@
BUNDLES = [
+ "@minimal_json//jar",
"@commons_net//jar",
"@ipaddress//jar",
"@k8s_client//jar",
diff --git a/apps/kubevirt-networking/app/BUILD b/apps/kubevirt-networking/app/BUILD
index 6b37d90..a6c1b8e 100644
--- a/apps/kubevirt-networking/app/BUILD
+++ b/apps/kubevirt-networking/app/BUILD
@@ -5,7 +5,7 @@
"//apps/kubevirt-node/api:onos-apps-kubevirt-node-api",
"//apps/kubevirt-networking/api:onos-apps-kubevirt-networking-api",
"@commons_net//jar",
- "@json//jar",
+ "@minimal_json//jar",
"@k8s_client//jar",
"@k8s_model//jar",
"@k8s_model_common//jar",
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java
index bde6454..d82a043 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java
@@ -15,14 +15,13 @@
*/
package org.onosproject.kubevirtnetworking.impl;
+import com.eclipsesource.json.JsonArray;
+import com.eclipsesource.json.JsonObject;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import org.apache.commons.lang.StringUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onosproject.cluster.ClusterService;
@@ -270,46 +269,45 @@
}
private KubevirtNetwork parseKubevirtNetwork(String resource) {
- try {
- JSONObject json = new JSONObject(resource);
+ JsonObject json = JsonObject.readFrom(resource);
String name = parseResourceName(resource);
- JSONObject annots = json.getJSONObject("metadata").getJSONObject("annotations");
- if (!annots.has(NETWORK_CONFIG)) {
+ JsonObject annots = json.get("metadata").asObject().get("annotations").asObject();
+ if (annots.get(NETWORK_CONFIG) == null) {
// SR-IOV network does not contain network-config field
return null;
}
- String networkConfig = annots.getString(NETWORK_CONFIG);
+ String networkConfig = annots.get(NETWORK_CONFIG).asString();
if (networkConfig != null) {
KubevirtNetwork.Builder builder = DefaultKubevirtNetwork.builder();
- JSONObject configJson = new JSONObject(networkConfig);
- String type = configJson.getString(TYPE).toUpperCase(Locale.ROOT);
- Integer mtu = configJson.getInt(MTU);
- String gatewayIp = configJson.getString(GATEWAY_IP);
- boolean defaultRoute = configJson.getBoolean(DEFAULT_ROUTE);
+ JsonObject configJson = JsonObject.readFrom(networkConfig);
+ String type = configJson.get(TYPE).asString().toUpperCase(Locale.ROOT);
+ Integer mtu = configJson.get(MTU).asInt();
+ String gatewayIp = configJson.getString(GATEWAY_IP, "");
+ boolean defaultRoute = configJson.getBoolean(DEFAULT_ROUTE, false);
if (!type.equalsIgnoreCase(FLAT.name())) {
- builder.segmentId(configJson.getString(SEGMENT_ID));
+ builder.segmentId(configJson.getString(SEGMENT_ID, ""));
}
- String cidr = configJson.getString(CIDR);
+ String cidr = configJson.getString(CIDR, "");
- JSONObject poolJson = configJson.getJSONObject(IP_POOL);
+ JsonObject poolJson = configJson.get(IP_POOL).asObject();
if (poolJson != null) {
- String start = poolJson.getString(START);
- String end = poolJson.getString(END);
+ String start = poolJson.getString(START, "");
+ String end = poolJson.getString(END, "");
builder.ipPool(new KubevirtIpPool(
IpAddress.valueOf(start), IpAddress.valueOf(end)));
}
- if (configJson.has(HOST_ROUTES)) {
- JSONArray routesJson = configJson.getJSONArray(HOST_ROUTES);
+ if (configJson.get(HOST_ROUTES) != null) {
+ JsonArray routesJson = configJson.get(HOST_ROUTES).asArray();
Set<KubevirtHostRoute> hostRoutes = new HashSet<>();
if (routesJson != null) {
- for (int i = 0; i < routesJson.length(); i++) {
- JSONObject route = routesJson.getJSONObject(i);
- String destinationStr = route.getString(DESTINATION);
- String nexthopStr = route.getString(NEXTHOP);
+ for (int i = 0; i < routesJson.size(); i++) {
+ JsonObject route = routesJson.get(i).asObject();
+ String destinationStr = route.getString(DESTINATION, "");
+ String nexthopStr = route.getString(NEXTHOP, "");
if (StringUtils.isNotEmpty(destinationStr) &&
StringUtils.isNotEmpty(nexthopStr)) {
@@ -322,12 +320,12 @@
builder.hostRoutes(hostRoutes);
}
- if (configJson.has(DNSES)) {
- JSONArray dnsesJson = configJson.getJSONArray(DNSES);
+ if (configJson.get(DNSES) != null) {
+ JsonArray dnsesJson = configJson.get(DNSES).asArray();
Set<IpAddress> dnses = new HashSet<>();
if (dnsesJson != null) {
- for (int i = 0; i < dnsesJson.length(); i++) {
- String dns = dnsesJson.getString(i);
+ for (int i = 0; i < dnsesJson.size(); i++) {
+ String dns = dnsesJson.get(i).asString();
if (StringUtils.isNotEmpty(dns)) {
dnses.add(IpAddress.valueOf(dns));
}
@@ -342,10 +340,6 @@
return builder.build();
}
- } catch (JSONException e) {
- log.error("Failed to parse network attachment definition object", e);
- }
-
return null;
}
}
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
index 82d3964..e9baecf 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.kubevirtnetworking.util;
+import com.eclipsesource.json.JsonObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -25,8 +26,6 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.net.util.SubnetUtils;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.onlab.packet.ARP;
import org.onlab.packet.Ethernet;
import org.onlab.packet.Ip4Address;
@@ -459,13 +458,9 @@
}
public static String parseResourceName(String resource) {
- try {
- JSONObject json = new JSONObject(resource);
- return json.getJSONObject("metadata").getString("name");
- } catch (JSONException e) {
- log.error("");
- }
- return "";
+ JsonObject json = JsonObject.readFrom(resource);
+ JsonObject metadata = json.get("metadata").asObject();
+ return metadata != null ? metadata.get("name").asString() : "";
}
public static PortNumber portNumber(DeviceService deviceService, DeviceId deviceId, String portName) {
diff --git a/apps/kubevirt-node/BUILD b/apps/kubevirt-node/BUILD
index 922b5ea..85da1d0 100644
--- a/apps/kubevirt-node/BUILD
+++ b/apps/kubevirt-node/BUILD
@@ -1,7 +1,6 @@
BUNDLES = JACKSON + [
"//apps/kubevirt-node/api:onos-apps-kubevirt-node-api",
"//apps/kubevirt-node/app:onos-apps-kubevirt-node-app",
- "@json//jar",
"@commons_net//jar",
"@k8s_client//jar",
"@k8s_model//jar",
diff --git a/apps/kubevirt-node/app/BUILD b/apps/kubevirt-node/app/BUILD
index ee9e94e..0a3705b 100644
--- a/apps/kubevirt-node/app/BUILD
+++ b/apps/kubevirt-node/app/BUILD
@@ -3,7 +3,7 @@
"//protocols/ovsdb/api:onos-protocols-ovsdb-api",
"//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
"//apps/kubevirt-node/api:onos-apps-kubevirt-node-api",
- "@json//jar",
+ "@minimal_json//jar",
"@k8s_client//jar",
"@k8s_model//jar",
"@k8s_model_common//jar",
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/util/KubevirtNodeUtil.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/util/KubevirtNodeUtil.java
index 7107285..46a5ea5 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/util/KubevirtNodeUtil.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/util/KubevirtNodeUtil.java
@@ -27,9 +27,8 @@
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.apache.commons.lang.StringUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import com.eclipsesource.json.JsonArray;
+import com.eclipsesource.json.JsonObject;
import org.onlab.packet.IpAddress;
import org.onosproject.kubevirtnode.api.DefaultKubevirtNode;
import org.onosproject.kubevirtnode.api.DefaultKubevirtPhyInterface;
@@ -359,17 +358,17 @@
String gatewayBridgeName = null;
try {
if (physnetConfig != null) {
- JSONArray configJson = new JSONArray(physnetConfig);
+ JsonArray configJson = JsonArray.readFrom(physnetConfig);
- for (int i = 0; i < configJson.length(); i++) {
- JSONObject object = configJson.getJSONObject(i);
- String network = object.getString(NETWORK_KEY);
- String intf = object.getString(INTERFACE_KEY);
+ for (int i = 0; i < configJson.size(); i++) {
+ JsonObject object = configJson.get(i).asObject();
+ String network = object.get(NETWORK_KEY).asString();
+ String intf = object.get(INTERFACE_KEY).asString();
if (network != null && intf != null) {
String physBridgeId;
- if (object.has(PHYS_BRIDGE_ID)) {
- physBridgeId = object.getString(PHYS_BRIDGE_ID);
+ if (object.get(PHYS_BRIDGE_ID) != null) {
+ physBridgeId = object.get(PHYS_BRIDGE_ID).asString();
} else {
physBridgeId = genDpidFromName(network + intf + hostname);
log.trace("host {} physnet dpid for network {} intf {} is null so generate dpid {}",
@@ -395,7 +394,7 @@
nodeType = GATEWAY;
gatewayBridgeName = jsonNode.get(GATEWAY_BRIDGE_NAME).asText();
}
- } catch (JSONException | JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Failed to parse physnet config or gateway config object", e);
}
diff --git a/deps/deps.json b/deps/deps.json
index 0942bef..d494f3b 100644
--- a/deps/deps.json
+++ b/deps/deps.json
@@ -286,7 +286,6 @@
"mibs-net-snmp": "mvn:org.onosproject:mibbler-mibs-net-snmp:1.0-20151221.1",
"mibs-rfc": "mvn:org.onosproject:mibbler-mibs-rfc:1.0-20151221.1",
"io.socket-client": "mvn:io.socket:socket.io-client:jar:0.8.3",
- "json": "mvn:org.json:json:jar:20090211",
"engine.io-client": "mvn:io.socket:engine.io-client:jar:0.8.3",
"org_codehaus_mojo_animal_sniffer_annotations": "mvn:org.codehaus.mojo:animal-sniffer-annotations:1.17",
"dns-java": "mvn:dnsjava:dnsjava:3.3.1",
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index 7c80fee..1609926 100644
--- a/tools/build/bazel/generate_workspace.bzl
+++ b/tools/build/bazel/generate_workspace.bzl
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Tue, 25 Jan 2022 16:09:48 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Thu, 9 Jun 2022 17:57:49 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -1072,12 +1072,6 @@
jar_sha256 = "b5ccc73724f0d188ada06aff41c8bf60e0e5d4462e7980af203a20ea87bfa583",
licenses = ["notice"],
jar_urls = ["https://repo1.maven.org/maven2/io/socket/socket.io-client/0.8.3/socket.io-client-0.8.3.jar"], )
- if "json" not in native.existing_rules():
- java_import_external(
- name = "json",
- jar_sha256 = "055be110a570f9cda3eba8d70a006ff46c77a048bc67868524879211c48b330a",
- licenses = ["notice"],
- jar_urls = ["https://repo1.maven.org/maven2/org/json/json/20090211/json-20090211.jar"], )
if "engine_io_client" not in native.existing_rules():
java_import_external(
name = "engine_io_client",
@@ -1639,7 +1633,6 @@
artifact_map["@mibs_net_snmp//:mibs_net_snmp"] = "mvn:org.onosproject:mibbler-mibs-net-snmp:jar:1.0-20151221.1"
artifact_map["@mibs_rfc//:mibs_rfc"] = "mvn:org.onosproject:mibbler-mibs-rfc:jar:1.0-20151221.1"
artifact_map["@io_socket_client//:io_socket_client"] = "mvn:io.socket:socket.io-client:jar:NON-OSGI:0.8.3"
-artifact_map["@json//:json"] = "mvn:org.json:json:jar:NON-OSGI:20090211"
artifact_map["@engine_io_client//:engine_io_client"] = "mvn:io.socket:engine.io-client:jar:NON-OSGI:0.8.3"
artifact_map["@org_codehaus_mojo_animal_sniffer_annotations//:org_codehaus_mojo_animal_sniffer_annotations"] = "mvn:org.codehaus.mojo:animal-sniffer-annotations:jar:NON-OSGI:1.17"
artifact_map["@dns_java//:dns_java"] = "mvn:dnsjava:dnsjava:jar:3.3.1"