return response;
}
@Override
public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering) {
VpcOfferingResponse response = new VpcOfferingResponse();
response.setId(offering.getId());
response.setName(offering.getName());
response.setDisplayText(offering.getDisplayText());
response.setIsDefault(offering.isDefault());
response.setState(offering.getState().name());
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
for (Service service : serviceProviderMap.keySet()) {
ServiceResponse svcRsp = new ServiceResponse();
// skip gateway service
if (service == Service.Gateway) {
continue;
}
svcRsp.setName(service.getName());
List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
for (Provider provider : serviceProviderMap.get(service)) {
if (provider != null) {
ProviderResponse providerRsp = new ProviderResponse();
providerRsp.setName(provider.getName());
providers.add(providerRsp);
}
}
svcRsp.setProviders(providers);
serviceResponses.add(svcRsp);
}
response.setServices(serviceResponses);
response.setObjectName("vpcoffering");
return response;
}