Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public interface QueryService {

ListResponse<UserResponse> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException;

ListResponse<UserResponse> searchForAllUsers(ListUsersCmd cmd);

ListResponse<EventResponse> searchForEvents(ListEventsCmd cmd);

ListResponse<ResourceTagResponse> listTags(ListTagsCmd cmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private String getListType() {
}

private boolean isACloudstackUser(final LdapUser ldapUser) {
final ListResponse<UserResponse> response = _queryService.searchForUsers(new ListUsersCmd());
final ListResponse<UserResponse> response = _queryService.searchForAllUsers(new ListUsersCmd());
final List<UserResponse> cloudstackUsers = response.getResponses();
if (cloudstackUsers != null && cloudstackUsers.size() != 0) {
for (final UserResponse cloudstackUser : response.getResponses()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class LdapListUsersCmdSpec extends spock.lang.Specification {
ListResponse<UserResponse> queryServiceResponse = new ListResponse<UserResponse>()
queryServiceResponse.setResponses(responses)

queryService.searchForUsers(_) >> queryServiceResponse
queryService.searchForAllUsers(_) >> queryServiceResponse

def ldapUser = new LdapUser("rmurphy", "rmurphy@cloudstack.org", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org", null, false, null)
def ldapListUsersCmd = new LdapListUsersCmd(ldapManager,queryService)
Expand All @@ -107,7 +107,7 @@ class LdapListUsersCmdSpec extends spock.lang.Specification {
def ldapManager = Mock(LdapManager)
def queryService = Mock(QueryService)

queryService.searchForUsers(_) >> new ListResponse<UserResponse>()
queryService.searchForAllUsers(_) >> new ListResponse<UserResponse>()

def ldapUser = new LdapUser("rmurphy", "rmurphy@cloudstack.org", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org", null, false, null)
def ldapListUsersCmd = new LdapListUsersCmd(ldapManager,queryService)
Expand Down
18 changes: 18 additions & 0 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,24 @@ public ListResponse<UserResponse> searchForUsers(ListUsersCmd cmd) throws Permis
return response;
}

@Override
public ListResponse<UserResponse> searchForAllUsers(ListUsersCmd cmd) {
Pair<List<UserAccountJoinVO>, Integer> result = null;
Account caller = CallContext.current().getCallingAccount();

Filter searchFilter = new Filter(UserAccountJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
SearchBuilder<UserAccountJoinVO> sb = _userAccountJoinDao.createSearchBuilder();
SearchCriteria<UserAccountJoinVO> sc = sb.create();

result = _userAccountJoinDao.searchAndCount(sc, searchFilter);
ListResponse<UserResponse> response = new ListResponse<UserResponse>();
List<UserResponse> userResponses =
ViewResponseHelper.createUserResponse(CallContext.current().getCallingAccount().getDomainId(),
result.first().toArray(new UserAccountJoinVO[result.first().size()]));
response.setResponses(userResponses, result.second());
return response;
}

private Pair<List<UserAccountJoinVO>, Integer> searchForUsersInternal(ListUsersCmd cmd) throws PermissionDeniedException {
Account caller = CallContext.current().getCallingAccount();

Expand Down