Search in sources :

Example 11 with User

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;
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) User(org.onebusaway.users.model.User) UserRole(org.onebusaway.users.model.UserRole) Date(java.util.Date) UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4) HashSet(java.util.HashSet)

Example 12 with User

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();
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User) UserBean(org.onebusaway.users.client.model.UserBean) Cacheable(org.onebusaway.container.cache.Cacheable) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with User

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);
}
Also used : User(org.onebusaway.users.model.User) ArrayList(java.util.ArrayList)

Example 14 with User

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());
}
Also used : User(org.onebusaway.users.model.User)

Example 15 with User

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);
    }
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) User(org.onebusaway.users.model.User) PostConstruct(javax.annotation.PostConstruct)

Aggregations

User (org.onebusaway.users.model.User)56 UserIndex (org.onebusaway.users.model.UserIndex)23 UserIndexKey (org.onebusaway.users.model.UserIndexKey)16 Test (org.junit.Test)13 Date (java.util.Date)9 UserBean (org.onebusaway.users.client.model.UserBean)8 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)7 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)4 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)4 Criteria (org.hibernate.Criteria)4 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 UserDetail (org.onebusaway.admin.model.ui.UserDetail)4 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 UserRole (org.onebusaway.users.model.UserRole)3