http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/auth/GetTokenFromApi.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/auth/GetTokenFromApi.java 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/auth/GetTokenFromApi.java
index a3ac09d..f38f0b3 100644
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/auth/GetTokenFromApi.java
+++ 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/auth/GetTokenFromApi.java
@@ -17,20 +17,20 @@
 package org.jclouds.abiquo.functions.auth;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.transform;
 import static com.google.common.collect.Iterables.tryFind;
 import static com.google.common.net.HttpHeaders.AUTHORIZATION;
 import static 
org.jclouds.abiquo.config.AbiquoAuthenticationModule.AUTH_TOKEN_NAME;
 import static org.jclouds.http.filters.BasicAuthentication.basic;
 
+import java.net.HttpCookie;
 import java.net.URI;
 import java.util.Collection;
+import java.util.List;
 
 import javax.annotation.Resource;
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.inject.Singleton;
-import javax.ws.rs.core.Cookie;
 
 import org.jclouds.abiquo.config.AbiquoProperties;
 import org.jclouds.domain.Credentials;
@@ -64,13 +64,13 @@ public class GetTokenFromApi implements 
Function<Credentials, String> {
    protected Logger logger = Logger.NULL;
 
    @Inject
-   public GetTokenFromApi(ProviderMetadata provider, HttpClient http) {
+   GetTokenFromApi(final ProviderMetadata provider, final HttpClient http) {
       this.provider = checkNotNull(provider, "provider must not be null");
       this.http = checkNotNull(http, "http must not be null");
    }
 
    @Override
-   public String apply(Credentials input) {
+   public String apply(final Credentials input) {
       logger.info(">> Requesting an authentication token for user: %s...", 
input.identity);
 
       HttpResponse response = http.invoke(HttpRequest.builder() //
@@ -79,7 +79,7 @@ public class GetTokenFromApi implements Function<Credentials, 
String> {
             .addHeader(AUTHORIZATION, basic(input.identity, input.credential)) 
//
             .build());
 
-      Optional<Cookie> token = readAuthenticationToken(response);
+      Optional<HttpCookie> token = readAuthenticationToken(response);
       if (!token.isPresent()) {
          throw new AuthorizationException("Could not obtain a new 
authentication token");
       }
@@ -88,24 +88,18 @@ public class GetTokenFromApi implements 
Function<Credentials, String> {
    }
 
    @VisibleForTesting
-   static Optional<Cookie> readAuthenticationToken(final HttpResponse 
response) {
-      Collection<String> cookies = 
response.getHeaders().get(HttpHeaders.SET_COOKIE);
-      return tryFind(transform(cookies, cookie()), new Predicate<Cookie>() {
-         @Override
-         public boolean apply(Cookie input) {
-            return input.getName().equals(AUTH_TOKEN_NAME);
-         }
-      });
-
-   }
+   static Optional<HttpCookie> readAuthenticationToken(final HttpResponse 
response) {
+      Collection<String> headers = 
response.getHeaders().get(HttpHeaders.SET_COOKIE);
+      for (String header : headers) {
+         List<HttpCookie> cookies = HttpCookie.parse(header);
+         return tryFind(cookies, new Predicate<HttpCookie>() {
+            @Override
+            public boolean apply(final HttpCookie input) {
+               return input.getName().equals(AUTH_TOKEN_NAME);
+            }
+         });
+      }
 
-   private static Function<String, Cookie> cookie() {
-      return new Function<String, Cookie>() {
-         @Override
-         public Cookie apply(String input) {
-            return Cookie.valueOf(input);
-         }
-      };
+      return Optional.absent();
    }
-
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java
deleted file mode 100644
index 98ca896..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java
+++ /dev/null
@@ -1,40 +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.abiquo.functions.enterprise;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.google.common.base.Function;
-
-/**
- * Parses a {@link EnterpriseDto} object to extract its id.
- */
-@Singleton
-public class ParseEnterpriseId implements Function<Object, String> {
-   @Override
-   public String apply(final Object input) {
-      checkArgument(checkNotNull(input, "input") instanceof EnterpriseDto,
-            "This parser is only valid for EnterpriseDto objects");
-
-      return ((EnterpriseDto) input).getId().toString();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java
deleted file mode 100644
index 2c97eb3..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java
+++ /dev/null
@@ -1,40 +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.abiquo.functions.infrastructure;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.google.common.base.Function;
-
-/**
- * Parses a {@link DatacenterDto} object to extract its id.
- */
-@Singleton
-public class ParseDatacenterId implements Function<Object, String> {
-   @Override
-   public String apply(final Object input) {
-      checkArgument(checkNotNull(input, "input") instanceof DatacenterDto,
-            "This parser is only valid for DatacenterDto objects");
-
-      return ((DatacenterDto) input).getId().toString();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java
deleted file mode 100644
index 1bf0e47..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java
+++ /dev/null
@@ -1,40 +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.abiquo.functions.infrastructure;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import com.abiquo.server.core.infrastructure.MachineDto;
-import com.google.common.base.Function;
-
-/**
- * Parses a {@link MachineDto} object to extract its id.
- */
-@Singleton
-public class ParseMachineId implements Function<Object, String> {
-   @Override
-   public String apply(final Object input) {
-      checkArgument(checkNotNull(input, "input") instanceof MachineDto,
-            "This parser is only valid for MachineDto objects");
-
-      return ((MachineDto) input).getId().toString();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java
deleted file mode 100644
index 5ba0ade..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java
+++ /dev/null
@@ -1,41 +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.abiquo.functions.infrastructure;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import com.abiquo.model.enumerator.RemoteServiceType;
-import com.google.common.base.Function;
-
-/**
- * Parses a {@link ParseRemoteServiceType} object to extract its type in the
- * format that the API expects it.
- */
-@Singleton
-public class ParseRemoteServiceType implements Function<Object, String> {
-   @Override
-   public String apply(final Object input) {
-      checkArgument(checkNotNull(input, "input") instanceof RemoteServiceType,
-            "This parser is only valid for RemoteServiceType objects");
-
-      return ((RemoteServiceType) input).name().replaceAll("_", 
"").toLowerCase();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/BasePaginationParser.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/BasePaginationParser.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/BasePaginationParser.java
deleted file mode 100644
index 0ee1b1e..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/BasePaginationParser.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.abiquo.functions.pagination;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.model.transport.WrapperDto;
-import com.google.common.base.Function;
-
-/**
- * Base class for all pagination response parsers.
- * <p>
- * Parses the response with the given parser, and wraps the results in a
- * {@link PaginatedCollection} so it can be properly iterated.
- * 
- * 
- * @see PaginatedCollection
- * @see PagedIterable
- */
-public abstract class BasePaginationParser<T, W extends WrapperDto<T>> 
implements
-      Function<HttpResponse, PaginatedCollection<T, W>> {
-   protected final AbiquoApi api;
-   protected final ParseXMLWithJAXB<W> parser;
-
-   public BasePaginationParser(AbiquoApi api, ParseXMLWithJAXB<W> parser) {
-      this.api = checkNotNull(api, "api must not be null");
-      this.parser = checkNotNull(parser, "parser must not be null");
-   }
-
-   @Override
-   public PaginatedCollection<T, W> apply(HttpResponse input) {
-      return new PaginatedCollection<T, W>(api, parser.apply(input), parser);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEnterprises.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEnterprises.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEnterprises.java
deleted file mode 100644
index 2539420..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEnterprises.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.enterprise.EnterprisesDto;
-
-/**
- * Parses a paginated enterprise list.
- */
-@Singleton
-public class ParseEnterprises extends BasePaginationParser<EnterpriseDto, 
EnterprisesDto> {
-   @Inject
-   public ParseEnterprises(AbiquoApi api, ParseXMLWithJAXB<EnterprisesDto> 
parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<EnterpriseDto, EnterprisesDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<EnterprisesDto> 
parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEvents.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEvents.java 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEvents.java
deleted file mode 100644
index 81f3a5f..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseEvents.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.event.EventDto;
-import com.abiquo.server.core.event.EventsDto;
-
-/**
- * Parses a paginated event list.
- */
-@Singleton
-public class ParseEvents extends BasePaginationParser<EventDto, EventsDto> {
-   @Inject
-   public ParseEvents(AbiquoApi api, ParseXMLWithJAXB<EventsDto> parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<EventDto, EventsDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<EventsDto> 
parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseExternalIps.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseExternalIps.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseExternalIps.java
deleted file mode 100644
index b10a922..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseExternalIps.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.infrastructure.network.ExternalIpDto;
-import com.abiquo.server.core.infrastructure.network.ExternalIpsDto;
-
-/**
- * Parses a paginated external ip list.
- */
-@Singleton
-public class ParseExternalIps extends BasePaginationParser<ExternalIpDto, 
ExternalIpsDto> {
-   @Inject
-   public ParseExternalIps(AbiquoApi api, ParseXMLWithJAXB<ExternalIpsDto> 
parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<ExternalIpDto, ExternalIpsDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<ExternalIpsDto> 
parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePrivateIps.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePrivateIps.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePrivateIps.java
deleted file mode 100644
index e10c9f0..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePrivateIps.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
-import com.abiquo.server.core.infrastructure.network.PrivateIpsDto;
-
-/**
- * Parses a paginated private ip list.
- */
-@Singleton
-public class ParsePrivateIps extends BasePaginationParser<PrivateIpDto, 
PrivateIpsDto> {
-   @Inject
-   public ParsePrivateIps(AbiquoApi api, ParseXMLWithJAXB<PrivateIpsDto> 
parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<PrivateIpDto, PrivateIpsDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<PrivateIpsDto> 
parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePublicIps.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePublicIps.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePublicIps.java
deleted file mode 100644
index a3eb3b8..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParsePublicIps.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.infrastructure.network.PublicIpDto;
-import com.abiquo.server.core.infrastructure.network.PublicIpsDto;
-
-/**
- * Parses a paginated public ip list.
- */
-@Singleton
-public class ParsePublicIps extends BasePaginationParser<PublicIpDto, 
PublicIpsDto> {
-   @Inject
-   public ParsePublicIps(AbiquoApi api, ParseXMLWithJAXB<PublicIpsDto> parser) 
{
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<PublicIpDto, PublicIpsDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<PublicIpsDto> 
parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUnmanagedIps.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUnmanagedIps.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUnmanagedIps.java
deleted file mode 100644
index 415d288..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUnmanagedIps.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto;
-import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto;
-
-/**
- * Parses a paginated unmnaged ip list.
- */
-@Singleton
-public class ParseUnmanagedIps extends BasePaginationParser<UnmanagedIpDto, 
UnmanagedIpsDto> {
-   @Inject
-   public ParseUnmanagedIps(AbiquoApi api, ParseXMLWithJAXB<UnmanagedIpsDto> 
parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<UnmanagedIpDto, UnmanagedIpsDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<UnmanagedIpsDto> 
parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUsers.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUsers.java 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUsers.java
deleted file mode 100644
index eba0031..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseUsers.java
+++ /dev/null
@@ -1,154 +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.abiquo.functions.pagination;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.Iterables.getFirst;
-import static org.jclouds.http.utils.Queries.encodeQueryLine;
-import static org.jclouds.http.utils.Queries.queryParser;
-
-import java.net.URI;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.enterprise.UserDto;
-import com.abiquo.server.core.enterprise.UsersDto;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.collect.Multimap;
-
-/**
- * Parses a paginated user list.
- */
-@Singleton
-public class ParseUsers extends BasePaginationParser<UserDto, UsersDto> {
-   @Inject
-   public ParseUsers(AbiquoApi api, ParseXMLWithJAXB<UsersDto> parser) {
-      super(api, parser);
-   }
-
-   // Return a custom class to bypass
-   // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-5927
-   // Remove once the fix has been deployed to production
-   @Override
-   public PaginatedCollection<UserDto, UsersDto> apply(HttpResponse input) {
-      return new UserPaginatedCollection(api, parser.apply(input), parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends 
PaginatedCollection.ToPagedIterable<UserDto, UsersDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, ParseXMLWithJAXB<UsersDto> parser) 
{
-         super(api, parser);
-      }
-
-      // Overwrite to return a custom class and bypass
-      // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-5927
-      // Remove once the fix has been deployed to production
-      @Override
-      protected Function<Object, IterableWithMarker<UserDto>> 
nextPage(PaginatedCollection<UserDto, UsersDto> input) {
-         return new Function<Object, IterableWithMarker<UserDto>>() {
-            @Override
-            public IterableWithMarker<UserDto> apply(Object marker) {
-               checkArgument(marker instanceof RESTLink, "Marker must be a 
RESTLink");
-               RESTLink next = RESTLink.class.cast(marker);
-
-               // The Abiquo API does not provide the media types in the
-               // pagination links, but it will be the same type than the
-               // current page, so just set it.
-               next.setType(UsersDto.BASE_MEDIA_TYPE);
-
-               UsersDto nextPage = parser.apply(api.get(next));
-               return new UserPaginatedCollection(api, nextPage, parser);
-            }
-         };
-      }
-   }
-
-   /**
-    * This class is used to bypass
-    * http://jira.abiquo.com/browse/ABICLOUDPREMIUM-5927
-    * <p>
-    * The issue has already been fixed but still not been deployed in
-    * production. Once that is done, this class should be removed.
-    * 
-    */
-   private static class UserPaginatedCollection extends 
PaginatedCollection<UserDto, UsersDto> {
-      public UserPaginatedCollection(AbiquoApi api, UsersDto delegate, 
ParseXMLWithJAXB<UsersDto> parser) {
-         super(api, delegate, parser);
-      }
-
-      @Override
-      public Optional<Object> nextMarker() {
-         Optional<Object> next = super.nextMarker();
-         // Pagination links are not consistent and a "next" link can be
-         // returned even if there are no more pages. Overwrite the
-         // default behavior to handle this, and to adapt the query
-         // parameters returned in the pagination links to what the api
-         // expects in the GET requests
-         if (next.isPresent()) {
-            checkArgument(next.get() instanceof RESTLink, "Marker must be a 
RESTLink");
-            RESTLink link = RESTLink.class.cast(next.get());
-
-            // Get the conflicting query parameters and remove them from the
-            // query parameter map
-            Multimap<String, String> params = 
queryParser().apply(URI.create(link.getHref()).getRawQuery());
-            String limit = getFirst(params.removeAll("limit"), null);
-            String startwith = getFirst(params.removeAll("startwith"), null);
-
-            // Next page links always have both query parameters. Otherwise
-            // assume there is no next page
-            if (limit != null && startwith != null) {
-               int resultsPerPage = Integer.parseInt(limit);
-               int totalResults = delegate.getTotalSize();
-               int pageNumber = Integer.parseInt(startwith) - resultsPerPage;
-
-               // Check if there is really a next page, and then return the
-               // marker with the appropriate values
-               if (totalResults / (double) resultsPerPage > pageNumber + 1) {
-                  params.put("numResults", limit);
-                  params.put("page", String.valueOf(pageNumber + 1));
-
-                  // Build the new URI stripping the existing query
-                  // parameters and using the new ones
-                  String uri = link.getHref().substring(0, 
link.getHref().indexOf('?') + 1);
-                  uri += encodeQueryLine(params);
-
-                  return Optional.<Object> of(new RESTLink(link.getRel(), 
uri));
-               }
-            }
-         }
-
-         return Optional.absent();
-      }
-
-      @Override
-      public PagedIterable<UserDto> toPagedIterable() {
-         return new ParseUsers.ToPagedIterable(api, parser).apply(this);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachineTemplates.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachineTemplates.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachineTemplates.java
deleted file mode 100644
index 7663c3d..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachineTemplates.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
-import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto;
-
-/**
- * Parses a paginated virtual machine template list.
- */
-@Singleton
-public class ParseVirtualMachineTemplates extends
-      BasePaginationParser<VirtualMachineTemplateDto, 
VirtualMachineTemplatesDto> {
-   @Inject
-   public ParseVirtualMachineTemplates(AbiquoApi api, 
ParseXMLWithJAXB<VirtualMachineTemplatesDto> parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends
-         PaginatedCollection.ToPagedIterable<VirtualMachineTemplateDto, 
VirtualMachineTemplatesDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, 
ParseXMLWithJAXB<VirtualMachineTemplatesDto> parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachines.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachines.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachines.java
deleted file mode 100644
index 4041793..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVirtualMachines.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.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
-import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
-
-/**
- * Parses a paginated virtual machine list.
- */
-@Singleton
-public class ParseVirtualMachines extends
-      BasePaginationParser<VirtualMachineWithNodeExtendedDto, 
VirtualMachinesWithNodeExtendedDto> {
-   @Inject
-   public ParseVirtualMachines(AbiquoApi api, 
ParseXMLWithJAXB<VirtualMachinesWithNodeExtendedDto> parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends
-         
PaginatedCollection.ToPagedIterable<VirtualMachineWithNodeExtendedDto, 
VirtualMachinesWithNodeExtendedDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, 
ParseXMLWithJAXB<VirtualMachinesWithNodeExtendedDto> parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVolumes.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVolumes.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVolumes.java
deleted file mode 100644
index ea6bab6..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/functions/pagination/ParseVolumes.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.functions.pagination;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-
-import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
-import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto;
-
-/**
- * Parses a paginated volume list.
- */
-@Singleton
-public class ParseVolumes extends BasePaginationParser<VolumeManagementDto, 
VolumesManagementDto> {
-   @Inject
-   public ParseVolumes(AbiquoApi api, ParseXMLWithJAXB<VolumesManagementDto> 
parser) {
-      super(api, parser);
-   }
-
-   @Singleton
-   public static class ToPagedIterable extends
-         PaginatedCollection.ToPagedIterable<VolumeManagementDto, 
VolumesManagementDto> {
-      @Inject
-      public ToPagedIterable(AbiquoApi api, 
ParseXMLWithJAXB<VolumesManagementDto> parser) {
-         super(api, parser);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java 
b/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java
index e82910e..da45966 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java
@@ -16,14 +16,10 @@
  */
 package org.jclouds.abiquo.handlers;
 
-import static javax.ws.rs.core.Response.Status.fromStatusCode;
 import static org.jclouds.util.Closeables2.closeQuietly;
 
-import javax.inject.Inject;
 import javax.inject.Singleton;
 
-import org.jclouds.abiquo.domain.exception.AbiquoException;
-import org.jclouds.abiquo.functions.ParseErrors;
 import org.jclouds.http.HttpCommand;
 import org.jclouds.http.HttpErrorHandler;
 import org.jclouds.http.HttpResponse;
@@ -31,21 +27,11 @@ import org.jclouds.http.HttpResponseException;
 import org.jclouds.rest.AuthorizationException;
 import org.jclouds.rest.ResourceNotFoundException;
 
-import com.abiquo.model.transport.error.ErrorsDto;
-
 /**
  * Parse Abiquo API errors and set the appropriate exception.
  */
 @Singleton
 public class AbiquoErrorHandler implements HttpErrorHandler {
-   /** The error parser. */
-   private ParseErrors errorParser;
-
-   @Inject
-   AbiquoErrorHandler(final ParseErrors errorParser) {
-      super();
-      this.errorParser = errorParser;
-   }
 
    @Override
    public void handleError(final HttpCommand command, final HttpResponse 
response) {
@@ -58,23 +44,25 @@ public class AbiquoErrorHandler implements HttpErrorHandler 
{
             case 401:
             case 403:
                // Authorization exceptions do not return an errors DTO, so we
-               // encapsulate a
-               // generic exception
+               // encapsulate a generic exception
                exception = new AuthorizationException(defaultMessage, new 
HttpResponseException(command, response,
                      defaultMessage));
                break;
             case 404:
-               exception = new ResourceNotFoundException(defaultMessage, 
getExceptionToPropagate(command, response,
-                     defaultMessage));
+               // TODO: get the exception to encapsulate from the returned 
error
+               // object
+               exception = new ResourceNotFoundException(defaultMessage);
                break;
             case 301:
                // Moved resources in Abiquo should be handled with the
-               // ReturnMovedResource
-               // exception parser to return the moved entity.
+               // ReturnMovedResource exception parser to return the moved
+               // entity.
                exception = new HttpResponseException(command, response, 
defaultMessage);
                break;
             default:
-               exception = getExceptionToPropagate(command, response, 
defaultMessage);
+               // TODO: get the exception to encapsulate from the returned 
error
+               // object
+               exception = new HttpResponseException(response.getMessage(), 
command, response);
                break;
          }
       } finally {
@@ -82,34 +70,4 @@ public class AbiquoErrorHandler implements HttpErrorHandler {
          command.setException(exception);
       }
    }
-
-   private Exception getExceptionToPropagate(final HttpCommand command, final 
HttpResponse response,
-         final String defaultMessage) {
-      Exception exception = null;
-
-      if (hasPayload(response)) {
-         try {
-            ErrorsDto errors = errorParser.apply(response);
-            exception = new 
AbiquoException(fromStatusCode(response.getStatusCode()), errors);
-         } catch (Exception ex) {
-            // If it is not an Abiquo Exception (can not be unmarshalled),
-            // propagate a standard
-            // HttpResponseException
-            exception = new HttpResponseException(command, response, 
defaultMessage);
-         }
-      } else {
-         // If it is not an Abiquo Exception (there is not an errors xml in the
-         // payload)
-         // propagate a standard HttpResponseException
-         exception = new HttpResponseException(command, response, 
defaultMessage);
-      }
-
-      return exception;
-   }
-
-   private static boolean hasPayload(final HttpResponse response) {
-      return response.getPayload() != null && 
response.getPayload().getContentMetadata() != null
-            && response.getPayload().getContentMetadata().getContentLength() 
!= null
-            && response.getPayload().getContentMetadata().getContentLength() > 
0L;
-   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java
index f18b333..3edcec8 100644
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java
+++ 
b/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java
@@ -39,7 +39,7 @@ public class AbiquoAuthentication implements 
HttpRequestFilter {
    private final Supplier<String> authTokenProvider;
 
    @Inject
-   public AbiquoAuthentication(@Authentication Supplier<String> 
authTokenProvider) {
+   AbiquoAuthentication(@Authentication Supplier<String> authTokenProvider) {
       this.authTokenProvider = checkNotNull(authTokenProvider, 
"authTokenProvider must not be null");
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java
index ba4cb86..0c6244b 100644
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java
+++ 
b/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java
@@ -40,8 +40,7 @@ public class AppendApiVersionToMediaType implements 
HttpRequestFilter {
    private AppendApiVersionToAbiquoMimeType versionAppender;
 
    @Inject
-   public AppendApiVersionToMediaType(final AppendApiVersionToAbiquoMimeType 
versionAppender) {
-      super();
+   AppendApiVersionToMediaType(final AppendApiVersionToAbiquoMimeType 
versionAppender) {
       this.versionAppender = versionAppender;
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java 
b/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
deleted file mode 100644
index c91618a..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.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.abiquo.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.Context;
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.AbiquoContext;
-import org.jclouds.abiquo.features.services.AdministrationService;
-import org.jclouds.abiquo.features.services.CloudService;
-import org.jclouds.abiquo.features.services.EventService;
-import org.jclouds.abiquo.features.services.MonitoringService;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.Utils;
-import org.jclouds.compute.internal.ComputeServiceContextImpl;
-import org.jclouds.location.Provider;
-import org.jclouds.rest.ApiContext;
-
-import com.google.common.reflect.TypeToken;
-
-/**
- * Abiquo {@link ApiContext} implementation to expose high level Abiquo
- * functionalities.
- */
-@Singleton
-public class AbiquoContextImpl extends ComputeServiceContextImpl implements 
AbiquoContext {
-   private final AdministrationService administrationService;
-
-   private final CloudService cloudService;
-
-   private final MonitoringService monitoringService;
-
-   private final EventService eventService;
-
-   @Inject
-   public AbiquoContextImpl(@Provider final Context wrapped, @Provider final 
TypeToken<? extends Context> wrappedType,
-         final ComputeService computeService, final Utils utils, final 
ApiContext<AbiquoApi> providerSpecificContext,
-         final AdministrationService administrationService, final CloudService 
cloudService,
-         final MonitoringService monitoringService, final EventService 
eventService) {
-      super(wrapped, wrappedType, computeService, utils);
-      this.administrationService = checkNotNull(administrationService, 
"administrationService");
-      this.cloudService = checkNotNull(cloudService, "cloudService");
-      this.monitoringService = checkNotNull(monitoringService, 
"monitoringService");
-      this.eventService = checkNotNull(eventService, "eventService");
-   }
-
-   @Override
-   public ApiContext<AbiquoApi> getApiContext() {
-      return unwrap();
-   }
-
-   @Override
-   public AdministrationService getAdministrationService() {
-      return administrationService;
-   }
-
-   @Override
-   public CloudService getCloudService() {
-      return cloudService;
-   }
-
-   @Override
-   public MonitoringService getMonitoringService() {
-      return monitoringService;
-   }
-
-   @Override
-   public EventService getEventService() {
-      return eventService;
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
 
b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
deleted file mode 100644
index 4e8b5b3..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
+++ /dev/null
@@ -1,231 +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.abiquo.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.getFirst;
-import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.config.Category;
-import org.jclouds.abiquo.domain.config.License;
-import org.jclouds.abiquo.domain.config.Privilege;
-import org.jclouds.abiquo.domain.config.SystemProperty;
-import org.jclouds.abiquo.domain.config.options.LicenseOptions;
-import org.jclouds.abiquo.domain.config.options.PropertyOptions;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.domain.enterprise.EnterpriseProperties;
-import org.jclouds.abiquo.domain.enterprise.Role;
-import org.jclouds.abiquo.domain.enterprise.User;
-import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.infrastructure.Machine;
-import org.jclouds.abiquo.features.services.AdministrationService;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.strategy.infrastructure.ListMachines;
-import org.jclouds.collect.Memoized;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.appslibrary.CategoriesDto;
-import com.abiquo.server.core.appslibrary.CategoryDto;
-import com.abiquo.server.core.config.LicensesDto;
-import com.abiquo.server.core.config.SystemPropertiesDto;
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.enterprise.EnterprisePropertiesDto;
-import com.abiquo.server.core.enterprise.EnterprisesDto;
-import com.abiquo.server.core.enterprise.PrivilegeDto;
-import com.abiquo.server.core.enterprise.PrivilegesDto;
-import com.abiquo.server.core.enterprise.RoleDto;
-import com.abiquo.server.core.enterprise.RolesDto;
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.DatacentersDto;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Supplier;
-
-/**
- * Provides high level Abiquo administration operations.
- */
-@Singleton
-public class BaseAdministrationService implements AdministrationService {
-   @VisibleForTesting
-   protected ApiContext<AbiquoApi> context;
-
-   @VisibleForTesting
-   protected final ListMachines listMachines;
-
-   @VisibleForTesting
-   protected final Supplier<User> currentUser;
-
-   @VisibleForTesting
-   protected final Supplier<Enterprise> currentEnterprise;
-
-   @Inject
-   protected BaseAdministrationService(final ApiContext<AbiquoApi> context, 
final ListMachines listMachines,
-         @Memoized final Supplier<User> currentUser, @Memoized final 
Supplier<Enterprise> currentEnterprise) {
-      this.context = checkNotNull(context, "context");
-      this.listMachines = checkNotNull(listMachines, "listMachines");
-      this.currentUser = checkNotNull(currentUser, "currentUser");
-      this.currentEnterprise = checkNotNull(currentEnterprise, 
"currentEnterprise");
-   }
-
-   /*********************** Datacenter ********************** */
-
-   @Override
-   public Iterable<Datacenter> listDatacenters() {
-      DatacentersDto result = 
context.getApi().getInfrastructureApi().listDatacenters();
-      return wrap(context, Datacenter.class, result.getCollection());
-   }
-
-   @Override
-   public Datacenter getDatacenter(final Integer datacenterId) {
-      DatacenterDto datacenter = 
context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
-      return wrap(context, Datacenter.class, datacenter);
-   }
-
-   /*********************** Machine ***********************/
-
-   @Override
-   public Iterable<Machine> listMachines() {
-      return listMachines.execute();
-   }
-
-   /*********************** Enterprise ***********************/
-
-   @Override
-   public Iterable<Enterprise> listEnterprises() {
-      PagedIterable<EnterpriseDto> result = 
context.getApi().getEnterpriseApi().listEnterprises();
-      return wrap(context, Enterprise.class, result.concat());
-   }
-
-   @Override
-   public Iterable<Enterprise> listEnterprises(EnterpriseOptions options) {
-      PaginatedCollection<EnterpriseDto, EnterprisesDto> result = 
context.getApi().getEnterpriseApi()
-            .listEnterprises(options);
-      return wrap(context, Enterprise.class, 
result.toPagedIterable().concat());
-   }
-
-   @Override
-   public Enterprise getEnterprise(final Integer enterpriseId) {
-      EnterpriseDto enterprise = 
context.getApi().getEnterpriseApi().getEnterprise(enterpriseId);
-      return wrap(context, Enterprise.class, enterprise);
-   }
-
-   /*********************** Enterprise Properties ***********************/
-
-   @Override
-   public EnterpriseProperties getEnterpriseProperties(final Enterprise 
enterprise) {
-      checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD 
+ " id in " + Enterprise.class);
-
-      EnterprisePropertiesDto properties = context.getApi().getEnterpriseApi()
-            .getEnterpriseProperties(enterprise.unwrap());
-      return wrap(context, EnterpriseProperties.class, properties);
-   }
-
-   /*********************** Role ********************** */
-
-   @Override
-   public Iterable<Role> listRoles() {
-      RolesDto result = context.getApi().getAdminApi().listRoles();
-      return wrap(context, Role.class, result.getCollection());
-   }
-
-   @Override
-   public Role getRole(final Integer roleId) {
-      RoleDto role = context.getApi().getAdminApi().getRole(roleId);
-      return wrap(context, Role.class, role);
-   }
-
-   /*********************** Privilege ***********************/
-
-   @Override
-   public Iterable<Privilege> listPrivileges() {
-      PrivilegesDto result = context.getApi().getConfigApi().listPrivileges();
-      return wrap(context, Privilege.class, result.getCollection());
-   }
-
-   @Override
-   public Privilege getPrivilege(Integer privilegeId) {
-      PrivilegeDto result = 
context.getApi().getConfigApi().getPrivilege(privilegeId);
-      return wrap(context, Privilege.class, result);
-   }
-
-   /*********************** User ***********************/
-
-   @Override
-   public User getCurrentUser() {
-      return currentUser.get();
-   }
-
-   @Override
-   public Enterprise getCurrentEnterprise() {
-      return currentEnterprise.get();
-   }
-
-   /*********************** License ***********************/
-
-   @Override
-   public Iterable<License> listLicenses() {
-      LicensesDto result = context.getApi().getConfigApi().listLicenses();
-      return wrap(context, License.class, result.getCollection());
-   }
-
-   @Override
-   public Iterable<License> listLicenses(final boolean active) {
-      LicenseOptions options = LicenseOptions.builder().active(active).build();
-      LicensesDto result = 
context.getApi().getConfigApi().listLicenses(options);
-      return wrap(context, License.class, result.getCollection());
-   }
-
-   /*********************** System Properties ***********************/
-
-   @Override
-   public Iterable<SystemProperty> listSystemProperties() {
-      SystemPropertiesDto result = 
context.getApi().getConfigApi().listSystemProperties();
-      return wrap(context, SystemProperty.class, result.getCollection());
-   }
-
-   @Override
-   public SystemProperty getSystemProperty(final String name) {
-      PropertyOptions options = PropertyOptions.builder().name(name).build();
-      SystemPropertiesDto result = 
context.getApi().getConfigApi().listSystemProperties(options);
-      return getFirst(wrap(context, SystemProperty.class, 
result.getCollection()), null);
-   }
-
-   @Override
-   public Iterable<SystemProperty> listSystemProperties(final String 
component) {
-      PropertyOptions options = 
PropertyOptions.builder().component(component).build();
-      SystemPropertiesDto result = 
context.getApi().getConfigApi().listSystemProperties(options);
-      return wrap(context, SystemProperty.class, result.getCollection());
-   }
-
-   @Override
-   public Iterable<Category> listCategories() {
-      CategoriesDto result = context.getApi().getConfigApi().listCategories();
-      return wrap(context, Category.class, result.getCollection());
-   }
-
-   @Override
-   public Category getCategory(Integer categoryId) {
-      CategoryDto result = 
context.getApi().getConfigApi().getCategory(categoryId);
-      return wrap(context, Category.class, result);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java 
b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
deleted file mode 100644
index af38612..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
+++ /dev/null
@@ -1,118 +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.abiquo.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
-
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.cloud.VirtualAppliance;
-import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
-import org.jclouds.abiquo.domain.cloud.VirtualMachine;
-import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions;
-import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.features.services.CloudService;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances;
-import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.cloud.VirtualDatacenterDto;
-import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
-import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto;
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * Provides high level Abiquo cloud operations.
- */
-@Singleton
-public class BaseCloudService implements CloudService {
-   @VisibleForTesting
-   protected final ApiContext<AbiquoApi> context;
-
-   @VisibleForTesting
-   protected final ListVirtualDatacenters listVirtualDatacenters;
-
-   @VisibleForTesting
-   protected final ListVirtualAppliances listVirtualAppliances;
-
-   @Inject
-   protected BaseCloudService(final ApiContext<AbiquoApi> context, final 
ListVirtualDatacenters listVirtualDatacenters,
-         final ListVirtualAppliances listVirtualAppliances) {
-      this.context = checkNotNull(context, "context");
-      this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, 
"listVirtualDatacenters");
-      this.listVirtualAppliances = checkNotNull(listVirtualAppliances, 
"listVirtualAppliances");
-   }
-
-   /*********************** Virtual Datacenter ********************** */
-
-   @Override
-   public Iterable<VirtualDatacenter> listVirtualDatacenters() {
-      return listVirtualDatacenters.execute();
-   }
-
-   @Override
-   public Iterable<VirtualDatacenter> listVirtualDatacenters(final Enterprise 
enterprise) {
-      checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + 
Enterprise.class);
-      checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD 
+ " id in " + Enterprise.class);
-
-      VirtualDatacenterOptions options = 
VirtualDatacenterOptions.builder().enterpriseId(enterprise.getId()).build();
-
-      return listVirtualDatacenters.execute(options);
-   }
-
-   @Override
-   public VirtualDatacenter getVirtualDatacenter(final Integer 
virtualDatacenterId) {
-      VirtualDatacenterDto virtualDatacenter = 
context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
-      return wrap(context, VirtualDatacenter.class, virtualDatacenter);
-   }
-
-   @Override
-   public Iterable<VirtualDatacenter> getVirtualDatacenters(final 
List<Integer> virtualDatacenterIds) {
-      return listVirtualDatacenters.execute(virtualDatacenterIds);
-   }
-
-   /*********************** Virtual Appliance ********************** */
-
-   @Override
-   public Iterable<VirtualAppliance> listVirtualAppliances() {
-      return listVirtualAppliances.execute();
-   }
-
-   /*********************** Virtual Machine ********************** */
-
-   @Override
-   public Iterable<VirtualMachine> listVirtualMachines() {
-      PagedIterable<VirtualMachineWithNodeExtendedDto> vms = 
context.getApi().getCloudApi().listAllVirtualMachines();
-      return wrap(context, VirtualMachine.class, vms.concat());
-   }
-
-   @Override
-   public Iterable<VirtualMachine> listVirtualMachines(VirtualMachineOptions 
options) {
-      PaginatedCollection<VirtualMachineWithNodeExtendedDto, 
VirtualMachinesWithNodeExtendedDto> vms = context.getApi()
-            .getCloudApi().listAllVirtualMachines(options);
-      return wrap(context, VirtualMachine.class, 
vms.toPagedIterable().concat());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java 
b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java
deleted file mode 100644
index 8944d8e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.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.abiquo.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.event.Event;
-import org.jclouds.abiquo.domain.event.options.EventOptions;
-import org.jclouds.abiquo.features.services.EventService;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.event.EventDto;
-import com.abiquo.server.core.event.EventsDto;
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * Provides high level Abiquo event operations.
- */
-@Singleton
-public class BaseEventService implements EventService {
-   @VisibleForTesting
-   protected ApiContext<AbiquoApi> context;
-
-   @Inject
-   protected BaseEventService(final ApiContext<AbiquoApi> context) {
-      this.context = checkNotNull(context, "context");
-   }
-
-   @Override
-   public Iterable<Event> listEvents() {
-      PagedIterable<EventDto> result = 
context.getApi().getEventApi().listEvents();
-      return wrap(context, Event.class, result.concat());
-   }
-
-   @Override
-   public Iterable<Event> listEvents(final EventOptions options) {
-      PaginatedCollection<EventDto, EventsDto> result = 
context.getApi().getEventApi().listEvents(options);
-      return wrap(context, Event.class, result.toPagedIterable().concat());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java 
b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
deleted file mode 100644
index a6dbb00..0000000
--- 
a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
+++ /dev/null
@@ -1,294 +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.abiquo.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS;
-import static 
org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY;
-
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.Resource;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.features.services.MonitoringService;
-import org.jclouds.abiquo.monitor.AsyncTaskMonitor;
-import org.jclouds.abiquo.monitor.ConversionMonitor;
-import org.jclouds.abiquo.monitor.MonitorStatus;
-import org.jclouds.abiquo.monitor.VirtualApplianceMonitor;
-import org.jclouds.abiquo.monitor.VirtualMachineMonitor;
-import org.jclouds.abiquo.monitor.events.CompletedEvent;
-import org.jclouds.abiquo.monitor.events.FailedEvent;
-import org.jclouds.abiquo.monitor.events.TimeoutEvent;
-import org.jclouds.abiquo.monitor.handlers.AbstractEventHandler;
-import org.jclouds.abiquo.monitor.handlers.BlockingEventHandler;
-import org.jclouds.logging.Logger;
-import org.jclouds.rest.ApiContext;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.eventbus.EventBus;
-import com.google.inject.Inject;
-
-/**
- * Utility service to monitor asynchronous operations.
- */
-@Singleton
-public class BaseMonitoringService implements MonitoringService {
-   @VisibleForTesting
-   protected ApiContext<AbiquoApi> context;
-
-   /** The scheduler used to perform monitoring tasks. */
-   @VisibleForTesting
-   protected ScheduledExecutorService scheduler;
-
-   @VisibleForTesting
-   protected Long pollingDelay;
-
-   /**
-    * The event bus used to dispatch monitoring events.
-    * <p>
-    * A sync bus is used by default, to prevent deadlocks when using the
-    * {@link BlockingEventHandler}.
-    */
-   @VisibleForTesting
-   protected EventBus eventBus;
-
-   @Resource
-   private Logger logger = Logger.NULL;
-
-   @Inject
-   public BaseMonitoringService(final ApiContext<AbiquoApi> context,
-         @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService 
scheduler,
-         @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final 
EventBus eventBus) {
-      this.context = checkNotNull(context, "context");
-      this.scheduler = checkNotNull(scheduler, "scheduler");
-      this.pollingDelay = checkNotNull(pollingDelay, "pollingDelay");
-      this.eventBus = checkNotNull(eventBus, "eventBus");
-   }
-
-   /*************** Generic monitoring methods ***************/
-
-   @Override
-   public <T> void awaitCompletion(final Function<T, MonitorStatus> 
completeCondition, final T... objects) {
-      awaitCompletion(null, null, completeCondition, objects);
-   }
-
-   @Override
-   public <T> void awaitCompletion(final Long maxWait, final TimeUnit timeUnit,
-         final Function<T, MonitorStatus> completeCondition, final T... 
objects) {
-      checkNotNull(completeCondition, "completeCondition");
-
-      if (objects != null && objects.length > 0) {
-         BlockingEventHandler<T> blockingHandler = new 
BlockingEventHandler<T>(logger, objects);
-         register(blockingHandler);
-
-         monitor(maxWait, timeUnit, completeCondition, objects);
-         blockingHandler.lock();
-
-         unregister(blockingHandler);
-      }
-   }
-
-   @Override
-   public <T> void monitor(final Function<T, MonitorStatus> completeCondition, 
final T... objects) {
-      monitor(null, null, completeCondition, objects);
-   }
-
-   @Override
-   public <T> void monitor(final Long maxWait, final TimeUnit timeUnit,
-         final Function<T, MonitorStatus> completeCondition, final T... 
objects) {
-      checkNotNull(completeCondition, "completeCondition");
-      if (maxWait != null) {
-         checkNotNull(timeUnit, "timeUnit");
-      }
-
-      if (objects != null && objects.length > 0) {
-         for (T object : objects) {
-            AsyncMonitor<T> monitor = new AsyncMonitor<T>(object, 
completeCondition);
-            monitor.startMonitoring(maxWait, timeUnit);
-         }
-      }
-   }
-
-   @Override
-   public <T extends AbstractEventHandler<?>> void register(final T handler) {
-      logger.debug("registering event handler %s", handler);
-      eventBus.register(handler);
-   }
-
-   @Override
-   public <T extends AbstractEventHandler<?>> void unregister(final T handler) 
{
-      logger.debug("unregistering event handler %s", handler);
-      eventBus.unregister(handler);
-   }
-
-   /*************** Delegating monitors ***************/
-
-   @Override
-   public VirtualMachineMonitor getVirtualMachineMonitor() {
-      return 
checkNotNull(context.utils().injector().getInstance(VirtualMachineMonitor.class),
 "virtualMachineMonitor");
-   }
-
-   @Override
-   public VirtualApplianceMonitor getVirtualApplianceMonitor() {
-      return 
checkNotNull(context.utils().injector().getInstance(VirtualApplianceMonitor.class),
-            "virtualApplianceMonitor");
-   }
-
-   @Override
-   public AsyncTaskMonitor getAsyncTaskMonitor() {
-      return 
checkNotNull(context.utils().injector().getInstance(AsyncTaskMonitor.class), 
"asyncTaskMonitor");
-   }
-
-   @Override
-   public ConversionMonitor getConversionMonitor() {
-      return 
checkNotNull(context.utils().injector().getInstance(ConversionMonitor.class), 
"conversionMonitor");
-   }
-
-   /**
-    * Performs the periodical monitoring tasks.
-    * 
-    * @param <T>
-    *           The type of the object being monitored.
-    */
-   @VisibleForTesting
-   class AsyncMonitor<T> implements Runnable {
-      /** The object being monitored. */
-      private T monitoredObject;
-
-      /** The function used to monitor the target object. */
-      private Function<T, MonitorStatus> completeCondition;
-
-      /**
-       * The future representing the monitoring job. Needed to be able to 
cancel
-       * it when monitor finishes.
-       */
-      private Future<?> future;
-
-      /** The timeout for this monitor. */
-      private Long timeout;
-
-      public AsyncMonitor(final T monitoredObject, final Function<T, 
MonitorStatus> completeCondition) {
-         super();
-         this.monitoredObject = checkNotNull(monitoredObject, 
"monitoredObject");
-         this.completeCondition = checkNotNull(completeCondition, 
"completeCondition");
-      }
-
-      /**
-       * Starts the monitoring job with the given timeout.
-       * 
-       * @param maxWait
-       *           The timeout.
-       * @param timeUnit
-       *           The timeunit used in the maxWait parameter.
-       */
-      public void startMonitoring(final Long maxWait, TimeUnit timeUnit) {
-         if (maxWait != null) {
-            checkNotNull(timeUnit, "timeUnit must not be null when using 
timeouts");
-         }
-         future = scheduler.scheduleWithFixedDelay(this, 0L, pollingDelay, 
TimeUnit.MILLISECONDS);
-         timeout = maxWait == null ? null : System.currentTimeMillis() + 
timeUnit.toMillis(maxWait);
-         logger.debug("started monitor job for %s with %s timeout", 
monitoredObject,
-               timeout == null ? "no" : String.valueOf(timeout));
-      }
-
-      /**
-       * Stops the monitoring job, if running.
-       */
-      public void stopMonitoring() {
-         logger.debug("stopping monitor job for %s", monitoredObject);
-
-         try {
-            if (future != null && !future.isCancelled() && !future.isDone()) {
-               // Do not force future cancel. Let it finish gracefully
-               logger.debug("cancelling future");
-               future.cancel(false);
-            }
-         } catch (Exception ex) {
-            logger.warn(ex, "failed to stop monitor job for %s", 
monitoredObject);
-         }
-      }
-
-      /**
-       * Checks if the monitor has timed out.
-       */
-      public boolean isTimeout() {
-         return timeout != null && timeout < System.currentTimeMillis();
-      }
-
-      @Override
-      public void run() {
-         // Do not use Thread.interrupted() since it will clear the interrupted
-         // flag
-         // and subsequent calls to it may not return the appropriate value
-         if (Thread.currentThread().isInterrupted()) {
-            // If the thread as already been interrupted, just stop monitoring
-            // the task and
-            // return
-            stopMonitoring();
-            return;
-         }
-
-         MonitorStatus status = completeCondition.apply(monitoredObject);
-         logger.debug("monitored object %s status %s", monitoredObject, 
status.name());
-
-         switch (status) {
-            case DONE:
-               stopMonitoring();
-               logger.debug("publishing COMPLETED event");
-               eventBus.post(new CompletedEvent<T>(monitoredObject));
-               break;
-            case FAILED:
-               stopMonitoring();
-               logger.debug("publishing FAILED event");
-               eventBus.post(new FailedEvent<T>(monitoredObject));
-               break;
-            case CONTINUE:
-            default:
-               if (isTimeout()) {
-                  logger.warn("monitor for object %s timed out. Shutting down 
monitor.", monitoredObject);
-                  stopMonitoring();
-                  logger.debug("publishing TIMEOUT event");
-                  eventBus.post(new TimeoutEvent<T>(monitoredObject));
-               }
-               break;
-         }
-      }
-
-      public T getMonitoredObject() {
-         return monitoredObject;
-      }
-
-      public Function<T, MonitorStatus> getCompleteCondition() {
-         return completeCondition;
-      }
-
-      public Future<?> getFuture() {
-         return future;
-      }
-
-      public Long getTimeout() {
-         return timeout;
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java
----------------------------------------------------------------------
diff --git 
a/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java 
b/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java
deleted file mode 100644
index a8e10c7..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.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.abiquo.monitor;
-
-import java.util.concurrent.TimeUnit;
-
-import org.jclouds.abiquo.domain.task.AsyncTask;
-import org.jclouds.abiquo.features.services.MonitoringService;
-import org.jclouds.abiquo.monitor.internal.BaseAsyncTaskMonitor;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * {@link VirtualMachine} monitoring features.
- */
-@ImplementedBy(BaseAsyncTaskMonitor.class)
-public interface AsyncTaskMonitor extends MonitoringService {
-   /**
-    * Monitor the given {@link AsyncTask}s and block until they finish.
-    * 
-    * @param tasks
-    *           The {@link AsyncTask}s to monitor.
-    */
-   void awaitCompletion(final AsyncTask<?, ?>... tasks);
-
-   /**
-    * Monitor the given {@link AsyncTask}s and populate an event when they
-    * finish.
-    * 
-    * @param tasks
-    *           The {@link AsyncTask}s to monitor.
-    */
-   void monitor(final AsyncTask<?, ?>... tasks);
-
-   /**
-    * Monitor the given {@link AsyncTask}s and block until they finish.
-    * 
-    * @param maxWait
-    *           The maximum time to wait.
-    * @param timeUnit
-    *           The time unit for the maxWait parameter.
-    * @param tasks
-    *           The {@link AsyncTask}s to monitor.
-    */
-   void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, final 
AsyncTask<?, ?>... tasks);
-
-   /**
-    * Monitor the given {@link AsyncTask}s and populate an event when they
-    * finish.
-    * 
-    * @param maxWait
-    *           The maximum time to wait.
-    * @param timeUnit
-    *           The time unit for the maxWait parameter.
-    * @param tasks
-    *           The {@link AsyncTask}s to monitor.
-    */
-   void monitor(final Long maxWait, final TimeUnit timeUnit, final 
AsyncTask<?, ?>... tasks);
-}

Reply via email to