http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java deleted file mode 100644 index 521d5a6..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Date; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.date.DateCodec; -import org.jclouds.date.DateCodecFactory; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.domain.RunningInstance.Builder; -import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult; -import org.jclouds.location.Region; -import org.xml.sax.Attributes; - -import com.google.common.base.Supplier; -import com.google.common.collect.Sets; - -/** - * - * @author Adrian Cole - */ -public abstract class BaseReservationHandler<T> extends HandlerForGeneratedRequestWithResult<T> { - - protected final DateCodec dateCodec; - protected final Supplier<String> defaultRegion; - - @Inject - public BaseReservationHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); - this.defaultRegion = defaultRegion; - } - - protected Builder<?> builder = newBuilder(); - - protected Builder<?> newBuilder() { - return RunningInstance.builder(); - } - - protected void inItem() { - if (endOfInstanceItem()) { - refineBuilderBeforeAddingInstance(); - instances.add(builder.build()); - builder = newBuilder(); - } - } - - protected StringBuilder currentText = new StringBuilder(); - protected int itemDepth; - protected boolean inInstancesSet; - protected boolean inProductCodes; - protected boolean inGroupSet; - - // attachments - private String volumeId; - private Attachment.Status attachmentStatus; - private Date attachTime; - private boolean deleteOnTermination; - private String deviceName; - - // reservation stuff - private Set<String> groupNames = Sets.newLinkedHashSet(); - private String ownerId; - private String requesterId; - private String reservationId; - - private Set<RunningInstance> instances = Sets.newLinkedHashSet(); - - - public void startElement(String uri, String name, String qName, Attributes attrs) { - if (equalsOrSuffix(qName, "item")) { - itemDepth++; - } else if (equalsOrSuffix(qName, "instancesSet")) { - inInstancesSet = true; - } else if (equalsOrSuffix(qName, "productCodes")) { - inProductCodes = true; - } else if (equalsOrSuffix(qName, "groupSet")) { - inGroupSet = true; - } - } - - public void endElement(String uri, String name, String qName) { - if (equalsOrSuffix(qName, "item")) { - inItem(); - itemDepth--; - } else if (equalsOrSuffix(qName, "instancesSet")) { - inInstancesSet = false; - } else if (equalsOrSuffix(qName, "productCodes")) { - inProductCodes = false; - } else if (equalsOrSuffix(qName, "groupSet")) { - inGroupSet = false; - } else if (equalsOrSuffix(qName, "groupId")) { - groupNames.add(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "ownerId")) { - ownerId = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "requesterId")) { - requesterId = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "reservationId")) { - reservationId = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "amiLaunchIndex")) { - builder.amiLaunchIndex(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "dnsName")) { - builder.dnsName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "imageId")) { - builder.imageId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "instanceId")) { - builder.instanceId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "name")) { - String rawState = currentOrNull(currentText); - if (rawState != null) { - builder.rawState(rawState); - builder.instanceState(InstanceState.fromValue(rawState)); - } - } else if (equalsOrSuffix(qName, "instanceType")) { - builder.instanceType(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "ipAddress")) { - builder.ipAddress(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "kernelId")) { - builder.kernelId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "keyName")) { - builder.keyName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "launchTime")) { - builder.launchTime(dateCodec.toDate(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "availabilityZone")) { - builder.availabilityZone(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "virtualizationType")) { - builder.virtualizationType(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "platform")) { - builder.platform(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "privateDnsName")) { - builder.privateDnsName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "privateIpAddress")) { - builder.privateIpAddress(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "ramdiskId")) { - builder.ramdiskId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "reason")) { - builder.reason(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "rootDeviceType")) { - builder.rootDeviceType(RootDeviceType.fromValue(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "rootDeviceName")) { - builder.rootDeviceName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "deviceName")) { - deviceName = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "volumeId")) { - volumeId = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "status")) { - attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim()); - } else if (equalsOrSuffix(qName, "attachTime")) { - attachTime = dateCodec.toDate(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "deleteOnTermination")) { - deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim()); - } else if (equalsOrSuffix(qName, "ebs")) { - builder.device(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination)); - this.deviceName = null; - this.volumeId = null; - this.attachmentStatus = null; - this.attachTime = null; - this.deleteOnTermination = true; - } - currentText = new StringBuilder(); - } - - - protected void refineBuilderBeforeAddingInstance() { - String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null; - builder.region((region == null) ? defaultRegion.get() : region); - builder.groupNames(groupNames); - } - - protected boolean endOfInstanceItem() { - return itemDepth <= 2 && inInstancesSet && !inProductCodes && !inGroupSet; - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected Reservation<? extends RunningInstance> newReservation() { - String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null; - if (region == null) - region = defaultRegion.get(); - Reservation<? extends RunningInstance> info = new Reservation<RunningInstance>(region, groupNames, instances, - ownerId, requesterId, reservationId); - this.groupNames = Sets.newLinkedHashSet(); - this.instances = Sets.newLinkedHashSet(); - this.ownerId = null; - this.requesterId = null; - this.reservationId = null; - return info; - } - -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java deleted file mode 100644 index fc5a33f..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.date.DateCodec; -import org.jclouds.date.DateCodecFactory; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.http.functions.ParseSax; - -import com.google.common.collect.Maps; -import com.google.inject.Inject; - -/** - * - * @author Adrian Cole - */ -public class BlockDeviceMappingHandler extends - ParseSax.HandlerWithResult<Map<String, BlockDevice>> { - private StringBuilder currentText = new StringBuilder(); - - private Map<String, BlockDevice> ebsBlockDevices = Maps.newHashMap(); - private String deviceName; - private String volumeId; - private boolean deleteOnTermination = true;// correct default is true. - private Attachment.Status attachmentStatus; - private Date attachTime; - - protected final DateCodec dateCodec; - - @Inject - public BlockDeviceMappingHandler(DateCodecFactory dateCodecFactory) { - this.dateCodec = dateCodecFactory.iso8601(); - } - - public Map<String, BlockDevice> getResult() { - return ebsBlockDevices; - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("deviceName")) { - deviceName = currentText.toString().trim(); - } else if (qName.equals("volumeId")) { - volumeId = currentText.toString().trim(); - } else if (qName.equals("deleteOnTermination")) { - deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim()); - } else if (qName.equals("status")) { - attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim()); - } else if (qName.equals("attachTime")) { - attachTime = dateCodec.toDate(currentText.toString().trim()); - } else if (qName.equals("item")) { - ebsBlockDevices.put(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination)); - this.volumeId = null; - this.deviceName = null; - this.deleteOnTermination = true; - this.attachmentStatus = null; - this.attachTime = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java deleted file mode 100644 index 35112d9..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import org.jclouds.http.functions.ParseSax; - -/** - * - * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeInstanceAttribute.html" - * /> - * @author Adrian Cole - */ -public class BooleanValueHandler extends ParseSax.HandlerWithResult<Boolean> { - - private StringBuilder currentText = new StringBuilder(); - private boolean value; - - public Boolean getResult() { - return value; - } - - public void endElement(String uri, String name, String qName) { - if (qName.equalsIgnoreCase("value")) { - this.value = Boolean.parseBoolean(currentText.toString().trim()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java deleted file mode 100644 index 2ffebc2..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Date; - -import javax.inject.Inject; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.date.DateCodec; -import org.jclouds.date.DateCodecFactory; -import org.jclouds.ec2.domain.BundleTask; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.location.Region; - -import com.google.common.base.Supplier; - -/** - * - * @author Adrian Cole - */ -public class BundleTaskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<BundleTask> { - protected final DateCodec dateCodec; - protected final Supplier<String> defaultRegion; - - @Inject - protected BundleTaskHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); - this.defaultRegion = defaultRegion; - } - - private StringBuilder currentText = new StringBuilder(); - - private String bundleId; - private String code; - private String message; - private String instanceId; - private int progress = 0; - private Date startTime; - private String state; - private String bucket; - private String prefix; - private Date updateTime; - - public BundleTask getResult() { - String region = AWSUtils.findRegionInArgsOrNull(getRequest()); - if (region == null) - region = defaultRegion.get(); - BundleTask.Error error = null; - if (code != null) - error = new BundleTask.Error(code, message); - BundleTask returnVal = new BundleTask(region, bundleId, error, instanceId, progress, startTime, - state, bucket, prefix, updateTime); - this.bundleId = null; - this.code = null; - this.message = null; - this.instanceId = null; - this.progress = 0; - this.startTime = null; - this.state = null; - this.bucket = null; - this.prefix = null; - this.updateTime = null; - return returnVal; - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("bundleId")) { - bundleId = currentText.toString().trim(); - } else if (qName.equals("code")) { - code = currentText.toString().trim(); - } else if (qName.equals("message")) { - message = currentText.toString().trim(); - } else if (qName.equals("instanceId")) { - instanceId = currentText.toString().trim(); - } else if (qName.equals("progress")) { - String temp = currentText.toString().trim(); - temp = temp.substring(0, temp.length() - 1); - progress = Integer.parseInt(temp); - } else if (qName.equals("startTime")) { - startTime = dateCodec.toDate(currentText.toString().trim()); - } else if (qName.equals("state")) { - state = currentText.toString().trim(); - } else if (qName.equals("bucket")) { - bucket = currentText.toString().trim(); - } else if (qName.equals("prefix")) { - prefix = currentText.toString().trim(); - } else if (qName.equals("updateTime")) { - updateTime = dateCodec.toDate(currentText.toString().trim()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java deleted file mode 100644 index ca1c77d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.date.DateCodec; -import org.jclouds.date.DateCodecFactory; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.location.Region; -import org.jclouds.location.Zone; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.xml.sax.Attributes; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * - * @author Adrian Cole - */ -public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Volume> { - protected final DateCodec dateCodec; - protected final Supplier<String> defaultRegion; - protected final Supplier<Map<String, Supplier<Set<String>>>> regionToZonesSupplier; - protected final Supplier<Set<String>> zonesSupplier; - - @Inject - protected CreateVolumeResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion, - @Zone Supplier<Map<String, Supplier<Set<String>>>> regionToZonesSupplier, - @Zone Supplier<Set<String>> zonesSupplier) { - this.dateCodec = dateCodecFactory.iso8601(); - this.defaultRegion = defaultRegion; - this.regionToZonesSupplier = regionToZonesSupplier; - this.zonesSupplier = zonesSupplier; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected String id; - protected int size; - protected String snapshotId; - protected String availabilityZone; - protected Volume.Status volumeStatus; - protected Date createTime; - protected Set<Attachment> attachments = Sets.newLinkedHashSet(); - - protected String volumeId; - protected String instanceId; - protected String device; - protected Attachment.Status attachmentStatus; - protected Date attachTime; - - protected boolean inAttachmentSet; - - protected String region; - - public Volume getResult() { - return newVolume(); - } - - public void startElement(String uri, String name, String qName, Attributes attrs) { - if (qName.equals("attachmentSet")) { - inAttachmentSet = true; - } - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("volumeId")) { - if (inAttachmentSet) { - volumeId = currentText.toString().trim(); - } else { - id = currentText.toString().trim(); - } - } else if (qName.equals("size")) { - size = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equals("availabilityZone")) { - availabilityZone = currentText.toString().trim(); - } else if (qName.equals("volumeId")) { - if (inAttachmentSet) { - volumeId = currentText.toString().trim(); - } else { - id = currentText.toString().trim(); - } - } else if (qName.equals("status")) { - if (inAttachmentSet) { - attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim()); - } else { - volumeStatus = Volume.Status.fromValue(currentText.toString().trim()); - } - } else if (qName.equals("createTime")) { - createTime = dateCodec.toDate(currentText.toString().trim()); - } else if (qName.equals("attachmentSet")) { - inAttachmentSet = false; - } else if (qName.equals("instanceId")) { - instanceId = currentText.toString().trim(); - } else if (qName.equals("snapshotId")) { - snapshotId = currentText.toString().trim(); - if (snapshotId.equals("")) - snapshotId = null; - } else if (qName.equals("device")) { - device = currentText.toString().trim(); - } else if (qName.equals("attachTime")) { - attachTime = dateCodec.toDate(currentText.toString().trim()); - } else if (qName.equals("item")) { - if (inAttachmentSet) { - attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime)); - volumeId = null; - instanceId = null; - device = null; - attachmentStatus = null; - attachTime = null; - } - - } - currentText = new StringBuilder(); - } - - private Volume newVolume() { - Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, attachments); - id = null; - size = 0; - snapshotId = null; - availabilityZone = null; - volumeStatus = null; - createTime = null; - attachments = Sets.newLinkedHashSet(); - return volume; - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - @Override - public CreateVolumeResponseHandler setContext(HttpRequest request) { - super.setContext(request); - region = AWSUtils.findRegionInArgsOrNull(getRequest()); - if (region == null) { - Set<String> zones = zonesSupplier.get(); - String zone = findAvailabilityZoneInArgsOrNull(getRequest(), zones); - if (zone != null) { - Map<String, Set<String>> regionToZones = Maps.transformValues(regionToZonesSupplier.get(), Suppliers - .<Set<String>> supplierFunction()); - for (Entry<String, Set<String>> entry : regionToZones.entrySet()) { - if (entry.getValue().contains(zone)) { - region = entry.getKey(); - break; - } - - } - checkNotNull(regionToZones, String.format("zone %s not in %s", zone, regionToZones)); - } else { - region = defaultRegion.get(); - } - } - return this; - } - - public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest gRequest, Set<String> zones) { - for (Object arg : gRequest.getInvocation().getArgs()) { - if (arg instanceof String) { - String zone = (String) arg; - if (zones.contains(zone)) - return zone; - } - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java deleted file mode 100644 index 731b8ff..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.ec2.domain.PublicIpInstanceIdPair; -import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult; -import org.jclouds.location.Region; -import org.jclouds.logging.Logger; - -import com.google.common.base.Supplier; -import com.google.common.collect.Sets; - -/** - * - * @author Adrian Cole - */ -public class DescribeAddressesResponseHandler extends - HandlerForGeneratedRequestWithResult<Set<PublicIpInstanceIdPair>> { - - @Resource - protected Logger logger = Logger.NULL; - private Set<PublicIpInstanceIdPair> pairs = Sets.newLinkedHashSet(); - private String ipAddress; - private StringBuilder currentText = new StringBuilder(); - @Inject - @Region - Supplier<String> defaultRegion; - private String instanceId; - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("publicIp")) { - ipAddress = currentOrNull(); - } else if (qName.equals("instanceId")) { - instanceId = currentOrNull(); - } else if (qName.equals("item")) { - String region = AWSUtils.findRegionInArgsOrNull(getRequest()); - if (region == null) - region = defaultRegion.get(); - pairs.add(new PublicIpInstanceIdPair(region, ipAddress, instanceId)); - ipAddress = null; - instanceId = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - @Override - public Set<PublicIpInstanceIdPair> getResult() { - return pairs; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java deleted file mode 100644 index 66d1403..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; - -import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.location.Region; -import org.jclouds.logging.Logger; -import org.xml.sax.Attributes; - -import com.google.common.base.Supplier; -import com.google.common.collect.Sets; - -/** - * - * @author Adrian Cole - */ -public class DescribeAvailabilityZonesResponseHandler extends ParseSax.HandlerWithResult<Set<AvailabilityZoneInfo>> { - private StringBuilder currentText = new StringBuilder(); - private final Supplier<String> defaultRegion; - - private Set<AvailabilityZoneInfo> availabilityZones = Sets.newLinkedHashSet(); - private String zone; - @Resource - protected Logger logger = Logger.NULL; - private String region; - private String zoneState; - private boolean inMessageSet; - private Set<String> messages = Sets.newHashSet(); - - /** - * clones like {@code openstack-nova-ec2}, which don't support multiple regions don't return region in the XML - * output. - */ - @Inject - DescribeAvailabilityZonesResponseHandler(@Region Supplier<String> defaultRegion) { - this.defaultRegion = defaultRegion; - } - - @Override - public void startDocument() { - region = defaultRegion.get(); - } - - public Set<AvailabilityZoneInfo> getResult() { - return availabilityZones; - } - - public void startElement(String uri, String name, String qName, Attributes attrs) { - if (qName.equals("messageSet")) { - inMessageSet = true; - } - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("zoneName")) { - zone = currentText.toString().trim(); - } else if (qName.equals("regionName")) { - try { - region = currentText.toString().trim(); - } catch (IllegalArgumentException e) { - logger.warn(e, "unsupported region: %s", currentText.toString().trim()); - region = "UNKNOWN"; - } - } else if (qName.equals("zoneState")) { - 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) { - availabilityZones.add(new AvailabilityZoneInfo(zone, zoneState, region, messages)); - this.zone = null; - this.region = defaultRegion.get(); - this.zoneState = null; - this.messages = Sets.newHashSet(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java deleted file mode 100644 index 1d826ce..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.ec2.domain.BundleTask; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.HandlerWithResult; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class DescribeBundleTasksResponseHandler extends ParseSax.HandlerWithResult<Set<BundleTask>> { - - private Set<BundleTask> bundleTasks = Sets.newLinkedHashSet(); - private final BundleTaskHandler bundleTaskHandler; - - @Inject - public DescribeBundleTasksResponseHandler(BundleTaskHandler bundleTaskHandler) { - this.bundleTaskHandler = bundleTaskHandler; - } - - public Set<BundleTask> getResult() { - return bundleTasks; - } - - @Override - public HandlerWithResult<Set<BundleTask>> setContext(HttpRequest request) { - bundleTaskHandler.setContext(request); - return super.setContext(request); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if (!qName.equals("item")) - bundleTaskHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equals("item")) { - bundleTasks.add(bundleTaskHandler.getResult()); - } - bundleTaskHandler.endElement(uri, localName, qName); - } - - public void characters(char ch[], int start, int length) { - bundleTaskHandler.characters(ch, start, length); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java deleted file mode 100644 index b55875a..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.ec2.domain.Hypervisor; -import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.ec2.domain.VirtualizationType; -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.ec2.domain.Image.EbsBlockDevice; -import org.jclouds.ec2.domain.Image.ImageState; -import org.jclouds.ec2.domain.Image.ImageType; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.location.Region; -import org.jclouds.logging.Logger; -import org.xml.sax.Attributes; - -import com.google.common.base.Supplier; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Parses the following XML document: - * <p/> - * DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" - * - * @author Adrian Cole - * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html" - * /> - */ -public class DescribeImagesResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Set<Image>> { - - @Inject - public DescribeImagesResponseHandler(@Region Supplier<String> defaultRegion, TagSetHandler tagSetHandler) { - this.defaultRegion = defaultRegion; - this.tagSetHandler = tagSetHandler; - } - - @Resource - protected Logger logger = Logger.NULL; - - protected Set<Image> contents = Sets.newLinkedHashSet(); - private StringBuilder currentText = new StringBuilder(); - private final Supplier<String> defaultRegion; - private final TagSetHandler tagSetHandler; - - private Architecture architecture; - private String name; - private String description; - private String imageId; - private String imageLocation; - private String imageOwnerId; - private ImageState imageState; - private String rawState; - private ImageType imageType; - private boolean isPublic; - private String kernelId; - private String platform; - private Set<String> productCodes = Sets.newHashSet(); - private String ramdiskId; - private boolean inProductCodes; - private boolean inBlockDeviceMapping; - private boolean inTagSet; - private RootDeviceType rootDeviceType = RootDeviceType.INSTANCE_STORE; - private Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap(); - private Map<String, String> tags = Maps.newLinkedHashMap(); - private String deviceName; - private String snapshotId; - private VirtualizationType virtualizationType = VirtualizationType.PARAVIRTUAL; - private Hypervisor hypervisor = Hypervisor.XEN; - - private int volumeSize; - private boolean deleteOnTermination = true;// correct default is true. - - private String rootDeviceName; - - public Set<Image> getResult() { - return contents; - } - - public void startElement(String uri, String name, String qName, Attributes attrs) { - if (qName.equals("productCodes")) { - inProductCodes = true; - } else if (qName.equals("blockDeviceMapping")) { - inBlockDeviceMapping = true; - } else if (equalsOrSuffix(qName, "tagSet")) { - inTagSet = true; - } - if (inTagSet) { - tagSetHandler.startElement(uri, name, qName, attrs); - } - } - - public void endElement(String uri, String name, String qName) { - if (equalsOrSuffix(qName, "tagSet")) { - inTagSet = false; - tags = tagSetHandler.getResult(); - } else if (inTagSet) { - tagSetHandler.endElement(uri, name, qName); - } - if (qName.equals("architecture")) { - architecture = Architecture.fromValue(currentText.toString().trim()); - // Nova Diablo uses the wrong name for this field - } else if (qName.equals("name") || qName.equals("displayName")) { - this.name = currentText.toString().trim(); - } else if (qName.equals("description")) { - description = currentText.toString().trim(); - } else if (qName.equals("imageId")) { - imageId = currentText.toString().trim(); - } else if (qName.equals("deviceName")) { - deviceName = currentText.toString().trim(); - } else if (qName.equals("imageLocation")) { - imageLocation = currentText.toString().trim(); - } else if (qName.equals("imageOwnerId")) { - imageOwnerId = currentText.toString().trim(); - } else if (qName.equals("imageState")) { - rawState = currentOrNull(currentText); - imageState = ImageState.fromValue(rawState); - } else if (qName.equals("imageType")) { - imageType = ImageType.fromValue(currentText.toString().trim()); - } else if (qName.equals("isPublic")) { - isPublic = Boolean.parseBoolean(currentText.toString().trim()); - } else if (qName.equals("kernelId")) { - kernelId = currentText.toString().trim(); - } else if (qName.equals("platform")) { - platform = currentText.toString().trim(); - } else if (qName.equals("productCode")) { - productCodes.add(currentText.toString().trim()); - } else if (qName.equals("productCodes")) { - inProductCodes = false; - } else if (qName.equals("blockDeviceMapping")) { - inBlockDeviceMapping = false; - } else if (qName.equals("snapshotId")) { - snapshotId = currentText.toString().trim(); - } else if (qName.equals("volumeSize")) { - volumeSize = Integer.parseInt(currentText.toString().trim()); - } else if (qName.equals("deleteOnTermination")) { - deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim()); - } else if (qName.equals("ramdiskId")) { - ramdiskId = currentText.toString().trim(); - } else if (qName.equals("rootDeviceType")) { - rootDeviceType = RootDeviceType.fromValue(currentText.toString().trim()); - } else if (qName.equals("rootDeviceName")) { - rootDeviceName = currentText.toString().trim(); - } else if (qName.equals("virtualizationType")) { - virtualizationType = VirtualizationType.fromValue(currentText.toString().trim()); - } else if (qName.equals("hypervisor")) { - hypervisor = Hypervisor.fromValue(currentText.toString().trim()); - } else if (qName.equals("item")) { - if (inBlockDeviceMapping) { - ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize, deleteOnTermination)); - this.deviceName = null; - this.snapshotId = null; - this.volumeSize = 0; - this.deleteOnTermination = true; - } else if (!inTagSet && !inProductCodes) { - try { - String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null; - if (region == null) - region = defaultRegion.get(); - contents.add(new Image(region, architecture, this.name, description, imageId, imageLocation, - imageOwnerId, imageState, rawState, imageType, isPublic, productCodes, kernelId, platform, - ramdiskId, rootDeviceType, rootDeviceName, ebsBlockDevices, tags, virtualizationType, hypervisor)); - } catch (NullPointerException e) { - logger.warn(e, "malformed image: %s", imageId); - } - this.name = null; - this.description = null; - this.architecture = null; - this.imageId = null; - this.imageLocation = null; - this.imageOwnerId = null; - this.imageState = null; - this.rawState = null; - this.imageType = null; - this.isPublic = false; - this.kernelId = null; - this.platform = null; - this.productCodes = Sets.newHashSet(); - this.ramdiskId = null; - this.rootDeviceType = RootDeviceType.INSTANCE_STORE; - this.rootDeviceName = null; - this.ebsBlockDevices = Maps.newHashMap(); - this.virtualizationType = VirtualizationType.PARAVIRTUAL; - this.hypervisor = Hypervisor.XEN; - } - - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - if (inTagSet) { - tagSetHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java deleted file mode 100644 index 2dc4c63..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.date.DateCodecFactory; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.location.Region; -import org.xml.sax.Attributes; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -/** - * Parses the following XML document: - * <p/> - * DescribeImagesResponse xmlns="http: - * - * @author Adrian Cole - * @see <a href="http: /> - */ -public class DescribeInstancesResponseHandler extends - BaseReservationHandler<Set<Reservation<? extends RunningInstance>>> { - private final TagSetHandler tagSetHandler; - private Builder<Reservation<? extends RunningInstance>> reservations = ImmutableSet - .<Reservation<? extends RunningInstance>> builder(); - private boolean inTagSet; - - @Inject - DescribeInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion, - TagSetHandler tagSetHandler) { - super(dateCodecFactory, defaultRegion); - this.tagSetHandler = tagSetHandler; - } - - @Override - public void startElement(String uri, String name, String qName, Attributes attrs) { - super.startElement(uri, name, qName, attrs); - if (equalsOrSuffix(qName, "tagSet")) { - inTagSet = true; - } - if (inTagSet) { - tagSetHandler.startElement(uri, name, qName, attrs); - } - } - - @Override - public void characters(char ch[], int start, int length) { - if (inTagSet) { - tagSetHandler.characters(ch, start, length); - } else { - super.characters(ch, start, length); - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (equalsOrSuffix(qName, "tagSet")) { - inTagSet = false; - builder.tags(tagSetHandler.getResult()); - } else if (inTagSet) { - tagSetHandler.endElement(uri, name, qName); - } - super.endElement(uri, name, qName); - } - - @Override - public Set<Reservation<? extends RunningInstance>> getResult() { - return reservations.build(); - } - - protected boolean endOfReservationItem() { - return itemDepth == 1; - } - - @Override - protected void inItem() { - if (endOfReservationItem()) { - reservations.add(super.newReservation()); - } else { - super.inItem(); - } - } - - protected boolean endOfInstanceItem() { - return itemDepth == 2 && inInstancesSet; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandler.java deleted file mode 100644 index aca734f..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.domain.KeyPair.Builder; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.location.Region; - -import com.google.common.base.Supplier; -import com.google.common.collect.Sets; - -/** - * Parses: DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" - * - * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html" - * /> - * @author Adrian Cole - */ -public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Set<KeyPair>> { - private final Supplier<String> defaultRegion; - private Builder builder; - - @Inject - public DescribeKeyPairsResponseHandler(@Region Supplier<String> defaultRegion) { - this.defaultRegion = defaultRegion; - } - - @Override - public void startDocument() { - builder = KeyPair.builder().region(defaultRegion.get()); - } - - private StringBuilder currentText = new StringBuilder(); - private Set<KeyPair> keyPairs = Sets.newLinkedHashSet(); - - public Set<KeyPair> getResult() { - return keyPairs; - } - - public void endElement(String uri, String name, String qName) { - - if (qName.equals("keyFingerprint")) { - builder.sha1OfPrivateKey(currentOrNull(currentText)); - } else if (qName.equals("item")) { - String region = AWSUtils.findRegionInArgsOrNull(getRequest()); - if (region != null) - builder.region(region); - try { - keyPairs.add(builder.build()); - } finally { - builder = KeyPair.builder().region(defaultRegion.get()); - } - } else if (qName.equals("keyName")) { - builder.keyName(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java deleted file mode 100644 index a9607fe..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.net.URI; -import java.util.Map; - -import javax.annotation.Resource; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; - -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -public class DescribeRegionsResponseHandler extends ParseSax.HandlerWithResult<Map<String, URI>> { - private StringBuilder currentText = new StringBuilder(); - - private Map<String, URI> regionEndpoints = Maps.newHashMap(); - private String region; - private URI regionEndpoint; - @Resource - protected Logger logger = Logger.NULL; - - public Map<String, URI> getResult() { - return regionEndpoints; - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("regionName")) { - String pending = currentText.toString().trim(); - if (pending.indexOf("Walrus") == -1) - region = pending; - // Nova uses regionUrl - } else if (qName.equals("regionEndpoint") || qName.equals("regionUrl")) { - String pending = currentText.toString().trim(); - if (pending.indexOf("Walrus") == -1) - regionEndpoint = URI.create(pending.startsWith("http") ? pending : String.format("https://%s", pending)); - } else if (qName.equals("item") && region != null && regionEndpoint != null) { - regionEndpoints.put(region, regionEndpoint); - this.region = null; - this.regionEndpoint = null; - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java deleted file mode 100644 index 8a00ac4..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -/** - * Parses: DescribeSecurityGroupsResponse - * xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" - * - * @see <a href= - * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribesecurityGroupInfo.html" - * /> - * @author Adrian Cole - */ -public class DescribeSecurityGroupsResponseHandler extends - ParseSax.HandlerForGeneratedRequestWithResult<Set<SecurityGroup>> { - - private final SecurityGroupHandler securityGroupHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder<SecurityGroup> securityGroups = ImmutableSet.<SecurityGroup> builder(); - private boolean inSecurityGroupInfo; - - protected int itemDepth; - - @Inject - public DescribeSecurityGroupsResponseHandler(SecurityGroupHandler securityGroupHandler) { - this.securityGroupHandler = securityGroupHandler; - } - - @Override - public HandlerForGeneratedRequestWithResult<Set<SecurityGroup>> setContext(HttpRequest request) { - securityGroupHandler.setContext(request); - return super.setContext(request); - } - - /** - * {@inheritDoc} - */ - @Override - public Set<SecurityGroup> getResult() { - return securityGroups.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "item")) { - itemDepth++; - } else if (equalsOrSuffix(qName, "securityGroupInfo")) { - inSecurityGroupInfo = true; - } - if (inSecurityGroupInfo) { - securityGroupHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "item")) { - endItem(uri, name, qName); - itemDepth--; - } else if (equalsOrSuffix(qName, "securityGroupInfo")) { - inSecurityGroupInfo = false; - } else if (inSecurityGroupInfo) { - securityGroupHandler.endElement(uri, name, qName); - } - currentText = new StringBuilder(); - } - - protected void endItem(String uri, String name, String qName) throws SAXException { - if (inSecurityGroupInfo) { - if (itemDepth == 1) - securityGroups.add(securityGroupHandler.getResult()); - else - securityGroupHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inSecurityGroupInfo) { - securityGroupHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java deleted file mode 100644 index a3c5870..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.ec2.domain.Snapshot; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class DescribeSnapshotsResponseHandler extends ParseSax.HandlerWithResult<Set<Snapshot>> { - - private Set<Snapshot> snapshots = Sets.newLinkedHashSet(); - private final SnapshotHandler snapshotHandler; - private int itemDepth = 0; - - @Inject - public DescribeSnapshotsResponseHandler(SnapshotHandler snapshotHandler) { - this.snapshotHandler = snapshotHandler; - } - - public Set<Snapshot> getResult() { - return snapshots; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) - throws SAXException { - itemDepth++; - snapshotHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - snapshotHandler.endElement(uri, localName, qName); - itemDepth--; - - if (qName.equals("item") && itemDepth == 2) { - this.snapshots.add(snapshotHandler.getResult()); - } - } - - public void characters(char ch[], int start, int length) { - snapshotHandler.characters(ch, start, length); - } - - @Override - public DescribeSnapshotsResponseHandler setContext(HttpRequest request) { - snapshotHandler.setContext(request); - super.setContext(request); - return this; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java deleted file mode 100644 index 20037d0..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.ec2.domain.Subnet; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html" >xml</a> - * - * @author Adrian Cole - * @author Andrew Bayer - */ -public class DescribeSubnetsResponseHandler extends - ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<Subnet>> { - private final SubnetHandler subnetHandler; - - private StringBuilder currentText = new StringBuilder(); - private boolean inSubnetSet; - private boolean inTagSet; - private Builder<Subnet> subnets = ImmutableSet.<Subnet> builder(); - - @Inject - public DescribeSubnetsResponseHandler(SubnetHandler subnetHandler) { - this.subnetHandler = subnetHandler; - } - - @Override - public FluentIterable<Subnet> getResult() { - return FluentIterable.from(subnets.build()); - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - if (equalsOrSuffix(qName, "subnetSet")) { - inSubnetSet = true; - } else if (inSubnetSet) { - if (equalsOrSuffix(qName, "tagSet")) { - inTagSet = true; - } - subnetHandler.startElement(url, name, qName, attributes); - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (equalsOrSuffix(qName, "subnetSet")) { - inSubnetSet = false; - } else if (equalsOrSuffix(qName, "tagSet")) { - inTagSet = false; - subnetHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "item") && !inTagSet) { - subnets.add(subnetHandler.getResult()); - } else if (inSubnetSet) { - subnetHandler.endElement(uri, name, qName); - } - - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - if (inSubnetSet) { - subnetHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java deleted file mode 100644 index 2824634..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.ec2.domain.Tag; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see <a - * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html" - * >xml</a> - * - * @author Adrian Cole - */ -public class DescribeTagsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<Tag>> { - - private final TagHandler tagHander; - - private StringBuilder currentText = new StringBuilder(); - private Builder<Tag> tags = ImmutableSet.<Tag> builder(); - private boolean inTags; - - @Inject - public DescribeTagsResponseHandler(TagHandler tagHander) { - this.tagHander = tagHander; - } - - /** - * {@inheritDoc} - */ - @Override - public FluentIterable<Tag> getResult() { - return FluentIterable.from(tags.build()); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "tagSet")) { - inTags = true; - } - if (inTags) { - tagHander.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "tagSet")) { - inTags = false; - } else if (equalsOrSuffix(qName, "item")) { - tags.add(tagHander.getResult()); - } else if (inTags) { - tagHander.endElement(uri, name, qName); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inTags) { - tagHander.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java deleted file mode 100644 index 7eb5c50..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.ec2.domain.Volume; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class DescribeVolumesResponseHandler extends ParseSax.HandlerWithResult<Set<Volume>> { - - private Set<Volume> volumes = Sets.newLinkedHashSet(); - private final CreateVolumeResponseHandler volumeHandler; - - private boolean inAttachmentSet; - - @Inject - public DescribeVolumesResponseHandler(CreateVolumeResponseHandler volumeHandler) { - this.volumeHandler = volumeHandler; - } - - public Set<Volume> getResult() { - return volumes; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) - throws SAXException { - if (qName.equals("attachmentSet")) { - inAttachmentSet = true; - } - volumeHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - volumeHandler.endElement(uri, localName, qName); - if (qName.equals("attachmentSet")) { - inAttachmentSet = false; - } else if (qName.equals("item") && !inAttachmentSet) { - this.volumes.add(volumeHandler.getResult()); - } - } - - public void characters(char ch[], int start, int length) { - volumeHandler.characters(ch, start, length); - } - - @Override - public DescribeVolumesResponseHandler setContext(HttpRequest request) { - volumeHandler.setContext(request); - super.setContext(request); - return this; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java deleted file mode 100644 index 7952c71..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; - -import java.util.regex.Pattern; - -import org.jclouds.http.functions.ParseSax; - -/** - * @author Andrew Kennedy - * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-GetConsoleOutput.html"> - * ApiReference query GetConsoleOutput</a> - */ -public class GetConsoleOutputResponseHandler extends ParseSax.HandlerWithResult<String> { - - private StringBuilder currentText = new StringBuilder(); - private String output; - - @Override - public String getResult() { - return output; - } - - private static final Pattern whitespace = Pattern.compile("\\s"); - - @Override - public void endElement(String uri, String name, String qName) { - if (qName.equalsIgnoreCase("output")) { - this.output = new String(base64().decode(whitespace.matcher(currentText).replaceAll("")), UTF_8); - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java deleted file mode 100644 index 26db141..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import javax.inject.Inject; - -import org.jclouds.date.DateCodec; -import org.jclouds.date.DateCodecFactory; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.http.functions.ParseSax; - -/** - * @author Richard Downer - */ -public class GetPasswordDataResponseHandler extends ParseSax.HandlerWithResult<PasswordData> { - protected final DateCodec dateCodec; - - - @Inject - protected GetPasswordDataResponseHandler(DateCodecFactory dateCodecFactory) { - this.dateCodec = dateCodecFactory.iso8601(); - } - - private StringBuilder currentText = new StringBuilder(); - private PasswordData.Builder builder = PasswordData.builder(); - - @Override - public PasswordData getResult() { - return builder.build(); - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("instanceId")) { - builder.instanceId(currentText.toString().trim()); - } else if (qName.equals("timestamp")) { - builder.timestamp(dateCodec.toDate(currentText.toString().trim())); - } else if (qName.equals("passwordData")) { - builder.passwordData(currentText.toString().trim()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java deleted file mode 100644 index 1c5a50d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ec2.xml; - -import org.jclouds.http.functions.ParseSax; - -/** - * - * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-RegisterImage.html" - * /> - * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-CreateImage.html" - * /> - * @author Adrian Cole - */ -public class ImageIdHandler extends ParseSax.HandlerWithResult<String> { - - private StringBuilder currentText = new StringBuilder(); - private String imageId; - - public String getResult() { - return imageId; - } - - public void endElement(String uri, String name, String qName) { - - if (qName.equalsIgnoreCase("ImageId")) { - this.imageId = currentText.toString().trim(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -}
