fixed cidr list parse error

This commit is contained in:
Adrian Cole 2011-12-21 22:26:03 -08:00
parent d1f4339c84
commit cc147a6ec6
2 changed files with 7 additions and 12 deletions

View File

@ -18,10 +18,10 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set; 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.common.collect.ImmutableSet;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -137,18 +137,12 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
@SerializedName("virtualmachinename") @SerializedName("virtualmachinename")
private String virtualMachineName; private String virtualMachineName;
@SerializedName("cidrlist") @SerializedName("cidrlist")
private Set<String> CIDRs = ImmutableSet.of(); private String CIDRs = "";
@SerializedName("privateendport") @SerializedName("privateendport")
private int privateEndPort; private int privateEndPort;
@SerializedName("publicendport") @SerializedName("publicendport")
private int publicEndPort; private int publicEndPort;
// for deserializer
PortForwardingRule() {
}
public PortForwardingRule(long id, String iPAddress, long iPAddressId, int privatePort, String protocol, public PortForwardingRule(long id, String iPAddress, long iPAddressId, int privatePort, String protocol,
int publicPort, String state, String virtualMachineDisplayName, long virtualMachineId, int publicPort, String state, String virtualMachineDisplayName, long virtualMachineId,
String virtualMachineName, Set<String> CIDRs, int privateEndPort, int publicEndPort) { String virtualMachineName, Set<String> CIDRs, int privateEndPort, int publicEndPort) {
@ -162,7 +156,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
this.virtualMachineDisplayName = virtualMachineDisplayName; this.virtualMachineDisplayName = virtualMachineDisplayName;
this.virtualMachineId = virtualMachineId; this.virtualMachineId = virtualMachineId;
this.virtualMachineName = virtualMachineName; this.virtualMachineName = virtualMachineName;
this.CIDRs = new HashSet<String>(CIDRs); this.CIDRs = Joiner.on(' ').join(CIDRs);
this.privateEndPort = privateEndPort; this.privateEndPort = privateEndPort;
this.publicEndPort = publicEndPort; this.publicEndPort = publicEndPort;
} }
@ -246,7 +240,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
* @return the cidr list to forward traffic from * @return the cidr list to forward traffic from
*/ */
public Set<String> getCIDRs() { public Set<String> getCIDRs() {
return Collections.unmodifiableSet(CIDRs); return ImmutableSet.copyOf(Splitter.on(' ').split(CIDRs));
} }
/** /**

View File

@ -11,7 +11,8 @@
"ipaddress": "10.27.27.64", "ipaddress": "10.27.27.64",
"startport": 22, "startport": 22,
"endport": 22, "endport": 22,
"state": "Active" "state": "Active",
"cidrlist":""
}] }]
} }
} }