Search in sources :

Example 1 with DomainResponse

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

the class ListDomainChildrenCmd method execute.

@Override
public void execute() {
    List<? extends Domain> result = _domainService.searchForDomainChildren(this);
    ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
    List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
    for (Domain domain : result) {
        DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
        domainResponse.setObjectName("domain");
        domainResponses.add(domainResponse);
    }
    response.setResponses(domainResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) DomainResponse(com.cloud.api.response.DomainResponse) ArrayList(java.util.ArrayList) Domain(com.cloud.domain.Domain)

Example 2 with DomainResponse

use of com.cloud.api.response.DomainResponse in project cosmic by MissionCriticalCloud.

the class ListDomainChildrenCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomainChildren(this);
    final ListResponse<DomainResponse> response = new ListResponse<>();
    final List<DomainResponse> domainResponses = new ArrayList<>();
    for (final Domain domain : result.first()) {
        final DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
        domainResponse.setObjectName("domain");
        domainResponses.add(domainResponse);
    }
    response.setResponses(domainResponses, result.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) DomainResponse(com.cloud.api.response.DomainResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Domain(com.cloud.domain.Domain)

Example 3 with DomainResponse

use of com.cloud.api.response.DomainResponse in project cosmic by MissionCriticalCloud.

the class UpdateDomainCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Domain Id: " + getId());
    final Domain domain = _regionService.updateDomain(this);
    if (domain != null) {
        final DomainResponse response = _responseGenerator.createDomainResponse(domain);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update domain");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainResponse(com.cloud.api.response.DomainResponse) Domain(com.cloud.domain.Domain)

Example 4 with DomainResponse

use of com.cloud.api.response.DomainResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createDomainResponse.

@Override
public DomainResponse createDomainResponse(final Domain domain) {
    final DomainResponse domainResponse = new DomainResponse();
    domainResponse.setDomainName(domain.getName());
    domainResponse.setId(domain.getUuid());
    domainResponse.setLevel(domain.getLevel());
    domainResponse.setNetworkDomain(domain.getNetworkDomain());
    domainResponse.setEmail(domain.getEmail());
    final Domain parentDomain = ApiDBUtils.findDomainById(domain.getParent());
    if (parentDomain != null) {
        domainResponse.setParentDomainId(parentDomain.getUuid());
    }
    final StringBuilder domainPath = new StringBuilder("ROOT");
    domainPath.append(domain.getPath()).deleteCharAt(domainPath.length() - 1);
    domainResponse.setPath(domainPath.toString());
    if (domain.getParent() != null) {
        domainResponse.setParentDomainName(ApiDBUtils.findDomainById(domain.getParent()).getName());
    }
    if (domain.getChildCount() > 0) {
        domainResponse.setHasChild(true);
    }
    domainResponse.setObjectName("domain");
    return domainResponse;
}
Also used : DomainResponse(com.cloud.api.response.DomainResponse) Domain(com.cloud.domain.Domain)

Example 5 with DomainResponse

use of com.cloud.api.response.DomainResponse in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForDomains.

@Override
public ListResponse<DomainResponse> searchForDomains(final ListDomainsCmd cmd) {
    final Pair<List<DomainJoinVO>, Integer> result = searchForDomainsInternal(cmd);
    final ListResponse<DomainResponse> response = new ListResponse<>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListDomainsCmdByAdmin) {
        respView = ResponseView.Full;
    }
    final List<DomainResponse> domainResponses = ViewResponseHelper.createDomainResponse(respView, result.first().toArray(new DomainJoinVO[result.first().size()]));
    response.setResponses(domainResponses, result.second());
    return response;
}
Also used : ResponseView(com.cloud.api.ResponseObject.ResponseView) ListResponse(com.cloud.api.response.ListResponse) ListDomainsCmdByAdmin(com.cloud.api.command.admin.domain.ListDomainsCmdByAdmin) DomainResponse(com.cloud.api.response.DomainResponse) ArrayList(java.util.ArrayList) List(java.util.List) DomainJoinVO(com.cloud.api.query.vo.DomainJoinVO)

Aggregations

DomainResponse (com.cloud.api.response.DomainResponse)10 Domain (com.cloud.domain.Domain)9 ServerApiException (com.cloud.api.ServerApiException)4 ListResponse (com.cloud.api.response.ListResponse)4 ArrayList (java.util.ArrayList)4 List (java.util.List)2 ResponseView (com.cloud.api.ResponseObject.ResponseView)1 ListDomainsCmdByAdmin (com.cloud.api.command.admin.domain.ListDomainsCmdByAdmin)1 DomainJoinVO (com.cloud.api.query.vo.DomainJoinVO)1