You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/04/02 11:14:25 UTC
[13/25] forking jclouds ec2 api
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..2dc4c63
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java
@@ -0,0 +1,109 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..aca734f
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandler.java
@@ -0,0 +1,84 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..a9607fe
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java
@@ -0,0 +1,67 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..8a00ac4
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java
@@ -0,0 +1,126 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..a3c5870
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java
@@ -0,0 +1,76 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..20037d0
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java
@@ -0,0 +1,91 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..2824634
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java
@@ -0,0 +1,99 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..7eb5c50
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java
@@ -0,0 +1,79 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..7952c71
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java
@@ -0,0 +1,55 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..26db141
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java
@@ -0,0 +1,61 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..1c5a50d
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java
@@ -0,0 +1,49 @@
+/*
+ * 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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java
new file mode 100644
index 0000000..7111a61
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java
@@ -0,0 +1,48 @@
+/*
+ * 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.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
+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 InstanceInitiatedShutdownBehaviorHandler extends
+ ParseSax.HandlerWithResult<InstanceInitiatedShutdownBehavior> {
+
+ private StringBuilder currentText = new StringBuilder();
+ private InstanceInitiatedShutdownBehavior behavior;
+
+ public InstanceInitiatedShutdownBehavior getResult() {
+ return behavior;
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equalsIgnoreCase("value")) {
+ this.behavior = InstanceInitiatedShutdownBehavior.fromValue(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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java
new file mode 100644
index 0000000..9c8933f
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java
@@ -0,0 +1,112 @@
+/*
+ * 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.aws.util.AWSUtils;
+import org.jclouds.ec2.domain.InstanceState;
+import org.jclouds.ec2.domain.InstanceStateChange;
+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;
+
+/**
+ * Parses the following XML document:
+ * <p/>
+ * TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/"
+ * StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" StopInstancesResponse
+ * xmlns="http://ec2.amazonaws.com/doc/2010-08-31/"
+ *
+ * @author Adrian Cole
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-TerminateInstancesResponseInfoType.html"
+ * />
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-StartInstancesResponseInfoType.html"
+ * />
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-StopInstancesResponseInfoType.html"
+ * />
+ */
+public class InstanceStateChangeHandler extends
+ HandlerForGeneratedRequestWithResult<Set<InstanceStateChange>> {
+ private StringBuilder currentText = new StringBuilder();
+ @Inject
+ @Region
+ Supplier<String> defaultRegion;
+
+ Set<InstanceStateChange> instances = Sets.newLinkedHashSet();
+ private InstanceState shutdownState;
+ private InstanceState previousState;
+ private String instanceId;
+
+ private boolean inCurrentState;
+
+ private boolean inPreviousState;
+
+ @Override
+ public Set<InstanceStateChange> getResult() {
+ return instances;
+ }
+
+ public void startElement(String uri, String name, String qName, Attributes attrs) {
+ if (qName.equals("shutdownState") || qName.equals("currentState")) {
+ inCurrentState = true;
+ } else if (qName.equals("previousState")) {
+ inPreviousState = true;
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+
+ if (qName.equals("instanceId")) {
+ this.instanceId = currentOrNull();
+ } else if (qName.equals("shutdownState") || qName.equals("currentState")) {
+ inCurrentState = false;
+ } else if (qName.equals("previousState")) {
+ inPreviousState = false;
+ } else if (qName.equals("name")) {
+ if (inCurrentState) {
+ shutdownState = InstanceState.fromValue(currentOrNull());
+ } else if (inPreviousState) {
+ previousState = InstanceState.fromValue(currentOrNull());
+ }
+ } else if (qName.equals("item")) {
+ String region = AWSUtils.findRegionInArgsOrNull(getRequest());
+ if (region == null)
+ region = defaultRegion.get();
+ instances.add(new InstanceStateChange(region, instanceId, shutdownState, previousState));
+ this.instanceId = null;
+ this.shutdownState = null;
+ this.previousState = null;
+ }
+
+ currentText = new StringBuilder();
+ }
+
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+ protected String currentOrNull() {
+ String returnVal = currentText.toString().trim();
+ return returnVal.equals("") ? null : returnVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java
new file mode 100644
index 0000000..b0ea53e
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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 InstanceTypeHandler extends
+ ParseSax.HandlerWithResult<String> {
+
+ private StringBuilder currentText = new StringBuilder();
+ private String type;
+
+ public String getResult() {
+ return type;
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equalsIgnoreCase("value")) {
+ this.type = 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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java
new file mode 100644
index 0000000..980ef35
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java
@@ -0,0 +1,94 @@
+/*
+ * 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 org.jclouds.http.functions.ParseSax;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class IpPermissionHandler extends ParseSax.HandlerForGeneratedRequestWithResult<IpPermission> {
+
+ private StringBuilder currentText = new StringBuilder();
+ private IpPermission.Builder builder = IpPermission.builder();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IpPermission getResult() {
+ try {
+ return builder.build();
+ } finally {
+ builder = IpPermission.builder();
+ }
+ }
+
+ private String userId;
+ private String groupId;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void endElement(String uri, String name, String qName) throws SAXException {
+ if (equalsOrSuffix(qName, "ipProtocol")) {
+ // Algorete: ipProtocol can be an empty tag on EC2 clone (e.g.
+ // OpenStack EC2)
+ builder.ipProtocol(IpProtocol.fromValue(currentOrNegative(currentText)));
+ } else if (equalsOrSuffix(qName, "fromPort")) {
+ // Algorete: fromPort can be an empty tag on EC2 clone (e.g. OpenStack
+ // EC2)
+ builder.fromPort(Integer.parseInt(currentOrNegative(currentText)));
+ } else if (equalsOrSuffix(qName, "toPort")) {
+ // Algorete: toPort can be an empty tag on EC2 clone (e.g. OpenStack
+ // EC2)
+ builder.toPort(Integer.parseInt(currentOrNegative(currentText)));
+ } else if (equalsOrSuffix(qName, "cidrIp")) {
+ builder.cidrBlock(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "userId")) {
+ this.userId = currentOrNull(currentText);
+ } else if (equalsOrSuffix(qName, "groupName") || equalsOrSuffix(qName, "groupId")) {
+ this.groupId = currentOrNull(currentText);
+ } else if (equalsOrSuffix(qName, "item")) {
+ if (userId != null && groupId != null)
+ builder.tenantIdGroupNamePair(userId, groupId);
+ userId = groupId = null;
+ }
+ currentText = new StringBuilder();
+ }
+
+ private static String currentOrNegative(StringBuilder currentText) {
+ String returnVal = currentText.toString().trim();
+ return returnVal.equals("") ? "-1" : returnVal;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java
new file mode 100644
index 0000000..9f0d305
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java
@@ -0,0 +1,79 @@
+/*
+ * 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 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;
+
+/**
+ *
+ * @see <a href=
+ * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html"
+ * />
+ * @author Adrian Cole
+ */
+public class KeyPairResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<KeyPair> {
+ private final Supplier<String> defaultRegion;
+ private Builder builder;
+
+ @Inject
+ public KeyPairResponseHandler(@Region Supplier<String> defaultRegion) {
+ this.defaultRegion = defaultRegion;
+ }
+
+ @Override
+ public void startDocument() {
+ builder = KeyPair.builder().region(defaultRegion.get());
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+
+ public KeyPair getResult() {
+ String region = AWSUtils.findRegionInArgsOrNull(getRequest());
+ if (region != null)
+ builder.region(region);
+ try {
+ return builder.build();
+ } finally {
+ builder = KeyPair.builder().region(defaultRegion.get());
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equals("keyFingerprint")) {
+ builder.sha1OfPrivateKey(currentOrNull(currentText));
+ } else if (qName.equals("keyMaterial")) {
+ builder.keyMaterial(currentOrNull(currentText));
+ } 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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java
new file mode 100644
index 0000000..08e088a
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java
@@ -0,0 +1,55 @@
+/*
+ * 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 org.jclouds.ec2.domain.Permission;
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.collect.Sets;
+
+/**
+ *
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImageAttribute.html"
+ * />
+ * @author Adrian Cole
+ */
+public class PermissionHandler extends ParseSax.HandlerWithResult<Permission> {
+
+ private StringBuilder currentText = new StringBuilder();
+ private Set<String> userIds = Sets.newHashSet();
+ private Set<String> groups = Sets.newHashSet();
+
+ public Permission getResult() {
+ return new Permission(userIds, groups);
+ }
+
+ public void endElement(String uri, String name, String qName) {
+
+ if (qName.equalsIgnoreCase("group")) {
+ groups.add(currentText.toString().trim());
+ } else if (qName.equalsIgnoreCase("userId")) {
+ userIds.add(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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java
new file mode 100644
index 0000000..22a9193
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java
@@ -0,0 +1,48 @@
+/*
+ * 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.DateCodecFactory;
+import org.jclouds.ec2.domain.Reservation;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Supplier;
+
+/**
+ * Parses the following XML document:
+ * <p/>
+ * RunInstancesResponse xmlns="http:
+ *
+ * @author Adrian Cole
+ * @see <a href="http: />
+ */
+public class RunInstancesResponseHandler extends BaseReservationHandler<Reservation<? extends RunningInstance>> {
+
+ @Inject
+ public RunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
+ super(dateCodecFactory, defaultRegion);
+ }
+
+ @Override
+ public Reservation<? extends RunningInstance> getResult() {
+ return newReservation();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java
new file mode 100644
index 0000000..bd7db04
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java
@@ -0,0 +1,143 @@
+/*
+ * 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 org.jclouds.aws.util.AWSUtils;
+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.jclouds.location.Region;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+/**
+ * @author Adrian Cole
+ */
+public class SecurityGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult<SecurityGroup> {
+
+ protected final IpPermissionHandler ipPermissionHandler;
+ protected final Supplier<String> defaultRegion;
+
+ protected StringBuilder currentText = new StringBuilder();
+ protected SecurityGroup.Builder<?> builder;
+ protected boolean inIpPermissions;
+
+ protected int itemDepth;
+
+ protected String region;
+
+ @Inject
+ public SecurityGroupHandler(IpPermissionHandler ipPermissionHandler, @Region Supplier<String> defaultRegion) {
+ this.ipPermissionHandler = ipPermissionHandler;
+ this.defaultRegion = defaultRegion;
+ }
+
+ protected SecurityGroup.Builder<?> builder() {
+ return SecurityGroup.builder().region(region);
+ }
+
+ @Override
+ public HandlerForGeneratedRequestWithResult<SecurityGroup> setContext(HttpRequest request) {
+ region = AWSUtils.findRegionInArgsOrNull(GeneratedHttpRequest.class.cast(request));
+ if (region == null)
+ region = defaultRegion.get();
+ builder = builder();
+ return super.setContext(request);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public SecurityGroup getResult() {
+ try {
+ return builder.build();
+ } finally {
+ builder = builder();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
+ if (equalsOrSuffix(qName, "item")) {
+ itemDepth++;
+ } else if (equalsOrSuffix(qName, "ipPermissions")) {
+ inIpPermissions = true;
+ }
+ if (inIpPermissions) {
+ ipPermissionHandler.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, "ipPermissions")) {
+ inIpPermissions = false;
+ itemDepth = 0;
+ } else if (inIpPermissions) {
+ ipPermissionHandler.endElement(uri, name, qName);
+ } else if (equalsOrSuffix(qName, "groupName")) {
+ builder.name(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "groupId")) {
+ builder.id(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "ownerId")) {
+ builder.ownerId(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "groupDescription")) {
+ builder.description(currentOrNull(currentText));
+ }
+ currentText = new StringBuilder();
+ }
+
+ protected void endItem(String uri, String name, String qName) throws SAXException {
+ if (inIpPermissions) {
+ if (itemDepth == 2)
+ builder.ipPermission(ipPermissionHandler.getResult());
+ else
+ ipPermissionHandler.endElement(uri, name, qName);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inIpPermissions) {
+ ipPermissionHandler.characters(ch, start, length);
+ } else {
+ currentText.append(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java
new file mode 100644
index 0000000..3d49aa6
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java
@@ -0,0 +1,107 @@
+/*
+ * 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.Snapshot;
+import org.jclouds.ec2.domain.Snapshot.Status;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.location.Region;
+
+import com.google.common.base.Supplier;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class SnapshotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Snapshot> {
+ private StringBuilder currentText = new StringBuilder();
+
+ protected final DateCodec dateCodec;
+ protected final Supplier<String> defaultRegion;
+
+ private String id;
+ private String volumeId;
+ private int volumeSize;
+ private Status status;
+ private Date startTime;
+ private int progress;
+ private String ownerId;
+ private String description;
+ private String ownerAlias;
+
+ @Inject
+ public SnapshotHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
+ this.dateCodec = dateCodecFactory.iso8601();
+ this.defaultRegion = defaultRegion;
+ }
+
+ public Snapshot getResult() {
+ String region = AWSUtils.findRegionInArgsOrNull(getRequest());
+ if (region == null)
+ region = defaultRegion.get();
+ Snapshot snapshot = new Snapshot(region, id, volumeId, volumeSize, status, startTime,
+ progress, ownerId, description, ownerAlias);
+ this.id = null;
+ this.volumeId = null;
+ this.volumeSize = 0;
+ this.status = null;
+ this.startTime = null;
+ this.progress = 0;
+ this.ownerId = null;
+ this.description = null;
+ this.ownerAlias = null;
+ return snapshot;
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equals("snapshotId")) {
+ id = currentText.toString().trim();
+ } else if (qName.equals("volumeId")) {
+ volumeId = currentText.toString().trim();
+ } else if (qName.equals("volumeSize")) {
+ volumeSize = Integer.parseInt(currentText.toString().trim());
+ } else if (qName.equals("status")) {
+ status = Snapshot.Status.fromValue(currentText.toString().trim());
+ } else if (qName.equals("startTime")) {
+ startTime = dateCodec.toDate(currentText.toString().trim());
+ } else if (qName.equals("progress")) {
+ String progressString = currentText.toString().trim();
+ if (!progressString.equals("")) {
+ progressString = progressString.substring(0, progressString.length() - 1);
+ progress = Integer.parseInt(progressString);
+ }
+ } else if (qName.equals("ownerId")) {
+ ownerId = currentText.toString().trim();
+ } else if (qName.equals("description")) {
+ description = currentText.toString().trim();
+ } else if (qName.equals("ownerAlias")) {
+ ownerAlias = 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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java
new file mode 100644
index 0000000..054b9f4
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java
@@ -0,0 +1,47 @@
+/*
+ * 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 StringValueHandler extends
+ ParseSax.HandlerWithResult<String> {
+
+ private StringBuilder currentText = new StringBuilder();
+ private String value;
+
+ public String getResult() {
+ return value;
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equalsIgnoreCase("value")) {
+ this.value = 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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java
new file mode 100644
index 0000000..6b3ca5d
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java
@@ -0,0 +1,95 @@
+/*
+ * 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 javax.inject.Inject;
+
+import org.jclouds.ec2.domain.Subnet;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+/**
+ * @see <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SubnetType.html" >xml</a>
+ *
+ * @author Adrian Cole
+ * @author Andrew Bayer
+ */
+public class SubnetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Subnet> {
+ private StringBuilder currentText = new StringBuilder();
+ private Subnet.Builder builder = Subnet.builder();
+ private final TagSetHandler tagSetHandler;
+ private boolean inTagSet;
+
+ @Inject
+ public SubnetHandler(TagSetHandler tagSetHandler) {
+ this.tagSetHandler = tagSetHandler;
+ }
+
+ @Override
+ public Subnet getResult() {
+ try {
+ return builder.build();
+ } finally {
+ builder = Subnet.builder();
+ }
+ }
+
+ @Override
+ public void startElement(String uri, String name, String qName, Attributes attrs) {
+ if (equalsOrSuffix(qName, "tagSet")) {
+ inTagSet = true;
+ }
+ if (inTagSet) {
+ tagSetHandler.startElement(uri, name, qName, attrs);
+ }
+ }
+
+ @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);
+ } else if (equalsOrSuffix(qName, "subnetId")) {
+ builder.subnetId(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "state")) {
+ builder.subnetState(Subnet.State.fromValue(currentOrNull(currentText)));
+ } else if (equalsOrSuffix(qName, "vpcId")) {
+ builder.vpcId(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "cidrBlock")) {
+ builder.cidrBlock(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "availableIpAddressCount")) {
+ builder.availableIpAddressCount(Integer.parseInt(currentOrNull(currentText)));
+ } else if (equalsOrSuffix(qName, "availabilityZone")) {
+ builder.availabilityZone(currentOrNull(currentText));
+ }
+ currentText = new StringBuilder();
+ }
+
+ @Override
+ 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/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java
new file mode 100644
index 0000000..6cd2934
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java
@@ -0,0 +1,77 @@
+/*
+ * 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 org.jclouds.ec2.domain.Tag;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Strings;
+
+/**
+ * @see <a
+ * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html"
+ * >xml</a>
+ *
+ * @author Adrian Cole
+ */
+public class TagHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Tag> {
+
+ private StringBuilder currentText = new StringBuilder();
+ private Tag.Builder builder = Tag.builder();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Tag getResult() {
+ try {
+ return builder.build();
+ } finally {
+ builder = Tag.builder();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void endElement(String uri, String name, String qName) throws SAXException {
+ if (equalsOrSuffix(qName, "resourceId")) {
+ builder.resourceId(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "resourceType")) {
+ builder.resourceType(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "key")) {
+ builder.key(currentOrNull(currentText));
+ } else if (equalsOrSuffix(qName, "value")) {
+ // empty is same as not present
+ builder.value(Strings.emptyToNull(currentOrNull(currentText)));
+ }
+ currentText = new StringBuilder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java
new file mode 100644
index 0000000..847b4b4
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java
@@ -0,0 +1,78 @@
+/*
+ * 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 org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author grkvlt@apache.org
+ */
+public class TagSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Map<String, String>> {
+ private StringBuilder currentText = new StringBuilder();
+
+ private ImmutableMap.Builder<String, String> result;
+ private boolean inItem = false;
+ private String key;
+ private String value;
+
+ public Map<String, String> getResult() {
+ return result.build();
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (equalsOrSuffix(qName, "tagSet")) {
+ result = ImmutableMap.builder();
+ } else if (qName.equals("item")) {
+ inItem = true;
+ key = null;
+ value = null;
+ }
+ currentText = new StringBuilder();
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.equals("item")) {
+ inItem = false;
+ if (key != null) {
+ result.put(key, Strings.nullToEmpty(value));
+ }
+ }
+ if (inItem) {
+ if (qName.equals("key")) {
+ key = currentOrNull(currentText);
+ } else if (qName.equals("value")) {
+ value = currentOrNull(currentText);
+ }
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java
new file mode 100644
index 0000000..f4db176
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ *
+ * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeInstanceAttribute.html"
+ * />
+ * @author Adrian Cole
+ */
+public class UnencodeStringValueHandler extends StringValueHandler {
+
+ @Override
+ public String getResult() {
+ String result = super.getResult();
+ if (result != null)
+ result = new String(base64().decode(result), UTF_8);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
new file mode 100644
index 0000000..dce15a1
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
@@ -0,0 +1 @@
+org.jclouds.ec2.EC2ApiMetadata
\ No newline at end of file