add a rest to get the IP address map to vBNG

Change-Id: I9f7c8cd082a5b6779fcb7d3636f873544f74d290
diff --git a/apps/virtualbng/pom.xml b/apps/virtualbng/pom.xml
index dcedd91..dd700b2 100644
--- a/apps/virtualbng/pom.xml
+++ b/apps/virtualbng/pom.xml
@@ -73,10 +73,12 @@
                         <Import-Package>
                             org.slf4j,
                             javax.ws.rs,
+                            javax.ws.rs.core,
                             com.sun.jersey.api.core,
                             com.sun.jersey.spi.container.servlet,
                             com.sun.jersey.server.impl.container.servlet,
                             com.fasterxml.jackson.databind,
+                            com.fasterxml.jackson.databind.node,
                             org.apache.karaf.shell.commands,
                             com.google.common.*,
                             org.onlab.packet.*,
diff --git a/apps/virtualbng/src/main/java/org/onosproject/virtualbng/IpAddressMapEntryCodec.java b/apps/virtualbng/src/main/java/org/onosproject/virtualbng/IpAddressMapEntryCodec.java
new file mode 100644
index 0000000..b2096b7
--- /dev/null
+++ b/apps/virtualbng/src/main/java/org/onosproject/virtualbng/IpAddressMapEntryCodec.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.virtualbng;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import java.util.Map.Entry;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+
+/**
+ * Codec for encoding a IP address mapping entry to JSON.
+ */
+public final class IpAddressMapEntryCodec extends JsonCodec<Entry<IpAddress, IpAddress>> {
+
+    @Override
+    public ObjectNode encode(Entry<IpAddress, IpAddress> entry, CodecContext context) {
+        checkNotNull(entry, "IP address map entry cannot be null");
+        final ObjectNode result = context.mapper().createObjectNode()
+                .put(entry.getKey().toString(), entry.getValue().toString());
+
+        return result;
+    }
+}
diff --git a/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngResource.java b/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngResource.java
index 2b0cd98..41bc5cc 100644
--- a/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngResource.java
+++ b/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngResource.java
@@ -17,20 +17,29 @@
 
 import static org.slf4j.LoggerFactory.getLogger;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import java.util.Map;
+
 import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 
 import org.onlab.packet.IpAddress;
-import org.onlab.rest.BaseResource;
+import org.onosproject.rest.AbstractWebResource;
 import org.slf4j.Logger;
 
 /**
  * This class provides REST services to virtual BNG.
  */
 @Path("privateip")
-public class VbngResource extends BaseResource {
+public class VbngResource extends AbstractWebResource {
 
     private final Logger log = getLogger(getClass());
 
@@ -81,4 +90,23 @@
             return "0";
         }
     }
+
+    @GET
+    @Path("map")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response privateIpDeleteNotification() {
+
+        log.info("Received vBNG IP address map request");
+
+        VbngConfigurationService vbngConfigurationService =
+                get(VbngConfigurationService.class);
+
+        Map<IpAddress, IpAddress> map =
+                vbngConfigurationService.getIpAddressMappings();
+        ObjectNode result = new ObjectMapper().createObjectNode();
+
+        result.set("map", new IpAddressMapEntryCodec().encode(map.entrySet(), this));
+
+        return ok(result.toString()).build();
+    }
 }
\ No newline at end of file