Committed by
Gerrit Code Review
Wrong Check and invalid check fix
Change-Id: I99e55295c68c073f4aa4c4d5c3218e5bc460e6cc
Showing
1 changed file
with
57 additions
and
66 deletions
| ... | @@ -269,42 +269,39 @@ public class TenantNetworkWebResource extends AbstractWebResource { | ... | @@ -269,42 +269,39 @@ public class TenantNetworkWebResource extends AbstractWebResource { |
| 269 | TenantNetwork network = null; | 269 | TenantNetwork network = null; |
| 270 | ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps | 270 | ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps |
| 271 | .newConcurrentMap(); | 271 | .newConcurrentMap(); |
| 272 | - if (node != null) { | 272 | + checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean"); |
| 273 | - checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean"); | 273 | + checkArgument(node.get("shared").isBoolean(), "shared should be boolean"); |
| 274 | - checkArgument(node.get("shared").isBoolean(), "shared should be boolean"); | 274 | + checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean"); |
| 275 | - checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean"); | 275 | + String name = node.get("name").asText(); |
| 276 | - String name = node.get("name").asText(); | 276 | + boolean adminStateUp = node.get("admin_state_up").asBoolean(); |
| 277 | - boolean adminStateUp = node.get("admin_state_up").asBoolean(); | 277 | + String state = node.get("status").asText(); |
| 278 | - String state = node.get("status").asText(); | 278 | + boolean shared = node.get("shared").asBoolean(); |
| 279 | - boolean shared = node.get("shared").asBoolean(); | 279 | + String tenantId = node.get("tenant_id").asText(); |
| 280 | - String tenantId = node.get("tenant_id").asText(); | 280 | + boolean routerExternal = node.get("router:external").asBoolean(); |
| 281 | - boolean routerExternal = node.get("router:external").asBoolean(); | 281 | + String type = node.get("provider:network_type").asText(); |
| 282 | - String type = node.get("provider:network_type").asText(); | 282 | + String physicalNetwork = node.get("provider:physical_network").asText(); |
| 283 | - String physicalNetwork = node.get("provider:physical_network") | 283 | + String segmentationId = node.get("provider:segmentation_id").asText(); |
| 284 | - .asText(); | 284 | + TenantNetworkId id = null; |
| 285 | - String segmentationId = node.get("provider:segmentation_id") | 285 | + if (flag.equals(CREATE_NETWORK)) { |
| 286 | - .asText(); | 286 | + id = TenantNetworkId.networkId(node.get("id").asText()); |
| 287 | - TenantNetworkId id = null; | 287 | + } else if (flag.equals(UPDATE_NETWORK)) { |
| 288 | - if (flag == CREATE_NETWORK) { | 288 | + id = networkId; |
| 289 | - id = TenantNetworkId.networkId(node.get("id").asText()); | ||
| 290 | - } else if (flag == UPDATE_NETWORK) { | ||
| 291 | - id = networkId; | ||
| 292 | - } | ||
| 293 | - network = new DefaultTenantNetwork( | ||
| 294 | - id, | ||
| 295 | - name, | ||
| 296 | - adminStateUp, | ||
| 297 | - isState(state), | ||
| 298 | - shared, | ||
| 299 | - TenantId.tenantId(tenantId), | ||
| 300 | - routerExternal, | ||
| 301 | - isType(type), | ||
| 302 | - PhysicalNetwork | ||
| 303 | - .physicalNetwork(physicalNetwork), | ||
| 304 | - SegmentationId | ||
| 305 | - .segmentationId(segmentationId)); | ||
| 306 | - networksMap.putIfAbsent(id, network); | ||
| 307 | } | 289 | } |
| 290 | + network = new DefaultTenantNetwork( | ||
| 291 | + id, | ||
| 292 | + name, | ||
| 293 | + adminStateUp, | ||
| 294 | + isState(state), | ||
| 295 | + shared, | ||
| 296 | + TenantId.tenantId(tenantId), | ||
| 297 | + routerExternal, | ||
| 298 | + isType(type), | ||
| 299 | + PhysicalNetwork | ||
| 300 | + .physicalNetwork(physicalNetwork), | ||
| 301 | + SegmentationId | ||
| 302 | + .segmentationId(segmentationId)); | ||
| 303 | + networksMap.putIfAbsent(id, network); | ||
| 304 | + | ||
| 308 | return Collections.unmodifiableCollection(networksMap.values()); | 305 | return Collections.unmodifiableCollection(networksMap.values()); |
| 309 | } | 306 | } |
| 310 | 307 | ||
| ... | @@ -319,38 +316,32 @@ public class TenantNetworkWebResource extends AbstractWebResource { | ... | @@ -319,38 +316,32 @@ public class TenantNetworkWebResource extends AbstractWebResource { |
| 319 | TenantNetwork network = null; | 316 | TenantNetwork network = null; |
| 320 | ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps | 317 | ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps |
| 321 | .newConcurrentMap(); | 318 | .newConcurrentMap(); |
| 322 | - if (nodes != null) { | 319 | + for (JsonNode node : nodes) { |
| 323 | - for (JsonNode node : nodes) { | 320 | + String id = node.get("id").asText(); |
| 324 | - String id = node.get("id").asText(); | 321 | + String name = node.get("name").asText(); |
| 325 | - String name = node.get("name").asText(); | 322 | + boolean adminStateUp = node.get("admin_state_up").asBoolean(); |
| 326 | - boolean adminStateUp = node.get("admin_state_up").asBoolean(); | 323 | + String state = node.get("status").asText(); |
| 327 | - String state = node.get("status").asText(); | 324 | + boolean shared = node.get("shared").asBoolean(); |
| 328 | - boolean shared = node.get("shared").asBoolean(); | 325 | + String tenantId = node.get("tenant_id").asText(); |
| 329 | - String tenantId = node.get("tenant_id").asText(); | 326 | + boolean routerExternal = node.get("router:external") |
| 330 | - boolean routerExternal = node.get("router:external") | 327 | + .asBoolean(); |
| 331 | - .asBoolean(); | 328 | + String type = node.get("provider:network_type").asText(); |
| 332 | - String type = node.get("provider:network_type").asText(); | 329 | + String physicalNetwork = node.get("provider:physical_network").asText(); |
| 333 | - String physicalNetwork = node.get("provider:physical_network") | 330 | + String segmentationId = node.get("provider:segmentation_id").asText(); |
| 334 | - .asText(); | 331 | + network = new DefaultTenantNetwork( |
| 335 | - String segmentationId = node.get("provider:segmentation_id") | 332 | + TenantNetworkId.networkId(id), |
| 336 | - .asText(); | 333 | + name, |
| 337 | - network = new DefaultTenantNetwork( | 334 | + adminStateUp, |
| 338 | - TenantNetworkId | 335 | + isState(state), |
| 339 | - .networkId(id), | 336 | + shared, |
| 340 | - name, | 337 | + TenantId.tenantId(tenantId), |
| 341 | - adminStateUp, | 338 | + routerExternal, |
| 342 | - isState(state), | 339 | + isType(type), |
| 343 | - shared, | 340 | + PhysicalNetwork.physicalNetwork(physicalNetwork), |
| 344 | - TenantId.tenantId(tenantId), | 341 | + SegmentationId.segmentationId(segmentationId)); |
| 345 | - routerExternal, | 342 | + networksMap.putIfAbsent(TenantNetworkId.networkId(id), network); |
| 346 | - isType(type), | ||
| 347 | - PhysicalNetwork | ||
| 348 | - .physicalNetwork(physicalNetwork), | ||
| 349 | - SegmentationId | ||
| 350 | - .segmentationId(segmentationId)); | ||
| 351 | - networksMap.putIfAbsent(TenantNetworkId.networkId(id), network); | ||
| 352 | - } | ||
| 353 | } | 343 | } |
| 344 | + | ||
| 354 | return Collections.unmodifiableCollection(networksMap.values()); | 345 | return Collections.unmodifiableCollection(networksMap.values()); |
| 355 | } | 346 | } |
| 356 | 347 | ... | ... |
-
Please register or login to post a comment