jiangrui
Committed by Gerrit Code Review

[ONOS-2736] Fix bug of getting json from subnet.

Change-Id: I386f622fba74f0303a5ed9e6820ebc68a817021d
......@@ -32,15 +32,19 @@ public final class SubnetCodec extends JsonCodec<Subnet> {
checkNotNull(subnet, "Subnet cannot be null");
ObjectNode result = context.mapper().createObjectNode()
.put("id", subnet.id().toString())
.put("gate_ip", subnet.gatewayIp().toString())
.put("gateway_ip", subnet.gatewayIp().toString())
.put("network_id", subnet.networkId().toString())
.put("name", subnet.subnetName().toString())
.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());
result.set("alloction_pools", new AllocationPoolsCodec().encode(subnet
.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));
......
......@@ -226,8 +226,8 @@ public class SubnetWebResource extends AbstractWebResource {
*/
public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
checkNotNull(subnetNodes, JSON_NOT_NULL);
checkArgument(!subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
checkArgument(!subnetNodes.get("shared").isBoolean(), "shared should be boolean");
checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
if (!subnetNodes.hasNonNull("id")) {
return null;
......
......@@ -269,9 +269,9 @@ public class TenantNetworkWebResource extends AbstractWebResource {
ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
.newConcurrentMap();
if (node != null) {
checkArgument(!node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
checkArgument(!node.get("shared").isBoolean(), "shared should be boolean");
checkArgument(!node.get("router:external").isBoolean(), "router:external should be boolean");
checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
checkArgument(node.get("shared").isBoolean(), "shared should be boolean");
checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");
String name = node.get("name").asText();
boolean adminStateUp = node.get("admin_state_up").asBoolean();
String state = node.get("status").asText();
......
......@@ -15,6 +15,7 @@
*/
package org.onosproject.vtnweb.resources;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
import static javax.ws.rs.core.Response.Status.OK;
......@@ -209,6 +210,7 @@ public class VirtualPortWebResource extends AbstractWebResource {
.asText());
TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
.get("network_id").asText());
checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
String state = vPortnode.get("status").asText();
MacAddress macAddress = MacAddress.valueOf(vPortnode
......