Search in sources :

Example 1 with User

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;
}
Also used : User(org.apache.openmeetings.db.entity.user.User)

Example 2 with User

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;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Address(org.apache.openmeetings.db.entity.user.Address) Date(java.util.Date)

Example 3 with 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);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Address(org.apache.openmeetings.db.entity.user.Address)

Example 4 with User

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);
}
Also used : User(org.apache.openmeetings.db.entity.user.User)

Example 5 with User

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());
}
Also used : User(org.apache.openmeetings.db.entity.user.User) OmException(org.apache.openmeetings.util.OmException) Date(java.util.Date)

Aggregations

User (org.apache.openmeetings.db.entity.user.User)101 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)29 Test (org.junit.Test)25 Date (java.util.Date)11 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)10 ArrayList (java.util.ArrayList)8 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)8 OmException (org.apache.openmeetings.util.OmException)8 Path (javax.ws.rs.Path)7 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)7 Room (org.apache.openmeetings.db.entity.room.Room)7 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)6 Client (org.apache.openmeetings.db.entity.basic.Client)6 Address (org.apache.openmeetings.db.entity.user.Address)5 Group (org.apache.openmeetings.db.entity.user.Group)5 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)4 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)4 OAuthUser (org.apache.openmeetings.db.dto.user.OAuthUser)4 Recording (org.apache.openmeetings.db.entity.record.Recording)4 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3