Search in sources :

Example 1 with UserSearchResult

use of io.apiman.manager.api.beans.search.searchResults.UserSearchResult in project apiman by apiman.

the class SearchResourceImpl method searchUsers.

/**
 * @see io.apiman.manager.api.rest.ISearchResource#searchUsers(io.apiman.manager.api.beans.search.SearchCriteriaBean)
 */
@Override
public SearchResultsBean<UserSearchResult> searchUsers(SearchCriteriaBean criteria) throws InvalidSearchCriteriaException {
    List<UserSearchResult> users = new ArrayList<>();
    try {
        // Maybe this should be a new query in the future?
        List<UserBean> userBeans = query.findUsers(criteria).getBeans();
        for (UserBean user : userBeans) {
            users.add(new UserSearchResult(user.getUsername(), user.getFullName()));
        }
        SearchResultsBean<UserSearchResult> searchResultsBean = new SearchResultsBean<>();
        searchResultsBean.setBeans(users);
        searchResultsBean.setTotalSize(users.size());
        return searchResultsBean;
    } catch (StorageException e) {
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) UserBean(io.apiman.manager.api.beans.idm.UserBean) UserSearchResult(io.apiman.manager.api.beans.search.searchResults.UserSearchResult) ArrayList(java.util.ArrayList) StorageException(io.apiman.manager.api.core.exceptions.StorageException)

Aggregations

UserBean (io.apiman.manager.api.beans.idm.UserBean)1 UserSearchResult (io.apiman.manager.api.beans.search.searchResults.UserSearchResult)1 StorageException (io.apiman.manager.api.core.exceptions.StorageException)1 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)1 ArrayList (java.util.ArrayList)1