throws RemoteException {
final DescribeAvailabilityZonesResponseType response =
new DescribeAvailabilityZonesResponseType();
final AvailabilityZoneSetType availabilityZoneSetType =
new AvailabilityZoneSetType();
response.setAvailabilityZoneInfo(availabilityZoneSetType);
final String[] zoneNames = this.zoneNames();
if (zoneNames == null || zoneNames.length == 0) {
availabilityZoneSetType.setItem(new AvailabilityZoneItemType[0]);
return response;
}
// this is pretty awesome
final List scopedQuery = new LinkedList();
if (describeAvailabilityZonesRequestMsg != null) {
final DescribeAvailabilityZonesSetType availabilityZoneSet =
describeAvailabilityZonesRequestMsg.getAvailabilityZoneSet();
if (availabilityZoneSet != null) {
final DescribeAvailabilityZonesSetItemType[] item =
availabilityZoneSet.getItem();
if (item != null) {
for (int i = 0; i < item.length; i++) {
final DescribeAvailabilityZonesSetItemType
describeAvailabilityZonesSetItemType = item[i];
if (describeAvailabilityZonesSetItemType != null) {
final String zone =
describeAvailabilityZonesSetItemType
.getZoneName();
if (zone != null) {
for (int j = 0; j < zoneNames.length; j++) {
final String zoneName = zoneNames[j];
if (zoneName.equals(zone)) {
scopedQuery.add(zone);
break;
}
}
}
}
}
}
}
}
final AvailabilityZoneItemType[] azits;
if (scopedQuery.isEmpty()) {
azits = new AvailabilityZoneItemType[zoneNames.length];
for (int i = 0; i < zoneNames.length; i++) {
final String zoneName = zoneNames[i];
azits[i] = this.getOneZone(zoneName);
}
} else {
azits = new AvailabilityZoneItemType[scopedQuery.size()];
int idx = 0;
final Iterator iter = scopedQuery.iterator();
while (iter.hasNext()) {
azits[idx] = this.getOneZone((String)iter.next());
idx += 1;
if (idx == zoneNames.length) {
break;
}
}
}
availabilityZoneSetType.setItem(azits);
return response;
}