You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/17 17:19:27 UTC
[11/19] jclouds git commit: JCLOUDS-780 Remove vcloud.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
deleted file mode 100644
index 2b249ce..0000000
--- a/apis/vcloud/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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
deleted file mode 100644
index 2429c6a..0000000
--- a/apis/vcloud/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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java
deleted file mode 100644
index 158debe..0000000
--- a/apis/vcloud/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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
deleted file mode 100644
index fbe8406..0000000
--- a/apis/vcloud/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.isEmpty(referenceTypes),
- "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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
deleted file mode 100644
index 08e1017..0000000
--- a/apis/vcloud/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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java
deleted file mode 100644
index 8bd10f1..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java
+++ /dev/null
@@ -1,66 +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");
- // 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
deleted file mode 100644
index 67e2445..0000000
--- a/apis/vcloud/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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
deleted file mode 100644
index 41546df..0000000
--- a/apis/vcloud/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.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
deleted file mode 100644
index 0a5e1a2..0000000
--- a/apis/vcloud/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.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
deleted file mode 100644
index 3c4704a..0000000
--- a/apis/vcloud/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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
deleted file mode 100644
index 548ea42..0000000
--- a/apis/vcloud/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.setLength(0);
- 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.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
deleted file mode 100644
index 0224a30..0000000
--- a/apis/vcloud/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.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
deleted file mode 100644
index e453ca6..0000000
--- a/apis/vcloud/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.setLength(0);
- }
-
- @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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
deleted file mode 100644
index ec79641..0000000
--- a/apis/vcloud/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.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
deleted file mode 100644
index 9088842..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
+++ /dev/null
@@ -1,51 +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.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;
-
-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);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java
deleted file mode 100644
index a4e3044..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java
+++ /dev/null
@@ -1,322 +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.util.SaxUtils.equalsOrSuffix;
-import static org.jclouds.vcloud.util.Utils.newReferenceType;
-
-import java.util.List;
-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.ReferenceType;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.network.DhcpService;
-import org.jclouds.vcloud.domain.network.Features;
-import org.jclouds.vcloud.domain.network.FenceMode;
-import org.jclouds.vcloud.domain.network.FirewallService;
-import org.jclouds.vcloud.domain.network.IpRange;
-import org.jclouds.vcloud.domain.network.IpScope;
-import org.jclouds.vcloud.domain.network.NatService;
-import org.jclouds.vcloud.domain.network.OrgNetwork;
-import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy;
-import org.jclouds.vcloud.domain.network.firewall.FirewallProtocols;
-import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
-import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl;
-import org.jclouds.vcloud.domain.network.nat.NatPolicy;
-import org.jclouds.vcloud.domain.network.nat.NatProtocol;
-import org.jclouds.vcloud.domain.network.nat.NatRule;
-import org.jclouds.vcloud.domain.network.nat.NatType;
-import org.jclouds.vcloud.domain.network.nat.rules.MappingMode;
-import org.jclouds.vcloud.domain.network.nat.rules.OneToOneVmRule;
-import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
-import org.jclouds.vcloud.domain.network.nat.rules.VmRule;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-public class OrgNetworkHandler extends ParseSax.HandlerWithResult<OrgNetwork> {
-
- protected final TaskHandler taskHandler;
-
- @Inject
- public OrgNetworkHandler(TaskHandler taskHandler) {
- this.taskHandler = taskHandler;
- }
-
- protected StringBuilder currentText = new StringBuilder();
-
- protected ReferenceType network;
- protected ReferenceType org;
- protected String orgDescription;
- protected List<Task> tasks = Lists.newArrayList();
-
- protected String startAddress;
- protected String endAddress;
-
- protected boolean inherited;
- protected String gateway;
- protected String netmask;
- protected String dns1;
- protected String dns2;
- protected String dnsSuffix;
- protected Set<IpRange> ipRanges = Sets.newLinkedHashSet();
- protected Set<String> allocatedIpAddresses = Sets.newLinkedHashSet();
-
- protected IpScope ipScope;
- protected ReferenceType parentNetwork;
- protected FenceMode fenceMode;
-
- protected boolean serviceEnabled;
- protected Integer defaultLeaseTime;
- protected Integer maxLeaseTime;
-
- protected DhcpService dhcpService;
-
- protected boolean inFirewallRule;
- protected boolean firewallRuleEnabled;
- protected String firewallRuleDescription;
- protected FirewallPolicy firewallPolicy;
-
- protected boolean tcp;
- protected boolean udp;
- protected FirewallProtocols protocols;
- protected int port;
- protected String destinationIp;
-
- protected List<FirewallRule> firewallRules = Lists.newArrayList();
- protected FirewallService firewallService;
-
- protected NatType natType;
- protected NatPolicy natPolicy;
-
- protected MappingMode mappingMode;
- protected String externalIP;
- protected String vAppScopedVmId;
- protected int vmNicId;
-
- protected int externalPort;
- protected String internalIP;
- protected int internalPort;
- protected NatProtocol natProtocol;
-
- protected String vAppScopedLocalId;
-
- protected List<NatRule> natRules = Lists.newArrayList();
- protected NatService natService;
-
- protected Features features;
- protected OrgNetwork.Configuration configuration;
-
- protected ReferenceType networkPool;
- protected Set<String> allowedExternalIpAddresses = Sets.newLinkedHashSet();
-
- public OrgNetwork getResult() {
- return new OrgNetworkImpl(network.getName(), network.getType(), network.getHref(), org, orgDescription, tasks,
- configuration, networkPool, allowedExternalIpAddresses);
- }
-
- @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, "OrgNetwork")) {
- network = newReferenceType(attributes);
- } else if (SaxUtils.equalsOrSuffix(qName, "FirewallRule")) {
- this.inFirewallRule = true;
- } else if (SaxUtils.equalsOrSuffix(qName, "ParentNetwork")) {
- parentNetwork = newReferenceType(attributes);
- } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
- org = newReferenceType(attributes);
- } else {
- taskHandler.startElement(uri, localName, qName, attrs);
- }
- String type = attributes.get("type");
- if (type != null) {
- if (type.indexOf("networkPool+xml") != -1) {
- networkPool = newReferenceType(attributes);
- }
- }
- }
-
- 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")) {
- if (inFirewallRule)
- firewallRuleDescription = currentOrNull();
- else
- orgDescription = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "FenceMode")) {
- fenceMode = FenceMode.fromValue(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "StartAddress")) {
- startAddress = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "EndAddress")) {
- endAddress = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "AllocatedIpAddress")) {
- allocatedIpAddresses.add(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "IpRange")) {
- ipRanges.add(new IpRange(startAddress, endAddress));
- this.startAddress = null;
- this.endAddress = null;
- } else if (SaxUtils.equalsOrSuffix(qName, "IsInherited")) {
- inherited = Boolean.parseBoolean(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "Gateway")) {
- gateway = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "Netmask")) {
- netmask = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "Dns1")) {
- dns1 = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "Dns2")) {
- dns2 = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "DnsSuffix")) {
- dnsSuffix = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "IpScope")) {
- ipScope = new IpScope(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses);
- this.inherited = false;
- this.gateway = null;
- this.netmask = null;
- this.dns1 = null;
- this.dns2 = null;
- this.dnsSuffix = null;
- this.ipRanges = Sets.newLinkedHashSet();
- this.allocatedIpAddresses = Sets.newLinkedHashSet();
- } else if (SaxUtils.equalsOrSuffix(qName, "IsEnabled")) {
- if (inFirewallRule)
- firewallRuleEnabled = Boolean.parseBoolean(currentOrNull());
- else
- serviceEnabled = Boolean.parseBoolean(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "DefaultLeaseTime")) {
- defaultLeaseTime = Integer.parseInt(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "MaxLeaseTime")) {
- maxLeaseTime = Integer.parseInt(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "DhcpService")) {
- this.dhcpService = new DhcpService(serviceEnabled, defaultLeaseTime, maxLeaseTime, Iterables
- .getOnlyElement(ipRanges));
- this.serviceEnabled = false;
- this.defaultLeaseTime = null;
- this.maxLeaseTime = null;
- this.ipRanges = Sets.newLinkedHashSet();
- } else if (SaxUtils.equalsOrSuffix(qName, "Policy")) {
- if (inFirewallRule)
- firewallPolicy = FirewallPolicy.fromValue(currentOrNull());
- else
- natPolicy = NatPolicy.fromValue(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "Tcp")) {
- tcp = Boolean.parseBoolean(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "Udp")) {
- udp = Boolean.parseBoolean(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "Protocols")) {
- this.protocols = new FirewallProtocols(tcp, udp);
- this.tcp = false;
- this.udp = false;
- } else if (SaxUtils.equalsOrSuffix(qName, "DestinationIp")) {
- this.destinationIp = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "FirewallRule")) {
- this.inFirewallRule = false;
- this.firewallRules.add(new FirewallRule(firewallRuleEnabled, firewallRuleDescription, firewallPolicy,
- protocols, port, destinationIp));
- this.firewallRuleEnabled = false;
- this.firewallRuleDescription = null;
- this.firewallPolicy = null;
- this.protocols = null;
- this.port = -1;
- this.destinationIp = null;
- } else if (SaxUtils.equalsOrSuffix(qName, "FirewallService")) {
- firewallService = new FirewallService(serviceEnabled, firewallRules);
- this.serviceEnabled = false;
- this.firewallRules = Lists.newArrayList();
- } else if (SaxUtils.equalsOrSuffix(qName, "NatType")) {
- natType = NatType.fromValue(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "MappingMode")) {
- mappingMode = MappingMode.fromValue(currentOrNull());
- } else if (qName.equalsIgnoreCase("ExternalIP")) {
- externalIP = currentOrNull();
- } else if (qName.equalsIgnoreCase("VAppScopedVmId")) {
- vAppScopedVmId = currentOrNull();
- } else if (qName.equalsIgnoreCase("VAppScopedLocalId")) {
- vAppScopedLocalId = currentOrNull();
- } else if (qName.equalsIgnoreCase("vmNicId")) {
- vmNicId = Integer.parseInt(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "OneToOneVmRule")) {
- natRules.add(new OneToOneVmRule(mappingMode, externalIP, vAppScopedVmId, vmNicId));
- this.mappingMode = null;
- this.externalIP = null;
- this.vAppScopedVmId = null;
- this.vmNicId = -1;
- } else if (qName.equalsIgnoreCase("ExternalPort")) {
- externalPort = Integer.parseInt(currentOrNull());
- } else if (qName.equalsIgnoreCase("InternalIP")) {
- internalIP = currentOrNull();
- } else if (qName.equalsIgnoreCase("InternalPort")) {
- internalPort = Integer.parseInt(currentOrNull());
- } else if (equalsOrSuffix(qName, "Protocol")) {
- natProtocol = NatProtocol.valueOf(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "PortForwardingRule")) {
- natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, natProtocol));
- this.externalIP = null;
- this.externalPort = -1;
- this.internalIP = null;
- this.internalPort = -1;
- this.natProtocol = null;
- } else if (SaxUtils.equalsOrSuffix(qName, "VmRule")) {
- natRules.add(new VmRule(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, natProtocol));
- this.externalIP = null;
- this.externalPort = -1;
- this.vAppScopedLocalId = null;
- this.vmNicId = -1;
- this.internalPort = -1;
- this.natProtocol = null;
- } else if (SaxUtils.equalsOrSuffix(qName, "NatService")) {
- this.natService = new NatService(serviceEnabled, natType, natPolicy, natRules);
- this.serviceEnabled = false;
- this.natType = null;
- this.natPolicy = null;
- this.natRules = Lists.newArrayList();
- } else if (SaxUtils.equalsOrSuffix(qName, "Features")) {
- this.features = new Features(dhcpService, firewallService, natService);
- this.dhcpService = null;
- this.firewallService = null;
- this.natService = null;
- } else if (SaxUtils.equalsOrSuffix(qName, "Configuration")) {
- configuration = new OrgNetworkImpl.ConfigurationImpl(ipScope, parentNetwork, fenceMode, features);
- this.ipScope = null;
- this.parentNetwork = null;
- this.fenceMode = null;
- this.features = null;
- } else if (SaxUtils.equalsOrSuffix(qName, "AllowedExternalIpAddress")) {
- allowedExternalIpAddresses.add(currentOrNull());
- }
- currentText.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java
deleted file mode 100644
index d778da5..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java
+++ /dev/null
@@ -1,57 +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.net.URI;
-import java.util.SortedMap;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-
-import com.google.common.collect.Maps;
-
-public class SupportedVersionsHandler extends ParseSax.HandlerWithResult<SortedMap<String, URI>> {
- private StringBuilder currentText = new StringBuilder();
-
- private SortedMap<String, URI> contents = Maps.newTreeMap();
- private String version;
- private URI location;
-
- public SortedMap<String, URI> getResult() {
- return contents;
- }
-
- public void endElement(String uri, String name, String qName) {
- if (SaxUtils.equalsOrSuffix(qName, "Version")) {
- version = currentOrNull();
- } else if (SaxUtils.equalsOrSuffix(qName, "LoginUrl")) {
- location = URI.create(currentOrNull());
- } else if (SaxUtils.equalsOrSuffix(qName, "VersionInfo")) {
- contents.put(version, location);
- }
- currentText.setLength(0);
- }
-
- 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/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java
deleted file mode 100644
index fd421ab..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java
+++ /dev/null
@@ -1,125 +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.util.SaxUtils.equalsOrSuffix;
-
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.logging.Logger;
-import org.jclouds.util.SaxUtils;
-import org.jclouds.vcloud.domain.ReferenceType;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.TaskStatus;
-import org.jclouds.vcloud.domain.VCloudError;
-import org.jclouds.vcloud.domain.internal.TaskImpl;
-import org.jclouds.vcloud.util.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
- protected final DateService dateService;
- private String operation;
- private ReferenceType taskLink;
- private ReferenceType owner;
- private TaskStatus status;
- private Date startTime;
- private Date endTime;
- private Date expiryTime;
- private Task task;
- private VCloudError error;
- private boolean inOwner;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public TaskHandler(DateService dateService) {
- this.dateService = dateService;
- }
-
- public Task getResult() {
- return task;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
- if (equalsOrSuffix(qName, "Task")) {
- if (attributes.get("href") != null && !inOwner)// queued tasks may not have an
- // href yet
- taskLink = Utils.newReferenceType(attributes);
- status = TaskStatus.fromValue(attributes.get("status"));
- operation = attributes.get("operation");
- if (attributes.containsKey("startTime"))
- startTime = parseDate(attributes.get("startTime"));
- if (attributes.containsKey("endTime"))
- endTime = parseDate(attributes.get("endTime"));
- if (attributes.containsKey("expiryTime"))
- expiryTime = parseDate(attributes.get("expiryTime"));
- // TODO technically the old Result object should only be owner for copy and delete tasks
- } else if (equalsOrSuffix(qName, "Owner") || equalsOrSuffix(qName, "Result")) {
- owner = Utils.newReferenceType(attributes);
- } else if (equalsOrSuffix(qName, "Link") && "self".equals(attributes.get("rel"))) {
- taskLink = Utils.newReferenceType(attributes);
- } else if (equalsOrSuffix(qName, "Error")) {
- error = Utils.newError(attributes);
- }
- }
-
- private Date parseDate(String toParse) {
- try {
- return dateService.iso8601DateParse(toParse);
- } catch (RuntimeException e) {
- if (e.getCause() instanceof ParseException) {
- if (!toParse.endsWith("Z"))
- toParse += "Z";
- return dateService.iso8601SecondsDateParse(toParse);
- } else {
- logger.error(e, "error parsing date");
- }
- }
- return null;
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) {
- if (equalsOrSuffix(qName, "Task")) {
- this.task = new TaskImpl(taskLink.getHref(), operation, status, startTime, endTime, expiryTime, owner, error);
- operation = null;
- taskLink = null;
- status = null;
- startTime = null;
- endTime = null;
- owner = null;
- error = null;
- } else if (equalsOrSuffix(qName, "Owner")) {
- inOwner = false;
- }
- }
-
- public void characters(char ch[], int start, int length) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java
deleted file mode 100644
index 47ef461..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java
+++ /dev/null
@@ -1,71 +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 java.util.SortedSet;
-
-import javax.inject.Inject;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.jclouds.vcloud.domain.ReferenceType;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.TasksList;
-import org.jclouds.vcloud.domain.internal.TasksListImpl;
-import org.jclouds.vcloud.util.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Sets;
-
-public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
-
- private SortedSet<Task> tasks = Sets.newTreeSet();
- private final TaskHandler taskHandler;
- private ReferenceType resource;
-
- @Inject
- public TasksListHandler(TaskHandler taskHandler) {
- this.taskHandler = taskHandler;
- }
-
- public TasksList getResult() {
- return new TasksListImpl(resource.getHref(), tasks);
- }
-
- @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, "TasksList")) {
- resource = Utils.newReferenceType(attributes);
- } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "self".equals(attributes.get("rel"))) {
- resource = Utils.newReferenceType(attributes);
- } else {
- taskHandler.startElement(uri, localName, qName, attrs);
- }
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- taskHandler.endElement(uri, localName, qName);
- if (SaxUtils.equalsOrSuffix(qName, "Task")) {
- this.tasks.add(taskHandler.getResult());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java
deleted file mode 100644
index 7214d9a..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java
+++ /dev/null
@@ -1,148 +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.util.SaxUtils.equalsOrSuffix;
-import static org.jclouds.vcloud.util.Utils.newReferenceType;
-
-import java.util.List;
-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.ReferenceType;
-import org.jclouds.vcloud.domain.Status;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.VApp;
-import org.jclouds.vcloud.domain.Vm;
-import org.jclouds.vcloud.domain.internal.VAppImpl;
-import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
-import org.jclouds.vcloud.xml.ovf.VCloudNetworkSectionHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
-
- protected final TaskHandler taskHandler;
- protected final VmHandler vmHandler;
- protected final VCloudNetworkSectionHandler networkSectionHandler;
-
- @Inject
- public VAppHandler(TaskHandler taskHandler, VmHandler vmHandler,
- VCloudNetworkSectionHandler networkSectionHandler) {
- this.taskHandler = taskHandler;
- this.vmHandler = vmHandler;
- this.networkSectionHandler = networkSectionHandler;
- }
-
- protected StringBuilder currentText = new StringBuilder();
-
- protected ReferenceType template;
- protected Status status;
- protected ReferenceType vdc;
- protected String description;
- protected List<Task> tasks = Lists.newArrayList();
- protected boolean ovfDescriptorUploaded = true;
-
- private boolean inChildren;
- private boolean inTasks;
- private boolean inNetworkSection;
- protected Set<Vm> children = Sets.newLinkedHashSet();
- private VCloudNetworkSection networkSection;
-
- public VApp getResult() {
- return new VAppImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description, tasks,
- ovfDescriptorUploaded, children, networkSection);
- }
-
- protected int depth = 0;
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
- Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
- depth++;
- if (depth == 2) {
- if (equalsOrSuffix(qName, "Children")) {
- inChildren = true;
- } else if (equalsOrSuffix(qName, "Tasks")) {
- inTasks = true;
- } else if (equalsOrSuffix(qName, "NetworkSection")) {
- inNetworkSection = true;
- }
- }
- if (inChildren) {
- vmHandler.startElement(uri, localName, qName, attrs);
- } else if (inTasks) {
- taskHandler.startElement(uri, localName, qName, attrs);
- } else if (inNetworkSection) {
- networkSectionHandler.startElement(uri, localName, qName, attrs);
- } else if (equalsOrSuffix(qName, "VApp")) {
- template = newReferenceType(attributes);
- if (attributes.containsKey("status"))
- this.status = Status.fromValue(Integer.parseInt(attributes.get("status")));
- } else if (equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
- vdc = newReferenceType(attributes);
- }
-
- }
-
- public void endElement(String uri, String name, String qName) {
- depth--;
- if (depth == 1) {
- if (equalsOrSuffix(qName, "Children")) {
- inChildren = false;
- this.children.add(vmHandler.getResult());
- } else if (equalsOrSuffix(qName, "Tasks")) {
- inTasks = false;
- this.tasks.add(taskHandler.getResult());
- } else if (equalsOrSuffix(qName, "Description")) {
- description = SaxUtils.currentOrNull(currentText);
- } else if (equalsOrSuffix(qName, "NetworkSection")) {
- inNetworkSection = false;
- this.networkSection = networkSectionHandler.getResult();
- }
- }
- if (inChildren) {
- vmHandler.endElement(uri, name, qName);
- } else if (inTasks) {
- taskHandler.endElement(uri, name, qName);
- } else if (inNetworkSection) {
- networkSectionHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "ovfDescriptorUploaded")) {
- ovfDescriptorUploaded = Boolean.parseBoolean(SaxUtils.currentOrNull(currentText));
- }
- currentText.setLength(0);
- }
-
- public void characters(char ch[], int start, int length) {
- if (inTasks)
- taskHandler.characters(ch, start, length);
- else if (inChildren)
- vmHandler.characters(ch, start, length);
- else if (inNetworkSection)
- networkSectionHandler.characters(ch, start, length);
- else
- currentText.append(ch, start, length);
- }
-
-}