use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserServiceImpl method getOrCreateUserForIndexKey.
@Override
public UserIndex getOrCreateUserForIndexKey(UserIndexKey key, String credentials, boolean isAnonymous) {
UserIndex userIndex = _userDao.getUserIndexForId(key);
if (userIndex == null) {
User user = new User();
user.setCreationTime(new Date());
user.setTemporary(true);
user.setProperties(new UserPropertiesV4());
Set<UserRole> roles = new HashSet<UserRole>();
if (isAnonymous)
roles.add(_authoritiesService.getAnonymousRole());
else
roles.add(_authoritiesService.getUserRole());
user.setRoles(roles);
userIndex = new UserIndex();
userIndex.setId(key);
userIndex.setCredentials(credentials);
userIndex.setUser(user);
user.getUserIndices().add(userIndex);
_userDao.saveOrUpdateUser(user);
}
return userIndex;
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserServiceImpl method getMinApiRequestIntervalForKey.
@Cacheable
@Transactional
@Override
public Long getMinApiRequestIntervalForKey(String key, @CacheableArgument(cacheRefreshIndicator = true) boolean forceRefresh) {
UserIndexKey indexKey = new UserIndexKey(UserIndexTypes.API_KEY, key);
UserIndex userIndex = getUserIndexForId(indexKey);
if (userIndex == null) {
return null;
}
User user = userIndex.getUser();
UserBean bean = getUserAsBean(user);
return bean.getMinApiRequestInterval();
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserDaoImpl method saveOrUpdateUsers.
@Override
public void saveOrUpdateUsers(User... users) {
List<User> list = new ArrayList<User>(users.length);
for (User user : users) list.add(user);
_template.saveOrUpdateAll(list);
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class UserDetailsServiceImpl method setLastAccessTimeForUser.
private void setLastAccessTimeForUser(UserIndex userIndex) {
User user = userIndex.getUser();
_userLastAccessTimeService.handleAccessForUser(user.getId(), SystemTime.currentTimeMillis());
}
use of org.onebusaway.users.model.User in project onebusaway-application-modules by camsys.
the class CreateUserAction method execute.
@PostConstruct
public void execute() {
UserIndex userIndex = _userService.getOrCreateUserForUsernameAndPassword(username, password);
if (userIndex == null)
throw new IllegalStateException("error creating user");
if (admin) {
User user = userIndex.getUser();
_userService.enableAdminRoleForUser(user, false);
}
}
Aggregations