From cc147a6ec609b5d8fea549e56b16a256a03d358f Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 21 Dec 2011 22:26:03 -0800 Subject: [PATCH] fixed cidr list parse error --- .../cloudstack/domain/PortForwardingRule.java | 16 +++++----------- .../resources/listipforwardingrulesresponse.json | 3 ++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java index bea2c6155a..105e926f9e 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java @@ -18,10 +18,10 @@ */ package org.jclouds.cloudstack.domain; -import java.util.Collections; -import java.util.HashSet; import java.util.Set; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -137,18 +137,12 @@ public class PortForwardingRule implements Comparable { @SerializedName("virtualmachinename") private String virtualMachineName; @SerializedName("cidrlist") - private Set CIDRs = ImmutableSet.of(); + private String CIDRs = ""; @SerializedName("privateendport") private int privateEndPort; @SerializedName("publicendport") private int publicEndPort; - - // for deserializer - PortForwardingRule() { - - } - public PortForwardingRule(long id, String iPAddress, long iPAddressId, int privatePort, String protocol, int publicPort, String state, String virtualMachineDisplayName, long virtualMachineId, String virtualMachineName, Set CIDRs, int privateEndPort, int publicEndPort) { @@ -162,7 +156,7 @@ public class PortForwardingRule implements Comparable { this.virtualMachineDisplayName = virtualMachineDisplayName; this.virtualMachineId = virtualMachineId; this.virtualMachineName = virtualMachineName; - this.CIDRs = new HashSet(CIDRs); + this.CIDRs = Joiner.on(' ').join(CIDRs); this.privateEndPort = privateEndPort; this.publicEndPort = publicEndPort; } @@ -246,7 +240,7 @@ public class PortForwardingRule implements Comparable { * @return the cidr list to forward traffic from */ public Set getCIDRs() { - return Collections.unmodifiableSet(CIDRs); + return ImmutableSet.copyOf(Splitter.on(' ').split(CIDRs)); } /** diff --git a/apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json b/apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json index 984f6ee4b6..8f1f4e2dfe 100644 --- a/apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json +++ b/apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json @@ -11,7 +11,8 @@ "ipaddress": "10.27.27.64", "startport": 22, "endport": 22, - "state": "Active" + "state": "Active", + "cidrlist":"" }] } }