Search in sources :

Example 1 with ProjectAccountResponse

use of org.apache.cloudstack.api.response.ProjectAccountResponse in project cloudstack by apache.

the class ApiResponseHelper method createProjectAccountResponse.

@Override
public ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount) {
    ProjectAccountJoinVO vProj = ApiDBUtils.newProjectAccountView(projectAccount);
    List<ProjectAccountResponse> listProjs = ViewResponseHelper.createProjectAccountResponse(vProj);
    assert listProjs != null && listProjs.size() == 1 : "There should be one project account returned";
    return listProjs.get(0);
}
Also used : ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse)

Example 2 with ProjectAccountResponse

use of org.apache.cloudstack.api.response.ProjectAccountResponse in project cloudstack by apache.

the class ViewResponseHelper method createProjectAccountResponse.

public static List<ProjectAccountResponse> createProjectAccountResponse(ProjectAccountJoinVO... projectAccounts) {
    List<ProjectAccountResponse> responseList = new ArrayList<ProjectAccountResponse>();
    for (ProjectAccountJoinVO proj : projectAccounts) {
        ProjectAccountResponse resp = ApiDBUtils.newProjectAccountResponse(proj);
        // update user list
        Account caller = CallContext.current().getCallingAccount();
        if (ApiDBUtils.isAdmin(caller)) {
            List<UserAccountJoinVO> users = ApiDBUtils.findUserViewByAccountId(proj.getAccountId());
            resp.setUsers(ViewResponseHelper.createUserResponse(users.toArray(new UserAccountJoinVO[users.size()])));
        }
        responseList.add(resp);
    }
    return responseList;
}
Also used : Account(com.cloud.user.Account) UserAccountJoinVO(com.cloud.api.query.vo.UserAccountJoinVO) ArrayList(java.util.ArrayList) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse)

Example 3 with ProjectAccountResponse

use of org.apache.cloudstack.api.response.ProjectAccountResponse in project cloudstack by apache.

the class ProjectAccountJoinDaoImpl method newProjectAccountResponse.

@Override
public ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj) {
    ProjectAccountResponse projectAccountResponse = new ProjectAccountResponse();
    projectAccountResponse.setProjectId(proj.getProjectUuid());
    projectAccountResponse.setProjectName(proj.getProjectName());
    projectAccountResponse.setAccountId(proj.getAccountUuid());
    projectAccountResponse.setAccountName(proj.getAccountName());
    projectAccountResponse.setAccountType(proj.getAccountType());
    projectAccountResponse.setRole(proj.getAccountRole().toString());
    projectAccountResponse.setDomainId(proj.getDomainUuid());
    projectAccountResponse.setDomainName(proj.getDomainName());
    projectAccountResponse.setObjectName("projectaccount");
    return projectAccountResponse;
}
Also used : ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse)

Aggregations

ProjectAccountResponse (org.apache.cloudstack.api.response.ProjectAccountResponse)3 ProjectAccountJoinVO (com.cloud.api.query.vo.ProjectAccountJoinVO)2 UserAccountJoinVO (com.cloud.api.query.vo.UserAccountJoinVO)1 Account (com.cloud.user.Account)1 ArrayList (java.util.ArrayList)1