use of org.apache.cloudstack.api.response.ResourceCountResponse in project cloudstack by apache.
the class ApiResponseHelper method createResourceCountResponse.
@Override
public ResourceCountResponse createResourceCountResponse(ResourceCount resourceCount) {
ResourceCountResponse resourceCountResponse = new ResourceCountResponse();
if (resourceCount.getResourceOwnerType() == ResourceOwnerType.Account) {
Account accountTemp = ApiDBUtils.findAccountById(resourceCount.getOwnerId());
if (accountTemp != null) {
populateAccount(resourceCountResponse, accountTemp.getId());
populateDomain(resourceCountResponse, accountTemp.getDomainId());
}
} else if (resourceCount.getResourceOwnerType() == ResourceOwnerType.Domain) {
populateDomain(resourceCountResponse, resourceCount.getOwnerId());
}
resourceCountResponse.setResourceType(Integer.toString(resourceCount.getType().getOrdinal()));
resourceCountResponse.setResourceCount(resourceCount.getCount());
resourceCountResponse.setObjectName("resourcecount");
return resourceCountResponse;
}
use of org.apache.cloudstack.api.response.ResourceCountResponse in project cloudstack by apache.
the class UpdateResourceCountCmd method execute.
@Override
public void execute() {
List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
if ((result != null) && (result.size() > 0)) {
ListResponse<ResourceCountResponse> response = new ListResponse<ResourceCountResponse>();
List<ResourceCountResponse> countResponses = new ArrayList<ResourceCountResponse>();
for (ResourceCount count : result) {
ResourceCountResponse resourceCountResponse = _responseGenerator.createResourceCountResponse(count);
resourceCountResponse.setObjectName("resourcecount");
countResponses.add(resourceCountResponse);
}
response.setResponses(countResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to recalculate resource counts");
}
}
Aggregations