use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method getActiveUsersDetails.
@Override
public List<UserDetail> getActiveUsersDetails() {
List<UserDetail> userDetails = new ArrayList<UserDetail>();
List<User> users = hibernateTemplate.execute(new HibernateCallback<List<User>>() {
@SuppressWarnings("unchecked")
@Override
public List<User> doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(User.class).createCriteria("userIndices").add(Restrictions.eq("id.type", UserIndexTypes.USERNAME));
List<User> users = criteria.list();
return users;
}
});
if (!users.isEmpty()) {
for (User user : users) {
UserBean bean = userService.getUserAsBean(user);
if (!bean.isDisabled()) {
if (!user.getUserIndices().isEmpty()) {
UserDetail userDetail = buildUserDetail(user);
userDetails.add(userDetail);
}
}
}
}
log.debug("Returning user details");
return userDetails;
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method activateUser.
// Marks the user as active
@Override
public boolean activateUser(UserDetail userDetail) {
User user = userService.getUserForId(userDetail.getId());
if (user == null) {
log.info("User '{}' does not exist in the system", userDetail.getUsername());
return false;
}
userPropertiesService.activateUser(user);
log.info("User '{}' activated successfully", userDetail.getUsername());
return true;
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method deactivateUser.
// deletes the user
@Override
public boolean deactivateUser(UserDetail userDetail) {
User user = userService.getUserForId(userDetail.getId());
if (user == null) {
log.info("User '{}' does not exist in the system", userDetail.getUsername());
return false;
}
// user record itself is still present
for (Iterator<UserIndex> it = user.getUserIndices().iterator(); it.hasNext(); ) {
UserIndex userIndex = it.next();
userDao.deleteUserIndex(userIndex);
it.remove();
}
userDao.saveOrUpdateUser(user);
log.info("User '{}' deleted successfully", userDetail.getUsername());
return true;
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class AccessControlServiceImpl method currentUserHasPrivilege.
@Override
public boolean currentUserHasPrivilege(Privilege privilege) {
UserIndex idx = currentUserService.getCurrentUserAsUserIndex();
User user = (idx == null) ? null : idx.getUser();
return userHasPrivilege(user, privilege);
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceVersionedInvocationHandler method getServiceForUserArgs.
private UserPropertiesService getServiceForUserArgs(Object[] args) {
if (_preferredVersion != -1)
return getServiceForVersion(_preferredVersion);
int maxVersion = 0;
if (args != null) {
for (Object arg : args) {
if (arg instanceof User) {
User user = (User) arg;
int version = getPropertiesVersion(user);
maxVersion = Math.max(maxVersion, version);
} else if (arg instanceof UserIndex) {
UserIndex userIndex = (UserIndex) arg;
int version = getPropertiesVersion(userIndex.getUser());
maxVersion = Math.max(maxVersion, version);
}
}
}
return getServiceForVersion(maxVersion);
}
Aggregations