Search in sources :

Example 1 with UserBean

use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.

the class ApiKeyAction method searchContactEmail.

public String searchContactEmail() {
    String searchResult = "Email address '" + contactEmail + "' could not be found";
    List<String> apiKeys = userService.getUserIndexKeyValuesForKeyType(UserIndexTypes.API_KEY);
    // clear other fields
    contactName = "";
    contactCompany = "";
    contactDetails = "";
    key = "";
    for (String apiKey : apiKeys) {
        // for each api key, check if contact email matches
        UserIndexKey userKey = new UserIndexKey(UserIndexTypes.API_KEY, apiKey);
        UserIndex userIndex = userService.getUserIndexForId(userKey);
        if (userIndex != null) {
            User user = userIndex.getUser();
            UserBean bean = userService.getUserAsBean(user);
            if (contactEmail.equals(bean.getContactEmail())) {
                minApiReqInt = bean.getMinApiRequestInterval();
                contactName = bean.getContactName();
                contactCompany = bean.getContactCompany();
                contactDetails = bean.getContactDetails();
                key = apiKey;
                searchResult = "Email address '" + contactEmail + "' found";
                break;
            }
        }
    }
    addActionMessage(searchResult);
    return SUCCESS;
}
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)

Example 2 with UserBean

use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.

the class ApiKeyAction method updateAPIKey.

public void updateAPIKey(UserIndex userIndexForId) {
    User user = userIndexForId.getUser();
    UserBean bean = userService.getUserAsBean(user);
    String keyContactName = bean.getContactName();
    String keyContactCompany = bean.getContactCompany();
    String keyContactEmail = bean.getContactEmail();
    String keyContactDetails = bean.getContactDetails();
    if (contactName != null) {
        keyContactName = contactName;
    }
    if (contactCompany != null) {
        keyContactCompany = contactCompany;
    }
    if (contactEmail != null) {
        keyContactEmail = contactEmail;
    }
    if (contactDetails != null) {
        keyContactDetails = contactDetails;
    }
    userPropertiesService.authorizeApi(user, minApiReqInt);
    userPropertiesService.updateApiKeyContactInfo(user, keyContactName, keyContactCompany, keyContactEmail, keyContactDetails);
    // Clear the cached value here
    userService.getMinApiRequestIntervalForKey(key, true);
    return;
}
Also used : User(org.onebusaway.users.model.User) UserBean(org.onebusaway.users.client.model.UserBean)

Example 3 with UserBean

use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.

the class UserManagementServiceImpl method getInactiveUsersDetails.

@Override
public List<UserDetail> getInactiveUsersDetails() {
    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;
}
Also used : User(org.onebusaway.users.model.User) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Criteria(org.hibernate.Criteria) UserDetail(org.onebusaway.admin.model.ui.UserDetail) UserBean(org.onebusaway.users.client.model.UserBean) ArrayList(java.util.ArrayList) List(java.util.List) Session(org.hibernate.Session)

Example 4 with UserBean

use of org.onebusaway.users.client.model.UserBean 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;
}
Also used : User(org.onebusaway.users.model.User) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Criteria(org.hibernate.Criteria) UserDetail(org.onebusaway.admin.model.ui.UserDetail) UserBean(org.onebusaway.users.client.model.UserBean) ArrayList(java.util.ArrayList) List(java.util.List) Session(org.hibernate.Session)

Example 5 with UserBean

use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.

the class UserServiceImpl method getAnonymousUser.

@Override
public UserBean getAnonymousUser() {
    UserBean bean = new UserBean();
    bean.setUserId("-1");
    bean.setAnonymous(true);
    bean.setAdmin(false);
    _userPropertiesService.getAnonymousUserAsBean(bean);
    return bean;
}
Also used : UserBean(org.onebusaway.users.client.model.UserBean)

Aggregations

UserBean (org.onebusaway.users.client.model.UserBean)16 User (org.onebusaway.users.model.User)8 UserIndex (org.onebusaway.users.model.UserIndex)8 UserIndexKey (org.onebusaway.users.model.UserIndexKey)6 ArrayList (java.util.ArrayList)3 UserDetail (org.onebusaway.admin.model.ui.UserDetail)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 List (java.util.List)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)2 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)2 Criteria (org.hibernate.Criteria)2 HibernateException (org.hibernate.HibernateException)2 Session (org.hibernate.Session)2 UserRole (org.onebusaway.users.model.UserRole)2 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1