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;
     }
 }
diff --git a/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteServiceWebResource.java b/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteServiceWebResource.java
index fc1a09a..a1c0296 100644
--- a/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteServiceWebResource.java
+++ b/apps/route-service/app/src/main/java/org/onosproject/routeservice/rest/RouteServiceWebResource.java
@@ -74,14 +74,13 @@
 
     /**
      * Create new unicast route.
-     * Creates a new route in the unicast RIB. Routes created through the REST
-     * API are always created as STATIC routes, so there is no need to specify
-     * the type.
+     * Creates a new route in the unicast RIB. Source field is kept optional.
+     * Without Source field routes are created as STATIC routes. Otherwise as per the mentioned Source
      *
      * @param route unicast route JSON
      * @return status of the request - CREATED if the JSON is correct,
      * BAD_REQUEST if the JSON is invalid, NO_CONTENT otherwise
-     * @onos.rsModel RoutePost
+     * @onos.rsModel RouteTypePost
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
@@ -103,14 +102,13 @@
 
     /**
      * Creates new unicast routes.
-     * Creates new routes in the unicast RIB. Routes created through the REST
-     * API are always created as STATIC routes, so there is no need to specify
-     * the type.
+     * Creates a new route in the unicast RIB. Source field is kept optional.
+     * Without Source field routes are created as STATIC routes. Otherwise as per the mentioned Source
      *
      * @param routesStream unicast routes JSON array
      * @return status of the request - CREATED if the JSON is correct,
      * BAD_REQUEST if the JSON is invalid, NO_CONTENT otherwise
-     * @onos.rsModel RoutesPost
+     * @onos.rsModel RoutesTypePost
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)