use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method getSingle.
private static User getSingle(List<User> list) {
User u = null;
if (list.size() == 1) {
u = list.get(0);
// this will initiate lazy collection
u.getGroupUsers().size();
}
return u;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method getNewUserInstance.
/**
* Get a new instance of the {@link User} entity, with all default values
* set
*
* @param currentUser - the user to copy time zone from
* @return new User instance
*/
public User getNewUserInstance(User currentUser) {
User user = new User();
user.setSalutation(Salutation.mr);
user.setRights(getDefaultRights());
user.setLanguageId(getDefaultLang());
user.setTimeZoneId(getTimeZone(currentUser).getID());
user.setForceTimeZoneCheck(false);
user.setSendSMS(false);
user.setAge(new Date());
Address address = new Address();
address.setCountry(Locale.getDefault().getCountry());
user.setAddress(address);
user.setShowContactData(false);
user.setShowContactDataToContacts(false);
return user;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method getContact.
public User getContact(String email, String firstName, String lastName, Long langId, String tzId, User owner) {
List<User> list = em.createNamedQuery("getContactByEmailAndUser", User.class).setParameter("email", email).setParameter("type", User.Type.contact).setParameter("ownerId", owner.getId()).getResultList();
if (list.isEmpty()) {
User to = new User();
to.setType(Type.contact);
// UserId prefix is used to ensure unique login
String login = owner.getId() + "_" + email;
to.setLogin(login.length() < getMinLoginLength(cfgDao) ? UUID.randomUUID().toString() : login);
to.setFirstname(firstName);
to.setLastname(lastName);
to.setLanguageId(null == langId || null == LabelDao.getLocale(langId) ? owner.getLanguageId() : langId.longValue());
to.setOwnerId(owner.getId());
to.setAddress(new Address());
to.getAddress().setEmail(email);
to.setTimeZoneId(Strings.isEmpty(tzId) ? owner.getTimeZoneId() : tzId);
return to;
}
return list.get(0);
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method updatePassword.
private User updatePassword(Long id, String pwd, Long updatedBy) throws NoSuchAlgorithmException {
// OpenJPA is not allowing to set fields not being fetched before
User u = get(id, true);
u.updatePassword(cfgDao, pwd);
return update(u, updatedBy);
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method login.
/**
* login logic
*
* @param userOrEmail - login or email of the user being tested
* @param userpass - password of the user being tested
* @return User object in case of successful login
* @throws OmException in case of any issue
*/
public User login(String userOrEmail, String userpass) throws OmException {
List<User> users = em.createNamedQuery("getUserByLoginOrEmail", User.class).setParameter("userOrEmail", userOrEmail).setParameter("type", Type.user).getResultList();
log.debug("login:: {} users were found", users.size());
if (users.isEmpty()) {
log.debug("No users was found: {}", userOrEmail);
return null;
}
User u = users.get(0);
if (!verifyPassword(u.getId(), userpass)) {
log.debug("Password does not match: {}", u);
return null;
}
// Check if activated
if (!AuthLevelUtil.hasLoginLevel(u.getRights())) {
log.debug("Not activated: {}", u);
throw new OmException("error.notactivated");
}
log.debug("loginUser " + u.getGroupUsers());
if (u.getGroupUsers().isEmpty()) {
log.debug("No Group assigned: {}", u);
throw new OmException("error.nogroup");
}
u.setLastlogin(new Date());
return update(u, u.getId());
}
Aggregations