Added javadoc for all the helper classes in SDN-IP.
Also changed a couple of names to better reflect the usage or comply with
naming standards:
in IBgpRouteService.java: getBGPdRestIp -> getBgpdRestIp
in Prefix.java: MAX_BYTES -> ADDRESS_LENGTH
Change-Id: Id23b6bb077d79d671d21e2490ab410f322d7c166
diff --git a/src/main/java/net/onrc/onos/apps/bgproute/RestClient.java b/src/main/java/net/onrc/onos/apps/bgproute/RestClient.java
index f1fc370..c7ff195 100644
--- a/src/main/java/net/onrc/onos/apps/bgproute/RestClient.java
+++ b/src/main/java/net/onrc/onos/apps/bgproute/RestClient.java
@@ -12,18 +12,30 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * A simple HTTP client. It is used to make REST calls to the BGPd process.
+ */
public final class RestClient {
private static final Logger log = LoggerFactory.getLogger(RestClient.class);
+ /**
+ * Default constructor.
+ */
private RestClient() {
// Private constructor to prevent instantiation
}
- public static String get(String str) {
+ /**
+ * Issues a HTTP GET request to the specified URL.
+ *
+ * @param strUrl the URL to make the request to
+ * @return a String containing any data returned by the server
+ */
+ public static String get(String strUrl) {
StringBuilder response = new StringBuilder();
try {
- URL url = new URL(str);
+ URL url = new URL(strUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(2 * 1000); // 2 seconds
conn.setRequestMethod("GET");
@@ -36,7 +48,7 @@
}
if (!conn.getContentType().equals("application/json")) {
- log.warn("The content received from {} is not json", str);
+ log.warn("The content received from {} is not json", strUrl);
}
BufferedReader br = new BufferedReader(new InputStreamReader(
@@ -60,10 +72,15 @@
return response.toString();
}
- public static void post(String str) {
+ /**
+ * Issues a HTTP POST request to the specified URL.
+ *
+ * @param strUrl the URL to make the request to
+ */
+ public static void post(String strUrl) {
try {
- URL url = new URL(str);
+ URL url = new URL(strUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
@@ -84,10 +101,15 @@
}
}
- public static void delete(String str) {
+ /**
+ * Issues a HTTP DELETE request to the specified URL.
+ *
+ * @param strUrl the URL to make the request to
+ */
+ public static void delete(String strUrl) {
try {
- URL url = new URL(str);
+ URL url = new URL(strUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("DELETE");
conn.setRequestProperty("Accept", "application/json");