Search in sources :

Example 1 with ResourceCountResponse

use of com.cloud.api.response.ResourceCountResponse in project CloudStack-archive by CloudStack-extras.

the class UpdateResourceCountCmd method execute.

@Override
public void execute() {
    List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(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(BaseCmd.INTERNAL_ERROR, "Failed to recalculate resource counts");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceCount(com.cloud.configuration.ResourceCount) ArrayList(java.util.ArrayList) ResourceCountResponse(com.cloud.api.response.ResourceCountResponse)

Aggregations

ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 ResourceCountResponse (com.cloud.api.response.ResourceCountResponse)1 ResourceCount (com.cloud.configuration.ResourceCount)1 ArrayList (java.util.ArrayList)1