use of org.eclipse.kapua.service.user.UserListResult in project kapua by eclipse.
the class UserServiceImpl method query.
@Override
public UserListResult query(KapuaQuery<User> query) throws KapuaException {
//
// Argument Validation
ArgumentValidator.notNull(query, "query");
ArgumentValidator.notNull(query.getScopeId(), "query.scopeId");
//
// Check Access
AuthorizationService authorizationService = locator.getService(AuthorizationService.class);
PermissionFactory permissionFactory = locator.getFactory(PermissionFactory.class);
authorizationService.checkPermission(permissionFactory.newPermission(UserDomain.USER, Actions.read, query.getScopeId()));
//
// Do count
UserListResult result = null;
EntityManager em = UserEntityManagerFactory.getInstance().createEntityManager();
;
try {
result = UserDAO.query(em, query);
} catch (Exception e) {
throw KapuaExceptionUtils.convertPersistenceException(e);
} finally {
em.close();
}
return result;
}
use of org.eclipse.kapua.service.user.UserListResult 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);
}
use of org.eclipse.kapua.service.user.UserListResult 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;
}
Aggregations