Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/main/java/net/onrc/onos/apps/bgproute/BgpRouteResource.java b/src/main/java/net/onrc/onos/apps/bgproute/BgpRouteResource.java
index cbb1634..2e14757 100644
--- a/src/main/java/net/onrc/onos/apps/bgproute/BgpRouteResource.java
+++ b/src/main/java/net/onrc/onos/apps/bgproute/BgpRouteResource.java
@@ -13,164 +13,160 @@
public class BgpRouteResource extends ServerResource {
- protected final static Logger log = LoggerFactory.getLogger(BgpRouteResource.class);
+ protected final static Logger log = LoggerFactory.getLogger(BgpRouteResource.class);
- @Get
- public String get(String fmJson) {
- String dest = (String) getRequestAttributes().get("dest");
- String output = "";
- IBgpRouteService bgpRoute = (IBgpRouteService)getContext().getAttributes().
- get(IBgpRouteService.class.getCanonicalName());
+ @Get
+ public String get(String fmJson) {
+ String dest = (String) getRequestAttributes().get("dest");
+ String output = "";
+ IBgpRouteService bgpRoute = (IBgpRouteService) getContext().getAttributes().
+ get(IBgpRouteService.class.getCanonicalName());
- if (dest != null) {
- //TODO Needs to be changed to use the new RestClient.get().
+ if (dest != null) {
+ //TODO Needs to be changed to use the new RestClient.get().
- // the dest here refers to router-id
- //bgpdRestIp includes port number, such as 1.1.1.1:8080
- String BGPdRestIp = bgpRoute.getBGPdRestIp();
- String url="http://"+BGPdRestIp+"/wm/bgp/"+dest;
+ // the dest here refers to router-id
+ //bgpdRestIp includes port number, such as 1.1.1.1:8080
+ String BGPdRestIp = bgpRoute.getBGPdRestIp();
+ String url = "http://" + BGPdRestIp + "/wm/bgp/" + dest;
- //Doesn't actually do anything with the response
- RestClient.get(url);
-
- output="Get rib from bgpd finished!\n";
- return output;
- }
- else {
- IPatriciaTrie<RibEntry> ptree = bgpRoute.getPtree();
- output += "{\n \"rib\": [\n";
- boolean printed = false;
-
- synchronized(ptree) {
- Iterator<IPatriciaTrie.Entry<RibEntry>> it = ptree.iterator();
- while (it.hasNext()) {
- IPatriciaTrie.Entry<RibEntry> entry = it.next();
-
- if (printed == true) {
- output += ",\n";
- }
-
- output += " {\"prefix\": \"" + entry.getPrefix() +"\", ";
- output += "\"nexthop\": \"" + entry.getValue().getNextHop().getHostAddress() +"\"}";
-
- printed = true;
- }
- }
-
- output += "\n ]\n}\n";
- }
-
- return output;
- }
+ //Doesn't actually do anything with the response
+ RestClient.get(url);
- @Post
- public String store(String fmJson) {
- IBgpRouteService bgpRoute = (IBgpRouteService) getContext().getAttributes().
- get(IBgpRouteService.class.getCanonicalName());
+ output = "Get rib from bgpd finished!\n";
+ return output;
+ } else {
+ IPatriciaTrie<RibEntry> ptree = bgpRoute.getPtree();
+ output += "{\n \"rib\": [\n";
+ boolean printed = false;
- String strSysuptime = (String) getRequestAttributes().get("sysuptime");
- String strSequence = (String) getRequestAttributes().get("sequence");
- String routerId = (String) getRequestAttributes().get("routerid");
- String prefix = (String) getRequestAttributes().get("prefix");
- String mask = (String) getRequestAttributes().get("mask");
- String nexthop = (String) getRequestAttributes().get("nexthop");
- String capability = (String) getRequestAttributes().get("capability");
-
- log.debug("sysuptime: {}", strSysuptime);
- log.debug("sequence: {}", strSequence);
+ synchronized (ptree) {
+ Iterator<IPatriciaTrie.Entry<RibEntry>> it = ptree.iterator();
+ while (it.hasNext()) {
+ IPatriciaTrie.Entry<RibEntry> entry = it.next();
- String reply = "";
+ if (printed == true) {
+ output += ",\n";
+ }
- if (capability == null) {
- // this is a prefix add
- Prefix p;
- long sysUpTime, sequenceNum;
- try {
- p = new Prefix(prefix, Integer.valueOf(mask));
- sysUpTime = Long.parseLong(strSysuptime);
- sequenceNum = Long.parseLong(strSequence);
- } catch (NumberFormatException e) {
- reply = "[POST: mask format is wrong]";
- log.info(reply);
- return reply + "\n";
- } catch (IllegalArgumentException e1) {
- reply = "[POST: prefix format is wrong]";
- log.info(reply);
- return reply + "\n";
- }
-
- RibEntry rib = new RibEntry(routerId, nexthop, sysUpTime, sequenceNum);
+ output += " {\"prefix\": \"" + entry.getPrefix() + "\", ";
+ output += "\"nexthop\": \"" + entry.getValue().getNextHop().getHostAddress() + "\"}";
- bgpRoute.newRibUpdate(new RibUpdate(Operation.UPDATE, p, rib));
-
- reply = "[POST: " + prefix + "/" + mask + ":" + nexthop + "]";
- log.info(reply);
- }
- else if(capability.equals("1")) {
- reply = "[POST-capability: " + capability + "]\n";
- log.info(reply);
- // to store the number in the top node of the Ptree
- }
- else {
- reply = "[POST-capability: " + capability + "]\n";
- log.info(reply);
- // to store the number in the top node of the Ptree
- }
+ printed = true;
+ }
+ }
- return reply + "\n";
- }
+ output += "\n ]\n}\n";
+ }
- @Delete
- public String delete(String fmJson) {
- IBgpRouteService bgpRoute = (IBgpRouteService)getContext().getAttributes().
- get(IBgpRouteService.class.getCanonicalName());
+ return output;
+ }
- String strSysuptime = (String) getRequestAttributes().get("sysuptime");
- String strSequence = (String) getRequestAttributes().get("sequence");
- String routerId = (String) getRequestAttributes().get("routerid");
- String prefix = (String) getRequestAttributes().get("prefix");
- String mask = (String) getRequestAttributes().get("mask");
- String nextHop = (String) getRequestAttributes().get("nexthop");
- String capability = (String) getRequestAttributes().get("capability");
+ @Post
+ public String store(String fmJson) {
+ IBgpRouteService bgpRoute = (IBgpRouteService) getContext().getAttributes().
+ get(IBgpRouteService.class.getCanonicalName());
- log.debug("sysuptime: {}", strSysuptime);
- log.debug("sequence: {}", strSequence);
-
- String reply = "";
+ String strSysuptime = (String) getRequestAttributes().get("sysuptime");
+ String strSequence = (String) getRequestAttributes().get("sequence");
+ String routerId = (String) getRequestAttributes().get("routerid");
+ String prefix = (String) getRequestAttributes().get("prefix");
+ String mask = (String) getRequestAttributes().get("mask");
+ String nexthop = (String) getRequestAttributes().get("nexthop");
+ String capability = (String) getRequestAttributes().get("capability");
- if (capability == null) {
- // this is a prefix delete
- Prefix p;
- long sysUpTime, sequenceNum;
- try {
- p = new Prefix(prefix, Integer.valueOf(mask));
- sysUpTime = Long.parseLong(strSysuptime);
- sequenceNum = Long.parseLong(strSequence);
- } catch (NumberFormatException e) {
- reply = "[DELE: mask format is wrong]";
- log.info(reply);
- return reply + "\n";
- } catch (IllegalArgumentException e1) {
- reply = "[DELE: prefix format is wrong]";
- log.info(reply);
- return reply + "\n";
- }
-
- RibEntry r = new RibEntry(routerId, nextHop, sysUpTime, sequenceNum);
-
- bgpRoute.newRibUpdate(new RibUpdate(Operation.DELETE, p, r));
-
- reply =reply + "[DELE: " + prefix + "/" + mask + ":" + nextHop + "]";
- }
- else {
- // clear the local rib: Ptree
- bgpRoute.clearPtree();
- reply = "[DELE-capability: " + capability + "; The local RibEntry is cleared!]\n";
+ log.debug("sysuptime: {}", strSysuptime);
+ log.debug("sequence: {}", strSequence);
- // to store the number in the top node of the Ptree
- }
-
- log.info(reply);
- return reply + "\n";
- }
+ String reply = "";
+
+ if (capability == null) {
+ // this is a prefix add
+ Prefix p;
+ long sysUpTime, sequenceNum;
+ try {
+ p = new Prefix(prefix, Integer.valueOf(mask));
+ sysUpTime = Long.parseLong(strSysuptime);
+ sequenceNum = Long.parseLong(strSequence);
+ } catch (NumberFormatException e) {
+ reply = "[POST: mask format is wrong]";
+ log.info(reply);
+ return reply + "\n";
+ } catch (IllegalArgumentException e1) {
+ reply = "[POST: prefix format is wrong]";
+ log.info(reply);
+ return reply + "\n";
+ }
+
+ RibEntry rib = new RibEntry(routerId, nexthop, sysUpTime, sequenceNum);
+
+ bgpRoute.newRibUpdate(new RibUpdate(Operation.UPDATE, p, rib));
+
+ reply = "[POST: " + prefix + "/" + mask + ":" + nexthop + "]";
+ log.info(reply);
+ } else if (capability.equals("1")) {
+ reply = "[POST-capability: " + capability + "]\n";
+ log.info(reply);
+ // to store the number in the top node of the Ptree
+ } else {
+ reply = "[POST-capability: " + capability + "]\n";
+ log.info(reply);
+ // to store the number in the top node of the Ptree
+ }
+
+ return reply + "\n";
+ }
+
+ @Delete
+ public String delete(String fmJson) {
+ IBgpRouteService bgpRoute = (IBgpRouteService) getContext().getAttributes().
+ get(IBgpRouteService.class.getCanonicalName());
+
+ String strSysuptime = (String) getRequestAttributes().get("sysuptime");
+ String strSequence = (String) getRequestAttributes().get("sequence");
+ String routerId = (String) getRequestAttributes().get("routerid");
+ String prefix = (String) getRequestAttributes().get("prefix");
+ String mask = (String) getRequestAttributes().get("mask");
+ String nextHop = (String) getRequestAttributes().get("nexthop");
+ String capability = (String) getRequestAttributes().get("capability");
+
+ log.debug("sysuptime: {}", strSysuptime);
+ log.debug("sequence: {}", strSequence);
+
+ String reply = "";
+
+ if (capability == null) {
+ // this is a prefix delete
+ Prefix p;
+ long sysUpTime, sequenceNum;
+ try {
+ p = new Prefix(prefix, Integer.valueOf(mask));
+ sysUpTime = Long.parseLong(strSysuptime);
+ sequenceNum = Long.parseLong(strSequence);
+ } catch (NumberFormatException e) {
+ reply = "[DELE: mask format is wrong]";
+ log.info(reply);
+ return reply + "\n";
+ } catch (IllegalArgumentException e1) {
+ reply = "[DELE: prefix format is wrong]";
+ log.info(reply);
+ return reply + "\n";
+ }
+
+ RibEntry r = new RibEntry(routerId, nextHop, sysUpTime, sequenceNum);
+
+ bgpRoute.newRibUpdate(new RibUpdate(Operation.DELETE, p, r));
+
+ reply = reply + "[DELE: " + prefix + "/" + mask + ":" + nextHop + "]";
+ } else {
+ // clear the local rib: Ptree
+ bgpRoute.clearPtree();
+ reply = "[DELE-capability: " + capability + "; The local RibEntry is cleared!]\n";
+
+ // to store the number in the top node of the Ptree
+ }
+
+ log.info(reply);
+ return reply + "\n";
+ }
}