diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java index a6648d171e..b73e35e9f2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java @@ -19,8 +19,6 @@ package org.jclouds.abiquo.features.services; -import java.util.List; - import org.jclouds.abiquo.domain.config.Category; import org.jclouds.abiquo.domain.config.License; import org.jclouds.abiquo.domain.config.Privilege; @@ -67,11 +65,6 @@ public interface AdministrationService { */ Datacenter getDatacenter(final Integer datacenterId); - /** - * Get the list of datacenters with the given ids. - */ - Iterable getDatacenters(final List datacenterIds); - /*********************** Machine ***********************/ /** @@ -160,6 +153,15 @@ public interface AdministrationService { */ Privilege findPrivilege(final Predicate filter); + /** + * Get a privilege given its id. + * + * @param privilegeId + * The id of the privilege. + * @return The privilege. + */ + Privilege getPrivilege(Integer privilegeId); + /*********************** User ***********************/ /** @@ -245,4 +247,13 @@ public interface AdministrationService { * null if none is found. */ Category findCategory(final Predicate filter); + + /** + * Get the category identified by the given id. + * + * @param categoryId + * The id of the category. + * @return The requested category. + */ + Category getCategory(Integer categoryId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java index dd26afdb3e..dc55123306 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java @@ -59,6 +59,15 @@ public interface PricingService { */ Currency findCurrency(final Predicate 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 ***********************/ /** @@ -77,37 +86,55 @@ public interface PricingService { */ CostCode findCostCode(final Predicate 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. */ - public Iterable listPricingTemplates(); + Iterable listPricingTemplates(); /** * Get the list of pricingtemplates matching the given filter. */ - public Iterable listPricingTemplates(final Predicate filter); + Iterable listPricingTemplates(final Predicate filter); /** * Get the first pricingtemplates that matches the given filter or * null if none is found. */ - public PricingTemplate findPricingTemplate(final Predicate filter); + PricingTemplate findPricingTemplate(final Predicate 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 */ - public Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); + Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); /*********************** PricingCostCode ***********************/ /** * Get pricing cost codes */ - public Collection getPricingCostCodes(Integer pricingTemplateId); + Collection getPricingCostCodes(Integer pricingTemplateId); /** * Get a pricing cost code diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java index 25aacb8f2a..458a091fe2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java @@ -20,15 +20,15 @@ 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.List; - import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.domain.config.Category; import org.jclouds.abiquo.domain.config.License; import org.jclouds.abiquo.domain.config.Privilege; @@ -43,21 +43,23 @@ 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.admin.ListRoles; -import org.jclouds.abiquo.strategy.config.ListCategories; -import org.jclouds.abiquo.strategy.config.ListLicenses; -import org.jclouds.abiquo.strategy.config.ListPrivileges; -import org.jclouds.abiquo.strategy.config.ListProperties; -import org.jclouds.abiquo.strategy.enterprise.ListEnterprises; -import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters; import org.jclouds.abiquo.strategy.infrastructure.ListMachines; import org.jclouds.collect.Memoized; import org.jclouds.rest.RestContext; +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.Predicate; import com.google.common.base.Supplier; @@ -74,30 +76,9 @@ public class BaseAdministrationService implements AdministrationService { @VisibleForTesting protected RestContext context; - @VisibleForTesting - protected final ListDatacenters listDatacenters; - @VisibleForTesting protected final ListMachines listMachines; - @VisibleForTesting - protected final ListEnterprises listEnterprises; - - @VisibleForTesting - protected final ListRoles listRoles; - - @VisibleForTesting - protected final ListLicenses listLicenses; - - @VisibleForTesting - protected final ListPrivileges listPrivileges; - - @VisibleForTesting - protected final ListProperties listProperties; - - @VisibleForTesting - protected final ListCategories listCategories; - @VisibleForTesting protected final Supplier currentUser; @@ -106,19 +87,10 @@ public class BaseAdministrationService implements AdministrationService { @Inject protected BaseAdministrationService(final RestContext context, - final ListDatacenters listDatacenters, final ListMachines listMachines, final ListEnterprises listEnterprises, - final ListRoles listRoles, final ListLicenses listLicenses, final ListPrivileges listPrivileges, - final ListProperties listProperties, final ListCategories listCategories, - @Memoized final Supplier currentUser, @Memoized final Supplier currentEnterprise) { + final ListMachines listMachines, @Memoized final Supplier currentUser, + @Memoized final Supplier currentEnterprise) { this.context = checkNotNull(context, "context"); - this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); this.listMachines = checkNotNull(listMachines, "listMachines"); - this.listEnterprises = checkNotNull(listEnterprises, "listEnterprises"); - this.listRoles = checkNotNull(listRoles, "listRoles"); - this.listLicenses = checkNotNull(listLicenses, "listLicenses"); - this.listPrivileges = checkNotNull(listPrivileges, "listPrivileges"); - this.listProperties = checkNotNull(listProperties, "listProperties"); - this.listCategories = checkNotNull(listCategories, "listCategories"); this.currentUser = checkNotNull(currentUser, "currentUser"); this.currentEnterprise = checkNotNull(currentEnterprise, "currentEnterprise"); } @@ -127,12 +99,18 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listDatacenters() { - return listDatacenters.execute(); + DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); + return wrap(context, Datacenter.class, result.getCollection()); } @Override public Iterable listDatacenters(final Predicate filter) { - return listDatacenters.execute(filter); + return filter(listDatacenters(), filter); + } + + @Override + public Datacenter findDatacenter(final Predicate filter) { + return getFirst(listDatacenters(filter), null); } @Override @@ -141,16 +119,6 @@ public class BaseAdministrationService implements AdministrationService { return wrap(context, Datacenter.class, datacenter); } - @Override - public Datacenter findDatacenter(final Predicate filter) { - return Iterables.getFirst(listDatacenters(filter), null); - } - - @Override - public Iterable getDatacenters(final List datacenterIds) { - return listDatacenters.execute(datacenterIds); - } - /*********************** Machine ***********************/ @Override @@ -172,12 +140,13 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listEnterprises() { - return listEnterprises.execute(); + EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); + return wrap(context, Enterprise.class, result.getCollection()); } @Override public Iterable listEnterprises(final Predicate filter) { - return listEnterprises.execute(filter); + return filter(listEnterprises(), filter); } @Override @@ -206,17 +175,18 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listRoles() { - return listRoles.execute(); + RolesDto result = context.getApi().getAdminApi().listRoles(); + return wrap(context, Role.class, result.getCollection()); } @Override public Iterable listRoles(final Predicate filter) { - return listRoles.execute(filter); + return filter(listRoles(), filter); } @Override public Role findRole(final Predicate filter) { - return Iterables.getFirst(listRoles(filter), null); + return getFirst(listRoles(filter), null); } @Override @@ -227,19 +197,26 @@ public class BaseAdministrationService implements AdministrationService { /*********************** Privilege ***********************/ - @Override - public Privilege findPrivilege(final Predicate filter) { - return Iterables.getFirst(listPrivileges(filter), null); - } - @Override public Iterable listPrivileges() { - return listPrivileges.execute(); + PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); + return wrap(context, Privilege.class, result.getCollection()); } @Override public Iterable listPrivileges(final Predicate filter) { - return listPrivileges.execute(filter); + return filter(listPrivileges(), filter); + } + + @Override + public Privilege findPrivilege(final Predicate 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); } /*********************** User ***********************/ @@ -258,52 +235,68 @@ public class BaseAdministrationService implements AdministrationService { @Override public Iterable listLicenses() { - return listLicenses.execute(); + LicensesDto result = context.getApi().getConfigApi().listLicenses(); + return wrap(context, License.class, result.getCollection()); } @Override public Iterable listLicenses(final boolean active) { LicenseOptions options = LicenseOptions.builder().active(active).build(); - return listLicenses.execute(options); + LicensesDto result = context.getApi().getConfigApi().listLicenses(options); + return wrap(context, License.class, result.getCollection()); } @Override public Iterable listLicenses(final Predicate filter) { - return listLicenses.execute(filter); + return filter(listLicenses(), filter); } @Override public License findLicense(final Predicate filter) { - return Iterables.getFirst(listLicenses(filter), null); + return getFirst(listLicenses(filter), null); } /*********************** System Properties ***********************/ @Override public Iterable listSystemProperties() { - return listProperties.execute(); + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); + return wrap(context, SystemProperty.class, result.getCollection()); } @Override public Iterable listSystemProperties(final Predicate filter) { - return listProperties.execute(filter); + return filter(listSystemProperties(), filter); } @Override public SystemProperty findSystemProperty(final Predicate filter) { - return Iterables.getFirst(listSystemProperties(filter), null); + return getFirst(listSystemProperties(filter), null); } @Override public SystemProperty getSystemProperty(final String name) { PropertyOptions options = PropertyOptions.builder().name(name).build(); - return Iterables.getFirst(listProperties.execute(options), null); + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); + return getFirst(wrap(context, SystemProperty.class, result.getCollection()), null); } @Override public Iterable listSystemProperties(final String component) { PropertyOptions options = PropertyOptions.builder().component(component).build(); - return listProperties.execute(options); + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); + return wrap(context, SystemProperty.class, result.getCollection()); + } + + @Override + public Iterable listCategories() { + CategoriesDto result = context.getApi().getConfigApi().listCategories(); + return wrap(context, Category.class, result.getCollection()); + } + + @Override + public Iterable listCategories(final Predicate filter) { + return filter(listCategories(), filter); } @Override @@ -312,12 +305,8 @@ public class BaseAdministrationService implements AdministrationService { } @Override - public Iterable listCategories() { - return listCategories.execute(); - } - - @Override - public Iterable listCategories(final Predicate filter) { - return listCategories.execute(filter); + public Category getCategory(Integer categoryId) { + CategoryDto result = context.getApi().getConfigApi().getCategory(categoryId); + return wrap(context, Category.class, result); } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java index 960065d16a..e3c5c994bc 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java @@ -20,18 +20,19 @@ 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.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; 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.abiquo.strategy.event.ListEvents; import org.jclouds.rest.RestContext; +import com.abiquo.server.core.event.EventsDto; import com.google.common.annotations.VisibleForTesting; /** @@ -45,22 +46,20 @@ public class BaseEventService implements EventService { @VisibleForTesting protected RestContext context; - @VisibleForTesting - protected final ListEvents listEvents; - @Inject - protected BaseEventService(final RestContext context, final ListEvents listEvents) { + protected BaseEventService(final RestContext context) { this.context = checkNotNull(context, "context"); - this.listEvents = checkNotNull(listEvents, "listEvents"); } @Override public Iterable listEvents() { - return listEvents.execute(); + EventsDto result = context.getApi().getEventApi().listEvents(); + return wrap(context, Event.class, result.getCollection()); } @Override public Iterable listEvents(final EventOptions options) { - return listEvents.execute(options); + EventsDto result = context.getApi().getEventApi().listEvents(options); + return wrap(context, Event.class, result.getCollection()); } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java index 1fc2c9aebc..27083cfefa 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java @@ -20,6 +20,8 @@ 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; @@ -36,14 +38,17 @@ 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.abiquo.strategy.config.ListCostCodes; -import org.jclouds.abiquo.strategy.config.ListCurrencies; -import org.jclouds.abiquo.strategy.config.ListPricingTemplates; import org.jclouds.rest.RestContext; 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; @@ -51,7 +56,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; /** - * Provides high level Abiquo administration operations. + * Provides access to Abiquo pricing features. * * @author Ignasi Barrera * @author Susana Acedo @@ -61,52 +66,46 @@ public class BasePricingService implements PricingService { @VisibleForTesting protected RestContext context; - @VisibleForTesting - protected final ListCurrencies listCurrencies; - - @VisibleForTesting - protected final ListCostCodes listCostCodes; - - @VisibleForTesting - protected final ListPricingTemplates listPricingTemplates; - @Inject - protected BasePricingService(final RestContext context, - final ListCurrencies listCurrencies, final ListCostCodes listCostCodes, - final ListPricingTemplates listPricingTemplates) { + protected BasePricingService(final RestContext context) { this.context = checkNotNull(context, "context"); - this.listCurrencies = checkNotNull(listCurrencies, "listCurrencies"); - this.listCostCodes = checkNotNull(listCostCodes, "listCostCodes"); - this.listPricingTemplates = checkNotNull(listPricingTemplates, "listPricingTemplates"); } /*********************** Currency ********************** */ @Override public Iterable listCurrencies() { - return listCurrencies.execute(); + CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); + return wrap(context, Currency.class, result.getCollection()); } @Override public Iterable listCurrencies(final Predicate filter) { - return listCurrencies.execute(filter); + return filter(listCurrencies(), filter); } @Override public Currency findCurrency(final Predicate filter) { - return Iterables.getFirst(listCurrencies(filter), null); + 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 listCostCodes() { - return listCostCodes.execute(); + CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); + return wrap(context, CostCode.class, result.getCollection()); } @Override public Iterable listCostCodes(final Predicate filter) { - return listCostCodes.execute(filter); + return filter(listCostCodes(), filter); } @Override @@ -114,21 +113,34 @@ public class BasePricingService implements PricingService { 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 listPricingTemplates() { - return listPricingTemplates.execute(); + PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); + return wrap(context, PricingTemplate.class, result.getCollection()); } @Override public Iterable listPricingTemplates(final Predicate filter) { - return listPricingTemplates.execute(filter); + return filter(listPricingTemplates(), filter); } @Override public PricingTemplate findPricingTemplate(final Predicate filter) { - return Iterables.getFirst(listPricingTemplates(filter), null); + 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 ********************** */ diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java deleted file mode 100644 index 3ff98c1c7a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.admin; - -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.admin.internal.ListRolesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List roles. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListRolesImpl.class) -public interface ListRoles extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java deleted file mode 100644 index 0e6d5f0bf4..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.admin.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.strategy.admin.ListRoles; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.RolesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List enterprises. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListRolesImpl implements ListRoles { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListRolesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - RolesDto result = context.getApi().getAdminApi().listRoles(); - return wrap(context, Role.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java deleted file mode 100644 index 61314cdbba..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListCategoriesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List privileges. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListCategoriesImpl.class) -public interface ListCategories extends ListRootEntities { -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java deleted file mode 100644 index 8a4ff4aa8a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListCostCodesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List cost codes - * - * @author Susana Acedo - */ -@ImplementedBy(ListCostCodesImpl.class) -public interface ListCostCodes extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java deleted file mode 100644 index 2b4ce779ab..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListCurrenciesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List currencies - * - * @author Susana Acedo - */ -@ImplementedBy(ListCurrenciesImpl.class) -public interface ListCurrencies extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java deleted file mode 100644 index 027e2e788c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListLicensesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List licenses. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListLicensesImpl.class) -public interface ListLicenses extends ListRootEntities { - public Iterable execute(LicenseOptions options); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java deleted file mode 100644 index 87c0eb4f36..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.PricingTemplate; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListPricingTemplatesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List pricing templates - * - * @author Susana Acedo - */ -@ImplementedBy(ListPricingTemplatesImpl.class) -public interface ListPricingTemplates extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java deleted file mode 100644 index 874d860c98..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListPrivilegesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List privileges. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListPrivilegesImpl.class) -public interface ListPrivileges extends ListRootEntities { -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java deleted file mode 100644 index fa54a9deb9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config; - -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.config.internal.ListPropertiesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List system properties. - * - * @author Francesc Montserrat - */ -@ImplementedBy(ListPropertiesImpl.class) -public interface ListProperties extends ListRootEntities { - public Iterable execute(PropertyOptions options); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java deleted file mode 100644 index 8fc5ed3bed..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.strategy.config.ListCategories; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.appslibrary.CategoriesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List categories. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListCategoriesImpl implements ListCategories { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListCategoriesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - CategoriesDto result = context.getApi().getConfigApi().listCategories(); - return wrap(context, Category.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java deleted file mode 100644 index 2187ce1838..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.strategy.config.ListCostCodes; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CostCodesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List cost codes - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class ListCostCodesImpl implements ListCostCodes { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListCostCodesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); - return wrap(context, CostCode.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java deleted file mode 100644 index 9ac1380f57..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.strategy.config.ListCurrencies; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CurrenciesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List currencies - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class ListCurrenciesImpl implements ListCurrencies { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListCurrenciesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); - return wrap(context, Currency.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java deleted file mode 100644 index ab28472b06..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.strategy.config.ListLicenses; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.config.LicensesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List licenses. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListLicensesImpl implements ListLicenses { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListLicensesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - LicensesDto result = context.getApi().getConfigApi().listLicenses(); - return wrap(context, License.class, result.getCollection()); - } - - @Override - public Iterable execute(final LicenseOptions options) { - LicensesDto result = context.getApi().getConfigApi().listLicenses(options); - return wrap(context, License.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java deleted file mode 100644 index 8d9ac4045e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.PricingTemplate; -import org.jclouds.abiquo.strategy.config.ListPricingTemplates; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.PricingTemplatesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List pricing templates - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class ListPricingTemplatesImpl implements ListPricingTemplates { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListPricingTemplatesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); - return wrap(context, PricingTemplate.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java deleted file mode 100644 index 6a16511abf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.strategy.config.ListPrivileges; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List licenses. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListPrivilegesImpl implements ListPrivileges { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListPrivilegesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); - return wrap(context, Privilege.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java deleted file mode 100644 index 07eaab416b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.strategy.config.ListProperties; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.config.SystemPropertiesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List properties. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListPropertiesImpl implements ListProperties { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListPropertiesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); - return wrap(context, SystemProperty.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - @Override - public Iterable execute(final PropertyOptions options) { - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); - return wrap(context, SystemProperty.class, result.getCollection()); - } -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java deleted file mode 100644 index 1e0ba94eb6..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.enterprise; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.enterprise.internal.ListEnterprisesImpl; - -import com.google.inject.ImplementedBy; - -/** - * List enterprises. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListEnterprisesImpl.class) -public interface ListEnterprises extends ListRootEntities { - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java deleted file mode 100644 index ee401b4e0e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.enterprise.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.strategy.enterprise.ListEnterprises; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.EnterprisesDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * List enterprises. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListEnterprisesImpl implements ListEnterprises { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListEnterprisesImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); - return wrap(context, Enterprise.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java deleted file mode 100644 index 083991599d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.event; - -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.event.internal.ListEventsImpl; - -import com.google.inject.ImplementedBy; - -/** - * List events. - * - * @author Vivien Mahé - */ -@ImplementedBy(ListEventsImpl.class) -public interface ListEvents extends ListRootEntities { - Iterable execute(EventOptions options); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java deleted file mode 100644 index ed1da35236..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.event.internal; - -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.strategy.event.ListEvents; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.event.EventsDto; -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -public class ListEventsImpl implements ListEvents { - // This strategy does not have still an Executor instance because the current - // methods call - // single api methods - - protected final RestContext context; - - @Inject - ListEventsImpl(final RestContext context) { - this.context = context; - } - - @Override - public Iterable execute() { - EventsDto result = context.getApi().getEventApi().listEvents(); - return wrap(context, Event.class, result.getCollection()); - } - - @Override - public Iterable execute(final EventOptions options) { - EventsDto result = context.getApi().getEventApi().listEvents(options); - return wrap(context, Event.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java deleted file mode 100644 index 99a67bfaaa..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.infrastructure; - -import java.util.List; - -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.abiquo.strategy.infrastructure.internal.ListDatacentersImpl; - -import com.google.inject.ImplementedBy; - -/** - * List datacenters. - * - * @author Ignasi Barrera - */ -@ImplementedBy(ListDatacentersImpl.class) -public interface ListDatacenters extends ListRootEntities { - Iterable execute(List datacenterIds); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java deleted file mode 100644 index fad587620f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.infrastructure.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; -import com.google.inject.Inject; - -/** - * List datacenters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class ListDatacentersImpl implements ListDatacenters { - - protected final RestContext context; - - protected final ExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListDatacentersImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { - this.context = context; - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); - return wrap(context, Datacenter.class, result.getCollection()); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - @Override - public Iterable execute(final List datacenterIds) { - // Find virtual datacenters in concurrent requests - return listConcurrentDatacenters(datacenterIds); - } - - private Iterable listConcurrentDatacenters(final List ids) { - Iterable dcs = transformParallel(ids, new Function>() { - @Override - public Future apply(final Integer input) { - return context.getAsyncApi().getInfrastructureApi().getDatacenter(input); - } - }, userExecutor, maxTime, logger, "getting datacenters"); - - return DomainWrapper.wrap(context, Datacenter.class, Lists.newArrayList(dcs)); - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java index 326d5febb4..c14f79f5f9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java @@ -32,16 +32,16 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; +import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.domain.DomainWrapper; import org.jclouds.abiquo.domain.infrastructure.Datacenter; import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters; import org.jclouds.abiquo.strategy.infrastructure.ListMachines; import org.jclouds.logging.Logger; import org.jclouds.rest.RestContext; +import com.abiquo.server.core.infrastructure.DatacentersDto; import com.abiquo.server.core.infrastructure.MachineDto; import com.abiquo.server.core.infrastructure.MachinesDto; import com.abiquo.server.core.infrastructure.RackDto; @@ -59,8 +59,6 @@ import com.google.inject.Inject; public class ListMachinesImpl implements ListMachines { protected RestContext context; - protected ListDatacenters listDatacenters; - protected final ExecutorService userExecutor; @Resource @@ -72,18 +70,17 @@ public class ListMachinesImpl implements ListMachines { @Inject ListMachinesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListDatacenters listDatacenters) { + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { super(); this.context = checkNotNull(context, "context"); - this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); this.userExecutor = checkNotNull(userExecutor, "userExecutor"); } @Override public Iterable execute() { // Find machines in concurrent requests - Iterable datacenters = listDatacenters.execute(); + DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); + Iterable datacenters = wrap(context, Datacenter.class, result.getCollection()); Iterable racks = listConcurrentRacks(datacenters); Iterable machines = listConcurrentMachines(racks); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java index 4a2b2122bc..05e5f47744 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java @@ -36,12 +36,7 @@ public class BaseAdministrationServiceTest extends BaseInjectionTest { BaseAdministrationService service = (BaseAdministrationService) injector.getInstance(AdministrationService.class); assertNotNull(service.context); - assertNotNull(service.listDatacenters); assertNotNull(service.listMachines); - assertNotNull(service.listEnterprises); - assertNotNull(service.listLicenses); - assertNotNull(service.listPrivileges); - assertNotNull(service.listRoles); assertNotNull(service.currentUser); assertNotNull(service.currentEnterprise); } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java index 137c88194b..ea3cb9489c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java @@ -35,6 +35,5 @@ public class BaseEventServiceTest extends BaseInjectionTest { BaseEventService service = (BaseEventService) injector.getInstance(EventService.class); assertNotNull(service.context); - assertNotNull(service.listEvents); } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java deleted file mode 100644 index 5e6aabbb1e..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.admin.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.predicates.enterprise.RolePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListRolesImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListRolesImplLiveApiTest") -public class ListRolesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListRolesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListRolesImpl.class); - } - - public void testExecute() { - Iterable roles = strategy.execute(); - assertNotNull(roles); - assertTrue(size(roles) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable roles = strategy.execute(RolePredicates.name("UNEXISTING")); - assertNotNull(roles); - assertEquals(size(roles), 0); - } - - public void testExecutePredicateWithResults() { - Iterable roles = strategy.execute(RolePredicates.name(env.role.getName())); - assertNotNull(roles); - assertEquals(size(roles), 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java deleted file mode 100644 index de62bb849f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.predicates.config.CategoryPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; - -/** - * Live tests for the {@link ListPropertiesImpl} strategy. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "ListCategoriesImplLiveApiTest") -public class ListCategoriesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListCategoriesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListCategoriesImpl.class); - } - - public void testExecute() { - Iterable categories = strategy.execute(); - assertNotNull(categories); - assertTrue(size(categories) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable categories = strategy.execute(CategoryPredicates.name("Unexisting category")); - assertNotNull(categories); - assertEquals(size(categories), 0); - } - - public void testExecutePredicateWithResults() { - Iterable categories = strategy.execute(CategoryPredicates.name("Applications servers")); - assertNotNull(categories); - assertEquals(size(categories), 1); - } - - public void testExecuteNotPredicateWithResults() { - Iterable categories = strategy.execute(Predicates.not(CategoryPredicates.name("Applications servers"))); - - Iterable allProperties = strategy.execute(); - - assertNotNull(categories); - assertNotNull(allProperties); - assertEquals(size(categories), size(allProperties) - 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java deleted file mode 100644 index d9776c52f8..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.predicates.config.LicensePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListLicenseImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListLicensesImplLiveApiTest") -public class ListLicensesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListLicensesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListLicensesImpl.class); - } - - public void testExecute() { - Iterable licenses = strategy.execute(); - assertNotNull(licenses); - assertTrue(size(licenses) > 0); - } - - public void testExecuteInactive() { - LicenseOptions options = LicenseOptions.builder().inactive(true).build(); - - Iterable licenses = strategy.execute(options); - assertNotNull(licenses); - assertTrue(size(licenses) == 1); - } - - public void testExecuteActive() { - LicenseOptions options = LicenseOptions.builder().active(true).build(); - - Iterable licenses = strategy.execute(options); - assertNotNull(licenses); - assertTrue(size(licenses) >= 1); - } - - public void testExecutePredicateWithoutResults() { - Iterable licenses = strategy.execute(LicensePredicates.customer("FAIL")); - assertNotNull(licenses); - assertEquals(size(licenses), 0); - } - - public void testExecutePredicateWithResults() { - Iterable licenses = strategy.execute(LicensePredicates.code(env.license.getCode())); - assertNotNull(licenses); - assertEquals(size(licenses), 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java deleted file mode 100644 index eea2ebc953..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.predicates.config.PrivilegePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; - -/** - * Live tests for the {@link ListPrivilegesImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListPrivilegesImplLiveApiTest") -public class ListPrivilegesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListPrivilegesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListPrivilegesImpl.class); - } - - public void testExecute() { - Iterable privileges = strategy.execute(); - assertNotNull(privileges); - assertTrue(size(privileges) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable privileges = strategy.execute(PrivilegePredicates.name("Destroy the universe")); - assertNotNull(privileges); - assertEquals(size(privileges), 0); - } - - public void testExecutePredicateWithResults() { - Iterable privileges = strategy.execute(PrivilegePredicates.name("USERS_MANAGE_USERS")); - assertNotNull(privileges); - assertEquals(size(privileges), 1); - } - - public void testExecuteNotPredicateWithResults() { - Iterable privileges = strategy.execute(Predicates.not(PrivilegePredicates.name("USERS_MANAGE_USERS"))); - - Iterable allPrivileges = strategy.execute(); - - assertNotNull(privileges); - assertNotNull(allPrivileges); - assertEquals(size(privileges), size(allPrivileges) - 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java deleted file mode 100644 index 28e747e5e3..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.config.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.predicates.config.SystemPropertyPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; - -/** - * Live tests for the {@link ListPropertiesImpl} strategy. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "ListPropertiesImplLiveApiTest") -public class ListPropertiesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListPropertiesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListPropertiesImpl.class); - } - - public void testExecute() { - Iterable properties = strategy.execute(); - assertNotNull(properties); - assertTrue(size(properties) > 0); - } - - public void testExecuteWithOptions() { - PropertyOptions options = PropertyOptions.builder().component("client").build(); - - Iterable properties = strategy.execute(options); - assertNotNull(properties); - assertTrue(size(properties) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable properties = strategy.execute(SystemPropertyPredicates.name("Cloud color")); - assertNotNull(properties); - assertEquals(size(properties), 0); - } - - public void testExecutePredicateWithResults() { - Iterable properties = strategy.execute(SystemPropertyPredicates - .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval")); - assertNotNull(properties); - assertEquals(size(properties), 1); - } - - public void testExecuteNotPredicateWithResults() { - Iterable properties = strategy.execute(Predicates.not(SystemPropertyPredicates - .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval"))); - - Iterable allProperties = strategy.execute(); - - assertNotNull(properties); - assertNotNull(allProperties); - assertEquals(size(properties), size(allProperties) - 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java deleted file mode 100644 index 13f1167e2d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.enterprise.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.predicates.enterprise.EnterprisePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListEnterprisesImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListEnterprisesImplLiveApiTest") -public class ListEnterprisesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListEnterprisesImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListEnterprisesImpl.class); - } - - public void testExecute() { - Iterable enterprises = strategy.execute(); - assertNotNull(enterprises); - assertTrue(size(enterprises) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable enterprises = strategy.execute(EnterprisePredicates.name("UNEXISTING")); - assertNotNull(enterprises); - assertEquals(size(enterprises), 0); - } - - public void testExecutePredicateWithResults() { - Iterable enterprises = strategy.execute(EnterprisePredicates.name(env.enterprise.getName())); - assertNotNull(enterprises); - assertEquals(size(enterprises), 1); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java deleted file mode 100644 index 391c46c857..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.strategy.infrastructure.internal; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.predicates.infrastructure.DatacenterPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListDatacentersImpl} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListDatacentersImplLiveApiTest") -public class ListDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListDatacentersImpl strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListDatacentersImpl.class); - } - - public void testExecute() { - Iterable datacenters = strategy.execute(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 0); - } - - public void testExecutePredicateWithoutResults() { - Iterable datacenters = strategy.execute(DatacenterPredicates.name("UNEXISTING")); - assertNotNull(datacenters); - assertEquals(size(datacenters), 0); - } - - public void testExecutePredicateWithResults() { - Iterable datacenters = strategy.execute(DatacenterPredicates.name(env.datacenter.getName())); - assertNotNull(datacenters); - assertEquals(size(datacenters), 1); - } -}