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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations