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 9729e56..d56a43f 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",
"@okhttp//jar",
diff --git a/apps/k8s-networking/app/BUILD b/apps/k8s-networking/app/BUILD
index 87c974e..df84aaf 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",
"@okhttp//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/deps/deps.json b/deps/deps.json
index d235951..e8a666e 100644
--- a/deps/deps.json
+++ b/deps/deps.json
@@ -284,7 +284,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",
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index 0944a76..7a34201 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, 8 Feb 2022 21:28:04 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Thu, 9 Jun 2022 15:04:07 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -1060,12 +1060,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",
@@ -1499,7 +1493,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["@com_google_api_grpc_proto_google_common_protos//:com_google_api_grpc_proto_google_common_protos"] = "mvn:com.google.api.grpc:proto-google-common-protos:jar:NON-OSGI:1.12.0"