Route Type Addition REST API
Change-Id: If521a97f68a12ef54feda656c499335fc58f3b98
diff --git a/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteCodec.java b/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteCodec.java
index 3ea9f07..b33dca1 100644
--- a/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteCodec.java
+++ b/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteCodec.java
@@ -52,11 +52,14 @@
IpPrefix prefix = IpPrefix.valueOf(json.path(PREFIX).asText());
IpAddress nextHop = IpAddress.valueOf(json.path(NEXT_HOP).asText());
+ String source = json.path(SOURCE).asText();
- // Routes through the REST API are created as STATIC, so we ignore
- // the source parameter if it is specified in the JSON.
- Route route = new Route(Route.Source.STATIC, prefix, nextHop);
+ // Routes through the REST API without mentioning source in the json are created as STATIC,
+ // otherwise routes are created with corresponding source.
+ Route route = source.isEmpty() ?
+ new Route(Route.Source.STATIC, prefix, nextHop) :
+ new Route(Route.Source.valueOf(source), prefix, nextHop);
return route;
}
}