VOL-1256: Support for transparent flows (with different Vlan IDs) on a ONU for DT FTTB Use case, after merge

Change-Id: I1fa25d826d87658e6951a2aa90f4577be81f301d
diff --git a/app/src/main/java/org/opencord/olt/rest/OltWebResource.java b/app/src/main/java/org/opencord/olt/rest/OltWebResource.java
index 4a786f0..1631b09 100644
--- a/app/src/main/java/org/opencord/olt/rest/OltWebResource.java
+++ b/app/src/main/java/org/opencord/olt/rest/OltWebResource.java
@@ -15,6 +15,7 @@
  */
 package org.opencord.olt.rest;
 
+import org.onlab.packet.VlanId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.PortNumber;
@@ -22,6 +23,7 @@
 import org.opencord.olt.AccessDeviceService;
 import org.opencord.olt.AccessSubscriberId;
 
+import java.util.Optional;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -93,7 +95,33 @@
             @PathParam("portName")String portName) {
         AccessDeviceService service = get(AccessDeviceService.class);
 
-        if (service.provisionSubscriber(new AccessSubscriberId(portName))) {
+        Optional<VlanId> emptyVlan = Optional.empty();
+        if (service.provisionSubscriber(new AccessSubscriberId(portName), emptyVlan, emptyVlan)) {
+            return ok("").build();
+        }
+        return Response.status(NOT_FOUND).build();
+    }
+
+    /**
+     * Provision service with particular tags for a subscriber.
+     *
+     * @param portName Name of the port on which the subscriber is connected
+     * @param sTagVal additional outer tag on this port
+     * @param cTagVal additional innter tag on this port
+     * @return 200 OK or 404 NOT_FOUND
+     */
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("services/{portName}/{sTag}/{cTag}")
+    public Response provisionAdditionalVlans(
+            @PathParam("portName")String portName,
+            @PathParam("sTag")String sTagVal,
+            @PathParam("cTag")String cTagVal) {
+        AccessDeviceService service = get(AccessDeviceService.class);
+        VlanId cTag = VlanId.vlanId(cTagVal);
+        VlanId sTag = VlanId.vlanId(sTagVal);
+
+        if (service.provisionSubscriber(new AccessSubscriberId(portName), Optional.of(sTag), Optional.of(cTag))) {
             return ok("").build();
         }
         return Response.status(NOT_FOUND).build();
@@ -112,7 +140,33 @@
             @PathParam("portName")String portName) {
         AccessDeviceService service = get(AccessDeviceService.class);
 
-        if (service.removeSubscriber(new AccessSubscriberId(portName))) {
+        Optional<VlanId> emptyVlan = Optional.empty();
+        if (service.removeSubscriber(new AccessSubscriberId(portName), emptyVlan, emptyVlan)) {
+            return ok("").build();
+        }
+        return Response.status(NOT_FOUND).build();
+    }
+
+    /**
+     * Removes additional vlans of a particular subscriber.
+     *
+     * @param portName Name of the port on which the subscriber is connected
+     * @param sTagVal additional outer tag on this port which needs to be removed
+     * @param cTagVal additional inner tag on this port which needs to be removed
+     * @return 200 OK or 404 NOT_FOUND
+     */
+    @DELETE
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("services/{portName}/{sTag}/{cTag}")
+    public Response removeAdditionalVlans(
+            @PathParam("portName")String portName,
+            @PathParam("sTag")String sTagVal,
+            @PathParam("cTag")String cTagVal) {
+        AccessDeviceService service = get(AccessDeviceService.class);
+        VlanId cTag = VlanId.vlanId(cTagVal);
+        VlanId sTag = VlanId.vlanId(sTagVal);
+
+        if (service.removeSubscriber(new AccessSubscriberId(portName), Optional.of(sTag), Optional.of(cTag))) {
             return ok("").build();
         }
         return Response.status(NOT_FOUND).build();