Search in sources :

Example 1 with UserQuery

use of org.eclipse.kapua.service.user.UserQuery in project kapua by eclipse.

the class GwtUserServiceImpl method findAll.

public ListLoadResult<GwtUser> findAll(String scopeIdString) throws GwtKapuaException {
    KapuaId scopeId = KapuaEid.parseShortId(scopeIdString);
    List<GwtUser> gwtUserList = new ArrayList<GwtUser>();
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        UserService userService = locator.getService(UserService.class);
        UserFactory userFactory = locator.getFactory(UserFactory.class);
        UserQuery query = userFactory.newQuery(scopeId);
        UserListResult list = userService.query(query);
        for (User user : list.getItems()) {
            gwtUserList.add(KapuaGwtConverter.convert(user));
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return new BaseListLoadResult<GwtUser>(gwtUserList);
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) GwtUser(org.eclipse.kapua.app.console.shared.model.GwtUser) User(org.eclipse.kapua.service.user.User) GwtUserService(org.eclipse.kapua.app.console.shared.service.GwtUserService) UserService(org.eclipse.kapua.service.user.UserService) UserQuery(org.eclipse.kapua.service.user.UserQuery) ArrayList(java.util.ArrayList) GwtUser(org.eclipse.kapua.app.console.shared.model.GwtUser) UserFactory(org.eclipse.kapua.service.user.UserFactory) KapuaId(org.eclipse.kapua.model.id.KapuaId) UserListResult(org.eclipse.kapua.service.user.UserListResult)

Example 2 with UserQuery

use of org.eclipse.kapua.service.user.UserQuery in project kapua by eclipse.

the class Users method getUsers.

/**
 * Returns the list of all the users associated to the account of the
 * currently connected user.
 *
 * @return The list of requested User objects.
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public UserListResult getUsers() {
    UserListResult userResult = userFactory.newUserListResult();
    try {
        UserQuery query = userFactory.newQuery(KapuaSecurityUtils.getSession().getScopeId());
        userResult = (UserListResult) userService.query(query);
    } catch (Throwable t) {
        handleException(t);
    }
    return userResult;
}
Also used : UserQuery(org.eclipse.kapua.service.user.UserQuery) UserListResult(org.eclipse.kapua.service.user.UserListResult) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

UserListResult (org.eclipse.kapua.service.user.UserListResult)2 UserQuery (org.eclipse.kapua.service.user.UserQuery)2 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 GwtUser (org.eclipse.kapua.app.console.shared.model.GwtUser)1 GwtUserService (org.eclipse.kapua.app.console.shared.service.GwtUserService)1 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)1 KapuaId (org.eclipse.kapua.model.id.KapuaId)1 User (org.eclipse.kapua.service.user.User)1 UserFactory (org.eclipse.kapua.service.user.UserFactory)1 UserService (org.eclipse.kapua.service.user.UserService)1