http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/features/IpBlockApi.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/features/IpBlockApi.java b/profitbricks/src/main/java/org/jclouds/profitbricks/features/IpBlockApi.java deleted file mode 100644 index ca9841d..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/features/IpBlockApi.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.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.profitbricks.domain.IpBlock; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.http.filters.ProfitBricksSoapMessageEnvelope; -import org.jclouds.profitbricks.http.parser.RequestIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.ipblock.IpBlockListResponseHandler; -import org.jclouds.profitbricks.http.parser.ipblock.IpBlockResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; - -@RequestFilters({BasicAuthentication.class, ProfitBricksSoapMessageEnvelope.class}) -@Consumes(MediaType.TEXT_XML) -@Produces(MediaType.TEXT_XML) -public interface IpBlockApi { - - @POST - @Named("publicipblock:get") - @Payload("<ws:getPublicIpBlock><blockId>{id}</blockId></ws:getPublicIpBlock>") - @XMLResponseParser(IpBlockResponseHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - IpBlock getIpBlock(@PayloadParam("id") String identifier); - - @POST - @Named("publicipblock:getall") - @Payload("<ws:getAllPublicIpBlocks />") - @XMLResponseParser(IpBlockListResponseHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<IpBlock> getAllIpBlock(); - - @POST - @Named("publicipblock:reserve") - @Payload("<ws:reservePublicIpBlock><request><blockSize>{blockSize}</blockSize><location>{location}</location></request></ws:reservePublicIpBlock>") - @XMLResponseParser(IpBlockResponseHandler.class) - IpBlock reservePublicIpBlock(@PayloadParam("blockSize") int blockSize, @PayloadParam("location") Location location); - - @POST - @Named("publicipblock:addip") - @Payload("<ws:addPublicIpToNic><ip>{ip}</ip><nicId>{nicid}</nicId></ws:addPublicIpToNic>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String addPublicIpToNic(@PayloadParam("ip") String ip, @PayloadParam("nicid") String nicid); - - @POST - @Named("publicipblock:removeip") - @Payload("<ws:removePublicIpFromNic><ip>{ip}</ip><nicId>{nicid}</nicId></ws:removePublicIpFromNic>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String removePublicIpFromNic(@PayloadParam("ip") String ip, @PayloadParam("nicid") String nicid); - - @POST - @Named("publicipblock:releaseblock") - @Payload("<ws:releasePublicIpBlock><blockId>{blockid}</blockId></ws:releasePublicIpBlock>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String releasePublicIpBlock(@PayloadParam("blockid") String blockid); -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/features/LoadBalancerApi.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/features/LoadBalancerApi.java b/profitbricks/src/main/java/org/jclouds/profitbricks/features/LoadBalancerApi.java deleted file mode 100644 index 6cf8e23..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/features/LoadBalancerApi.java +++ /dev/null @@ -1,93 +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.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import java.util.List; - -import org.jclouds.Fallbacks; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.profitbricks.binder.loadbalancer.CreateLoadBalancerRequestBinder; -import org.jclouds.profitbricks.binder.loadbalancer.DeregisterLoadBalancerRequestBinder; -import org.jclouds.profitbricks.binder.loadbalancer.RegisterLoadBalancerRequestBinder; -import org.jclouds.profitbricks.binder.loadbalancer.UpdateLoadBalancerRequestBinder; -import org.jclouds.profitbricks.domain.LoadBalancer; -import org.jclouds.profitbricks.http.filters.ProfitBricksSoapMessageEnvelope; -import org.jclouds.profitbricks.http.parser.RequestIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.loadbalancer.LoadBalancerIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.loadbalancer.LoadBalancerListResponseHandler; -import org.jclouds.profitbricks.http.parser.loadbalancer.LoadBalancerResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; - -@RequestFilters({BasicAuthentication.class, ProfitBricksSoapMessageEnvelope.class}) -@Consumes(MediaType.TEXT_XML) -@Produces(MediaType.TEXT_XML) -public interface LoadBalancerApi { - - @POST - @Named("loadbalancer:getall") - @Payload("<ws:getAllLoadBalancers/>") - @XMLResponseParser(LoadBalancerListResponseHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<LoadBalancer> getAllLoadBalancers(); - - @POST - @Named("loadbalancer:get") - @Payload("<ws:getLoadBalancer><loadBalancerId>{id}</loadBalancerId></ws:getLoadBalancer>") - @XMLResponseParser(LoadBalancerResponseHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - LoadBalancer getLoadBalancer(@PayloadParam("id") String identifier); - - @POST - @Named("loadbalancer:create") - @MapBinder(CreateLoadBalancerRequestBinder.class) - @XMLResponseParser(LoadBalancerIdOnlyResponseHandler.class) - String createLoadBalancer(@PayloadParam("loadbalancer") LoadBalancer.Request.CreatePayload payload); - - @POST - @Named("loadbalancer:register") - @MapBinder(RegisterLoadBalancerRequestBinder.class) - @XMLResponseParser(LoadBalancerResponseHandler.class) - LoadBalancer registerLoadBalancer(@PayloadParam("loadbalancer") LoadBalancer.Request.RegisterPayload payload); - - @POST - @Named("loadbalancer:deregister") - @MapBinder(DeregisterLoadBalancerRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String deregisterLoadBalancer(@PayloadParam("loadbalancer") LoadBalancer.Request.DeregisterPayload payload); - - @POST - @Named("loadbalancer:delete") - @Payload("<ws:deleteLoadBalancer><loadBalancerId>{id}</loadBalancerId></ws:deleteLoadBalancer>") - boolean deleteLoadBalancer(@PayloadParam("id") String id); - - @POST - @Named("loadbalancer:update") - @MapBinder(UpdateLoadBalancerRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String updateLoadBalancer(@PayloadParam("loadbalancer") LoadBalancer.Request.UpdatePayload payload); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/features/NicApi.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/features/NicApi.java b/profitbricks/src/main/java/org/jclouds/profitbricks/features/NicApi.java deleted file mode 100644 index c945935..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/features/NicApi.java +++ /dev/null @@ -1,88 +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.features; - -import org.jclouds.Fallbacks; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.profitbricks.binder.nic.CreateNicRequestBinder; -import org.jclouds.profitbricks.binder.nic.SetInternetAccessBinder; -import org.jclouds.profitbricks.binder.nic.UpdateNicRequestBinder; -import org.jclouds.profitbricks.domain.Nic; -import org.jclouds.profitbricks.http.filters.ProfitBricksSoapMessageEnvelope; -import org.jclouds.profitbricks.http.parser.nic.NicListResponseHandler; -import org.jclouds.profitbricks.http.parser.nic.NicResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.POST; - -import java.util.List; - -import org.jclouds.profitbricks.http.parser.RequestIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.nic.NicIdOnlyResponseHandler; - -@RequestFilters({BasicAuthentication.class, ProfitBricksSoapMessageEnvelope.class}) -@Consumes(MediaType.TEXT_XML) -@Produces(MediaType.TEXT_XML) -public interface NicApi { - - @POST - @Named("nics:getall") - @Payload("<ws:getAllNic/>") - @XMLResponseParser(NicListResponseHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<Nic> getAllNics(); - - @POST - @Named("nic:create") - @MapBinder(CreateNicRequestBinder.class) - @XMLResponseParser(NicIdOnlyResponseHandler.class) - String createNic(@PayloadParam("nic") Nic.Request.CreatePayload payload); - - @POST - @Named("nic:get") - @Payload("<ws:getNic><nicId>{id}</nicId></ws:getNic>") - @XMLResponseParser(NicResponseHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Nic getNic(@PayloadParam("id") String identifier); - - @POST - @Named("nic:update") - @MapBinder(UpdateNicRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String updateNic(@PayloadParam("nic") Nic.Request.UpdatePayload payload); - - @POST - @Named("nic:setInternetAccess") - @MapBinder(SetInternetAccessBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String setInternetAccess(@PayloadParam("nic") Nic.Request.SetInternetAccessPayload payload); - - @POST - @Named("nic:delete") - @Payload("<ws:deleteNic><nicId>{id}</nicId></ws:deleteNic>") - @Fallback(Fallbacks.FalseOnNotFoundOr404.class) - boolean deleteNic(@PayloadParam("id") String id); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/features/ServerApi.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/features/ServerApi.java b/profitbricks/src/main/java/org/jclouds/profitbricks/features/ServerApi.java deleted file mode 100644 index 344797d..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/features/ServerApi.java +++ /dev/null @@ -1,166 +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.features; - -import java.util.List; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import org.jclouds.Fallbacks; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.profitbricks.binder.server.CreateServerRequestBinder; -import org.jclouds.profitbricks.binder.server.UpdateServerRequestBinder; -import org.jclouds.profitbricks.domain.Server; -import org.jclouds.profitbricks.http.filters.ProfitBricksSoapMessageEnvelope; -import org.jclouds.profitbricks.http.parser.RequestIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.server.ServerIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.server.ServerInfoResponseHandler; -import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; - -@RequestFilters({BasicAuthentication.class, ProfitBricksSoapMessageEnvelope.class}) -@Consumes(MediaType.TEXT_XML) -@Produces(MediaType.TEXT_XML) -public interface ServerApi { - - /** - * @return Returns information about all virtual server, such as configuration, provisioning status, power status, - * etc. - */ - @POST - @Named("server:getall") - @Payload("<ws:getAllServers/>") - @XMLResponseParser(ServerListResponseHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<Server> getAllServers(); - - /** - * @param identifier Identifier of the virtual server - * @return Returns information about a virtual server, such as configuration, provisioning status, power status, etc. - */ - @POST - @Named("server:get") - @Payload("<ws:getServer><serverId>{id}</serverId></ws:getServer>") - @XMLResponseParser(ServerInfoResponseHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Server getServer(@PayloadParam("id") String identifier); - - /** - * Starts an existing virtual server - * <ul> - * <li>Server may receive new public IP addresses if necessary </li> - * <li>Billing will continue</li> - * </ul> - * - * - * @param id Identifier of the target virtual server - * @return Identifier of current request - */ - @POST - @Named("server:start") - @Payload("<ws:startServer><serverId>{id}</serverId></ws:startServer>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String startServer(@PayloadParam("id") String id); - - /** - * - * Stops an existing virtual server forcefully (HARD stop) - * <ul> - * <li>Server will be forcefully powered off. Any unsaved data may be lost! </li> - * <li>Billing for this server will be stopped </li> - * <li>When restarting the server a new public IP gets assigned, alternatively, you can reserve IP addresses, see - * reservation of public IP blocks</li> - * </ul> - * - * A graceful stop of a server is not possible through the ProfitBricks API. We recommend to access and execute the - * command on the virtual server directly. Once the server was shutdown you still can use the "stopServer" method - * that will stop billing. - * - * @param id Identifier of the target virtual server - * @return Identifier of current request - */ - @POST - @Named("server:stop") - @Payload("<ws:stopServer><serverId>{id}</serverId></ws:stopServer>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String stopServer(@PayloadParam("id") String id); - - /** - * Resets an existing virtual server (POWER CYCLE). - * <ul> - * <li>Server will be forcefully powered off and restarted immediately. Any unsaved data may be lost!</li> - * <li> Billing will continue</li> - * </ul> - * <b>Graceful REBOOT</b> - * - * A graceful reboot of a server is not possible through the ProfitBricks API. We recommend to access and execute the - * command on the virtual server directly. - * - * @param id Identifier of the target virtual server - * @return Identifier of current request - */ - @POST - @Named("server:reset") - @Payload("<ws:resetServer><serverId>{id}</serverId></ws:resetServer>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String resetServer(@PayloadParam("id") String id); - - /** - * Creates a Virtual Server within an existing data center. Parameters can be specified to set up a boot device and - * connect the server to an existing LAN or the Internet. - * - * @param payload Payload - * @return serverId of the created server - */ - @POST - @Named("server:create") - @MapBinder(CreateServerRequestBinder.class) - @XMLResponseParser(ServerIdOnlyResponseHandler.class) - String createServer(@PayloadParam("server") Server.Request.CreatePayload payload); - - /** - * Updates parameters of an existing virtual server device. - * - * @param payload Payload - * @return Identifier of current request - */ - @POST - @Named("server:update") - @MapBinder(UpdateServerRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String updateServer(@PayloadParam("server") Server.Request.UpdatePayload payload); - - /** - * Deletes an existing Virtual Server. - * - * @param id Identifier of the target virtual server - * @return Identifier of current request - */ - @POST - @Named("server:delete") - @Payload("<ws:deleteServer><serverId>{id}</serverId></ws:deleteServer>") - @Fallback(Fallbacks.FalseOnNotFoundOr404.class) - boolean deleteServer(@PayloadParam("id") String id); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/features/SnapshotApi.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/features/SnapshotApi.java b/profitbricks/src/main/java/org/jclouds/profitbricks/features/SnapshotApi.java deleted file mode 100644 index 3faa386..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/features/SnapshotApi.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.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.profitbricks.binder.snapshot.CreateSnapshotRequestBinder; -import org.jclouds.profitbricks.binder.snapshot.RollbackSnapshotRequestBinder; -import org.jclouds.profitbricks.binder.snapshot.UpdateSnapshotRequestBinder; -import org.jclouds.profitbricks.domain.Snapshot; -import org.jclouds.profitbricks.http.filters.ProfitBricksSoapMessageEnvelope; -import org.jclouds.profitbricks.http.parser.RequestIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.snapshot.SnapshotResponseHandler; -import org.jclouds.profitbricks.http.parser.snapshot.SnapshotListResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; - -@RequestFilters({BasicAuthentication.class, ProfitBricksSoapMessageEnvelope.class}) -@Consumes(MediaType.TEXT_XML) -@Produces(MediaType.TEXT_XML) -public interface SnapshotApi { - - @POST - @Named("snapshot:getall") - @Payload("<ws:getAllSnapshots/>") - @XMLResponseParser(SnapshotListResponseHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<Snapshot> getAllSnapshots(); - - @POST - @Named("snapshot:get") - @Payload("<ws:getSnapshot><snapshotId>{snapshotId}</snapshotId></ws:getSnapshot>") - @XMLResponseParser(SnapshotResponseHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Snapshot getSnapshot(@PayloadParam("snapshotId") String identifier); - - @POST - @Named("snapshot:create") - @MapBinder(CreateSnapshotRequestBinder.class) - @XMLResponseParser(SnapshotResponseHandler.class) - Snapshot createSnapshot(@PayloadParam("snapshot") Snapshot.Request.CreatePayload payload); - - @POST - @Named("snapshot:update") - @MapBinder(UpdateSnapshotRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String updateSnapshot(@PayloadParam("snapshot") Snapshot.Request.UpdatePayload payload); - - @POST - @Named("snapshot:delete") - @Payload("<ws:deleteSnapshot><snapshotId>{id}</snapshotId></ws:deleteSnapshot>") - @Fallback(Fallbacks.FalseOnNotFoundOr404.class) - boolean deleteSnapshot(@PayloadParam("id") String id); - - @POST - @Named("snapshot:rollback") - @MapBinder(RollbackSnapshotRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String rollbackSnapshot(@PayloadParam("snapshot") Snapshot.Request.RollbackPayload payload); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/features/StorageApi.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/features/StorageApi.java b/profitbricks/src/main/java/org/jclouds/profitbricks/features/StorageApi.java deleted file mode 100644 index 0589af6..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/features/StorageApi.java +++ /dev/null @@ -1,137 +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.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.profitbricks.binder.storage.ConnectStorageToServerRequestBinder; -import org.jclouds.profitbricks.binder.storage.CreateStorageRequestBinder; -import org.jclouds.profitbricks.binder.storage.UpdateStorageRequestBinder; -import org.jclouds.profitbricks.domain.Storage; -import org.jclouds.profitbricks.http.filters.ProfitBricksSoapMessageEnvelope; -import org.jclouds.profitbricks.http.parser.RequestIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.storage.StorageIdOnlyResponseHandler; -import org.jclouds.profitbricks.http.parser.storage.StorageInfoResponseHandler; -import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; - -@RequestFilters({BasicAuthentication.class, ProfitBricksSoapMessageEnvelope.class}) -@Consumes(MediaType.TEXT_XML) -@Produces(MediaType.TEXT_XML) -public interface StorageApi { - - /** - * - * @return Returns information about all virtual storage, such as configuration and provisioning state. - */ - @POST - @Named("storage:getall") - @Payload("<ws:getAllStorages/>") - @XMLResponseParser(StorageListResponseHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<Storage> getAllStorages(); - - /** - * - * @param id Storage identifier - * @return Returns information about a virtual storageâs configuration and provisioning state. - */ - @POST - @Named("storage:get") - @Payload("<ws:getStorage><storageId>{id}</storageId></ws:getStorage>") - @XMLResponseParser(StorageInfoResponseHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Storage getStorage(@PayloadParam("id") String id); - - /** - * Creates a virtual storage within an existing virtual data center. Additional parameters can be specified, e.g. for - * assigning a HDD image to the storage. - * - * @param payload Payload - * @return storageId of the created storage - */ - @POST - @Named("storage:create") - @MapBinder(CreateStorageRequestBinder.class) - @XMLResponseParser(StorageIdOnlyResponseHandler.class) - String createStorage(@PayloadParam("storage") Storage.Request.CreatePayload payload); - - /** - * Updates parameters of an existing virtual storage device. It is possible to increase the storage size without - * reboot of an already provisioned storage. The additional capacity is not added to any partition. You have to - * partition the storage afterwards. Vice versa, it is not possible to decrease the storage size of an already - * provisioned storage. - * - * @param payload Payload - * @return Identifier of current request - */ - @POST - @Named("storage:update") - @MapBinder(UpdateStorageRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String updateStorage(@PayloadParam("storage") Storage.Request.UpdatePayload payload); - - /** - * Deletes an existing virtual storage device. - * - * @param id Identifier of the target virtual storage - * @return Identifier of current request - */ - @POST - @Named("storage:delete") - @Payload("<ws:deleteStorage><storageId>{id}</storageId></ws:deleteStorage>") - @Fallback(Fallbacks.FalseOnNotFoundOr404.class) - boolean deleteStorage(@PayloadParam("id") String id); - - /** - * Connects a virtual storage device to an existing server. - * - * @param payload Payload - * @return Identifier of current request - */ - @POST - @Named("storage:connect") - @MapBinder(ConnectStorageToServerRequestBinder.class) - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String connectStorageToServer(@PayloadParam("storage") Storage.Request.ConnectPayload payload); - - /** - * Disconnects a virtual storage device from a connected server. - * - * @param storageId Identifier of the connected virtual storage - * @param serverId Identifier of the connected virtual server - * @return Identifier of current request - */ - @POST - @Named("storage:disconnect") - @Payload("<ws:disconnectStorageFromServer><storageId>{storageId}</storageId><serverId>{serverId}</serverId></ws:disconnectStorageFromServer>") - @XMLResponseParser(RequestIdOnlyResponseHandler.class) - String disconnectStorageFromServer(@PayloadParam("storageId") String storageId, @PayloadParam("serverId") String serverId); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/handlers/ProfitBricksHttpErrorHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/handlers/ProfitBricksHttpErrorHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/handlers/ProfitBricksHttpErrorHandler.java deleted file mode 100644 index a4ecb50..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/handlers/ProfitBricksHttpErrorHandler.java +++ /dev/null @@ -1,75 +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.handlers; - -import static org.jclouds.util.Closeables2.closeQuietly; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.InsufficientResourcesException; -import org.jclouds.rest.ResourceNotFoundException; - -/** - * Parse ProfitBricks API errors and set the appropriate exception. - * - * @see org.jclouds.profitbricks.http.ResponseStatusFromPayloadHttpCommandExecutorService - * - */ -@Singleton -public class ProfitBricksHttpErrorHandler implements HttpErrorHandler { - - @Override - public void handleError(final HttpCommand command, final HttpResponse response) { - Exception exception = null; - try { - switch (response.getStatusCode()) { - case 400: - case 405: - exception = new IllegalArgumentException(response.getMessage(), exception); - break; - case 401: - exception = new AuthorizationException("This request requires authentication.", exception); - break; - case 402: - case 409: - exception = new IllegalStateException(response.getMessage(), exception); - break; - case 404: - case 410: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) - exception = new ResourceNotFoundException(response.getMessage(), exception); - break; - case 413: - case 503: - // if nothing (default message was OK) was parsed from command executor, assume it was an 503 (Maintenance) html response. - if (response.getMessage().equals("OK")) - exception = new HttpResponseException("The ProfitBricks team is currently carrying out maintenance.", command, response); - else - exception = new InsufficientResourcesException(response.getMessage(), exception); - break; - } - } finally { - closeQuietly(response.getPayload()); - command.setException(exception); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorService.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorService.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorService.java deleted file mode 100644 index 00ca238..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorService.java +++ /dev/null @@ -1,140 +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; - -import static org.jclouds.util.Closeables2.closeQuietly; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.Proxy; -import java.net.URI; -import java.util.regex.Pattern; - -import javax.inject.Named; -import javax.inject.Singleton; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.IOExceptionRetryHandler; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.handlers.DelegatingErrorHandler; -import org.jclouds.http.handlers.DelegatingRetryHandler; -import org.jclouds.http.internal.HttpWire; -import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService; -import org.jclouds.io.ContentMetadataCodec; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; -import org.jclouds.profitbricks.domain.ServiceFault; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.io.ByteStreams; -import com.google.inject.Inject; - -/** - * Custom implementation of the HTTP driver to read actual http status and message from SOAP Fault. - * <br/> - * ProfitBricks API errors are always returned with 500 HTTP code. This class parses and reads the SOAP response to map - * the actual http code and message - */ -@Singleton -public class ResponseStatusFromPayloadHttpCommandExecutorService extends JavaUrlHttpCommandExecutorService { - - private final ParseSax<ServiceFault> faultHandler; - - private static final Pattern endSoapTag = Pattern.compile("</.+:Envelope>$"); - - @Inject - ResponseStatusFromPayloadHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec, - DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler, - DelegatingErrorHandler errorHandler, HttpWire wire, @Named("untrusted") HostnameVerifier verifier, - @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider, Function<URI, Proxy> proxyForURI, - ParseSax<ServiceFault> faultHandler) { - super(utils, contentMetadataCodec, retryHandler, ioRetryHandler, errorHandler, wire, verifier, untrustedSSLContextProvider, proxyForURI); - this.faultHandler = faultHandler; - } - - @Override - protected HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { - HttpResponse originalResponse = super.invoke(connection); - HttpResponse.Builder<?> responseBuilder = originalResponse.toBuilder(); - - if (hasServerError(originalResponse) && hasPayload(originalResponse)) { - // As we need to read the response body to determine if there are errors, but we may need to process the body - // again later in the response parsers if everything is OK, we buffer the body into an InputStream we can reset - InputStream in = null; - InputStream originalInputStream = originalResponse.getPayload().openStream(); - - if (originalInputStream instanceof ByteArrayInputStream) - in = originalInputStream; - else - try { - in = new ByteArrayInputStream(ByteStreams.toByteArray(originalInputStream)); - } finally { - closeQuietly(originalInputStream); - } - try { - if (isSoapPayload(in)) { - ServiceFault fault = faultHandler.parse(in); - if (fault != null) - responseBuilder - .statusCode(fault.httpCode()) - .message(fault.message()); - } - } catch (Exception ex) { - // ignore - } finally { - // Reset the input stream and set the payload, so it can be read again - // by the response and error parsers - if (in != null) { - in.reset(); - Payload payload = Payloads.newInputStreamPayload(in); - contentMetadataCodec.fromHeaders(payload.getContentMetadata(), originalResponse.getHeaders()); - responseBuilder.payload(payload); - } - } - } - - return responseBuilder.build(); - } - - private static boolean hasServerError(final HttpResponse response) { - return response.getStatusCode() >= 500; - } - - private static boolean hasPayload(final HttpResponse response) { - return response.getPayload() != null && response.getPayload().getRawContent() != null; - } - - private static boolean isSoapPayload(final InputStream is) throws IOException { - int size = is.available(); - char[] chars = new char[size]; - byte[] bytes = new byte[size]; - - is.read(bytes, 0, size); - for (int i = 0; i < size;) - chars[i] = (char) (bytes[i++] & 0xff); - - is.reset(); // throws premature end of file w/o this - - return endSoapTag.matcher(new String(chars)).find(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelope.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelope.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelope.java deleted file mode 100644 index af78403..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelope.java +++ /dev/null @@ -1,59 +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.filters; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.http.HttpUtils; -import org.jclouds.io.ContentMetadata; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; - -/** - * Filters {@link HttpRequest} request and wraps request body into SOAP envelope. - */ -public class ProfitBricksSoapMessageEnvelope implements HttpRequestFilter { - - private final String SOAP_PREFIX - = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"http://ws.api.profitbricks.com/\">" - + "<soapenv:Header/>" - + "<soapenv:Body>"; - - private final String SOAP_SUFFIX = "</soapenv:Body></soapenv:Envelope>"; - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - checkNotNull(request.getPayload(), "HTTP Request must contain payload message."); - return createSoapRequest(request); - } - - private HttpRequest createSoapRequest(HttpRequest request) { - Payload oldPayload = request.getPayload(); - ContentMetadata oldMetadata = oldPayload.getContentMetadata(); - - String body = SOAP_PREFIX.concat(oldPayload.getRawContent().toString()).concat(SOAP_SUFFIX); - Payload newPayload = Payloads.newStringPayload(body); - HttpUtils.copy(oldMetadata, newPayload.getContentMetadata()); - newPayload.getContentMetadata().setContentLength(Long.valueOf(body.getBytes().length)); // resize, add prefix/suffix length - - return request.toBuilder().payload(newPayload).build(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/BaseProfitBricksResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/BaseProfitBricksResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/BaseProfitBricksResponseHandler.java deleted file mode 100644 index 3520b37..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/BaseProfitBricksResponseHandler.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; - -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -public abstract class BaseProfitBricksResponseHandler<T> extends ParseSax.HandlerForGeneratedRequestWithResult<T> { - - private final StringBuilder strBuilder; - - public BaseProfitBricksResponseHandler() { - this.strBuilder = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - strBuilder.append(ch, start, length); - } - - protected String textToStringValue() { - return strBuilder.toString().trim(); - } - - protected Float textToFloatValue() { - return Float.valueOf(textToStringValue()); - } - - protected Double textToDoubleValue() { - return Double.valueOf(textToStringValue()); - } - - protected int textToIntValue() { - return Integer.parseInt(textToStringValue()); - } - - protected boolean textToBooleanValue() { - return Boolean.parseBoolean(textToStringValue()); - } - - protected void clearTextBuffer() { - strBuilder.setLength(0); - } - - public void reset() { - - } - - @Override - public abstract void endElement(String uri, String localName, String qName) throws SAXException; - - protected abstract void setPropertyOnEndTag(String qName); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandler.java deleted file mode 100644 index 2914e50..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.http.parser; - -import org.xml.sax.SAXException; - -public class RequestIdOnlyResponseHandler extends BaseProfitBricksResponseHandler<String> { - - private String requestId; - - RequestIdOnlyResponseHandler() { - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - setPropertyOnEndTag(qName); - clearTextBuffer(); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("requestId".equals(qName)) - requestId = textToStringValue(); - } - - @Override - public String getResult() { - return requestId; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandler.java deleted file mode 100644 index f21c32e..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandler.java +++ /dev/null @@ -1,58 +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; - -import org.jclouds.profitbricks.domain.ServiceFault; -import org.xml.sax.SAXException; - -public class ServiceFaultResponseHandler extends BaseProfitBricksResponseHandler<ServiceFault> { - - private final ServiceFault.Builder builder; - private boolean done = false; - - ServiceFaultResponseHandler() { - this.builder = ServiceFault.builder(); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("faultCode".equals(qName)) - builder.faultCode(ServiceFault.FaultCode.fromValue(textToStringValue())); - else if ("httpCode".equals(qName)) - builder.httpCode(textToIntValue()); - else if ("message".equals(qName)) - builder.message(textToStringValue()); - else if ("requestId".equals(qName)) - builder.requestId(textToIntValue()); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (done) - return; - setPropertyOnEndTag(qName); - if ("detail".equals(qName)) - done = true; - clearTextBuffer(); - } - - @Override - public ServiceFault 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/datacenter/BaseDataCenterResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/BaseDataCenterResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/BaseDataCenterResponseHandler.java deleted file mode 100644 index 931d5e9..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/BaseDataCenterResponseHandler.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.datacenter; - -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler; - -public abstract class BaseDataCenterResponseHandler<T> extends BaseProfitBricksResponseHandler<T> { - - protected DataCenter.Builder builder; - - BaseDataCenterResponseHandler() { - this.builder = DataCenter.builder(); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("dataCenterId".equals(qName)) - builder.id(textToStringValue()); - else if ("dataCenterVersion".equals(qName)) - builder.version(textToIntValue()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandler.java deleted file mode 100644 index 3e833e5..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandler.java +++ /dev/null @@ -1,110 +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.datacenter; - -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.http.parser.server.ServerListResponseHandler; -import org.jclouds.profitbricks.http.parser.storage.StorageListResponseHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.inject.Inject; - -public class DataCenterInfoResponseHandler extends BaseDataCenterResponseHandler<DataCenter> { - - private final ServerListResponseHandler serverListResponseHandler; - private final StorageListResponseHandler storageListResponseHandler; - - private boolean done = false; - private boolean useServerParser = false; - private boolean useStorageParser = false; - - @Inject - DataCenterInfoResponseHandler(ServerListResponseHandler serverListResponseHandler, StorageListResponseHandler storageListResponseHandler) { - this.serverListResponseHandler = serverListResponseHandler; - this.storageListResponseHandler = storageListResponseHandler; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("servers".equals(qName)) - useServerParser = true; - else if ("storages".equals(qName)) - useStorageParser = true; - - if (useServerParser) - serverListResponseHandler.startElement(uri, localName, qName, attributes); - else if (useStorageParser) - storageListResponseHandler.startElement(uri, localName, qName, attributes); - else - super.startElement(uri, localName, qName, attributes); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - super.setPropertyOnEndTag(qName); - if ("dataCenterName".equals(qName)) - builder.name(textToStringValue()); - else if ("location".equals(qName)) - builder.location(Location.fromId(textToStringValue())); - else if ("provisioningState".equals(qName)) - builder.state(ProvisioningState.fromValue(textToStringValue())); - } - - @Override - public void characters(char[] ch, int start, int length) { - if (useServerParser) - serverListResponseHandler.characters(ch, start, length); - else if (useStorageParser) - storageListResponseHandler.characters(ch, start, length); - else - super.characters(ch, start, length); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (done) - return; - - if (useServerParser) - serverListResponseHandler.endElement(uri, localName, qName); - else if (useStorageParser) - storageListResponseHandler.endElement(uri, localName, qName); - else { - setPropertyOnEndTag(qName); - if ("return".equals(qName)) { - done = true; - builder.servers(serverListResponseHandler.getResult()); - builder.storages(storageListResponseHandler.getResult()); - } - clearTextBuffer(); - } - - if ("servers".equals(qName)) - useServerParser = false; - else if ("storages".equals(qName)) - useStorageParser = false; - } - - @Override - public DataCenter 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/datacenter/DataCenterListResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandler.java deleted file mode 100644 index b66264e..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandler.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.datacenter; - -import java.util.List; - -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; - -public class DataCenterListResponseHandler extends BaseDataCenterResponseHandler<List<DataCenter>> { - - private final List<DataCenter> dataCenters; - - DataCenterListResponseHandler() { - this.dataCenters = Lists.newArrayList(); - } - - @Override - public List<DataCenter> getResult() { - return dataCenters; - } - - @Override - protected void setPropertyOnEndTag(String qName) { - super.setPropertyOnEndTag(qName); - if ("dataCenterName".equals(qName)) - builder.name(textToStringValue()); - else if ("location".equals(qName)) - builder.location(Location.fromValue(textToStringValue())); - else if ("provisioningState".equals(qName)) - builder.state(ProvisioningState.fromValue(textToStringValue())); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - setPropertyOnEndTag(qName); - if ("return".equals(qName)) { - dataCenters.add(builder.build()); - builder = DataCenter.builder(); - } - clearTextBuffer(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/BaseFirewallResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/BaseFirewallResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/BaseFirewallResponseHandler.java deleted file mode 100644 index 310156b..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/BaseFirewallResponseHandler.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.firewall; - -import com.google.inject.Inject; - -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler; -import org.jclouds.profitbricks.http.parser.firewall.rule.FirewallRuleListResponseHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -public abstract class BaseFirewallResponseHandler<T> extends BaseProfitBricksResponseHandler<T> { - - protected final FirewallRuleListResponseHandler firewallRuleListResponseHandler; - - protected boolean useFirewallRuleParser = false; - protected Firewall.Builder builder; - - @Inject - BaseFirewallResponseHandler(FirewallRuleListResponseHandler firewallRuleListResponseHandler) { - this.builder = Firewall.builder(); - this.firewallRuleListResponseHandler = firewallRuleListResponseHandler; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("firewallRules".equals(qName)) - useFirewallRuleParser = true; - - if (useFirewallRuleParser) - firewallRuleListResponseHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void characters(char[] ch, int start, int length) { - if (useFirewallRuleParser) - firewallRuleListResponseHandler.characters(ch, start, length); - else - super.characters(ch, start, length); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("firewallId".equals(qName)) - builder.id(textToStringValue()); - else if ("active".equals(qName)) - builder.active(textToBooleanValue()); - else if ("nicId".equals(qName)) - builder.nicId(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/firewall/FirewallListResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandler.java deleted file mode 100644 index df0d3e0..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandler.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.firewall; - -import java.util.List; - -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.http.parser.firewall.rule.FirewallRuleListResponseHandler; -import org.xml.sax.SAXException; - -import com.google.inject.Inject; -import com.google.common.collect.Lists; - -public class FirewallListResponseHandler extends BaseFirewallResponseHandler<List<Firewall>> { - - private List<Firewall> firewalls; - - @Inject - FirewallListResponseHandler(FirewallRuleListResponseHandler firewallRuleListResponseHandler) { - super(firewallRuleListResponseHandler); - this.firewalls = Lists.newArrayList(); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (useFirewallRuleParser) - firewallRuleListResponseHandler.endElement(uri, localName, qName); - else { - setPropertyOnEndTag(qName); - if ("return".equals(qName) || "firewall".equals(qName)) { - firewalls.add(builder - .rules(firewallRuleListResponseHandler.getResult()) - .build()); - firewallRuleListResponseHandler.reset(); - builder = Firewall.builder(); - } - clearTextBuffer(); - } - - if ("firewallRules".equals(qName)) - useFirewallRuleParser = false; - } - - @Override - public void reset() { - this.firewalls = Lists.newArrayList(); - } - - @Override - public List<Firewall> getResult() { - return firewalls; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandler.java deleted file mode 100644 index dae5191..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandler.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.firewall; - -import com.google.inject.Inject; - -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.http.parser.firewall.rule.FirewallRuleListResponseHandler; -import org.xml.sax.SAXException; - -public class FirewallResponseHandler extends BaseFirewallResponseHandler<Firewall> { - - private boolean done = false; - - @Inject - FirewallResponseHandler(FirewallRuleListResponseHandler firewallRuleListResponseHandler) { - super(firewallRuleListResponseHandler); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (done) - return; - - if (useFirewallRuleParser) - firewallRuleListResponseHandler.endElement(uri, localName, qName); - else { - setPropertyOnEndTag(qName); - if ("return".equals(qName)) { - done = true; - builder.rules(firewallRuleListResponseHandler.getResult()); - } - clearTextBuffer(); - } - - if ("firewallRules".equals(qName)) - useFirewallRuleParser = false; - } - - @Override - public void reset() { - this.builder = Firewall.builder(); - } - - @Override - public Firewall 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/firewall/rule/BaseFirewallRuleResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/BaseFirewallRuleResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/BaseFirewallRuleResponseHandler.java deleted file mode 100644 index 9461f46..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/BaseFirewallRuleResponseHandler.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.firewall.rule; - -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.Firewall.Protocol; - -import com.google.inject.Inject; - -import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler; - -public abstract class BaseFirewallRuleResponseHandler<T> extends BaseProfitBricksResponseHandler<T> { - - protected Firewall.Rule.Builder builder; - - @Inject - BaseFirewallRuleResponseHandler() { - this.builder = Firewall.Rule.builder(); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("firewallRuleId".equals(qName)) - builder.id(textToStringValue()); - else if ("name".equals(qName)) - builder.name(textToStringValue()); - else if ("portRangeEnd".equals(qName)) - builder.portRangeEnd(textToIntValue()); - else if ("portRangeStart".equals(qName)) - builder.portRangeStart(textToIntValue()); - else if ("protocol".equals(qName)) - builder.protocol(Protocol.fromValue(textToStringValue())); - else if ("sourceIp".equals(qName)) - builder.sourceIp(textToStringValue()); - else if ("sourceMac".equals(qName)) - builder.sourceMac(textToStringValue()); - else if ("targetIp".equals(qName)) - builder.targetIp(textToStringValue()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/FirewallRuleListResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/FirewallRuleListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/FirewallRuleListResponseHandler.java deleted file mode 100644 index 3085839..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/firewall/rule/FirewallRuleListResponseHandler.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.firewall.rule; - -import java.util.List; - -import org.jclouds.profitbricks.domain.Firewall.Rule; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; - -public class FirewallRuleListResponseHandler extends BaseFirewallRuleResponseHandler<List<Rule>> { - - private List<Rule> rules; - - FirewallRuleListResponseHandler() { - this.rules = Lists.newArrayList(); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - setPropertyOnEndTag(qName); - - if ("firewallRules".equals(qName)) - rules.add(builder.build()); - clearTextBuffer(); - - } - - @Override - public void reset() { - this.rules = Lists.newArrayList(); - } - - @Override - public List<Rule> getResult() { - return rules; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/BaseImageResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/BaseImageResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/BaseImageResponseHandler.java deleted file mode 100644 index 1e8828c..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/BaseImageResponseHandler.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.profitbricks.http.parser.image; - -import org.jclouds.profitbricks.domain.Image; -import org.jclouds.profitbricks.domain.Image.Type; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.OsType; -import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler; - -public abstract class BaseImageResponseHandler<T> extends BaseProfitBricksResponseHandler<T> { - - protected Image.Builder builder; - - BaseImageResponseHandler() { - this.builder = Image.builder(); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("imageId".equals(qName)) - builder.id(textToStringValue()); - else if ("imageName".equals(qName)) - builder.name(textToStringValue()); - else if ("imageSize".equals(qName)) - builder.size(textToFloatValue()); - else if ("imageType".equals(qName)) - builder.type(Type.fromValue(textToStringValue())); - else if ("location".equals(qName)) - builder.location(Location.fromId(textToStringValue())); - else if ("osType".equals(qName)) - builder.osType(OsType.fromValue(textToStringValue())); - else if ("public".equals(qName)) - builder.isPublic(textToBooleanValue()); - else if ("writeable".equals(qName)) - builder.isWriteable(textToBooleanValue()); - 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()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandler.java deleted file mode 100644 index 62d3973..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandler.java +++ /dev/null @@ -1,44 +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.image; - -import org.jclouds.profitbricks.domain.Image; -import org.xml.sax.SAXException; - -public class ImageInfoResponseHandler extends BaseImageResponseHandler<Image> { - - private boolean done = false; - - ImageInfoResponseHandler() { - } - - @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 Image 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/image/ImageListResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandler.java deleted file mode 100644 index ee73908..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandler.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.image; - -import com.google.common.collect.Lists; - -import java.util.List; - -import org.jclouds.profitbricks.domain.Image; -import org.xml.sax.SAXException; - -public class ImageListResponseHandler extends BaseImageResponseHandler<List<Image>> { - - private final List<Image> images; - - ImageListResponseHandler() { - this.images = Lists.newArrayList(); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - setPropertyOnEndTag(qName); - if ("return".equals(qName)) { - images.add(builder.build()); - builder = Image.builder(); - } - clearTextBuffer(); - } - - @Override - public List<Image> getResult() { - return images; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/BaseIpBlockResponseHandler.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/BaseIpBlockResponseHandler.java b/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/BaseIpBlockResponseHandler.java deleted file mode 100644 index 50adfe4..0000000 --- a/profitbricks/src/main/java/org/jclouds/profitbricks/http/parser/ipblock/BaseIpBlockResponseHandler.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.ipblock; - -import java.util.List; - -import com.google.common.collect.Lists; - -import org.jclouds.profitbricks.domain.IpBlock; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler; -import org.jclouds.profitbricks.http.parser.publicip.PublicIpListResponseHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -public abstract class BaseIpBlockResponseHandler<T> extends BaseProfitBricksResponseHandler<T> { - - protected final PublicIpListResponseHandler publicIpListResponseHandler; - protected List<String> ips; - - protected IpBlock.Builder builder; - protected boolean usePublicIpListParser = false; - - BaseIpBlockResponseHandler(PublicIpListResponseHandler publicIpListResponseHandler) { - this.builder = IpBlock.builder(); - this.publicIpListResponseHandler = publicIpListResponseHandler; - this.ips = Lists.newArrayList(); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("publicIps".equals(qName)) - usePublicIpListParser = true; - if (usePublicIpListParser) - publicIpListResponseHandler.startElement(uri, localName, qName, attributes); - } - - @Override - public void characters(char[] ch, int start, int length) { - if (usePublicIpListParser) - publicIpListResponseHandler.characters(ch, start, length); - else - super.characters(ch, start, length); - } - - @Override - protected void setPropertyOnEndTag(String qName) { - if ("blockId".equals(qName)) - builder.id(textToStringValue()); - else if ("location".equals(qName)) - builder.location(Location.fromId(textToStringValue())); - else if ("ips".equals(qName)) - ips.add(textToStringValue()); - } -}
