You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by de...@apache.org on 2016/02/22 13:20:20 UTC
[07/11] jclouds-labs git commit: Remove ProfitBricks
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandler.java
deleted file mode 100644
index 3ef85b3..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandler.java
+++ /dev/null
@@ -1,64 +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.profitbricks.http.parser.ipblock;
-
-import java.util.List;
-
-import org.jclouds.profitbricks.domain.IpBlock;
-import org.jclouds.profitbricks.http.parser.publicip.PublicIpListResponseHandler;
-import org.xml.sax.SAXException;
-
-import com.google.inject.Inject;
-import com.google.common.collect.Lists;
-
-public class IpBlockListResponseHandler extends BaseIpBlockResponseHandler<List<IpBlock>> {
-
- private final List<IpBlock> ipBlocks;
-
- @Inject
- IpBlockListResponseHandler(PublicIpListResponseHandler publicIpListResponseHandler) {
- super(publicIpListResponseHandler);
- ipBlocks = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (usePublicIpListParser)
- publicIpListResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- ipBlocks.add(builder
- .publicIps(publicIpListResponseHandler.getResult())
- .build());
- publicIpListResponseHandler.reset();
- builder = IpBlock.builder();
- }
- clearTextBuffer();
- }
-
- if ("publicIps".equals(qName))
- usePublicIpListParser = false;
-
- }
-
- @Override
- public List<IpBlock> getResult() {
- return ipBlocks;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandler.java
deleted file mode 100644
index 95bc81a..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandler.java
+++ /dev/null
@@ -1,64 +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.profitbricks.http.parser.ipblock;
-
-import com.google.inject.Inject;
-import org.jclouds.profitbricks.domain.IpBlock;
-import org.jclouds.profitbricks.http.parser.publicip.PublicIpListResponseHandler;
-import org.xml.sax.SAXException;
-
-public class IpBlockResponseHandler extends BaseIpBlockResponseHandler<IpBlock> {
-
- private boolean done = false;
-
- @Inject
- IpBlockResponseHandler(PublicIpListResponseHandler publicIpListResponseHandler) {
- super(publicIpListResponseHandler);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (done)
- return;
-
- if (usePublicIpListParser)
- publicIpListResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- done = true;
- builder.publicIps(publicIpListResponseHandler.getResult())
- .ips(ips);
- }
- clearTextBuffer();
- }
-
- if ("publicIps".equals(qName))
- usePublicIpListParser = false;
- }
-
- @Override
- public void reset() {
- this.builder = IpBlock.builder();
- }
-
- @Override
- public IpBlock getResult() {
- return builder.build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/BaseLoadBalancerResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/BaseLoadBalancerResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/BaseLoadBalancerResponseHandler.java
deleted file mode 100644
index b796125..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/BaseLoadBalancerResponseHandler.java
+++ /dev/null
@@ -1,114 +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.profitbricks.http.parser.loadbalancer;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Date;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.DataCenter;
-import org.jclouds.profitbricks.domain.LoadBalancer;
-import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
-import org.jclouds.profitbricks.domain.ProvisioningState;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
-import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public abstract class BaseLoadBalancerResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
-
- protected final ServerListResponseHandler balancedServerResponseHandler;
- protected final FirewallListResponseHandler firewallListResponseHandler;
-
- protected LoadBalancer.Builder builder;
- protected DataCenter.Builder dataCenterBuilder;
-
- protected final DateService dateService;
-
- protected boolean useBalancedServerParser = false;
- protected boolean useFirewallParser = false;
-
- protected BaseLoadBalancerResponseHandler(DateService dateService,
- ServerListResponseHandler balancedServerResponseHandler, FirewallListResponseHandler firewallResponseHandler) {
-
- checkNotNull(dateService, "DateService cannot be null");
- checkNotNull(balancedServerResponseHandler, "BalancedServerResponseHandler cannot be null");
- checkNotNull(firewallResponseHandler, "FirewallListResponseHandler cannot be null");
-
- this.dateService = dateService;
- this.builder = LoadBalancer.builder();
- this.dataCenterBuilder = DataCenter.builder();
-
- this.balancedServerResponseHandler = balancedServerResponseHandler;
- this.firewallListResponseHandler = firewallResponseHandler;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if ("balancedServers".equals(qName))
- useBalancedServerParser = true;
- if ("firewall".equals(qName))
- useFirewallParser = true;
-
- if (useBalancedServerParser)
- balancedServerResponseHandler.startElement(uri, localName, qName, attributes);
- else if (useFirewallParser)
- firewallListResponseHandler.startElement(uri, localName, qName, attributes);
- }
-
- @Override
- public void characters(char[] ch, int start, int length) {
- if (useBalancedServerParser)
- balancedServerResponseHandler.characters(ch, start, length);
- else if (useFirewallParser)
- firewallListResponseHandler.characters(ch, start, length);
- else
- super.characters(ch, start, length);
- }
-
- protected final Date textToIso8601Date() {
- return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("loadBalancerId".equals(qName))
- builder.id(textToStringValue());
- else if ("loadBalancerName".equals(qName))
- builder.name(textToStringValue());
- else if ("loadBalancerAlgorithm".equals(qName))
- builder.algorithm(Algorithm.fromValue(textToStringValue()));
- else if ("dataCenterId".equals(qName))
- dataCenterBuilder.id(textToStringValue());
- else if ("dataCenterVersion".equals(qName))
- dataCenterBuilder.version(textToIntValue());
- else if ("internetAccess".equals(qName))
- builder.internetAccess(textToBooleanValue());
- else if ("ip".equals(qName))
- builder.ip(textToStringValue());
- else if ("lanId".equals(qName))
- builder.lanId(textToIntValue());
- else if ("provisioningState".equals(qName))
- builder.state(ProvisioningState.fromValue(textToStringValue()));
- else if ("creationTime".equals(qName))
- builder.creationTime(textToIso8601Date());
- else if ("lastModificationTime".equals(qName))
- builder.lastModificationTime(textToIso8601Date());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandler.java
deleted file mode 100644
index a239336..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandler.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.profitbricks.http.parser.loadbalancer;
-
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Handler for parsing SOAP response where <i>loadBalancerId</i> is the only <i>usable</i> value.
- *
- * Other properties available (which are ignored): requestId, dataCenterId, dataCenterVersion
- */
-public class LoadBalancerIdOnlyResponseHandler extends BaseProfitBricksResponseHandler<String> {
-
- private String loadBalancerId;
-
- LoadBalancerIdOnlyResponseHandler() {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- clearTextBuffer();
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("loadBalancerId".equals(qName))
- loadBalancerId = textToStringValue();
- }
-
- @Override
- public String getResult() {
- return loadBalancerId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandler.java
deleted file mode 100644
index 9c60d33..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandler.java
+++ /dev/null
@@ -1,79 +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.profitbricks.http.parser.loadbalancer;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-
-import java.util.List;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.DataCenter;
-import org.jclouds.profitbricks.domain.LoadBalancer;
-import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
-import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
-import org.xml.sax.SAXException;
-
-public class LoadBalancerListResponseHandler extends BaseLoadBalancerResponseHandler<List<LoadBalancer>> {
-
- private final List<LoadBalancer> loadBalancers;
-
- @Inject
- LoadBalancerListResponseHandler(DateService dateService, ServerListResponseHandler balancedServerResponseHandler, FirewallListResponseHandler firewallListResponseHandler) {
- super(dateService, balancedServerResponseHandler, firewallListResponseHandler);
- this.loadBalancers = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (useBalancedServerParser)
- balancedServerResponseHandler.endElement(uri, localName, qName);
- else if (useFirewallParser)
- firewallListResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- loadBalancers.add(builder
- .dataCenter(dataCenterBuilder.build())
- .firewalls(firewallListResponseHandler.getResult())
- .balancedServers(balancedServerResponseHandler.getResult())
- .build());
-
- balancedServerResponseHandler.reset();
- firewallListResponseHandler.reset();
-
- builder = LoadBalancer.builder();
- }
- clearTextBuffer();
- }
- if ("firewall".equals(qName))
- useFirewallParser = false;
- else if ("balancedServers".equals(qName))
- useBalancedServerParser = false;
-
- }
-
- @Override
- public void reset() {
- this.dataCenterBuilder = DataCenter.builder();
- }
-
- @Override
- public List<LoadBalancer> getResult() {
- return loadBalancers;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandler.java
deleted file mode 100644
index 4a17535..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandler.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.profitbricks.http.parser.loadbalancer;
-
-import com.google.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.LoadBalancer;
-import org.jclouds.profitbricks.http.parser.firewall.FirewallListResponseHandler;
-import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler;
-import org.xml.sax.SAXException;
-
-public class LoadBalancerResponseHandler extends BaseLoadBalancerResponseHandler<LoadBalancer> {
-
- private boolean done = false;
-
- @Inject
- LoadBalancerResponseHandler(DateService dateService, ServerListResponseHandler serverListResponseHandler,
- FirewallListResponseHandler firewallListResponseHandler) {
- super(dateService, serverListResponseHandler, firewallListResponseHandler);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (done)
- return;
-
- if (useBalancedServerParser)
- balancedServerResponseHandler.endElement(uri, localName, qName);
- else if (useFirewallParser)
- firewallListResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- done = true;
- builder.dataCenter(dataCenterBuilder.build())
- .balancedServers(balancedServerResponseHandler.getResult())
- .firewalls(firewallListResponseHandler.getResult());
- }
- clearTextBuffer();
- }
-
- if ("balancedServers".equals(qName))
- useBalancedServerParser = false;
- else if ("firewall".equals(qName))
- useFirewallParser = false;
-
- }
-
- @Override
- public LoadBalancer getResult() {
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/BaseNicResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/BaseNicResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/BaseNicResponseHandler.java
deleted file mode 100644
index 0b4b537..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/BaseNicResponseHandler.java
+++ /dev/null
@@ -1,87 +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.profitbricks.http.parser.nic;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.google.inject.Inject;
-
-import org.jclouds.profitbricks.domain.Nic;
-import org.jclouds.profitbricks.domain.ProvisioningState;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.jclouds.profitbricks.http.parser.firewall.FirewallResponseHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public abstract class BaseNicResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
-
- protected final FirewallResponseHandler firewallResponseHandler;
-
- protected boolean useFirewallParser = false;
- protected Nic.Builder builder;
- protected List<String> ips;
-
- @Inject
- BaseNicResponseHandler(FirewallResponseHandler firewallResponseHandler) {
- this.builder = Nic.builder();
- this.firewallResponseHandler = firewallResponseHandler;
- this.ips = new ArrayList<String>();
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if ("firewall".equals(qName))
- useFirewallParser = true;
- if (useFirewallParser)
- firewallResponseHandler.startElement(uri, localName, qName, attributes);
- }
-
- @Override
- public void characters(char[] ch, int start, int length) {
- if (useFirewallParser)
- firewallResponseHandler.characters(ch, start, length);
- else
- super.characters(ch, start, length);
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("dataCenterId".equals(qName))
- builder.dataCenterId(textToStringValue());
- else if ("nicName".equals(qName))
- builder.name(textToStringValue());
- else if ("nicId".equals(qName))
- builder.id(textToStringValue());
- else if ("lanId".equals(qName))
- builder.lanId(textToIntValue());
- else if ("internetAccess".equals(qName))
- builder.internetAccess(textToBooleanValue());
- else if ("serverId".equals(qName))
- builder.serverId(textToStringValue());
- else if ("ips".equals(qName))
- ips.add(textToStringValue());
- else if ("macAddress".equals(qName))
- builder.macAddress(textToStringValue());
- else if ("dhcpActive".equals(qName))
- builder.dhcpActive(textToBooleanValue());
- else if ("gatewayIp".equals(qName))
- builder.gatewayIp(textToStringValue());
- else if ("provisioningState".equals(qName))
- builder.state(ProvisioningState.fromValue(textToStringValue()));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandler.java
deleted file mode 100644
index 8f8ba03..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandler.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.profitbricks.http.parser.nic;
-
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Handler for parsing SOAP response where <i>nicId</i> is the only <i>usable</i> value.
- *
- * Other properties available (which are ignored): requestId, dataCenterId, dataCenterVersion
- */
-public class NicIdOnlyResponseHandler extends BaseProfitBricksResponseHandler<String> {
-
- private String nicId;
-
- NicIdOnlyResponseHandler() {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- clearTextBuffer();
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("nicId".equals(qName))
- nicId = textToStringValue();
- }
-
- @Override
- public String getResult() {
- return nicId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandler.java
deleted file mode 100644
index 87e7f43..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandler.java
+++ /dev/null
@@ -1,73 +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.profitbricks.http.parser.nic;
-
-import java.util.ArrayList;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-
-import org.jclouds.profitbricks.domain.Nic;
-import org.xml.sax.SAXException;
-
-import java.util.List;
-
-import org.jclouds.profitbricks.http.parser.firewall.FirewallResponseHandler;
-
-public class NicListResponseHandler extends BaseNicResponseHandler<List<Nic>> {
-
- private List<Nic> nics;
-
- @Inject
- public NicListResponseHandler(FirewallResponseHandler firewallResponseHandler) {
- super(firewallResponseHandler);
- this.nics = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (useFirewallParser)
- firewallResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName) || "nics".equals(qName)) {
- nics.add(builder
- .ips(ips)
- .firewall(firewallResponseHandler.getResult())
- .build());
- builder = Nic.builder();
- ips = new ArrayList<String>();
- firewallResponseHandler.reset();
- }
- clearTextBuffer();
- }
-
- if ("firewall".equals(qName))
- useFirewallParser = false;
- }
-
- @Override
- public void reset() {
- this.ips = new ArrayList<String>();
- this.nics = Lists.newArrayList();
- }
-
- @Override
- public List<Nic> getResult() {
- return nics;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandler.java
deleted file mode 100644
index ec4dd10..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandler.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.profitbricks.http.parser.nic;
-
-import java.util.ArrayList;
-
-import com.google.inject.Inject;
-
-import org.jclouds.profitbricks.domain.Nic;
-import org.jclouds.profitbricks.http.parser.firewall.FirewallResponseHandler;
-import org.xml.sax.SAXException;
-
-public class NicResponseHandler extends BaseNicResponseHandler<Nic> {
-
- private boolean done = false;
-
- @Inject
- public NicResponseHandler(FirewallResponseHandler firewallResponseHandler) {
- super(firewallResponseHandler);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (done)
- return;
-
- if (useFirewallParser)
- firewallResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- done = true;
- builder.ips(ips)
- .firewall(firewallResponseHandler.getResult());
- ips = new ArrayList<String>();
- firewallResponseHandler.reset();
- }
- clearTextBuffer();
- }
-
- if ("firewall".equals(qName))
- useFirewallParser = false;
- }
-
- @Override
- public Nic getResult() {
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/BasePublicIpResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/BasePublicIpResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/BasePublicIpResponseHandler.java
deleted file mode 100644
index 8561aad..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/BasePublicIpResponseHandler.java
+++ /dev/null
@@ -1,38 +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.profitbricks.http.parser.publicip;
-
-import org.jclouds.profitbricks.domain.IpBlock;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-
-public abstract class BasePublicIpResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
-
- protected IpBlock.PublicIp.Builder builder;
-
- BasePublicIpResponseHandler() {
- this.builder = IpBlock.PublicIp.builder();
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("ip".equals(qName))
- builder.ip(textToStringValue());
- else if ("nicId".equals(qName))
- builder.nicId(textToStringValue());
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/PublicIpListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/PublicIpListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/PublicIpListResponseHandler.java
deleted file mode 100644
index 8b01be9..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/publicip/PublicIpListResponseHandler.java
+++ /dev/null
@@ -1,53 +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.profitbricks.http.parser.publicip;
-
-import com.google.common.collect.Lists;
-import java.util.List;
-import org.jclouds.profitbricks.domain.IpBlock.PublicIp;
-import org.xml.sax.SAXException;
-
-public class PublicIpListResponseHandler extends BasePublicIpResponseHandler<List<PublicIp>> {
-
- private List<PublicIp> publicIps;
-
- PublicIpListResponseHandler() {
- this.publicIps = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
-
- if ("publicIps".equals(qName)){
- publicIps.add(builder.build());
- this.builder = PublicIp.builder();
- }
- clearTextBuffer();
- }
-
- @Override
- public void reset() {
- this.publicIps = Lists.newArrayList();
- }
-
- @Override
- public List<PublicIp> getResult() {
- return publicIps;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/BaseServerResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/BaseServerResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/BaseServerResponseHandler.java
deleted file mode 100644
index 2185aed..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/BaseServerResponseHandler.java
+++ /dev/null
@@ -1,136 +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.profitbricks.http.parser.server;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Date;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.AvailabilityZone;
-import org.jclouds.profitbricks.domain.DataCenter;
-import org.jclouds.profitbricks.domain.OsType;
-import org.jclouds.profitbricks.domain.ProvisioningState;
-import org.jclouds.profitbricks.domain.Server;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
-import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public abstract class BaseServerResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
-
- protected final StorageListResponseHandler storageListResponseHandler;
- protected final NicListResponseHandler nicListResponseHandler;
-
- protected DataCenter.Builder dataCenterBuilder;
- protected Server.Builder builder;
-
- protected final DateService dateService;
-
- protected boolean useStorageParser = false;
- protected boolean useNicParser = false;
-
- BaseServerResponseHandler(DateService dateService, StorageListResponseHandler storageListResponseHandler,
- NicListResponseHandler nicListResponseHandler) {
- checkNotNull(dateService, "DateService cannot be null");
- checkNotNull(storageListResponseHandler, "StorageListResponseHandler cannot be null");
- checkNotNull(nicListResponseHandler, "NicListResponseHandler cannot be null");
-
- this.dateService = dateService;
- this.storageListResponseHandler = storageListResponseHandler;
- this.nicListResponseHandler = nicListResponseHandler;
- this.builder = Server.builder();
- this.dataCenterBuilder = DataCenter.builder();
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if ("connectedStorages".equals(qName))
- useStorageParser = true;
- else if ("nics".equals(qName))
- useNicParser = true;
-
- if (useStorageParser)
- storageListResponseHandler.startElement(uri, localName, qName, attributes);
- else if (useNicParser)
- nicListResponseHandler.startElement(uri, localName, qName, attributes);
- else
- super.startElement(uri, localName, qName, attributes);
- }
-
- @Override
- public void characters(char[] ch, int start, int length) {
- if (useStorageParser)
- storageListResponseHandler.characters(ch, start, length);
- else if (useNicParser)
- nicListResponseHandler.characters(ch, start, length);
- else
- super.characters(ch, start, length);
- }
-
- protected final Date textToIso8601Date() {
- return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("dataCenterId".equals(qName))
- dataCenterBuilder.id(textToStringValue());
- else if ("dataCenterVersion".equals(qName))
- dataCenterBuilder.version(textToIntValue());
- else if ("serverId".equals(qName))
- builder.id(textToStringValue());
- else if ("serverName".equals(qName))
- builder.name(textToStringValue());
- else if ("cores".equals(qName))
- builder.cores(textToIntValue());
- else if ("ram".equals(qName))
- builder.ram(textToIntValue());
- else if ("provisioningState".equals(qName))
- builder.state(ProvisioningState.fromValue(textToStringValue()));
- else if ("virtualMachineState".equals(qName))
- builder.status(Server.Status.fromValue(textToStringValue()));
- else if ("osType".equals(qName))
- builder.osType(OsType.fromValue(textToStringValue()));
- else if ("availabilityZone".equals(qName))
- builder.availabilityZone(AvailabilityZone.fromValue(textToStringValue()));
- else if ("creationTime".equals(qName))
- builder.creationTime(textToIso8601Date());
- else if ("lastModificationTime".equals(qName))
- builder.lastModificationTime(textToIso8601Date());
- else if ("internetAccess".equals(qName))
- builder.hasInternetAccess(textToBooleanValue());
- else if ("cpuHotPlug".equals(qName))
- builder.isCpuHotPlug(textToBooleanValue());
- else if ("ramHotPlug".equals(qName))
- builder.isRamHotPlug(textToBooleanValue());
- else if ("nicHotPlug".equals(qName))
- builder.isNicHotPlug(textToBooleanValue());
- else if ("nicHotUnPlug".equals(qName))
- builder.isNicHotUnPlug(textToBooleanValue());
- else if ("discVirtioHotPlug".equals(qName))
- builder.isDiscVirtioHotPlug(textToBooleanValue());
- else if ("discVirtioHotUnPlug".equals(qName))
- builder.isDiscVirtioHotUnPlug(textToBooleanValue());
- else if ("activate".equals(qName))
- builder.loadBalanced(textToBooleanValue());
- else if ("balancedNicId".equals(qName))
- builder.balancedNicId(textToStringValue());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerIdOnlyResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerIdOnlyResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerIdOnlyResponseHandler.java
deleted file mode 100644
index 1c74354..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerIdOnlyResponseHandler.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.profitbricks.http.parser.server;
-
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Handler for parsing SOAP response where <i>serverId</i> is the only <i>usable</i> value.
- *
- * Other properties available (which are ignored): requestId, dataCenterId, dataCenterVersion
- */
-public class ServerIdOnlyResponseHandler extends BaseProfitBricksResponseHandler<String> {
-
- private String serverId;
-
- ServerIdOnlyResponseHandler() {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- clearTextBuffer();
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("serverId".equals(qName))
- serverId = textToStringValue();
- }
-
- @Override
- public String getResult() {
- return serverId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandler.java
deleted file mode 100644
index 016e164..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandler.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.profitbricks.http.parser.server;
-
-import com.google.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.Server;
-import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
-import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
-import org.xml.sax.SAXException;
-
-public class ServerInfoResponseHandler extends BaseServerResponseHandler<Server> {
-
- private boolean done = false;
-
- @Inject
- ServerInfoResponseHandler(DateService dateService, StorageListResponseHandler storageListResponseHandler,
- NicListResponseHandler nicListResponseHandler) {
- super(dateService, storageListResponseHandler, nicListResponseHandler);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (done)
- return;
-
- if (useStorageParser)
- storageListResponseHandler.endElement(uri, localName, qName);
- else if (useNicParser)
- nicListResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- done = true;
- builder
- .dataCenter(dataCenterBuilder.build())
- .storages(storageListResponseHandler.getResult())
- .nics(nicListResponseHandler.getResult());
- }
- clearTextBuffer();
- }
-
- if ("connectedStorages".equals(qName))
- useStorageParser = false;
- else if ("nics".equals(qName))
- useNicParser = false;
- }
-
- @Override
- public Server getResult() {
- return builder.build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandler.java
deleted file mode 100644
index d39fbad..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandler.java
+++ /dev/null
@@ -1,89 +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.profitbricks.http.parser.server;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-
-import java.util.List;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.DataCenter;
-import org.jclouds.profitbricks.domain.Server;
-import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler;
-import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler;
-import org.xml.sax.SAXException;
-
-public class ServerListResponseHandler extends BaseServerResponseHandler<List<Server>> {
-
- private List<Server> servers;
-
- @Inject
- ServerListResponseHandler(DateService dateService, StorageListResponseHandler storageListResponseHandler,
- NicListResponseHandler nicListResponseHandler) {
- super(dateService, storageListResponseHandler, nicListResponseHandler);
- this.servers = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
-
- if (useStorageParser)
- storageListResponseHandler.endElement(uri, localName, qName);
- else if (useNicParser)
- nicListResponseHandler.endElement(uri, localName, qName);
- else {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName) || "servers".equals(qName) || "balancedServers".equals(qName)) {
- Server.Builder sdb = null;
- try {
- sdb = builder
- .storages(storageListResponseHandler.getResult())
- .nics(nicListResponseHandler.getResult());
- servers.add(sdb
- // For LoadBalancer's case, there's no DataCenter (may throw NPE on #build()).
- .dataCenter(dataCenterBuilder.build())
- .build());
- } catch (Exception ex) {
- servers.add(sdb.build());
- }
- storageListResponseHandler.reset();
- nicListResponseHandler.reset();
-
- builder = Server.builder();
- }
- clearTextBuffer();
- }
-
- if ("connectedStorages".equals(qName))
- useStorageParser = false;
- else if ("nics".equals(qName))
- useNicParser = false;
- }
-
- @Override
- public void reset() {
- this.servers = Lists.newArrayList();
- this.dataCenterBuilder = DataCenter.builder();
- }
-
- @Override
- public List<Server> getResult() {
- return servers;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/BaseSnapshotResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/BaseSnapshotResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/BaseSnapshotResponseHandler.java
deleted file mode 100644
index aa27199..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/BaseSnapshotResponseHandler.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.profitbricks.http.parser.snapshot;
-
-import java.util.Date;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.Location;
-import org.jclouds.profitbricks.domain.OsType;
-import org.jclouds.profitbricks.domain.ProvisioningState;
-import org.jclouds.profitbricks.domain.Snapshot;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-
-public abstract class BaseSnapshotResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
-
- protected Snapshot.Builder builder;
-
- protected final DateService dateService;
-
- BaseSnapshotResponseHandler(DateService dateService) {
- this.dateService = dateService;
- this.builder = Snapshot.builder();
- }
-
- protected final Date textToIso8601Date() {
- return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("snapshotId".equals(qName))
- builder.id(textToStringValue());
- else if ("snapshotName".equals(qName))
- builder.name(textToStringValue());
- else if ("snapshotSize".equals(qName))
- builder.size(textToFloatValue());
- else if ("osType".equals(qName))
- builder.osType(OsType.fromValue(textToStringValue()));
- else if ("location".equals(qName))
- builder.location(Location.fromId(textToStringValue()));
- else if ("description".equals(qName))
- builder.description(qName);
- else if ("bootable".equals(qName))
- builder.isBootable(textToBooleanValue());
- else if ("cpuHotPlug".equals(qName))
- builder.isCpuHotPlug(textToBooleanValue());
- else if ("cpuHotUnPlug".equals(qName))
- builder.isCpuHotUnPlug(textToBooleanValue());
- else if ("ramHotPlug".equals(qName))
- builder.isRamHotPlug(textToBooleanValue());
- else if ("ramHotUnPlug".equals(qName))
- builder.isRamHotUnPlug(textToBooleanValue());
- else if ("nicHotPlug".equals(qName))
- builder.isNicHotPlug(textToBooleanValue());
- else if ("nicHotUnPlug".equals(qName))
- builder.isNicHotUnPlug(textToBooleanValue());
- else if ("discVirtioHotPlug".equals(qName))
- builder.isDiscVirtioHotPlug(textToBooleanValue());
- else if ("discVirtioHotUnPlug".equals(qName))
- builder.isDiscVirtioHotUnPlug(textToBooleanValue());
- else if ("provisioningState".equals(qName))
- builder.state(ProvisioningState.fromValue(textToStringValue()));
- else if ("creationTimestamp".equals(qName))
- builder.creationTime(textToIso8601Date());
- else if ("modificationTimestamp".equals(qName))
- builder.lastModificationTime(textToIso8601Date());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotListResponseHandler.java
deleted file mode 100644
index 27e8583..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotListResponseHandler.java
+++ /dev/null
@@ -1,54 +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.profitbricks.http.parser.snapshot;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-
-import org.jclouds.profitbricks.domain.Snapshot;
-import org.xml.sax.SAXException;
-
-import java.util.List;
-
-import org.jclouds.date.DateService;
-
-public class SnapshotListResponseHandler extends BaseSnapshotResponseHandler<List<Snapshot>> {
-
- private final List<Snapshot> snapshots;
-
- @Inject
- SnapshotListResponseHandler(DateService dateService) {
- super(dateService);
- this.snapshots = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- snapshots.add(builder.build());
- builder = Snapshot.builder();
- }
- clearTextBuffer();
- }
-
- @Override
- public List<Snapshot> getResult() {
- return snapshots;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotResponseHandler.java
deleted file mode 100644
index c57e385..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/snapshot/SnapshotResponseHandler.java
+++ /dev/null
@@ -1,49 +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.profitbricks.http.parser.snapshot;
-
-import com.google.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.Snapshot;
-import org.xml.sax.SAXException;
-
-public class SnapshotResponseHandler extends BaseSnapshotResponseHandler<Snapshot> {
-
- private boolean done = false;
-
- @Inject
- SnapshotResponseHandler(DateService dateService) {
- super(dateService);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (done)
- return;
- setPropertyOnEndTag(qName);
- if ("return".equals(qName))
- done = true;
- clearTextBuffer();
- }
-
- @Override
- public Snapshot getResult() {
- return builder.build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/state/GetProvisioningStateResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/state/GetProvisioningStateResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/state/GetProvisioningStateResponseHandler.java
deleted file mode 100644
index d618cc1..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/state/GetProvisioningStateResponseHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.profitbricks.http.parser.state;
-
-import org.jclouds.profitbricks.domain.ProvisioningState;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.xml.sax.SAXException;
-
-public class GetProvisioningStateResponseHandler extends BaseProfitBricksResponseHandler<ProvisioningState> {
-
- private ProvisioningState state = ProvisioningState.UNRECOGNIZED;
-
- GetProvisioningStateResponseHandler() {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- clearTextBuffer();
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("return".equals(qName))
- state = ProvisioningState.fromValue(textToStringValue());
- }
-
- @Override
- public ProvisioningState getResult() {
- return state;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/BaseStorageResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/BaseStorageResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/BaseStorageResponseHandler.java
deleted file mode 100644
index 9026592..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/BaseStorageResponseHandler.java
+++ /dev/null
@@ -1,81 +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.profitbricks.http.parser.storage;
-
-import java.util.Date;
-import java.util.List;
-
-import com.google.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.ProvisioningState;
-import org.jclouds.profitbricks.domain.Storage;
-import org.jclouds.profitbricks.domain.Storage.BusType;
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-
-import com.google.common.collect.Lists;
-
-public abstract class BaseStorageResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
-
- protected final DateService dateService;
-
- protected Storage.Builder builder;
- protected List<String> serverIds;
-
- @Inject
- BaseStorageResponseHandler(DateService dateService) {
- this.dateService = dateService;
- this.builder = Storage.builder();
- this.serverIds = Lists.newArrayList();
- }
-
- protected final Date textToIso8601Date() {
- return dateService.iso8601DateOrSecondsDateParse(textToStringValue());
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
-// <requestId>?</requestId>
-// <dataCenterId>?</dataCenterId>
-// <dataCenterVersion>?</dataCenterVersion>
- if ("storageId".equals(qName))
- builder.id(textToStringValue());
- else if ("size".equals(qName))
- builder.size(textToFloatValue());
- else if ("storageName".equals(qName))
- builder.name(textToStringValue());
- else if ("provisioningState".equals(qName))
- builder.state(ProvisioningState.fromValue(textToStringValue()));
- else if ("creationTime".equals(qName))
- builder.creationTime(textToIso8601Date());
- else if ("lastModificationTime".equals(qName))
- builder.lastModificationTime(textToIso8601Date());
-// <mountImage>
-// <imageId>?</imageId>
-// <imageName>?</imageName>
-// </mountImage>
- else if ("serverIds".equals(qName))
- serverIds.add(textToStringValue());
- else if ("bootDevice".equals(qName))
- builder.bootDevice(textToBooleanValue());
- else if ("busType".equals(qName))
- builder.busType(BusType.fromValue(textToStringValue()));
- else if ("deviceNumber".equals(qName))
- builder.deviceNumber(textToIntValue());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageIdOnlyResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageIdOnlyResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageIdOnlyResponseHandler.java
deleted file mode 100644
index ac3a039..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageIdOnlyResponseHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.profitbricks.http.parser.storage;
-
-import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
-import org.xml.sax.SAXException;
-
-public class StorageIdOnlyResponseHandler extends BaseProfitBricksResponseHandler<String> {
-
- private String storageId;
-
- StorageIdOnlyResponseHandler() {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- clearTextBuffer();
- }
-
- @Override
- protected void setPropertyOnEndTag(String qName) {
- if ("storageId".equals(qName))
- storageId = textToStringValue();
- }
-
- @Override
- public String getResult() {
- return storageId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageInfoResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageInfoResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageInfoResponseHandler.java
deleted file mode 100644
index ae667ca..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageInfoResponseHandler.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.profitbricks.http.parser.storage;
-
-import com.google.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.Storage;
-import org.xml.sax.SAXException;
-
-public class StorageInfoResponseHandler extends BaseStorageResponseHandler<Storage> {
-
- private boolean done = false;
-
- @Inject
- StorageInfoResponseHandler(DateService dateService) {
- super(dateService);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (done)
- return;
- setPropertyOnEndTag(qName);
- if ("return".equals(qName)) {
- done = true;
- builder.serverIds(serverIds);
- }
- clearTextBuffer();
- }
-
- @Override
- public Storage getResult() {
- return builder.build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageListResponseHandler.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageListResponseHandler.java
deleted file mode 100644
index 3048f66..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/storage/StorageListResponseHandler.java
+++ /dev/null
@@ -1,61 +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.profitbricks.http.parser.storage;
-
-import java.util.List;
-
-import org.jclouds.date.DateService;
-import org.jclouds.profitbricks.domain.Storage;
-import org.xml.sax.SAXException;
-
-import com.google.inject.Inject;
-import com.google.common.collect.Lists;
-
-public class StorageListResponseHandler extends BaseStorageResponseHandler<List<Storage>> {
-
- private List<Storage> storages;
-
- @Inject
- StorageListResponseHandler(DateService dateService) {
- super(dateService);
- this.storages = Lists.newArrayList();
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- setPropertyOnEndTag(qName);
- if ("return".equals(qName) || "connectedStorages".equals(qName) || "storages".equals(qName)) {
- storages.add(builder
- .serverIds(serverIds)
- .build());
- builder = Storage.builder();
- serverIds = Lists.newArrayList();
- }
- clearTextBuffer();
- }
-
- @Override
- public void reset() {
- this.storages = Lists.newArrayList();
- }
-
- @Override
- public List<Storage> getResult() {
- return storages;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/util/MacAddresses.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/util/MacAddresses.java b/profitbricks/src/main/java/org/jclouds/profitbricks/util/MacAddresses.java
deleted file mode 100644
index 5725e4b..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/util/MacAddresses.java
+++ /dev/null
@@ -1,29 +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.profitbricks.util;
-
-import java.util.regex.Pattern;
-
-public class MacAddresses {
-
- private static final String MAC_ADDR_FORMAT = "^([0-9a-f]{2}[:]){5}([0-9a-f]{2})$";
- private static final Pattern MAC_ADDR_PATTERN = Pattern.compile(MAC_ADDR_FORMAT);
-
- public static boolean isMacAddress(String in) {
- return MAC_ADDR_PATTERN.matcher(in).matches();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/util/Passwords.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/util/Passwords.java b/profitbricks/src/main/java/org/jclouds/profitbricks/util/Passwords.java
deleted file mode 100644
index 338f064..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/util/Passwords.java
+++ /dev/null
@@ -1,64 +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.profitbricks.util;
-
-import java.util.Random;
-import java.util.regex.Pattern;
-
-import com.google.common.collect.ImmutableSet;
-
-public class Passwords {
-
- private static final Random random = new Random();
-
- private static final int MIN_CHAR = 8;
- private static final int MAX_CHAR = 50;
- private static final String PASSWORD_FORMAT = String.format(
- "[a-zA-Z0-9][^iIloOwWyYzZ10]{%d,%d}", MIN_CHAR - 1, MAX_CHAR);
- private static final Pattern PASSWORD_PATTERN = Pattern.compile(PASSWORD_FORMAT);
-
- private static final ImmutableSet<Character> INVALID_CHARS = ImmutableSet.<Character>of(
- 'i', 'I', 'l', 'o', 'O', 'w', 'W', 'y', 'Y', 'z', 'Z', '1', '0');
-
- public static boolean isValidPassword(String password) {
- return PASSWORD_PATTERN.matcher(password).matches();
- }
-
- public static String generate() {
- int count = random.nextInt(MAX_CHAR - MIN_CHAR) + MIN_CHAR;
-
- final char[] buffer = new char[count];
-
- final int start = 'A';
- final int end = 'z';
- final int gap = end - start + 1;
-
- while (count-- != 0) {
- char ch = (char) (random.nextInt(gap) + start);
- if ((isBetween(ch, start, 'Z') || isBetween(ch, 'a', end))
- && !INVALID_CHARS.contains(ch))
- buffer[count] = ch;
- else
- count++;
- }
- return new String(buffer);
- }
-
- private static boolean isBetween(char ch, int start, int end) {
- return ch >= start && ch <= end;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/util/Preconditions.java
----------------------------------------------------------------------
diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/util/Preconditions.java b/profitbricks/src/main/java/org/jclouds/profitbricks/util/Preconditions.java
deleted file mode 100644
index b15689d..0000000
--- a/profitbricks/src/main/java/org/jclouds/profitbricks/util/Preconditions.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.profitbricks.util;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static com.google.common.net.InetAddresses.isInetAddress;
-import static org.jclouds.profitbricks.util.MacAddresses.isMacAddress;
-import static org.jclouds.profitbricks.util.Passwords.isValidPassword;
-
-import java.util.List;
-import java.util.regex.Pattern;
-
-import org.jclouds.profitbricks.domain.Firewall;
-import org.jclouds.profitbricks.domain.Firewall.Protocol;
-
-/**
- * Static convenience methods for validating various ProfitBricks domain preconditions
- */
-public final class Preconditions {
-
- private static final Pattern INVALID_CHARS = Pattern.compile("^.*[@/\\|'`’^].*$");
-
- public static void checkInvalidChars(String name) {
- checkArgument(!isNullOrEmpty(name), "Name is required.");
- checkArgument(!INVALID_CHARS.matcher(name).matches(), "Name must not contain any of: @ / \\ | ' ` ’ ^");
- }
-
- public static void checkIp(String ip) {
- checkArgument(isInetAddress(ip), "IP '%s' is invalid", ip);
- }
-
- public static void checkIps(List<String> ips) {
- checkNotNull(ips, "Null ip list");
- for (String ip : ips)
- checkIp(ip);
- }
-
- public static void checkPortRange(Integer portRangeStart, Integer portRangeEnd, Firewall.Protocol protocol) {
- checkArgument(!(portRangeEnd == null ^ portRangeStart == null), "Port range must be both present or null");
- if (portRangeEnd != null) {
- checkArgument(protocol == Firewall.Protocol.TCP || protocol == Firewall.Protocol.UDP, "Port range can only be set for TCP or UDP");
- checkArgument(portRangeEnd > portRangeStart, "portRangeEnd must be greater than portRangeStart");
- checkArgument(portRangeEnd >= 1 && portRangeEnd <= 65534, "Port range end must be 1 to 65534");
- checkArgument(portRangeStart >= 1 && portRangeStart <= 65534, "Port range start must be 1 to 65534");
- }
- }
-
- public static void checkMacAddress(String macAddress) {
- checkArgument(isMacAddress(macAddress), "MAC must match pattern 'aa:bb:cc:dd:ee:ff'");
- }
-
- public static void checkIcmp(Integer icmpType, Integer icmpCode, Protocol protocol) {
- checkNotNull(protocol, "Protocol can't be null");
- if (protocol == Protocol.ICMP) {
- if (icmpType != null)
- checkArgument(icmpType >= 1 && icmpType <= 254, "ICMP type must be 1 to 254");
- if (icmpCode != null)
- checkArgument(icmpCode >= 1 && icmpCode <= 254, "ICMP code must be 1 to 254");
- }
- }
-
- public static void checkLanId(Integer id) {
- checkArgument(id >= 0, "LAN ID must be non-negative");
- }
-
- public static void checkCores(Integer cores) {
- checkArgument(cores > 0, "Number of cores must be atleast 1.");
- }
-
- public static void checkRam(Integer ram, Boolean isRamHotPlug) {
- int minRam = (isRamHotPlug == null || !isRamHotPlug) ? 256 : 1024;
- checkArgument(ram >= minRam && ram % 256 == 0, "RAM must be multiples of 256 with minimum of 256 MB "
- + "(1024 MB if ramHotPlug is enabled)");
- }
-
- public static void checkSize(Float size) {
- checkArgument(size > 1, "Storage size must be > 1GB");
- }
-
- public static void checkPassword(String password) {
- checkArgument(isValidPassword(password), "Password must be between 8 and 50 characters, "
- + "only a-z, A-Z, 0-9 without characters i, I, l, o, O, w, W, y, Y, z, Z and 1, 0");
- }
-}