use of com.cloud.api.query.vo.ProjectAccountJoinVO 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);
}
use of com.cloud.api.query.vo.ProjectAccountJoinVO in project cloudstack by apache.
the class QueryManagerImpl method listProjectAccountsInternal.
public Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccountsInternal(ListProjectAccountsCmd cmd) {
long projectId = cmd.getProjectId();
String accountName = cmd.getAccountName();
String role = cmd.getRole();
Long startIndex = cmd.getStartIndex();
Long pageSizeVal = cmd.getPageSizeVal();
// long projectId, String accountName, String role, Long startIndex,
// Long pageSizeVal) {
Account caller = CallContext.current().getCallingAccount();
// check that the project exists
Project project = _projectDao.findById(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find the project id=" + projectId);
}
// project's account
if (!_accountMgr.isAdmin(caller.getId()) && _projectAccountDao.findByProjectIdAccountId(projectId, caller.getAccountId()) == null) {
throw new PermissionDeniedException("Account " + caller + " is not authorized to list users of the project id=" + projectId);
}
Filter searchFilter = new Filter(ProjectAccountJoinVO.class, "id", false, startIndex, pageSizeVal);
SearchBuilder<ProjectAccountJoinVO> sb = _projectAccountJoinDao.createSearchBuilder();
sb.and("accountRole", sb.entity().getAccountRole(), Op.EQ);
sb.and("projectId", sb.entity().getProjectId(), Op.EQ);
if (accountName != null) {
sb.and("accountName", sb.entity().getAccountName(), Op.EQ);
}
SearchCriteria<ProjectAccountJoinVO> sc = sb.create();
sc.setParameters("projectId", projectId);
if (role != null) {
sc.setParameters("accountRole", role);
}
if (accountName != null) {
sc.setParameters("accountName", accountName);
}
return _projectAccountJoinDao.searchAndCount(sc, searchFilter);
}
use of com.cloud.api.query.vo.ProjectAccountJoinVO 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;
}
Aggregations