mirror of https://github.com/apache/jclouds.git
Issue 27: stopped setting availability zone state as an enum, as it isn't required to be by spec
This commit is contained in:
parent
41e3ec6709
commit
23c9bbe33c
|
@ -33,28 +33,12 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
public class AvailabilityZoneInfo implements Comparable<AvailabilityZoneInfo>{
|
||||
|
||||
public static enum State {
|
||||
UNKNOWN, AVAILABLE;
|
||||
public String value() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static State fromValue(String state) {
|
||||
return valueOf(checkNotNull(state, "state").toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
private final String zone;
|
||||
private final State state;
|
||||
private final String state;
|
||||
private final String region;
|
||||
private final Set<String> messages = Sets.newHashSet();
|
||||
|
||||
public AvailabilityZoneInfo(String zone, State zoneState,
|
||||
public AvailabilityZoneInfo(String zone, String zoneState,
|
||||
String region, Iterable<String> messages) {
|
||||
this.zone = checkNotNull(zone, "zone");
|
||||
this.state = checkNotNull(zoneState, "zoneState");
|
||||
|
@ -72,7 +56,7 @@ public class AvailabilityZoneInfo implements Comparable<AvailabilityZoneInfo>{
|
|||
/**
|
||||
* State of the Availability Zone.
|
||||
*/
|
||||
public State getState() {
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Set;
|
|||
import javax.annotation.Resource;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
|
||||
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo.State;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -43,7 +42,7 @@ public class DescribeAvailabilityZonesResponseHandler extends
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
private String region;
|
||||
private State zoneState;
|
||||
private String zoneState;
|
||||
private boolean inMessageSet;
|
||||
private Set<String> messages = Sets.newHashSet();
|
||||
|
||||
|
@ -68,19 +67,13 @@ public class DescribeAvailabilityZonesResponseHandler extends
|
|||
region = "UNKNOWN";
|
||||
}
|
||||
} else if (qName.equals("zoneState")) {
|
||||
try {
|
||||
zoneState = AvailabilityZoneInfo.State.fromValue(currentText.toString().trim());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warn(e, "unsupported zoneState: %s", currentText.toString().trim());
|
||||
zoneState = AvailabilityZoneInfo.State.UNKNOWN;
|
||||
}
|
||||
zoneState = currentText.toString().trim();
|
||||
} else if (qName.equals("message")) {
|
||||
messages.add(currentText.toString().trim());
|
||||
} else if (qName.equals("messageSet")) {
|
||||
inMessageSet = false;
|
||||
} else if (qName.equals("item") && !inMessageSet) {
|
||||
availablilityZones.add(new AvailabilityZoneInfo(zone, zoneState, region,
|
||||
messages));
|
||||
availablilityZones.add(new AvailabilityZoneInfo(zone, zoneState, region, messages));
|
||||
this.zone = null;
|
||||
this.region = null;
|
||||
this.zoneState = null;
|
||||
|
|
|
@ -45,20 +45,15 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes
|
|||
|
||||
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
|
||||
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A,
|
||||
AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet
|
||||
.<String> of()),
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B,
|
||||
AvailabilityZoneInfo.State.AVAILABLE,
|
||||
Region.US_EAST_1, ImmutableSet.<String> of()),
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1,
|
||||
ImmutableSet.<String> of()), new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B,
|
||||
"available", Region.US_EAST_1, ImmutableSet.<String> of()),
|
||||
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C,
|
||||
AvailabilityZoneInfo.State.AVAILABLE, Region.US_EAST_1, ImmutableSet
|
||||
.<String> of("our service is awesome")),
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, "available", Region.US_EAST_1,
|
||||
ImmutableSet.<String> of("our service is awesome")),
|
||||
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D,
|
||||
AvailabilityZoneInfo.State.UNKNOWN, Region.US_EAST_1, ImmutableSet
|
||||
.<String> of()));
|
||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, "downlikeaclown", Region.US_EAST_1,
|
||||
ImmutableSet.<String> of()));
|
||||
Set<AvailabilityZoneInfo> result = factory.create(
|
||||
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);
|
||||
|
||||
|
|
Loading…
Reference in New Issue