http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java deleted file mode 100644 index 5176165..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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("Link") || 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/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java deleted file mode 100644 index bd0a4d1..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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("ExternalIPAddress")) { - 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("InternalIPAddress")) { - 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 = 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/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java deleted file mode 100644 index 3e393ac..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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 = 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/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java deleted file mode 100644 index fd421ab..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java deleted file mode 100644 index 47ef461..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java deleted file mode 100644 index 34ac869..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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 = new StringBuilder(); - } - - 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); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java deleted file mode 100644 index 2476c16..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java +++ /dev/null @@ -1,149 +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.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; -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 VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate> { - - protected final TaskHandler taskHandler; - protected final VmHandler vmHandler; - protected final VCloudNetworkSectionHandler networkSectionHandler; - - @Inject - public VAppTemplateHandler(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; - protected String vAppScopedLocalId; - - private boolean inChildren; - private boolean inTasks; - private boolean inNetworkSection; - protected Set<Vm> children = Sets.newLinkedHashSet(); - private VCloudNetworkSection networkSection; - - public VAppTemplate getResult() { - return new VAppTemplateImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description, - tasks, ovfDescriptorUploaded, vAppScopedLocalId, children, networkSection); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - 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, "VAppTemplate")) { - 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) { - if (equalsOrSuffix(qName, "Children")) { - inChildren = false; - Vm vm = vmHandler.getResult(); - if (vm != null) - this.children.add(vmHandler.getResult()); - } else if (equalsOrSuffix(qName, "Tasks")) { - inTasks = false; - this.tasks.add(taskHandler.getResult()); - } 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, "Description")) { - description = currentOrNull(); - } else if (equalsOrSuffix(qName, "VAppScopedLocalId")) { - vAppScopedLocalId = currentOrNull(); - } else if (equalsOrSuffix(qName, "ovfDescriptorUploaded")) { - ovfDescriptorUploaded = Boolean.parseBoolean(currentOrNull()); - } - currentText = new StringBuilder(); - } - - 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); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java deleted file mode 100644 index cf6f6e5..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java +++ /dev/null @@ -1,69 +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 javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.ovf.VirtualHardwareSection; -import org.jclouds.ovf.xml.VirtualHardwareSectionHandler; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; -import org.xml.sax.Attributes; - -public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCloudVirtualHardwareSection> { - - private final VirtualHardwareSectionHandler hardwareHandler; - - private ReferenceType hardware; - - @Inject - public VCloudVirtualHardwareHandler(VirtualHardwareSectionHandler hardwareHandler) { - this.hardwareHandler = hardwareHandler; - } - - public VCloudVirtualHardwareSection getResult() { - VirtualHardwareSection hardware = hardwareHandler.getResult(); - return new VCloudVirtualHardwareSection(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware - .getTransports(), hardware.getSystem(), hardware.getItems()); - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("VirtualHardwareSection")) { - hardware = newReferenceType(attributes); - } - hardwareHandler.startElement(uri, localName, qName, attrs); - } - - @Override - public void endElement(String uri, String localName, String qName) { - hardwareHandler.endElement(uri, localName, qName); - - } - - @Override - public void characters(char ch[], int start, int length) { - hardwareHandler.characters(ch, start, length); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java deleted file mode 100644 index a7670be..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java +++ /dev/null @@ -1,164 +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.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.VDCImpl; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class VDCHandler extends ParseSax.HandlerWithResult<VDC> { - - protected final TaskHandler taskHandler; - - @Inject - public VDCHandler(TaskHandler taskHandler) { - this.taskHandler = taskHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType vDC; - protected VDCStatus status = VDCStatus.READY; - protected ReferenceType org; - protected String description; - protected List<Task> tasks = Lists.newArrayList(); - protected AllocationModel allocationModel = AllocationModel.UNRECOGNIZED; - - protected Capacity storageCapacity; - protected Capacity cpuCapacity; - protected Capacity memoryCapacity; - - protected String units; - protected long allocated = 0; - protected long limit = 0; - protected int used = 0; - protected long overhead = 0; - - protected Map<String, ReferenceType> resourceEntities = Maps.newLinkedHashMap(); - protected Map<String, ReferenceType> availableNetworks = Maps.newLinkedHashMap(); - - protected int nicQuota; - protected int networkQuota; - protected int vmQuota; - protected boolean isEnabled = true; - - public VDC getResult() { - return new VDCImpl(vDC.getName(), vDC.getType(), vDC.getHref(), status, org, description, tasks, allocationModel, - storageCapacity, cpuCapacity, memoryCapacity, resourceEntities, availableNetworks, nicQuota, - networkQuota, vmQuota, isEnabled); - } - - void resetCapacity() { - units = null; - allocated = 0; - limit = 0; - used = 0; - overhead = 0; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Vdc")) { - vDC = newReferenceType(attributes); - String status = attributes.get("status"); - if (status != null) - this.status = VDCStatus.fromValue(Integer.parseInt(status)); - } else if (qName.endsWith("Network")) { - putReferenceType(availableNetworks, attributes); - } else if (qName.endsWith("ResourceEntity")) { - putReferenceType(resourceEntities, attributes); - } else if (qName.endsWith("Link") && "up".equals(attributes.get("rel"))) { - org = newReferenceType(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("AllocationModel")) { - allocationModel = AllocationModel.fromValue(currentOrNull()); - } else if (qName.endsWith("Units")) { - units = currentOrNull(); - } else if (qName.endsWith("Allocated")) { - allocated = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("Used")) { - used = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("Limit")) { - limit = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("Overhead")) { - overhead = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("StorageCapacity")) { - storageCapacity = new Capacity(units, allocated, limit, used, overhead); - resetCapacity(); - } else if (qName.endsWith("Cpu")) { - cpuCapacity = new Capacity(units, allocated, limit, used, overhead); - resetCapacity(); - } else if (qName.endsWith("Memory")) { - memoryCapacity = new Capacity(units, allocated, limit, used, overhead); - resetCapacity(); - } else if (qName.endsWith("DeployedVmsQuota")) { - vmQuota = (int) limit; - // vcloud express doesn't have the zero is unlimited rule - if (vmQuota == -1) - vmQuota = 0; - } else if (qName.endsWith("VmQuota")) { - vmQuota = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("NicQuota")) { - nicQuota = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("NetworkQuota")) { - networkQuota = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("IsEnabled")) { - isEnabled = 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/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java deleted file mode 100644 index dd04477..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java +++ /dev/null @@ -1,175 +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.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.GuestCustomizationSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.VmImpl; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; -import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; - -public class VmHandler extends ParseSax.HandlerWithResult<Vm> { - - protected final TaskHandler taskHandler; - protected final VCloudVirtualHardwareHandler virtualHardwareHandler; - protected final VCloudOperatingSystemHandler operatingSystemHandler; - protected final GuestCustomizationSectionHandler guestCustomizationHandler; - protected final NetworkConnectionSectionHandler networkConnectionSectionHandler; - - @Inject - public VmHandler(TaskHandler taskHandler, VCloudVirtualHardwareHandler virtualHardwareHandler, - VCloudOperatingSystemHandler operatingSystemHandler, - NetworkConnectionSectionHandler networkConnectionSectionHandler, - GuestCustomizationSectionHandler guestCustomizationHandler) { - this.taskHandler = taskHandler; - this.virtualHardwareHandler = virtualHardwareHandler; - this.operatingSystemHandler = operatingSystemHandler; - this.networkConnectionSectionHandler = networkConnectionSectionHandler; - this.guestCustomizationHandler = guestCustomizationHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType vm; - protected Status status; - protected ReferenceType vdc; - protected String description; - protected List<Task> tasks = Lists.newArrayList(); - protected VCloudVirtualHardwareSection hardware; - protected VCloudOperatingSystemSection os; - protected NetworkConnectionSection networkConnectionSection; - protected GuestCustomizationSection guestCustomization; - protected String vAppScopedLocalId; - - private boolean inTasks; - private boolean inHardware; - private boolean inOs; - private boolean inNetworkConnectionSection; - private boolean inGuestCustomization; - - public Vm getResult() { - return vm == null ? null : new VmImpl(vm.getName(), vm.getType(), vm.getHref(), status, vdc, description, tasks, - hardware, os, networkConnectionSection, guestCustomization, vAppScopedLocalId); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("VirtualHardwareSection")) { - inHardware = true; - } else if (qName.endsWith("OperatingSystemSection")) { - inOs = true; - } else if (qName.endsWith("GuestCustomizationSection")) { - inGuestCustomization = true; - } else if (qName.endsWith("NetworkConnectionSection")) { - inNetworkConnectionSection = true; - } else if (qName.endsWith("Tasks")) { - inTasks = true; - } - if (inHardware) { - virtualHardwareHandler.startElement(uri, localName, qName, attrs); - } else if (inOs) { - operatingSystemHandler.startElement(uri, localName, qName, attrs); - } else if (inNetworkConnectionSection) { - networkConnectionSectionHandler.startElement(uri, localName, qName, attrs); - } else if (inGuestCustomization) { - guestCustomizationHandler.startElement(uri, localName, qName, attrs); - } else if (inTasks) { - taskHandler.startElement(uri, localName, qName, attrs); - } else if (SaxUtils.equalsOrSuffix(qName, "Vm")) { - vm = newReferenceType(attributes); - String status = attributes.get("status"); - if (status != null) - this.status = Status.fromValue(Integer.parseInt(status)); - } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) { - vdc = newReferenceType(attributes); - } - } - - public void endElement(String uri, String name, String qName) { - if (qName.endsWith("VirtualHardwareSection")) { - inHardware = false; - this.hardware = virtualHardwareHandler.getResult(); - } else if (qName.endsWith("OperatingSystemSection")) { - inOs = false; - os = operatingSystemHandler.getResult(); - } else if (qName.endsWith("NetworkConnectionSection")) { - inNetworkConnectionSection = false; - networkConnectionSection = networkConnectionSectionHandler.getResult(); - } else if (qName.endsWith("GuestCustomizationSection")) { - inGuestCustomization = false; - guestCustomization = guestCustomizationHandler.getResult(); - } else if (qName.endsWith("Tasks")) { - inTasks = false; - this.tasks.add(taskHandler.getResult()); - } - if (inHardware) { - virtualHardwareHandler.endElement(uri, name, qName); - } else if (inOs) { - operatingSystemHandler.endElement(uri, name, qName); - } else if (inGuestCustomization) { - guestCustomizationHandler.endElement(uri, name, qName); - } else if (inNetworkConnectionSection) { - networkConnectionSectionHandler.endElement(uri, name, qName); - } else if (inTasks) { - taskHandler.endElement(uri, name, qName); - } else if (SaxUtils.equalsOrSuffix(qName, "Description")) { - description = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "VAppScopedLocalId")) { - vAppScopedLocalId = currentOrNull(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - if (inHardware) - virtualHardwareHandler.characters(ch, start, length); - else if (inOs) - operatingSystemHandler.characters(ch, start, length); - else if (inGuestCustomization) - guestCustomizationHandler.characters(ch, start, length); - else if (inNetworkConnectionSection) - networkConnectionSectionHandler.characters(ch, start, length); - else if (inTasks) - taskHandler.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/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java deleted file mode 100644 index 39013bf..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.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.xml.ovf; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.ovf.NetworkSection; -import org.jclouds.ovf.xml.NetworkSectionHandler; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult<VCloudNetworkSection> { - private final NetworkSectionHandler networkSectionHandler; - - @Inject - VCloudNetworkSectionHandler(NetworkSectionHandler networkSectionHandler) { - this.networkSectionHandler = networkSectionHandler; - } - - private ReferenceType net; - - public VCloudNetworkSection getResult() { - NetworkSection system = networkSectionHandler.getResult(); - return new VCloudNetworkSection(net.getType(), net.getHref(), system.getInfo(), system.getNetworks()); - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - if (equalsOrSuffix(qName, "NetworkSection")) { - this.net = Utils.newReferenceType(attributes); - } - networkSectionHandler.startElement(uri, localName, qName, attrs); - } - - @Override - public void endElement(String uri, String localName, String qName) { - networkSectionHandler.endElement(uri, localName, qName); - } - - public void characters(char ch[], int start, int length) { - networkSectionHandler.characters(ch, start, length); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java deleted file mode 100644 index 058e76a..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.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.ovf; - -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.ReferenceType; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCloudOperatingSystemSection> { - private StringBuilder currentText = new StringBuilder(); - - protected ReferenceType os; - protected Integer id; - protected String info; - protected String vmwOsType; - protected String description; - protected ReferenceType edit; - - public VCloudOperatingSystemSection getResult() { - VCloudOperatingSystemSection system = new VCloudOperatingSystemSection(id, info, description, os.getType(), os.getHref(), - vmwOsType, edit); - os = null; - id = null; - info = null; - vmwOsType = null; - description = null; - edit = null; - return system; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Link")) { - this.edit = Utils.newReferenceType(attributes); - } else if (qName.endsWith("OperatingSystemSection")) { - os = newReferenceType(attributes); - vmwOsType = attributes.get("osType"); - if (attributes.containsKey("id")) - this.id = Integer.parseInt(attributes.get("id")); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("Info")) { - this.info = currentText.toString().trim(); - } else if (qName.endsWith("Description")) { - this.description = currentText.toString().trim(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java deleted file mode 100644 index b576c1f..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java +++ /dev/null @@ -1,86 +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.ovf; - -import java.util.Map; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData; -import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -public class VCloudResourceAllocationSettingDataHandler extends ResourceAllocationSettingDataHandler { - - private ReferenceType edit; - - private long capacity; - private int busType; - private String busSubType; - - private String ipAddress; - private boolean primaryNetworkConnection; - private String ipAddressingMode; - - public ResourceAllocationSettingData getResult() { - try { - ResourceAllocationSettingData from = super.getResult(); - if (edit != null) { - return EditableResourceAllocationSettingData.builder().fromResourceAllocationSettingData(from).edit(edit) - .build(); - } else if (busSubType != null) { - return VCloudHardDisk.builder().fromResourceAllocationSettingData(from).capacity(capacity).busType(busType) - .busSubType(busSubType).build(); - } else if (ipAddress != null) { - return VCloudNetworkAdapter.builder().fromResourceAllocationSettingData(from).ipAddress(ipAddress) - .primaryNetworkConnection(primaryNetworkConnection).ipAddressingMode(ipAddressingMode).build(); - } else { - return from; - } - } finally { - ipAddress = null; - primaryNetworkConnection = false; - ipAddressingMode = null; - capacity = -1; - busType = -1; - busSubType = null; - edit = null; - } - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Link")) { - this.edit = Utils.newReferenceType(attributes); - } else if (qName.endsWith("HostResource") && attributes.size() > 0) { - capacity = Long.parseLong(attributes.get("capacity")); - busType = Integer.parseInt(attributes.get("busType")); - busSubType = attributes.get("busSubType"); - } else if (qName.endsWith("Connection") && attributes.size() > 0) { - ipAddress = attributes.get("ipAddress"); - primaryNetworkConnection = Boolean.parseBoolean(attributes.get("primaryNetworkConnection")); - ipAddressingMode = attributes.get("ipAddressingMode"); - } - super.startElement(uri, localName, qName, attrs); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index d800a94..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.vcloud.VCloudApiMetadata \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java deleted file mode 100644 index 8e3f826..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java +++ /dev/null @@ -1,28 +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; - -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "VCloudApiMetadataTest") -public class VCloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public VCloudApiMetadataTest() { - super(new VCloudApiMetadata()); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java deleted file mode 100644 index 049b3d9..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java +++ /dev/null @@ -1,62 +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; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.utils.TestUtils; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code VCloudApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "VCloudApiTest") -public class VCloudApiTest extends BaseVCloudApiTest<VCloudApi> { - - private VCloudApi syncClient; - - public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { - assert syncClient.getVAppApi() != null; - assert syncClient.getCatalogApi() != null; - assert syncClient.getVmApi() != null; - assert syncClient.getVAppTemplateApi() != null; - assert syncClient.getTaskApi() != null; - assert syncClient.getVDCApi() != null; - assert syncClient.getNetworkApi() != null; - assert syncClient.getOrgApi() != null; - } - - @BeforeClass - @Override - protected void setupFactory() throws IOException { - super.setupFactory(); - syncClient = injector.getInstance(VCloudApi.class); - } - - @DataProvider - public Object[][] ignoreOnWindows() { - return TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS - : TestUtils.SINGLE_NO_ARG_INVOCATION; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java deleted file mode 100644 index dcd3e8e..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java +++ /dev/null @@ -1,39 +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; - -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * Tests session refresh works - */ -@Test(groups = "live", singleThreaded = true) -public class VCloudSessionRefreshLiveTest extends BaseVCloudApiLiveTest { - - private static final int timeOut = 40; - - @Test - public void testSessionRefresh() throws Exception { - VCloudApi connection = view.unwrapApi(VCloudApi.class); - - connection.getOrgApi().findOrgNamed(null); - Thread.sleep(timeOut * 1000); - connection.getOrgApi().findOrgNamed(null); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java deleted file mode 100644 index 37ae52b..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java +++ /dev/null @@ -1,68 +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; - -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.xml.SupportedVersionsHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests behavior of {@code VCloudVersionsApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VCloudVersionsApiTest") -public class VCloudVersionsApiTest extends BaseRestAnnotationProcessingTest<VCloudVersionsApi> { - - public void testVersions() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(VCloudVersionsApi.class, "getSupportedVersions"); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); - - assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SupportedVersionsHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return AnonymousProviderMetadata.forApiOnEndpoint(VCloudVersionsApi.class, - "http://localhost:8080"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java deleted file mode 100644 index 599f4a1..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.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.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.jclouds.vcloud.options.CatalogItemOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -/** - * Tests behavior of {@code BindCatalogItemToXmlPayload} - */ -@Test(groups = "unit") -public class BindCatalogItemToXmlPayloadTest extends BasePayloadTest { - - public void testDefault() throws IOException { - String expected = "<CatalogItem xmlns=\"http://www.vmware.com/vcloud/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"myname\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd\"><Description>mydescription</Description><Entity href=\"http://fooentity\"/><Property key=\"foo\">bar</Property></CatalogItem>"; - - CatalogItemOptions options = CatalogItemOptions.Builder.description("mydescription").properties( - ImmutableMap.of("foo", "bar")); - GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options)); - - BindCatalogItemToXmlPayload binder = injector.getInstance(BindCatalogItemToXmlPayload.class); - - Map<String, Object> map = ImmutableMap.<String, Object> of("name", "myname", "Entity", "http://fooentity"); - - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } -}
