move vtnrsc.web from vtnrsc bundle to vtnweb bundle

Change-Id: I847da38f4ffeb88ef8d6e771b4560b652d979616
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java
new file mode 100644
index 0000000..4b6b662
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java
@@ -0,0 +1,40 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.AllocationPool;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Subnet AllocationPool codec.
+ */
+public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {
+
+    @Override
+    public ObjectNode encode(AllocationPool alocPool, CodecContext context) {
+        checkNotNull(alocPool, "AllocationPools cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("start", alocPool.startIp().toString())
+                .put("end", alocPool.endIp().toString());
+        return result;
+    }
+
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java
new file mode 100644
index 0000000..8ffc4e9
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java
@@ -0,0 +1,40 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * VirtualPort AllowedAddressPair codec.
+ */
+public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
+
+    @Override
+    public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
+        checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("ip_address", alocAddPair.ip().toString())
+                .put("mac_address", alocAddPair.mac().toString());
+        return result;
+    }
+
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java
new file mode 100644
index 0000000..559de68
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java
@@ -0,0 +1,40 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.FixedIp;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * VirtualPort FixedIp codec.
+ */
+public final class FixedIpCodec extends JsonCodec<FixedIp> {
+
+    @Override
+    public ObjectNode encode(FixedIp fixIp, CodecContext context) {
+        checkNotNull(fixIp, "FixedIp cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("subnet_id", fixIp.subnetId().toString())
+                .put("ip_address", fixIp.ip().toString());
+        return result;
+    }
+
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java
new file mode 100644
index 0000000..815a0d0
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java
@@ -0,0 +1,40 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.HostRoute;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Subnet HostRoute codec.
+ */
+public final class HostRoutesCodec extends JsonCodec<HostRoute> {
+
+    @Override
+    public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
+        checkNotNull(hostRoute, "HostRoute cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("nexthop", hostRoute.nexthop().toString())
+                .put("destination", hostRoute.destination().toString());
+        return result;
+    }
+
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java
new file mode 100644
index 0000000..18ed61b
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java
@@ -0,0 +1,39 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.SecurityGroup;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Virtualport SecurityGroup codec.
+ */
+public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {
+
+    @Override
+    public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {
+        checkNotNull(securGroup, "SecurityGroup cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("security_group", securGroup.securityGroup());
+        return result;
+    }
+
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java
new file mode 100644
index 0000000..e3d92fe
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java
@@ -0,0 +1,53 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.Subnet;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Subnet JSON codec.
+ */
+public final class SubnetCodec extends JsonCodec<Subnet> {
+    @Override
+    public ObjectNode encode(Subnet subnet, CodecContext context) {
+        checkNotNull(subnet, "Subnet cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("id", subnet.id().toString())
+                .put("gateway_ip", subnet.gatewayIp().toString())
+                .put("network_id", subnet.networkId().toString())
+                .put("name", subnet.subnetName())
+                .put("ip_version", subnet.ipVersion().toString())
+                .put("cidr", subnet.cidr().toString())
+                .put("shared", subnet.shared())
+                .put("enabled_dchp", subnet.dhcpEnabled())
+                .put("tenant_id", subnet.tenantId().toString())
+                .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null
+                          : subnet.ipV6AddressMode().toString())
+                .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null
+                          : subnet.ipV6RaMode().toString());
+        result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet
+                .allocationPools(), context));
+        result.set("host_routes",
+                   new HostRoutesCodec().encode(subnet.hostRoutes(), context));
+        return result;
+    }
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java
new file mode 100644
index 0000000..8adba03
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java
@@ -0,0 +1,47 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.TenantNetwork;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * TenantNetwork JSON codec.
+ */
+public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {
+
+    @Override
+    public ObjectNode encode(TenantNetwork network, CodecContext context) {
+        checkNotNull(network, "Network cannot be null");
+        ObjectNode result = context.mapper().createObjectNode()
+                .put("id", network.id().toString())
+                .put("name", network.name())
+                .put("admin_state_up", network.adminStateUp())
+                .put("status", "" + network.state())
+                .put("shared", network.shared())
+                .put("tenant_id", network.tenantId().toString())
+                .put("router:external", network.routerExternal())
+                .put("provider:network_type", "" + network.type())
+                .put("provider:physical_network", network.physicalNetwork().toString())
+                .put("provider:segmentation_id", network.segmentationId().toString());
+        return result;
+    }
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java
new file mode 100644
index 0000000..5cea532
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java
@@ -0,0 +1,57 @@
+/*
+ * 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.vtnweb.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.VirtualPort;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * VirtualPort JSON codec.
+ */
+public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
+    @Override
+    public ObjectNode encode(VirtualPort vPort, CodecContext context) {
+        checkNotNull(vPort, "VPort cannot be null");
+        ObjectNode result = context
+                .mapper()
+                .createObjectNode()
+                .put("id", vPort.portId().toString())
+                .put("network_id", vPort.networkId().toString())
+                .put("admin_state_up", vPort.adminStateUp())
+                .put("name", vPort.name())
+                .put("status", vPort.state().toString())
+                .put("mac_address", vPort.macAddress().toString())
+                .put("tenant_id", vPort.tenantId().toString())
+                .put("device_id", vPort.deviceId().toString())
+                .put("device_owner", vPort.deviceOwner())
+                .put("binding:vnic_type", vPort.bindingVnicType())
+                .put("binding:Vif_type", vPort.bindingVifType())
+                .put("binding:host_id", vPort.bindingHostId().toString())
+                .put("binding:vif_details", vPort.bindingVifDetails());
+        result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
+                                                                               vPort.allowedAddressPairs(), context));
+        result.set("fixed_ips", new FixedIpCodec().encode(
+                                                        vPort.fixedIps(), context));
+        result.set("security_groups", new SecurityGroupCodec().encode(
+                                                        vPort.securityGroups(), context));
+        return result;
+    }
+}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java
new file mode 100644
index 0000000..3a60943
--- /dev/null
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Codecs for virtual tenant objects.
+ */
+package org.onosproject.vtnweb.web;