http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java deleted file mode 100644 index 74a7be4..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.internal; - -import java.io.Closeable; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; - -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; -import org.jclouds.vcloud.http.filters.VCloudBasicAuthentication; - -@Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class) -@RequestFilters(VCloudBasicAuthentication.class) -public interface VCloudLoginApi extends Closeable { - - /** - * This request returns a token to use in subsequent requests. After 30 minutes of inactivity, - * the token expires and you have to request a new token with this call. - */ - @POST - @ResponseParser(ParseLoginResponseFromHeaders.class) - @Consumes({VCloudMediaType.SESSION_XML,VCloudMediaType.ORGLIST_XML}) - VCloudSession login(); -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java deleted file mode 100644 index f004f97..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.loaders; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Envelope; -import org.jclouds.vcloud.VCloudApi; - -import com.google.common.cache.CacheLoader; - -@Singleton -public class OVFLoader extends CacheLoader<URI, Envelope> { - @Resource - protected Logger logger = Logger.NULL; - - private final VCloudApi client; - - @Inject - OVFLoader(VCloudApi client) { - this.client = client; - } - - @Override - public Envelope load(URI template) { - return client.getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(template); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java deleted file mode 100644 index ee707db..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.loaders; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.cache.CacheLoader; - -@Singleton -public class VAppTemplateLoader extends CacheLoader<URI, VAppTemplate> { - @Resource - protected Logger logger = Logger.NULL; - - private final VCloudApi client; - - @Inject - VAppTemplateLoader(VCloudApi client) { - this.client = client; - } - - @Override - public VAppTemplate load(URI template) { - return client.getVAppTemplateApi().getVAppTemplate(template); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java deleted file mode 100644 index 38fb340..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.location; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.find; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.VDC; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultVDC implements ImplicitLocationSupplier { - private final Supplier<Set<? extends Location>> locationsSupplier; - private final IsDefaultVDC isDefaultVDC; - - @Inject - DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) { - this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier"); - this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC"); - } - - @Override - public Location get() { - return find(locationsSupplier.get(), isDefaultVDC); - } - - - @Singleton - public static class IsDefaultVDC implements Predicate<Location> { - private final Supplier<ReferenceType> defaultVDCSupplier; - - @Inject - IsDefaultVDC(@VDC Supplier<ReferenceType> defaultVDCSupplier) { - this.defaultVDCSupplier = checkNotNull(defaultVDCSupplier, "defaultVDCSupplier"); - } - - @Override - public boolean apply(Location input) { - ReferenceType defaultVDC = defaultVDCSupplier.get(); - return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString()); - } - - @Override - public String toString() { - return "isDefaultVDC()"; - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java deleted file mode 100644 index 92b3c2e..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -@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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java deleted file mode 100644 index 89580fd..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java deleted file mode 100644 index 6512031..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java deleted file mode 100644 index e3f5eea..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java deleted file mode 100644 index 8aed313..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkState; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java deleted file mode 100644 index e10d45d..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java deleted file mode 100644 index 8d35d1d..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java deleted file mode 100644 index 2b249ce..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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. - */ -@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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java deleted file mode 100644 index 2429c6a..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.reference; - -/** - * Configuration properties and constants used in VCloud connections. - */ -public final class 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"; - - private VCloudConstants() { - throw new AssertionError("intentionally unimplemented"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java deleted file mode 100644 index 158debe..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This package contains properties and reference data used in vCloud. - */ -package org.jclouds.vcloud.reference; http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java deleted file mode 100644 index 938b6fd..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java deleted file mode 100644 index 08e1017..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -@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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java deleted file mode 100644 index 623ee08..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -public class Utils { - - public static ReferenceType newReferenceType(Map<String, String> attributes, String defaultType) { - String uri = attributes.get("href"); - String type = attributes.get("type"); - String relationship = attributes.get("rel"); - // savvis org has null href - URI href = (uri != null) ? URI.create(uri) : null; - return new ReferenceTypeImpl(attributes.get("name"), type != null ? type : defaultType, href, relationship); - } - - 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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java deleted file mode 100644 index 67e2445..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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. - */ -@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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java deleted file mode 100644 index 60bd01f..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java deleted file mode 100644 index 926e8a8..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java deleted file mode 100644 index 3c4704a..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java deleted file mode 100644 index 3fb2227..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java deleted file mode 100644 index aefb753..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java deleted file mode 100644 index e8d4c74..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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/stratos/blob/897edde8/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java deleted file mode 100644 index 1892e30..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.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; - -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; - } -}
