You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by me...@apache.org on 2014/03/05 06:57:11 UTC
[10/18] Forking jclouds's vcloud API
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java
new file mode 100755
index 0000000..d2827e5
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java
@@ -0,0 +1,93 @@
+/*
+ * 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.vcloud.location;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.location.Iso3166;
+import org.jclouds.location.Provider;
+import org.jclouds.location.suppliers.LocationsSupplier;
+import org.jclouds.location.suppliers.all.JustProvider;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier {
+
+ private final Supplier<Map<String, ReferenceType>> orgNameToResource;
+ private final Supplier<Map<String, Org>> orgNameToVDCResource;
+ private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
+
+ @Inject
+ OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName,
+ @Provider Supplier<URI> endpoint,
+ @org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
+ Supplier<Map<String, Org>> orgNameToVDCResource,
+ @Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
+ super(providerName, endpoint, isoCodes);
+ this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
+ this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
+ this.isoCodesByIdSupplier = checkNotNull(isoCodesByIdSupplier, "isoCodesByIdSupplier");
+ }
+
+ @Override
+ public Set<Location> get() {
+ return buildJustProviderOrVDCs().build();
+ }
+
+ protected Builder<Location> buildJustProviderOrVDCs() {
+ Builder<Location> locations = ImmutableSet.builder();
+ Location provider = Iterables.getOnlyElement(super.get());
+ if (orgNameToResource.get().size() == 0)
+ return locations.add(provider);
+ Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
+ for (ReferenceType org : orgNameToResource.get().values()) {
+ LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString())
+ .description(org.getName()).parent(provider);
+ if (isoCodesById.containsKey(org.getHref().toASCIIString()))
+ builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get());
+ Location orgL = builder.build();
+ for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
+ builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
+ vdc.getName()).parent(orgL);
+ if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
+ builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get());
+ locations.add(builder.build());
+ }
+ }
+ return locations;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java
new file mode 100755
index 0000000..d74b246
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java
@@ -0,0 +1,51 @@
+/*
+ * 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.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+public class CaptureVAppOptions {
+
+ private String description;
+
+ public CaptureVAppOptions withDescription(String description) {
+ checkNotNull(description, "description");
+ this.description = description;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CaptureVAppOptions#withDescription(String)
+ */
+ public static CaptureVAppOptions withDescription(String description) {
+ CaptureVAppOptions options = new CaptureVAppOptions();
+ return options.withDescription(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java
new file mode 100755
index 0000000..a018530
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.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.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+public class CatalogItemOptions {
+
+ private String description;
+ private Map<String, String> properties = Maps.newLinkedHashMap();
+
+ /**
+ * optional description for the CatalogItem
+ */
+ public CatalogItemOptions description(String description) {
+ this.description = checkNotNull(description, "description");
+ return this;
+ }
+
+ /**
+ * optional properties for the CatalogItem
+ */
+ public CatalogItemOptions properties(Map<String, String> properties) {
+ this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties"));
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CatalogItemOptions#description
+ */
+ public static CatalogItemOptions description(String description) {
+ return new CatalogItemOptions().description(description);
+ }
+
+ /**
+ * @see CatalogItemOptions#properties
+ */
+ public static CatalogItemOptions properties(Map<String, String> properties) {
+ return new CatalogItemOptions().properties(properties);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java
new file mode 100755
index 0000000..0b6d3a5
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java
@@ -0,0 +1,53 @@
+/*
+ * 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.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+public class CloneOptions {
+
+ private String description;
+
+ /**
+ * the clone should be powered on after it is deployed
+ */
+ public CloneOptions description(String description) {
+ checkNotNull(description, "description");
+ this.description = description;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CloneOptions#description(String)
+ */
+ public static CloneOptions description(String description) {
+ return new CloneOptions().description(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java
new file mode 100755
index 0000000..81185c8
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java
@@ -0,0 +1,88 @@
+/*
+ * 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.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkState;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+public class CloneVAppOptions extends CloneOptions {
+
+ private boolean deploy;
+ private boolean powerOn;
+
+ /**
+ * the clone should be deployed after it is created
+ */
+ public CloneVAppOptions deploy() {
+ this.deploy = true;
+ return this;
+ }
+
+ /**
+ * the clone should be powered on after it is deployed
+ */
+ public CloneVAppOptions powerOn() {
+ checkState(deploy, "must set deploy before setting powerOn");
+ powerOn = true;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CloneVAppOptions description(String description) {
+ return CloneVAppOptions.class.cast(super.description(description));
+ }
+
+ public boolean isDeploy() {
+ return deploy;
+ }
+
+ public boolean isPowerOn() {
+ return powerOn;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CloneVAppOptions#deploy()
+ */
+ public static CloneVAppOptions deploy() {
+ return new CloneVAppOptions().deploy();
+ }
+
+ /**
+ * @see CloneVAppOptions#powerOn()
+ */
+ public static CloneVAppOptions powerOn() {
+ return new CloneVAppOptions().powerOn();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public static CloneVAppOptions description(String description) {
+ return new CloneVAppOptions().description(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java
new file mode 100755
index 0000000..8f701eb
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java
@@ -0,0 +1,42 @@
+/*
+ * 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.vcloud.options;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+public class CloneVAppTemplateOptions extends CloneOptions {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CloneVAppTemplateOptions description(String description) {
+ return CloneVAppTemplateOptions.class.cast(super.description(description));
+ }
+
+ public static class Builder {
+ /**
+ * {@inheritDoc}
+ */
+ public static CloneVAppTemplateOptions description(String description) {
+ return new CloneVAppTemplateOptions().description(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java
new file mode 100755
index 0000000..37d1d03
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java
@@ -0,0 +1,178 @@
+/*
+ * 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.vcloud.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Sets;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+public class InstantiateVAppTemplateOptions {
+ private Set<NetworkConfig> networkConfig = Sets.newLinkedHashSet();
+
+ private Boolean customizeOnInstantiate;
+ private String description = null;
+ private boolean deploy = true;
+ private boolean powerOn = true;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean shouldDeploy() {
+ return deploy;
+ }
+
+ public boolean shouldPowerOn() {
+ return powerOn;
+ }
+
+ /**
+ * Optional description. Used for the Description of the vApp created by this
+ * instantiation.
+ */
+ public InstantiateVAppTemplateOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * deploy the vapp after it is instantiated?
+ */
+ public InstantiateVAppTemplateOptions deploy(boolean deploy) {
+ this.deploy = deploy;
+ return this;
+ }
+
+ /**
+ * powerOn the vapp after it is instantiated?
+ */
+ public InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
+ this.powerOn = powerOn;
+ return this;
+ }
+
+ /**
+ * {@networkConfig VAppTemplate}s have internal networks that can be
+ * connected in order to access the internet or other external networks.
+ *
+ * <h4>default behaviour if you don't use this option</h4> By default, we
+ * connect the first internal {@networkConfig
+ * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the
+ * vapp template}to a default chosen from the org or specified via
+ * {@networkConfig
+ * org.jclouds.vcloud.reference.VCloudConstants#
+ * PROPERTY_VCLOUD_DEFAULT_NETWORK} using the {@networkConfig
+ * org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an
+ * override set by the property {@networkConfig
+ * org.jclouds.vcloud.reference.VCloudConstants#
+ * PROPERTY_VCLOUD_DEFAULT_FENCEMODE}.
+ */
+ public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
+ this.networkConfig.add(checkNotNull(networkConfig, "networkConfig"));
+ return this;
+ }
+
+ public Set<NetworkConfig> getNetworkConfig() {
+ return networkConfig;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see InstantiateVAppTemplateOptions#description
+ */
+ public static InstantiateVAppTemplateOptions description(String description) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.description(description);
+ }
+
+ /**
+ * @see InstantiateVAppTemplateOptions#deploy
+ */
+ public static InstantiateVAppTemplateOptions deploy(boolean deploy) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.deploy(deploy);
+ }
+
+ /**
+ * @see InstantiateVAppTemplateOptions#powerOn
+ */
+ public static InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.powerOn(powerOn);
+ }
+
+ /**
+ * @see InstantiateVAppTemplateOptions#addNetworkConfig
+ */
+ public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.addNetworkConfig(networkConfig);
+ }
+
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof InstantiateVAppTemplateOptions) {
+ final InstantiateVAppTemplateOptions other = InstantiateVAppTemplateOptions.class.cast(object);
+ return equal(networkConfig, other.networkConfig)
+ && equal(customizeOnInstantiate, other.customizeOnInstantiate) && equal(description, other.description)
+ && equal(deploy, other.deploy) && equal(powerOn, other.powerOn);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(networkConfig, customizeOnInstantiate, description, deploy, powerOn);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("customizeOnInstantiate", customizeOnInstantiate).add("description", description);
+ if (networkConfig.size() > 0)
+ toString.add("networkConfig", networkConfig);
+ if (!deploy)
+ toString.add("deploy", deploy);
+ if (!powerOn)
+ toString.add("powerOn", powerOn);
+ return toString;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
new file mode 100755
index 0000000..b7fabb8
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
@@ -0,0 +1,65 @@
+/*
+ * 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.vcloud.predicates;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.TaskInErrorStateException;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+
+import com.google.common.base.Predicate;
+import com.google.inject.Inject;
+
+/**
+ *
+ * Tests to see if a task succeeds.
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class TaskSuccess implements Predicate<URI> {
+
+ private final VCloudApi client;
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ public TaskSuccess(VCloudApi client) {
+ this.client = client;
+ }
+
+ public boolean apply(URI taskId) {
+ logger.trace("looking for status on task %s", taskId);
+
+ Task task = client.getTaskApi().getTask(taskId);
+ // perhaps task isn't available, yet
+ if (task == null)
+ return false;
+ logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task.getStatus());
+ if (task.getStatus() == TaskStatus.ERROR)
+ throw new TaskInErrorStateException(task);
+ return task.getStatus() == TaskStatus.SUCCESS;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
new file mode 100755
index 0000000..4c93a72
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
@@ -0,0 +1,51 @@
+/*
+ * 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.vcloud.reference;
+
+/**
+ * Configuration properties and constants used in VCloud connections.
+ *
+ * @author Adrian Cole
+ */
+public interface VCloudConstants {
+ public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema";
+ /**
+ * name of the default org that your vApp will join, if an org isn't
+ * explicitly specified.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_ORG = "jclouds.vcloud.defaults.org";
+ /**
+ * name of the default catalog to query, if it isn't explicitly specified.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_CATALOG = "jclouds.vcloud.defaults.catalog";
+ /**
+ * name of the VDC that your vApp will join, if a vDC isn't explicitly
+ * specified.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_VDC = "jclouds.vcloud.defaults.vdc";
+ /**
+ * name of the default network, in the default VDC that your vApp will join.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
+ public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode";
+
+ public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns";
+ public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema";
+
+ public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud.timeout.task-complete";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java
new file mode 100755
index 0000000..efd5c8e
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+/**
+ * This package contains properties and reference data used in vCloud.
+ * @author Adrian Cole
+ */
+package org.jclouds.vcloud.reference;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
new file mode 100755
index 0000000..03f994e
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.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.vcloud.suppliers;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.NoSuchElementException;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault implements
+ Function<Iterable<ReferenceType>, ReferenceType> {
+
+ protected final ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull;
+ protected final String configurationKey;
+ protected final Predicate<ReferenceType> defaultSelector;
+
+ public OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(
+ ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, String configurationKey,
+ Predicate<ReferenceType> defaultSelector) {
+ this.configurationKey = checkNotNull(configurationKey, "configurationKey");
+ this.valueOfConfigurationKeyOrNull = checkNotNull(valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull");
+ this.defaultSelector = checkNotNull(defaultSelector, "defaultSelector");
+ }
+
+ @Override
+ public ReferenceType apply(Iterable<ReferenceType> referenceTypes) {
+ checkNotNull(referenceTypes, "referenceTypes");
+ checkArgument(Iterables.size(referenceTypes) > 0,
+ "No referenceTypes corresponding to configuration key %s present", configurationKey);
+ if (Iterables.size(referenceTypes) == 1)
+ return Iterables.getLast(referenceTypes);
+ String namingPattern = valueOfConfigurationKeyOrNull.apply(configurationKey);
+ if (namingPattern != null) {
+ return findReferenceTypeWithNameMatchingPattern(referenceTypes, namingPattern);
+ } else {
+ return defaultReferenceType(referenceTypes);
+ }
+ }
+
+ public ReferenceType defaultReferenceType(Iterable<ReferenceType> referenceTypes) {
+ return Iterables.find(referenceTypes, defaultSelector);
+ }
+
+ public ReferenceType findReferenceTypeWithNameMatchingPattern(Iterable<ReferenceType> referenceTypes,
+ String namingPattern) {
+ try {
+ return Iterables.find(referenceTypes, new ReferenceTypeNameMatchesPattern(namingPattern));
+ } catch (NoSuchElementException e) {
+ throw new NoSuchElementException(String.format(
+ "referenceType matching pattern [%s], corresponding to configuration key %s, not in %s", namingPattern,
+ configurationKey, referenceTypes));
+ }
+ }
+
+ static class ReferenceTypeNameMatchesPattern implements Predicate<ReferenceType> {
+
+ private final String namingPattern;
+
+ public ReferenceTypeNameMatchesPattern(String namingPattern) {
+ this.namingPattern = checkNotNull(namingPattern, "namingPattern");
+ }
+
+ @Override
+ public boolean apply(ReferenceType arg0) {
+ return arg0.getName().matches(namingPattern);
+ }
+
+ @Override
+ public String toString() {
+ return "nameMatchesPattern(" + namingPattern + ")";
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
new file mode 100755
index 0000000..839ffd7
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
@@ -0,0 +1,86 @@
+/*
+ * 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.vcloud.suppliers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Sets.newLinkedHashSet;
+import static org.jclouds.concurrent.FutureIterables.transformParallel;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class VAppTemplatesSupplier implements Supplier<Set<VAppTemplate>> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ public Logger logger = Logger.NULL;
+
+ private final Supplier<Map<String, Org>> orgMap;
+ private final Function<Org, Iterable<VAppTemplate>> imagesInOrg;
+ private final ListeningExecutorService userExecutor;
+
+ @Inject
+ VAppTemplatesSupplier(Supplier<Map<String, Org>> orgMap,
+ Function<Org, Iterable<VAppTemplate>> imagesInOrg,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ this.orgMap = checkNotNull(orgMap, "orgMap");
+ this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg");
+ this.userExecutor = checkNotNull(userExecutor, "userExecutor");
+ }
+
+ @Override
+ public Set<VAppTemplate> get() {
+ Iterable<Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
+ Iterable<? extends Iterable<VAppTemplate>> images = transformParallel(orgs,
+ new Function<Org, ListenableFuture<? extends Iterable<VAppTemplate>>>() {
+ public ListenableFuture<Iterable<VAppTemplate>> apply(final Org from) {
+ checkNotNull(from, "org");
+ return userExecutor.submit(new Callable<Iterable<VAppTemplate>>() {
+ public Iterable<VAppTemplate> call() throws Exception {
+ return imagesInOrg.apply(from);
+ }
+ public String toString() {
+ return "imagesInOrg(" + from.getHref() + ")";
+ }
+ });
+ }
+ }, userExecutor, null, logger, "images in " + orgs);
+ return newLinkedHashSet(concat(images));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java
new file mode 100755
index 0000000..7c16d10
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java
@@ -0,0 +1,70 @@
+/*
+ * 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.vcloud.util;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.domain.VCloudError.MinorCode;
+import org.jclouds.vcloud.domain.internal.ErrorImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class Utils {
+
+ public static ReferenceType newReferenceType(Map<String, String> attributes, String defaultType) {
+ String uri = attributes.get("href");
+ String type = attributes.get("type");
+ // savvis org has null href
+ URI href = (uri != null) ? URI.create(uri) : null;
+ return new ReferenceTypeImpl(attributes.get("name"), type != null ? type : defaultType, href);
+ }
+
+ public static ReferenceType newReferenceType(Map<String, String> attributes) {
+ return newReferenceType(attributes, null);
+ }
+
+ public static VCloudError newError(Map<String, String> attributes) {
+
+ String vendorSpecificErrorCode = attributes.get("vendorSpecificErrorCode");
+ int errorCode;
+ // remove this logic when vcloud 0.8 is gone
+ try {
+ errorCode = Integer.parseInt(attributes.get("majorErrorCode"));
+ } catch (NumberFormatException e) {
+ errorCode = 500;
+ vendorSpecificErrorCode = attributes.get("majorErrorCode");
+ }
+ MinorCode minorErrorCode = attributes.containsKey("minorErrorCode") ? MinorCode.fromValue(attributes
+ .get("minorErrorCode")) : null;
+ if (minorErrorCode == null || minorErrorCode == MinorCode.UNRECOGNIZED) {
+ vendorSpecificErrorCode = attributes.get("minorErrorCode");
+ }
+
+ return new ErrorImpl(attributes.get("message"), errorCode, minorErrorCode, vendorSpecificErrorCode, attributes
+ .get("stackTrace"));
+ }
+
+ public static void putReferenceType(Map<String, ReferenceType> map, Map<String, String> attributes) {
+ map.put(attributes.get("name"), newReferenceType(attributes));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
new file mode 100755
index 0000000..00f9ebf
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.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.vcloud.util;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.xml.ErrorHandler;
+
+/**
+ * Needed to sign and verify requests and responses.
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class VCloudUtils {
+ private final ParseSax.Factory factory;
+ private final Provider<ErrorHandler> errorHandlerProvider;
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ VCloudUtils(Factory factory, Provider<ErrorHandler> errorHandlerProvider) {
+ this.factory = factory;
+ this.errorHandlerProvider = errorHandlerProvider;
+ }
+
+ public VCloudError parseErrorFromContent(HttpRequest request, HttpResponse response) {
+ // HEAD has no content
+ if (response.getPayload() == null)
+ return null;
+ // NOTE in vCloud Datacenter 1.5, if you make vCloud 1.0 requests, the content type
+ // header is suffixed with ;1.0
+ String contentType = response.getPayload().getContentMetadata().getContentType();
+ if (contentType != null && contentType.startsWith(VCloudMediaType.ERROR_XML)) {
+ try {
+ return factory.create(errorHandlerProvider.get()).setContext(request).apply(response);
+ } catch (RuntimeException e) {
+ logger.warn(e, "error parsing error");
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
new file mode 100755
index 0000000..0bb3549
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
@@ -0,0 +1,104 @@
+/*
+ * 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.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.CatalogImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adrian Cole
+ */
+public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
+
+ protected final TaskHandler taskHandler;
+
+ @Inject
+ public CatalogHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+
+ private ReferenceType catalog;
+ private Map<String, ReferenceType> contents = Maps.newLinkedHashMap();
+ protected List<Task> tasks = Lists.newArrayList();
+ private String description;
+ private ReferenceType org;
+
+ private boolean published = true;
+ private boolean readOnly = true;
+
+ public Catalog getResult() {
+ return new CatalogImpl(catalog.getName(), catalog.getType(), catalog.getHref(), org, description, contents,
+ tasks, published, readOnly);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "Catalog")) {
+ catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML);
+ } else if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) {
+ putReferenceType(contents, attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
+ org = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "add".equals(attributes.get("rel"))) {
+ readOnly = false;
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ taskHandler.endElement(uri, name, qName);
+ if (SaxUtils.equalsOrSuffix(qName, "Task")) {
+ this.tasks.add(taskHandler.getResult());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Description")) {
+ description = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "IsPublished")) {
+ published = Boolean.parseBoolean(currentOrNull());
+ }
+ 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/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
new file mode 100755
index 0000000..714bb5e
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
@@ -0,0 +1,81 @@
+/*
+ * 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.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+import java.util.SortedMap;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adrian Cole
+ */
+public class CatalogItemHandler extends ParseSax.HandlerWithResult<CatalogItem> {
+ private StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType catalogItem;
+ protected ReferenceType entity;
+
+ protected String description;
+ protected String key;
+ protected SortedMap<String, String> properties = Maps.newTreeMap();
+
+ public CatalogItem getResult() {
+ return new CatalogItemImpl(catalogItem.getName(), catalogItem.getHref(), description, entity, properties);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) {
+ catalogItem = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Entity")) {
+ entity = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Property")) {
+ key = attributes.get("key");
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (SaxUtils.equalsOrSuffix(qName, "Description")) {
+ description = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Property")) {
+ properties.put(key, currentOrNull());
+ key = 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/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
new file mode 100755
index 0000000..44e88a9
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
@@ -0,0 +1,45 @@
+/*
+ * 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.vcloud.xml;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Adrian Cole
+ */
+public class ErrorHandler extends ParseSax.HandlerWithResult<VCloudError> {
+ private VCloudError error;
+
+ public VCloudError getResult() {
+ return error;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "Error")) {
+ error = Utils.newError(attributes);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
new file mode 100755
index 0000000..487bf7a
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
@@ -0,0 +1,137 @@
+/*
+ * 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.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.xml.sax.Attributes;
+
+/**
+ * @author Adrian Cole
+ */
+public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult<GuestCustomizationSection> {
+ protected StringBuilder currentText = new StringBuilder();
+ private ReferenceType guest;
+ private ReferenceType edit;
+
+ protected String info;
+ protected String name;
+ protected Boolean enabled;
+ protected Boolean changeSid;
+ protected String virtualMachineId;
+ protected Boolean joinDomainEnabled;
+ protected Boolean useOrgSettings;
+ protected String domainName;
+ protected String domainUserName;
+ protected String domainUserPassword;
+ protected Boolean adminPasswordEnabled;
+ protected Boolean adminPasswordAuto;
+ protected String adminPassword;
+ protected Boolean resetPasswordRequired;
+ protected String customizationScript;
+ protected String computerName;
+
+ public GuestCustomizationSection getResult() {
+ GuestCustomizationSection system = new GuestCustomizationSection(guest.getType(), guest.getHref(), info, enabled,
+ changeSid, virtualMachineId, joinDomainEnabled, useOrgSettings, domainName, domainUserName,
+ domainUserPassword, adminPasswordEnabled, adminPasswordAuto, adminPassword, resetPasswordRequired,
+ customizationScript, computerName, edit);
+ this.guest = null;
+ this.info = null;
+ this.edit = null;
+ this.enabled = null;
+ this.changeSid = null;
+ this.virtualMachineId = null;
+ this.joinDomainEnabled = null;
+ this.useOrgSettings = null;
+ this.domainName = null;
+ this.domainUserName = null;
+ this.domainUserPassword = null;
+ this.adminPasswordEnabled = null;
+ this.adminPasswordAuto = null;
+ this.adminPassword = null;
+ this.resetPasswordRequired = null;
+ this.customizationScript = null;
+ this.computerName = null;
+ return system;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ this.currentText = new StringBuilder();
+ if (qName.endsWith("GuestCustomizationSection")) {
+ guest = newReferenceType(attributes);
+ } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) {
+ edit = newReferenceType(attributes);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("Info")) {
+ this.info = currentOrNull();
+ } else if (qName.endsWith("AdminPasswordEnabled")) {
+ this.adminPasswordEnabled = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("JoinDomainEnabled")) {
+ this.joinDomainEnabled = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("Enabled")) {
+ this.enabled = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("ChangeSid")) {
+ this.changeSid = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("VirtualMachineId")) {
+ this.virtualMachineId = currentOrNull();
+ } else if (qName.endsWith("UseOrgSettings")) {
+ this.useOrgSettings = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("DomainName")) {
+ this.domainName = currentOrNull();
+ } else if (qName.endsWith("DomainUserName")) {
+ this.domainUserName = currentOrNull();
+ } else if (qName.endsWith("DomainUserPassword")) {
+ this.domainUserPassword = currentOrNull();
+ } else if (qName.endsWith("AdminPasswordAuto")) {
+ this.adminPasswordAuto = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("AdminPassword")) {
+ this.adminPassword = currentOrNull();
+ } else if (qName.endsWith("ResetPasswordRequired")) {
+ this.resetPasswordRequired = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("CustomizationScript")) {
+ this.customizationScript = currentOrNull();
+ if (this.customizationScript != null)
+ customizationScript = customizationScript.replace(">", ">");
+ } else if (qName.endsWith("ComputerName")) {
+ this.computerName = currentOrNull();
+ } else if (qName.endsWith("Name")) {
+ this.name = currentOrNull();
+ }
+ currentText = new StringBuilder();
+ }
+
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+ protected String currentOrNull() {
+ String returnVal = currentText.toString();
+ return returnVal.equals("") ? null : returnVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
new file mode 100755
index 0000000..647f120
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
@@ -0,0 +1,87 @@
+/*
+ * 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.vcloud.xml;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.xml.sax.Attributes;
+
+/**
+ * @author Adrian Cole
+ */
+public class NetworkConnectionHandler extends ParseSax.HandlerWithResult<NetworkConnection> {
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected String network;
+ protected int networkConnectionIndex;
+ protected String ipAddress;
+ protected String externalIpAddress;
+ protected boolean connected;
+ protected String MACAddress;
+ protected IpAddressAllocationMode ipAddressAllocationMode;
+
+ public NetworkConnection getResult() {
+ NetworkConnection connection = new NetworkConnection(network, networkConnectionIndex, ipAddress,
+ externalIpAddress, connected, MACAddress, ipAddressAllocationMode);
+ this.network = null;
+ this.networkConnectionIndex = -1;
+ this.ipAddress = null;
+ this.externalIpAddress = null;
+ this.connected = false;
+ this.MACAddress = null;
+ this.ipAddressAllocationMode = null;
+ return connection;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("NetworkConnection")) {
+ network = attributes.get("network");
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("NetworkConnectionIndex")) {
+ this.networkConnectionIndex = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("IpAddress")) {
+ this.ipAddress = currentOrNull();
+ } else if (qName.endsWith("ExternalIpAddress")) {
+ this.externalIpAddress = currentOrNull();
+ } else if (qName.endsWith("IsConnected")) {
+ this.connected = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("MACAddress")) {
+ this.MACAddress = currentOrNull();
+ } else if (qName.endsWith("IpAddressAllocationMode")) {
+ this.ipAddressAllocationMode = IpAddressAllocationMode.valueOf(currentOrNull());
+ }
+ 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/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
new file mode 100755
index 0000000..3c80bc6
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
@@ -0,0 +1,103 @@
+/*
+ * 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.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Sets;
+
+/**
+ * @author Adrian Cole
+ */
+public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult<NetworkConnectionSection> {
+ protected StringBuilder currentText = new StringBuilder();
+
+ private final NetworkConnectionHandler networkConnectionHandler;
+
+ @Inject
+ public NetworkConnectionSectionHandler(NetworkConnectionHandler networkConnectionHandler) {
+ this.networkConnectionHandler = networkConnectionHandler;
+ }
+
+ protected String info;
+ protected Set<NetworkConnection> connections = Sets.newLinkedHashSet();
+ protected ReferenceType section;
+ protected ReferenceType edit;
+ protected Integer primaryNetworkConnectionIndex;
+ protected boolean inConnections;
+
+ public NetworkConnectionSection getResult() {
+ return new NetworkConnectionSection(section.getType(), section.getHref(), info, primaryNetworkConnectionIndex,
+ connections, edit);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("NetworkConnection")) {
+ inConnections = true;
+ }
+ if (inConnections) {
+ networkConnectionHandler.startElement(uri, localName, qName, attrs);
+ } else if (qName.endsWith("NetworkConnectionSection")) {
+ section = newReferenceType(attributes);
+ } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) {
+ edit = newReferenceType(attributes);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("NetworkConnection")) {
+ inConnections = false;
+ connections.add(networkConnectionHandler.getResult());
+ }
+ if (inConnections) {
+ networkConnectionHandler.endElement(uri, localName, qName);
+ } else if (qName.endsWith("Info")) {
+ this.info = currentOrNull();
+ } else if (qName.endsWith("PrimaryNetworkConnectionIndex")) {
+ this.primaryNetworkConnectionIndex = Integer.valueOf(currentOrNull());
+ }
+ currentText = new StringBuilder();
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inConnections)
+ networkConnectionHandler.characters(ch, start, length);
+ else
+ 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/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
new file mode 100755
index 0000000..ebd6d20
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.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.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.OrgImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adrian Cole
+ */
+public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
+
+ protected final TaskHandler taskHandler;
+
+ @Inject
+ public OrgHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType org;
+ protected Map<String, ReferenceType> vdcs = Maps.newLinkedHashMap();
+ protected ReferenceType tasksList;
+ protected Map<String, ReferenceType> catalogs = Maps.newLinkedHashMap();
+ protected Map<String, ReferenceType> networks = Maps.newLinkedHashMap();
+ protected List<Task> tasks = Lists.newArrayList();
+
+ protected String description;
+ protected String fullName;
+
+ public Org getResult() {
+ return new OrgImpl(org.getName(), org.getType(), org.getHref(), fullName != null ? fullName : org.getName(),
+ description, catalogs, vdcs, networks, tasksList, tasks);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("Org")) {
+ org = newReferenceType(attributes);
+ } else if (qName.endsWith("Link")) {
+ String type = attributes.get("type");
+ if (type != null) {
+ if (type.indexOf("vdc+xml") != -1) {
+ putReferenceType(vdcs, attributes);
+ } else if (type.indexOf("catalog+xml") != -1) {
+ putReferenceType(catalogs, attributes);
+ } else if (type.indexOf("tasksList+xml") != -1) {
+ tasksList = newReferenceType(attributes);
+ } else if (type.indexOf("network+xml") != -1) {
+ putReferenceType(networks, attributes);
+ }
+ }
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ taskHandler.endElement(uri, name, qName);
+ if (qName.endsWith("Task")) {
+ this.tasks.add(taskHandler.getResult());
+ } else if (qName.endsWith("Description")) {
+ description = currentOrNull();
+ } else if (qName.endsWith("FullName")) {
+ fullName = currentOrNull();
+ }
+ 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/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
new file mode 100755
index 0000000..7f734b4
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
@@ -0,0 +1,54 @@
+/*
+ * 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.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adrian Cole
+ */
+public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, ReferenceType>> {
+
+ private Map<String, ReferenceType> org = Maps.newHashMap();
+
+ public Map<String, ReferenceType> getResult() {
+ return org;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("Org")) {
+ String type = attributes.get("type");
+ if (type != null) {
+ if (type.indexOf("org+xml") != -1) {
+ putReferenceType(org, attributes);
+ }
+ }
+ }
+ }
+}