You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2013/07/02 18:28:52 UTC
[5/8] JCLOUDS-156: Cleanup Abiquo provider
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java
deleted file mode 100644
index 83da1ed..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java
+++ /dev/null
@@ -1,404 +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.features;
-
-import java.io.Closeable;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.abiquo.binders.BindToPath;
-import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath;
-import org.jclouds.abiquo.http.filters.AbiquoAuthentication;
-import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType;
-import org.jclouds.abiquo.rest.annotations.EndpointLink;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.JAXBResponseParser;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.binders.BindToXMLPayload;
-
-import com.abiquo.server.core.pricing.CostCodeCurrenciesDto;
-import com.abiquo.server.core.pricing.CostCodeDto;
-import com.abiquo.server.core.pricing.CostCodesDto;
-import com.abiquo.server.core.pricing.CurrenciesDto;
-import com.abiquo.server.core.pricing.CurrencyDto;
-import com.abiquo.server.core.pricing.PricingCostCodeDto;
-import com.abiquo.server.core.pricing.PricingCostCodesDto;
-import com.abiquo.server.core.pricing.PricingTemplateDto;
-import com.abiquo.server.core.pricing.PricingTemplatesDto;
-import com.abiquo.server.core.pricing.PricingTierDto;
-import com.abiquo.server.core.pricing.PricingTiersDto;
-
-/**
- * Provides synchronous access to Abiquo Pricing API.
- *
- * @see API: <a href="http://community.abiquo.com/display/ABI20/APIReference">
- * http://community.abiquo.com/display/ABI20/APIReference</a>
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class })
-@Path("/config")
-public interface PricingApi extends Closeable {
-
- /*********************** Currency ********************** */
-
- /**
- * List all currencies
- *
- * @return The list of currencies
- */
- @Named("currency:list")
- @GET
- @Path("/currencies")
- @Consumes(CurrenciesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CurrenciesDto listCurrencies();
-
- /**
- * Get the given currency
- *
- * @param currencyId
- * The id of the currency
- * @return The currency
- */
- @Named("currency:get")
- @GET
- @Path("/currencies/{currency}")
- @Consumes(CurrencyDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- CurrencyDto getCurrency(@PathParam("currency") Integer currencyId);
-
- /**
- * Create a new currency
- *
- * @param currency
- * The currency to be created.
- * @return The created currency.
- */
- @Named("currency:create")
- @POST
- @Path("/currencies")
- @Produces(CurrencyDto.BASE_MEDIA_TYPE)
- @Consumes(CurrencyDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CurrencyDto createCurrency(@BinderParam(BindToXMLPayload.class) CurrencyDto currency);
-
- /**
- * Updates an existing currency
- *
- * @param currency
- * The new attributes for the currency
- * @return The updated currency
- */
- @Named("currency:update")
- @PUT
- @Produces(CurrencyDto.BASE_MEDIA_TYPE)
- @Consumes(CurrencyDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CurrencyDto updateCurrency(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CurrencyDto currency);
-
- /**
- * Deletes an existing currency
- *
- * @param currency
- * The currency to delete
- */
- @Named("currency:delete")
- @DELETE
- void deleteCurrency(@EndpointLink("edit") @BinderParam(BindToPath.class) CurrencyDto currency);
-
- /*********************** CostCode ********************** */
-
- /**
- * List all costcodes
- *
- * @return The list of costcodes
- */
- @Named("costcode:list")
- @GET
- @Path("/costcodes")
- @Consumes(CostCodesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodesDto listCostCodes();
-
- /**
- * Get the given costcode
- *
- * @param costcodeId
- * The id of the costcode
- * @return The costcode
- */
- @Named("costcode:get")
- @GET
- @Path("/costcodes/{costcode}")
- @Consumes(CostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- CostCodeDto getCostCode(@PathParam("costcode") Integer costcodeId);
-
- /**
- * Create a new costcode
- *
- * @param costcode
- * The costcode to be created.
- * @return The created costcode.
- */
- @Named("costcode:create")
- @POST
- @Path("/costcodes")
- @Produces(CostCodeDto.BASE_MEDIA_TYPE)
- @Consumes(CostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodeDto createCostCode(@BinderParam(BindToXMLPayload.class) CostCodeDto costcode);
-
- /**
- * Updates an existing costcode
- *
- * @param costcode
- * The new attributes for the costcode
- * @return The updated costcode
- */
- @Named("costcode:update")
- @PUT
- @Produces(CostCodeDto.BASE_MEDIA_TYPE)
- @Consumes(CostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodeDto updateCostCode(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CostCodeDto costcode);
-
- /**
- * Deletes an existing costcode
- *
- * @param currency
- * The costcode to delete
- */
- @Named("costcode:delete")
- @DELETE
- void deleteCostCode(@EndpointLink("edit") @BinderParam(BindToPath.class) CostCodeDto costcode);
-
- /*********************** PricingTemplate ********************** */
-
- /**
- * List all pricingtemplates
- *
- * @return The list of pricingtemplates
- */
- @Named("pricingtemplate:list")
- @GET
- @Path("/pricingtemplates")
- @Consumes(PricingTemplatesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTemplatesDto listPricingTemplates();
-
- /**
- * Get the given pricingtemplate
- *
- * @param pricingTemplateId
- * The id of the pricingtemplate
- * @return The pricingtemplate
- */
- @Named("pricingtemplate:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}")
- @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingTemplateDto getPricingTemplate(@PathParam("pricingtemplate") Integer pricingTemplateId);
-
- /**
- * Create a new pricing template
- *
- * @param pricingtemplate
- * The pricingtemplate to be created
- * @return The created pricingtemplate
- */
- @Named("pricingtemplate:create")
- @POST
- @Path("/pricingtemplates")
- @Produces(PricingTemplateDto.BASE_MEDIA_TYPE)
- @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTemplateDto createPricingTemplate(@BinderParam(BindToXMLPayload.class) PricingTemplateDto pricingtemplate);
-
- /**
- * Updates an existing pricing template
- *
- * @param pricingtemplate
- * The new attributes for the pricingtemplate
- * @return The updated pricingtemplate
- */
- @Named("pricingtemplate:update")
- @PUT
- @Produces(PricingTemplateDto.BASE_MEDIA_TYPE)
- @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTemplateDto updatePricingTemplate(
- @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTemplateDto pricingtemplate);
-
- /**
- * Deletes an existing pricingtemplate
- *
- * @param pricingtemplate
- * The pricingtemplate to delete
- */
- @Named("pricingtemplate:delete")
- @DELETE
- void deletePricingTemplate(@EndpointLink("edit") @BinderParam(BindToPath.class) PricingTemplateDto pricingtemplate);
-
- /*********************** CostCodeCurrency ********************** */
-
- /**
- * Get the given costcodecurrency
- *
- * @param costcodecurrencyId
- * The id of the costcodecurrency
- * @return The costcodecurrency
- */
- @Named("costcodecurrency:get")
- @GET
- @Path("/costcodes/{costcode}/currencies")
- @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- CostCodeCurrenciesDto getCostCodeCurrencies(@PathParam("costcode") Integer costcodeId,
- @QueryParam("idCurrency") Integer currencyId);
-
- /**
- * Updates cost code currencies
- *
- * @param costcodeCurrency
- * The new attributes for the costcodecurrencies
- * @return The updated costcodecurrencies
- */
- @Named("costcodecurrency:update")
- @PUT
- @Path("/costcodes/{costcode}/currencies")
- @Produces(CostCodeCurrenciesDto.BASE_MEDIA_TYPE)
- @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- CostCodeCurrenciesDto updateCostCodeCurrencies(@PathParam("costcode") Integer costcodeId,
- @BinderParam(BindToXMLPayload.class) CostCodeCurrenciesDto costcodecurrencies);
-
- /*********************** PricingTemplateCostCode ********************** */
-
- /**
- * Get the pricing cost codes for a pricing template
- *
- * @param pricingTemplateId
- * @return pricingcostcodes
- */
- @Named("pricingcostcode:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/costcodes")
- @Consumes(PricingCostCodesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingCostCodesDto getPricingCostCodes(@PathParam("pricingtemplate") Integer pricingTemplateId);
-
- /**
- * Get the given pricing cost code
- *
- * @param pricingCostCodeId
- * the id of the pricing cost code
- * @return The pricingcostcode
- */
- @Named("pricingcostcode:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}")
- @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingCostCodeDto getPricingCostCode(@PathParam("pricingtemplate") Integer pricingTemplateId,
- @PathParam("costcode") Integer pricingCostcodeId);
-
- /**
- * Updates an existing pricingcostcode
- *
- * @param costcodeCurrency
- * The new attributes for the pricingcostcode
- * @return The updated pricingcostcode
- */
- @Named("pricingcostcode:update")
- @PUT
- @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}")
- @Produces(PricingCostCodeDto.BASE_MEDIA_TYPE)
- @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingCostCodeDto updatePricingCostCode(
- @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingCostCodeDto pricingcostcode,
- @PathParam("pricingtemplate") Integer pricingTemplateId, @PathParam("costcode") Integer pricingCostcodeId);
-
- /*********************** PricingTemplateTier ********************** */
-
- /**
- * Get the pricing tiers for a pricing template
- *
- * @param pricingTemplateId
- * @return pricingtiers
- */
- @Named("pricingtier:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/tiers")
- @Consumes(PricingTiersDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingTiersDto getPricingTiers(@PathParam("pricingtemplate") Integer pricingTemplateId);
-
- /**
- * Get the given pricing tier
- *
- * @param pricingTierId
- * The id of the pricing tier
- * @return The pricingtier
- */
- @Named("pricingtier:get")
- @GET
- @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}")
- @Consumes(PricingTierDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- PricingTierDto getPricingTier(@PathParam("pricingtemplate") Integer pricingTemplateId,
- @PathParam("tier") Integer pricingTierId);
-
- /**
- * Updates an existing pricing tier
- *
- * @param costcodeCurrency
- * The new attributes for the pricing tier
- * @return The updated pricing tier
- */
- @Named("pricingtier:update")
- @PUT
- @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}")
- @Produces(PricingTierDto.BASE_MEDIA_TYPE)
- @Consumes(PricingTierDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PricingTierDto updatePricingTier(
- @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTierDto pricingtier,
- @PathParam("pricingtemplate") Integer pricingTemplateId, @PathParam("tier") Integer pricingTierId);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
index 836b98b..2278708 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java
@@ -28,7 +28,6 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Machine;
import org.jclouds.abiquo.internal.BaseAdministrationService;
-import com.google.common.base.Predicate;
import com.google.inject.ImplementedBy;
/**
@@ -47,17 +46,6 @@ public interface AdministrationService {
Iterable<Datacenter> listDatacenters();
/**
- * Get the list of datacenters matching the given filter.
- */
- Iterable<Datacenter> listDatacenters(final Predicate<Datacenter> filter);
-
- /**
- * Get the first datacenter that matches the given filter or
- * <code>null</code> if none is found.
- */
- Datacenter findDatacenter(final Predicate<Datacenter> filter);
-
- /**
* Get the datacenter with the given id.
*/
Datacenter getDatacenter(final Integer datacenterId);
@@ -69,17 +57,6 @@ public interface AdministrationService {
*/
public Iterable<Machine> listMachines();
- /**
- * Get the list of all machines in the infrastructure matching the given
- * filter.
- */
- public Iterable<Machine> listMachines(Predicate<Machine> filter);
-
- /**
- * Get the first machine in the infrastructure that matches the given filter.
- */
- public Machine findMachine(Predicate<Machine> filter);
-
/*********************** Enterprise ***********************/
/**
@@ -88,17 +65,6 @@ public interface AdministrationService {
Iterable<Enterprise> listEnterprises();
/**
- * Get the list of enterprises matching the given filter.
- */
- Iterable<Enterprise> listEnterprises(final Predicate<Enterprise> filter);
-
- /**
- * Get the first enterprises that matches the given filter or
- * <code>null</code> if none is found.
- */
- Enterprise findEnterprise(final Predicate<Enterprise> filter);
-
- /**
* Get the enterprise with the given id.
*/
Enterprise getEnterprise(final Integer enterpriseId);
@@ -117,17 +83,6 @@ public interface AdministrationService {
Iterable<Role> listRoles();
/**
- * Get the list of roles matching the given filter.
- */
- Iterable<Role> listRoles(final Predicate<Role> filter);
-
- /**
- * Get the first role that matches the given filter or <code>null</code> if
- * none is found.
- */
- Role findRole(final Predicate<Role> filter);
-
- /**
* Get the role with the given id.
*/
Role getRole(final Integer roleId);
@@ -140,17 +95,6 @@ public interface AdministrationService {
Iterable<Privilege> listPrivileges();
/**
- * Get the list of privileges matching the given filter.
- */
- Iterable<Privilege> listPrivileges(final Predicate<Privilege> filter);
-
- /**
- * Get the first privilege that matches the given filter or <code>null</code>
- * if none is found.
- */
- Privilege findPrivilege(final Predicate<Privilege> filter);
-
- /**
* Get a privilege given its id.
*
* @param privilegeId
@@ -187,17 +131,6 @@ public interface AdministrationService {
*/
Iterable<License> listLicenses(boolean active);
- /**
- * Get the list of licenses matching the given filter.
- */
- Iterable<License> listLicenses(final Predicate<License> filter);
-
- /**
- * Get the first license that matches the given filter or <code>null</code>
- * if none is found.
- */
- License findLicense(final Predicate<License> filter);
-
/*********************** System Properties ***********************/
/**
@@ -206,17 +139,6 @@ public interface AdministrationService {
Iterable<SystemProperty> listSystemProperties();
/**
- * Get the list of system properties matching the given filter.
- */
- Iterable<SystemProperty> listSystemProperties(final Predicate<SystemProperty> filter);
-
- /**
- * Get the first system property that matches the given filter or
- * <code>null</code> if none is found.
- */
- SystemProperty findSystemProperty(final Predicate<SystemProperty> filter);
-
- /**
* Get the system property with the give name or <code>null</code> if none is
* found.
*/
@@ -235,17 +157,6 @@ public interface AdministrationService {
Iterable<Category> listCategories();
/**
- * Get the list of categories matching the given filter.
- */
- Iterable<Category> listCategories(final Predicate<Category> filter);
-
- /**
- * Get the first categories that matches the given filter or
- * <code>null</code> if none is found.
- */
- Category findCategory(final Predicate<Category> filter);
-
- /**
* Get the category identified by the given id.
*
* @param categoryId
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
index c81c2fa..fc1aeed 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java
@@ -24,7 +24,6 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachine;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.internal.BaseCloudService;
-import com.google.common.base.Predicate;
import com.google.inject.ImplementedBy;
/**
@@ -53,17 +52,6 @@ public interface CloudService {
Iterable<VirtualDatacenter> listVirtualDatacenters(final Enterprise enterprise);
/**
- * Get the list of virtual datacenters matching the given filter.
- */
- Iterable<VirtualDatacenter> listVirtualDatacenters(final Predicate<VirtualDatacenter> filter);
-
- /**
- * Get the first virtual datacenter that matches the given filter or
- * <code>null</code> if none is found.
- */
- VirtualDatacenter findVirtualDatacenter(final Predicate<VirtualDatacenter> filter);
-
- /**
* Get the virtual datacenter with the given id.
*/
VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId);
@@ -80,16 +68,6 @@ public interface CloudService {
*/
Iterable<VirtualAppliance> listVirtualAppliances();
- /**
- * Get the list of the virtual appliances matching the given filter.
- */
- Iterable<VirtualAppliance> listVirtualAppliances(Predicate<VirtualAppliance> filter);
-
- /**
- * Get the first virtual appliance that matches the given filter.
- */
- VirtualAppliance findVirtualAppliance(Predicate<VirtualAppliance> filter);
-
/*********************** Virtual Machine ***********************/
/**
@@ -97,13 +75,4 @@ public interface CloudService {
*/
Iterable<VirtualMachine> listVirtualMachines();
- /**
- * Get the list of the virtual machines matching the given filter.
- */
- Iterable<VirtualMachine> listVirtualMachines(Predicate<VirtualMachine> filter);
-
- /**
- * Get the first virtual machine that matches the given filter.
- */
- VirtualMachine findVirtualMachine(Predicate<VirtualMachine> filter);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
index 4602c5a..2a3d558 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java
@@ -18,13 +18,13 @@ package org.jclouds.abiquo.features.services;
import java.util.concurrent.TimeUnit;
-import org.jclouds.abiquo.events.handlers.AbstractEventHandler;
import org.jclouds.abiquo.internal.BaseMonitoringService;
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.handlers.AbstractEventHandler;
import com.google.common.base.Function;
import com.google.inject.ImplementedBy;
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java
deleted file mode 100644
index 1c2004b..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java
+++ /dev/null
@@ -1,153 +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.features.services;
-
-import java.util.Collection;
-
-import org.jclouds.abiquo.domain.config.CostCode;
-import org.jclouds.abiquo.domain.config.CostCodeCurrency;
-import org.jclouds.abiquo.domain.config.Currency;
-import org.jclouds.abiquo.domain.config.PricingCostCode;
-import org.jclouds.abiquo.domain.config.PricingTemplate;
-import org.jclouds.abiquo.domain.config.PricingTier;
-import org.jclouds.abiquo.internal.BasePricingService;
-
-import com.google.common.base.Predicate;
-import com.google.inject.ImplementedBy;
-
-/**
- * Provides high level Abiquo administration operations.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@ImplementedBy(BasePricingService.class)
-public interface PricingService {
-
- /*********************** Currency ***********************/
-
- /**
- * Get the list of currencies.
- */
- Iterable<Currency> listCurrencies();
-
- /**
- * Get the list of currencies matching the given filter.
- */
- Iterable<Currency> listCurrencies(final Predicate<Currency> filter);
-
- /**
- * Get the first currencies that matches the given filter or
- * <code>null</code> if none is found.
- */
- Currency findCurrency(final Predicate<Currency> filter);
-
- /**
- * Get the currency with the given id.
- *
- * @param currencyId
- * The id of the currency to get.
- * @return The currency with the gicen id.
- */
- Currency getCurrency(final Integer currencyId);
-
- /*********************** CostCode ***********************/
-
- /**
- * Get the list of costcodes.
- */
- Iterable<CostCode> listCostCodes();
-
- /**
- * Get the list of costcodes matching the given filter.
- */
- Iterable<CostCode> listCostCodes(final Predicate<CostCode> filter);
-
- /**
- * Get the first costcodes that matches the given filter or <code>null</code>
- * if none is found.
- */
- CostCode findCostCode(final Predicate<CostCode> filter);
-
- /**
- * Get a cost code given its id.
- *
- * @param costCodeId
- * The id of the cost code.
- * @return The cost code.
- */
- CostCode getCostCode(Integer costCodeId);
-
- /*********************** PricingTemplate ***********************/
-
- /**
- * Get the list of pricingtemplates.
- */
- Iterable<PricingTemplate> listPricingTemplates();
-
- /**
- * Get the list of pricingtemplates matching the given filter.
- */
- Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter);
-
- /**
- * Get the first pricingtemplates that matches the given filter or
- * <code>null</code> if none is found.
- */
- PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> filter);
-
- /**
- * Get a pricing template given its id.
- *
- * @param pricingTemplateId
- * The id of the pricing template.
- * @return The pricing template.
- */
- PricingTemplate getPricingTemplate(Integer pricingTemplateId);
-
- /*********************** CostCodeCurrency ***********************/
-
- /**
- * Get a cost code currency
- */
- Iterable<CostCodeCurrency> getCostCodeCurrencies(Integer costcodeid, Integer currencyid);
-
- /*********************** PricingCostCode ***********************/
-
- /**
- * Get pricing cost codes
- */
- Collection<PricingCostCode> getPricingCostCodes(Integer pricingTemplateId);
-
- /**
- * Get a pricing cost code
- */
- PricingCostCode getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId);
-
- /*********************** PricingTier ***********************/
-
- /**
- * Get pricing tiers
- */
- Collection<PricingTier> getPricingTiers(Integer pricingTemplateId);
-
- /**
- * Get a pricing tier
- */
- PricingTier getPricingTier(Integer pricingTemplateId, Integer pricingTierId);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
index 3473468..7588879 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java
@@ -22,8 +22,6 @@ import org.jclouds.abiquo.domain.cloud.options.VolumeOptions;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.infrastructure.LogicServer;
-import org.jclouds.abiquo.domain.infrastructure.ManagedRack;
import org.jclouds.abiquo.domain.infrastructure.StorageDevice;
import org.jclouds.abiquo.domain.infrastructure.StoragePool;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
@@ -31,7 +29,6 @@ import org.jclouds.abiquo.domain.network.PrivateIp;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.domain.options.search.FilterOptions;
import org.jclouds.abiquo.internal.BaseSearchService;
import com.google.inject.ImplementedBy;
@@ -125,26 +122,4 @@ public interface SearchService {
* The set of filtering and pagination options of the search.
*/
Iterable<PublicIp> searchPurchasedPublicIps(final VirtualDatacenter virtualDatacenter, final IpOptions options);
-
- /*********************** Logic Server ***********************/
-
- /**
- * Get the list of service profiles for managed rack.
- *
- * @param managedRack
- * The given rack.
- * @param options
- * The set of filtering and pagination options of the search.
- */
- Iterable<LogicServer> searchServiceProfiles(final ManagedRack rack, final FilterOptions options);
-
- /**
- * Get the list of service profile templates for managed rack.
- *
- * @param managedRack
- * The given rack.
- * @param options
- * The set of filtering and pagination options of the search.
- */
- Iterable<LogicServer> searchServiceProfileTemplates(final ManagedRack rack, final FilterOptions options);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/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
index 66a541c..9ab82e4 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java
@@ -28,7 +28,6 @@ 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.abiquo.features.services.PricingService;
import org.jclouds.abiquo.features.services.SearchService;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.Utils;
@@ -56,21 +55,17 @@ public class AbiquoContextImpl extends ComputeServiceContextImpl implements Abiq
private final EventService eventService;
- private final PricingService pricingService;
-
@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 SearchService searchService, final MonitoringService monitoringService, final EventService eventService,
- final PricingService pricingService) {
+ final SearchService searchService, final MonitoringService monitoringService, final EventService eventService) {
super(wrapped, wrappedType, computeService, utils);
this.administrationService = checkNotNull(administrationService, "administrationService");
this.cloudService = checkNotNull(cloudService, "cloudService");
this.searchService = checkNotNull(searchService, "searchService");
this.monitoringService = checkNotNull(monitoringService, "monitoringService");
this.eventService = checkNotNull(eventService, "eventService");
- this.pricingService = checkNotNull(pricingService, "pricingService");
}
@Override
@@ -102,9 +97,4 @@ public class AbiquoContextImpl extends ComputeServiceContextImpl implements Abiq
public EventService getEventService() {
return eventService;
}
-
- @Override
- public PricingService getPricingService() {
- return pricingService;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/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
index b5bb885..ceffaa4 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java
@@ -17,7 +17,6 @@
package org.jclouds.abiquo.internal;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getFirst;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
@@ -57,9 +56,7 @@ 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.Predicate;
import com.google.common.base.Supplier;
-import com.google.common.collect.Iterables;
/**
* Provides high level Abiquo administration operations.
@@ -99,16 +96,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Datacenter> listDatacenters(final Predicate<Datacenter> filter) {
- return filter(listDatacenters(), filter);
- }
-
- @Override
- public Datacenter findDatacenter(final Predicate<Datacenter> filter) {
- return getFirst(listDatacenters(filter), null);
- }
-
- @Override
public Datacenter getDatacenter(final Integer datacenterId) {
DatacenterDto datacenter = context.getApi().getInfrastructureApi().getDatacenter(datacenterId);
return wrap(context, Datacenter.class, datacenter);
@@ -121,16 +108,6 @@ public class BaseAdministrationService implements AdministrationService {
return listMachines.execute();
}
- @Override
- public Iterable<Machine> listMachines(final Predicate<Machine> filter) {
- return listMachines.execute(filter);
- }
-
- @Override
- public Machine findMachine(final Predicate<Machine> filter) {
- return Iterables.getFirst(listMachines(filter), null);
- }
-
/*********************** Enterprise ***********************/
@Override
@@ -140,16 +117,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Enterprise> listEnterprises(final Predicate<Enterprise> filter) {
- return filter(listEnterprises(), filter);
- }
-
- @Override
- public Enterprise findEnterprise(final Predicate<Enterprise> filter) {
- return Iterables.getFirst(listEnterprises(filter), null);
- }
-
- @Override
public Enterprise getEnterprise(final Integer enterpriseId) {
EnterpriseDto enterprise = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId);
return wrap(context, Enterprise.class, enterprise);
@@ -175,16 +142,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Role> listRoles(final Predicate<Role> filter) {
- return filter(listRoles(), filter);
- }
-
- @Override
- public Role findRole(final Predicate<Role> filter) {
- return getFirst(listRoles(filter), null);
- }
-
- @Override
public Role getRole(final Integer roleId) {
RoleDto role = context.getApi().getAdminApi().getRole(roleId);
return wrap(context, Role.class, role);
@@ -199,16 +156,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Privilege> listPrivileges(final Predicate<Privilege> filter) {
- return filter(listPrivileges(), filter);
- }
-
- @Override
- public Privilege findPrivilege(final Predicate<Privilege> filter) {
- return getFirst(listPrivileges(filter), null);
- }
-
- @Override
public Privilege getPrivilege(Integer privilegeId) {
PrivilegeDto result = context.getApi().getConfigApi().getPrivilege(privilegeId);
return wrap(context, Privilege.class, result);
@@ -241,16 +188,6 @@ public class BaseAdministrationService implements AdministrationService {
return wrap(context, License.class, result.getCollection());
}
- @Override
- public Iterable<License> listLicenses(final Predicate<License> filter) {
- return filter(listLicenses(), filter);
- }
-
- @Override
- public License findLicense(final Predicate<License> filter) {
- return getFirst(listLicenses(filter), null);
- }
-
/*********************** System Properties ***********************/
@Override
@@ -260,16 +197,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<SystemProperty> listSystemProperties(final Predicate<SystemProperty> filter) {
- return filter(listSystemProperties(), filter);
- }
-
- @Override
- public SystemProperty findSystemProperty(final Predicate<SystemProperty> filter) {
- return getFirst(listSystemProperties(filter), null);
- }
-
- @Override
public SystemProperty getSystemProperty(final String name) {
PropertyOptions options = PropertyOptions.builder().name(name).build();
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options);
@@ -290,16 +217,6 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
- public Iterable<Category> listCategories(final Predicate<Category> filter) {
- return filter(listCategories(), filter);
- }
-
- @Override
- public Category findCategory(final Predicate<Category> filter) {
- return Iterables.getFirst(listCategories(filter), null);
- }
-
- @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/incubator-jclouds-labs/blob/c5e108a8/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
index 5a434c7..6d0ca53 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java
@@ -39,8 +39,6 @@ import org.jclouds.rest.ApiContext;
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
/**
* Provides high level Abiquo cloud operations.
@@ -89,11 +87,6 @@ public class BaseCloudService implements CloudService {
}
@Override
- public Iterable<VirtualDatacenter> listVirtualDatacenters(final Predicate<VirtualDatacenter> filter) {
- return listVirtualDatacenters.execute(filter);
- }
-
- @Override
public VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId) {
VirtualDatacenterDto virtualDatacenter = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId);
return wrap(context, VirtualDatacenter.class, virtualDatacenter);
@@ -104,11 +97,6 @@ public class BaseCloudService implements CloudService {
return listVirtualDatacenters.execute(virtualDatacenterIds);
}
- @Override
- public VirtualDatacenter findVirtualDatacenter(final Predicate<VirtualDatacenter> filter) {
- return Iterables.getFirst(listVirtualDatacenters(filter), null);
- }
-
/*********************** Virtual Appliance ********************** */
@Override
@@ -116,30 +104,10 @@ public class BaseCloudService implements CloudService {
return listVirtualAppliances.execute();
}
- @Override
- public Iterable<VirtualAppliance> listVirtualAppliances(final Predicate<VirtualAppliance> filter) {
- return listVirtualAppliances.execute(filter);
- }
-
- @Override
- public VirtualAppliance findVirtualAppliance(final Predicate<VirtualAppliance> filter) {
- return Iterables.getFirst(listVirtualAppliances(filter), null);
- }
-
/*********************** Virtual Machine ********************** */
@Override
public Iterable<VirtualMachine> listVirtualMachines() {
return listVirtualMachines.execute();
}
-
- @Override
- public Iterable<VirtualMachine> listVirtualMachines(final Predicate<VirtualMachine> filter) {
- return listVirtualMachines.execute(filter);
- }
-
- @Override
- public VirtualMachine findVirtualMachine(final Predicate<VirtualMachine> filter) {
- return Iterables.getFirst(listVirtualMachines(filter), null);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/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
index eb682e8..5ee4d2c 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java
@@ -29,17 +29,17 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.events.handlers.AbstractEventHandler;
-import org.jclouds.abiquo.events.handlers.BlockingEventHandler;
-import org.jclouds.abiquo.events.monitor.CompletedEvent;
-import org.jclouds.abiquo.events.monitor.FailedEvent;
-import org.jclouds.abiquo.events.monitor.TimeoutEvent;
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;
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java
deleted file mode 100644
index d5f2159..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java
+++ /dev/null
@@ -1,178 +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.filter;
-import static com.google.common.collect.Iterables.getFirst;
-import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
-
-import java.util.Collection;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.config.CostCode;
-import org.jclouds.abiquo.domain.config.CostCodeCurrency;
-import org.jclouds.abiquo.domain.config.Currency;
-import org.jclouds.abiquo.domain.config.PricingCostCode;
-import org.jclouds.abiquo.domain.config.PricingTemplate;
-import org.jclouds.abiquo.domain.config.PricingTier;
-import org.jclouds.abiquo.features.services.PricingService;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.pricing.CostCodeCurrenciesDto;
-import com.abiquo.server.core.pricing.CostCodeDto;
-import com.abiquo.server.core.pricing.CostCodesDto;
-import com.abiquo.server.core.pricing.CurrenciesDto;
-import com.abiquo.server.core.pricing.CurrencyDto;
-import com.abiquo.server.core.pricing.PricingCostCodeDto;
-import com.abiquo.server.core.pricing.PricingCostCodesDto;
-import com.abiquo.server.core.pricing.PricingTemplateDto;
-import com.abiquo.server.core.pricing.PricingTemplatesDto;
-import com.abiquo.server.core.pricing.PricingTierDto;
-import com.abiquo.server.core.pricing.PricingTiersDto;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- * Provides access to Abiquo pricing features.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-@Singleton
-public class BasePricingService implements PricingService {
- @VisibleForTesting
- protected ApiContext<AbiquoApi> context;
-
- @Inject
- protected BasePricingService(final ApiContext<AbiquoApi> context) {
- this.context = checkNotNull(context, "context");
- }
-
- /*********************** Currency ********************** */
-
- @Override
- public Iterable<Currency> listCurrencies() {
- CurrenciesDto result = context.getApi().getPricingApi().listCurrencies();
- return wrap(context, Currency.class, result.getCollection());
- }
-
- @Override
- public Iterable<Currency> listCurrencies(final Predicate<Currency> filter) {
- return filter(listCurrencies(), filter);
- }
-
- @Override
- public Currency findCurrency(final Predicate<Currency> filter) {
- return getFirst(listCurrencies(filter), null);
- }
-
- @Override
- public Currency getCurrency(final Integer currencyId) {
- CurrencyDto result = context.getApi().getPricingApi().getCurrency(currencyId);
- return wrap(context, Currency.class, result);
- }
-
- /*********************** CostCode ********************** */
-
- @Override
- public Iterable<CostCode> listCostCodes() {
- CostCodesDto result = context.getApi().getPricingApi().listCostCodes();
- return wrap(context, CostCode.class, result.getCollection());
- }
-
- @Override
- public Iterable<CostCode> listCostCodes(final Predicate<CostCode> filter) {
- return filter(listCostCodes(), filter);
- }
-
- @Override
- public CostCode findCostCode(final Predicate<CostCode> filter) {
- return Iterables.getFirst(listCostCodes(filter), null);
- }
-
- @Override
- public CostCode getCostCode(Integer costCodeId) {
- CostCodeDto result = context.getApi().getPricingApi().getCostCode(costCodeId);
- return wrap(context, CostCode.class, result);
- }
-
- /*********************** PricingTemplate ********************** */
-
- @Override
- public Iterable<PricingTemplate> listPricingTemplates() {
- PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates();
- return wrap(context, PricingTemplate.class, result.getCollection());
- }
-
- @Override
- public Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter) {
- return filter(listPricingTemplates(), filter);
- }
-
- @Override
- public PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> filter) {
- return getFirst(listPricingTemplates(filter), null);
- }
-
- @Override
- public PricingTemplate getPricingTemplate(Integer pricingTemplateId) {
- PricingTemplateDto result = context.getApi().getPricingApi().getPricingTemplate(pricingTemplateId);
- return wrap(context, PricingTemplate.class, result);
- }
-
- /*********************** CostCodeCurrency ********************** */
-
- @Override
- public Iterable<CostCodeCurrency> getCostCodeCurrencies(final Integer costcodeId, final Integer currencyId) {
- CostCodeCurrenciesDto result = context.getApi().getPricingApi().getCostCodeCurrencies(costcodeId, currencyId);
- return wrap(context, CostCodeCurrency.class, result.getCollection());
- }
-
- /*********************** Pricing Cost Code ********************** */
-
- @Override
- public Collection<PricingCostCode> getPricingCostCodes(final Integer pricingTemplateId) {
- PricingCostCodesDto result = context.getApi().getPricingApi().getPricingCostCodes(pricingTemplateId);
- return wrap(context, PricingCostCode.class, result.getCollection());
- }
-
- @Override
- public PricingCostCode getPricingCostCode(final Integer pricingTemplateId, final Integer pricingCostCodeId) {
- PricingCostCodeDto pricingcostcode = context.getApi().getPricingApi()
- .getPricingCostCode(pricingTemplateId, pricingCostCodeId);
- return wrap(context, PricingCostCode.class, pricingcostcode);
- }
-
- /*********************** Pricing Tier********************** */
-
- @Override
- public Collection<PricingTier> getPricingTiers(final Integer pricingTemplateId) {
- PricingTiersDto result = context.getApi().getPricingApi().getPricingTiers(pricingTemplateId);
- return wrap(context, PricingTier.class, result.getCollection());
- }
-
- @Override
- public PricingTier getPricingTier(final Integer pricingTemplateId, final Integer pricingTierId) {
- PricingTierDto pricingtier = context.getApi().getPricingApi().getPricingTier(pricingTemplateId, pricingTierId);
- return wrap(context, PricingTier.class, pricingtier);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
index 803f94b..42070e9 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java
@@ -31,8 +31,6 @@ import org.jclouds.abiquo.domain.cloud.options.VolumeOptions;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.infrastructure.LogicServer;
-import org.jclouds.abiquo.domain.infrastructure.ManagedRack;
import org.jclouds.abiquo.domain.infrastructure.StorageDevice;
import org.jclouds.abiquo.domain.infrastructure.StoragePool;
import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions;
@@ -40,12 +38,10 @@ import org.jclouds.abiquo.domain.network.PrivateIp;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.domain.options.search.FilterOptions;
import org.jclouds.abiquo.features.services.SearchService;
import org.jclouds.rest.ApiContext;
import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
import com.abiquo.server.core.infrastructure.network.PublicIpDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
@@ -133,20 +129,4 @@ public class BaseSearchService implements SearchService {
return wrap(context, PublicIp.class, ips);
}
- @Override
- public Iterable<LogicServer> searchServiceProfiles(final ManagedRack rack, final FilterOptions options) {
- List<LogicServerDto> profiles = context.getApi().getInfrastructureApi()
- .listServiceProfiles(rack.unwrap(), options).getCollection();
-
- return wrap(context, LogicServer.class, profiles);
- }
-
- @Override
- public Iterable<LogicServer> searchServiceProfileTemplates(final ManagedRack rack, final FilterOptions options) {
- List<LogicServerDto> profiles = context.getApi().getInfrastructureApi()
- .listServiceProfileTemplates(rack.unwrap(), options).getCollection();
-
- return wrap(context, LogicServer.class, profiles);
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java
new file mode 100644
index 0000000..352f304
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/CompletedEvent.java
@@ -0,0 +1,29 @@
+/*
+ * 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.events;
+
+/**
+ * Event dispatched when a monitoring job completes without error.
+ *
+ * @author Ignasi Barrera
+ */
+public class CompletedEvent<T> extends MonitorEvent<T> {
+ public CompletedEvent(final T target) {
+ super(MonitorEvent.Type.COMPLETED, target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java
new file mode 100644
index 0000000..af18d1d
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/FailedEvent.java
@@ -0,0 +1,29 @@
+/*
+ * 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.events;
+
+/**
+ * Event dispatched when a monitoring job completes with errors.
+ *
+ * @author Ignasi Barrera
+ */
+public class FailedEvent<T> extends MonitorEvent<T> {
+ public FailedEvent(final T target) {
+ super(MonitorEvent.Type.FAILED, target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java
new file mode 100644
index 0000000..0d43335
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/MonitorEvent.java
@@ -0,0 +1,67 @@
+/*
+ * 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.events;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * base class for all monitor events.
+ *
+ * @author Ignasi Barrera
+ */
+public class MonitorEvent<T> {
+ /**
+ * The type of the event.
+ */
+ public static enum Type {
+ COMPLETED, FAILED, TIMEOUT;
+ }
+
+ /** The type of the event. */
+ private Type type;
+
+ /** The target object being monitored. */
+ private T target;
+
+ public MonitorEvent(final Type type, final T target) {
+ super();
+ this.type = checkNotNull(type, "type");
+ this.target = checkNotNull(target, "target");
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(final Type type) {
+ this.type = type;
+ }
+
+ public T getTarget() {
+ return target;
+ }
+
+ public void setTarget(final T target) {
+ this.target = target;
+ }
+
+ @Override
+ public String toString() {
+ return "MonitorEvent [type=" + type + ", target=" + target + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java
new file mode 100644
index 0000000..e46c3d6
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/events/TimeoutEvent.java
@@ -0,0 +1,29 @@
+/*
+ * 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.events;
+
+/**
+ * Event dispatched when a monitoring job times out.
+ *
+ * @author Ignasi Barrera
+ */
+public class TimeoutEvent<T> extends MonitorEvent<T> {
+ public TimeoutEvent(final T target) {
+ super(MonitorEvent.Type.TIMEOUT, target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java
new file mode 100644
index 0000000..a1bec36
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/AbstractEventHandler.java
@@ -0,0 +1,54 @@
+/*
+ * 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.handlers;
+
+import javax.annotation.Resource;
+
+import org.jclouds.abiquo.monitor.events.MonitorEvent;
+import org.jclouds.logging.Logger;
+
+/**
+ * Base class for all {@link MonitorEvent} handlers.
+ *
+ * @author Ignasi Barrera
+ */
+public abstract class AbstractEventHandler<T> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ /**
+ * Checks if the current handler must handle the dispatched event.
+ *
+ * @param event
+ * The event being dispatched.
+ * @return Boolean indicating if the event must be handled by the current
+ * handler.
+ */
+ protected abstract boolean handles(MonitorEvent<T> event);
+
+ // Public getters and setters to allow non-guice code to set the appropriate
+ // logger
+
+ public Logger getLogger() {
+ return logger;
+ }
+
+ public void setLogger(final Logger logger) {
+ this.logger = logger;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java
new file mode 100644
index 0000000..0419e1a
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/monitor/handlers/BlockingEventHandler.java
@@ -0,0 +1,146 @@
+/*
+ * 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.handlers;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import org.jclouds.abiquo.monitor.events.MonitorEvent;
+import org.jclouds.logging.Logger;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * An event handler that blocks the thread until all monitored objects have been
+ * finished being watched.
+ * <p>
+ * Due to <a
+ * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
+ * Issue 786</a> {@link #handle(MonitorEvent)} is marked <code>final</code>to
+ * avoid having duplicate events.
+ *
+ * @author Ignasi Barrera
+ * @param <T>
+ * The monitored object.
+ */
+public class BlockingEventHandler<T> extends AbstractEventHandler<T> {
+ /** The signal used to lock the thread. */
+ @VisibleForTesting
+ CountDownLatch completeSignal;
+
+ /**
+ * The objects being locked.
+ * <p>
+ * This class handles events in a thread safe way. Otherwise this collections
+ * should be synchronised.
+ */
+ protected List<T> lockedObjects;
+
+ public BlockingEventHandler(final T... lockedObjects) {
+ this(Logger.NULL, lockedObjects);
+ }
+
+ public BlockingEventHandler(final Logger logger, final T... lockedObjects) {
+ super();
+ checkArgument(checkNotNull(lockedObjects, "lockedObjects").length > 0, "must provide at least one object");
+ this.logger = checkNotNull(logger, "logger");
+ this.lockedObjects = Lists.newArrayList(lockedObjects);
+ this.logger.debug("created BlockingEventHandler locking %s objects", lockedObjects.length);
+ }
+
+ @Override
+ protected boolean handles(final MonitorEvent<T> event) {
+ logger.debug("checking if %s event on %s must be handled by %s", event.getType(), event.getTarget(), this);
+ boolean handles = lockedObjects.contains(event.getTarget());
+ logger.debug("%s event on %s must %sbe handled", event.getType(), event.getTarget(), handles ? "" : "not ");
+ return handles;
+ }
+
+ /**
+ * Handles the dispatched event in a thread safe way.
+ * <p>
+ * Due to <a
+ * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
+ * Issue 786</a> {@link #handle(MonitorEvent)} is marked <code>final</code>to
+ * avoid having duplicate events.
+ *
+ * @see {@link #doBeforeRelease(MonitorEvent)}
+ */
+ @Subscribe
+ public final void handle(final MonitorEvent<T> event) {
+ if (handles(event)) {
+ logger.debug("handling %s", event);
+
+ try {
+ doBeforeRelease(event);
+ } finally {
+ // Always release the lock, even if the handler code fails
+ release(event.getTarget());
+ }
+ }
+ }
+
+ /**
+ * Blocks the thread until all locked objects have been released.
+ */
+ public void lock() {
+ // When invoking the lock, it is possible that all events have
+ // already been consumed. If there are no objects to monitor,
+ // just ignore the lock.
+ if (!lockedObjects.isEmpty()) {
+ try {
+ completeSignal = new CountDownLatch(lockedObjects.size());
+ logger.debug("creating lock for %s object(s)", lockedObjects.size());
+ completeSignal.await();
+ } catch (InterruptedException ex) {
+ Throwables.propagate(ex);
+ }
+ } else {
+ logger.debug("there is nothing to watch. Ignoring lock.");
+ }
+ }
+
+ /**
+ * Releases the lock on the given object.
+ */
+ protected void release(final T target) {
+ logger.debug("releasing %s", target);
+ lockedObjects.remove(target);
+
+ // The completeSignal might be null if the events have been consumed
+ // before acquiring the lock
+ if (completeSignal != null) {
+ completeSignal.countDown();
+ logger.debug("releasing lock for %s. %s remaining objects", target, completeSignal.getCount());
+ }
+ }
+
+ /**
+ * Convenience method to bypass the <a
+ * href="http://code.google.com/p/guava-libraries/issues/detail?id=783">Guava
+ * Issue 786</a> that forces the subscriber method to be <code>final</code>.
+ */
+ protected void doBeforeRelease(final MonitorEvent<T> event) {
+ // Let subclasses may override it to customize behavior
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java
deleted file mode 100644
index c2b06a9..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import com.abiquo.model.transport.error.ErrorDto;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link ErrorDto} filters.
- *
- * @author Ignasi Barrera
- */
-public class ErrorPredicates {
- public static Predicate<ErrorDto> code(final String... codes) {
- checkNotNull(codes, "codes must be defined");
-
- return new Predicate<ErrorDto>() {
- @Override
- public boolean apply(final ErrorDto error) {
- return Arrays.asList(codes).contains(error.getCode());
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java
new file mode 100644
index 0000000..3a918f9
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/IpPredicates.java
@@ -0,0 +1,48 @@
+/*
+ * 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.predicates;
+
+import org.jclouds.abiquo.domain.network.AbstractPublicIp;
+import org.jclouds.abiquo.domain.network.Ip;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link Network} filters.
+ *
+ * @author Francesc Montserrat
+ */
+public class IpPredicates {
+
+ public static <T extends AbstractPublicIp<?, ?>> Predicate<T> available() {
+ return new Predicate<T>() {
+ @Override
+ public boolean apply(final T address) {
+ return address.isAvailable();
+ }
+ };
+ }
+
+ public static <T extends Ip<?, ?>> Predicate<T> notUsed() {
+ return new Predicate<T>() {
+ @Override
+ public boolean apply(final T address) {
+ return address.unwrap().searchLink("virtualmachine") == null;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
index cfcc818..524fcfe 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
@@ -18,8 +18,6 @@ package org.jclouds.abiquo.predicates;
import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Arrays;
-
import com.abiquo.model.rest.RESTLink;
import com.google.common.base.Predicate;
@@ -29,13 +27,12 @@ import com.google.common.base.Predicate;
* @author Ignasi Barrera
*/
public class LinkPredicates {
- public static Predicate<RESTLink> rel(final String... rels) {
- checkNotNull(rels, "rels must be defined");
-
+ public static Predicate<RESTLink> rel(final String rel) {
+ checkNotNull(rel, "rel must be defined");
return new Predicate<RESTLink>() {
@Override
public boolean apply(final RESTLink link) {
- return Arrays.asList(rels).contains(link.getRel());
+ return link.getRel().equals(rel);
}
};
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java
new file mode 100644
index 0000000..1e8b16e
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/NetworkServiceTypePredicates.java
@@ -0,0 +1,37 @@
+/*
+ * 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.predicates;
+
+import org.jclouds.abiquo.domain.network.NetworkServiceType;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link NetworkServiceType} filters.
+ *
+ * @author Jaume Devesa
+ */
+public class NetworkServiceTypePredicates {
+ public static Predicate<NetworkServiceType> isDefault() {
+ return new Predicate<NetworkServiceType>() {
+ @Override
+ public boolean apply(final NetworkServiceType ni) {
+ return ni.isDefaultNST();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java
new file mode 100644
index 0000000..ac71720
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualDatacenterPredicates.java
@@ -0,0 +1,81 @@
+/*
+ * 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.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.jclouds.abiquo.domain.cloud.Conversion;
+import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
+import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
+import org.jclouds.abiquo.domain.infrastructure.Datacenter;
+import org.jclouds.abiquo.reference.ValidationErrors;
+import org.jclouds.abiquo.reference.rest.ParentLinkName;
+
+import com.abiquo.model.enumerator.ConversionState;
+import com.abiquo.model.enumerator.HypervisorType;
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link VirtualDatacenter} filters.
+ *
+ * @author Ignasi Barrera
+ */
+public class VirtualDatacenterPredicates {
+
+ public static Predicate<VirtualDatacenter> datacenter(final Datacenter datacenter) {
+ checkNotNull(datacenter, "datacenter must be defined");
+
+ return new Predicate<VirtualDatacenter>() {
+ @Override
+ public boolean apply(final VirtualDatacenter virtualDatacenter) {
+ // Avoid using the getDatacenter() method since it will generate an
+ // unnecessary API
+ // call. We can get the ID from the datacenter link.
+ Integer datacenterId = checkNotNull(virtualDatacenter.unwrap().getIdFromLink(ParentLinkName.DATACENTER),
+ ValidationErrors.MISSING_REQUIRED_LINK);
+
+ return datacenterId.equals(datacenter.getId());
+ }
+ };
+ }
+
+ /**
+ * Check if the given template type is compatible with the given virtual
+ * datacenter type taking into account the conversions of the template.
+ *
+ * @param template
+ * The template to check.
+ * @return Predicate to check if the template or its conversions are
+ * compatibles with the given virtual datacenter.
+ */
+ public static Predicate<VirtualDatacenter> compatibleWithTemplateOrConversions(final VirtualMachineTemplate template) {
+ return new Predicate<VirtualDatacenter>() {
+ @Override
+ public boolean apply(final VirtualDatacenter vdc) {
+ HypervisorType type = vdc.getHypervisorType();
+ boolean compatible = type.isCompatible(template.getDiskFormatType());
+ if (!compatible) {
+ List<Conversion> compatibleConversions = template.listConversions(type, ConversionState.FINISHED);
+ compatible = compatibleConversions != null && !compatibleConversions.isEmpty();
+ }
+ return compatible;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java
new file mode 100644
index 0000000..445566e
--- /dev/null
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/VirtualMachineTemplatePredicates.java
@@ -0,0 +1,47 @@
+/*
+ * 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.predicates;
+
+import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Container for {@link VirtualMachineTemplate} filters.
+ *
+ * @author Francesc Montserrat
+ */
+public class VirtualMachineTemplatePredicates {
+
+ public static Predicate<VirtualMachineTemplate> isShared() {
+ return new Predicate<VirtualMachineTemplate>() {
+ @Override
+ public boolean apply(final VirtualMachineTemplate input) {
+ return input.unwrap().isShared();
+ }
+ };
+ }
+
+ public static Predicate<VirtualMachineTemplate> isInstance() {
+ return new Predicate<VirtualMachineTemplate>() {
+ @Override
+ public boolean apply(final VirtualMachineTemplate input) {
+ return input.unwrap().searchLink("master") != null;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java
deleted file mode 100644
index 777df74..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.predicates.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Arrays;
-
-import org.jclouds.abiquo.domain.cloud.Conversion;
-
-import com.abiquo.model.enumerator.ConversionState;
-import com.abiquo.model.enumerator.DiskFormatType;
-import com.abiquo.model.enumerator.HypervisorType;
-import com.google.common.base.Predicate;
-
-/**
- * Container for {@link VirtualMachineTemplate} filters.
- *
- * @author Francesc Montserrat
- */
-public class ConversionPredicates {
-
- public static Predicate<Conversion> sourceFormat(final DiskFormatType... formats) {
- checkNotNull(formats, "formats must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return Arrays.asList(formats).contains(conversion.getSourceFormat());
- }
- };
- }
-
- public static Predicate<Conversion> targetFormat(final DiskFormatType... formats) {
- checkNotNull(formats, "formats must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return Arrays.asList(formats).contains(conversion.getTargetFormat());
- }
- };
- }
-
- public static Predicate<Conversion> state(final ConversionState... states) {
- checkNotNull(states, "states must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return Arrays.asList(states).contains(conversion.getState());
- }
- };
- }
-
- public static Predicate<Conversion> compatible(final HypervisorType type) {
- checkNotNull(type, "type must be defined");
-
- return new Predicate<Conversion>() {
- @Override
- public boolean apply(final Conversion conversion) {
- return type.isCompatible(conversion.getTargetFormat());
- }
- };
- }
-
-}