Search in sources :

Example 6 with Address

use of org.apache.openmeetings.db.entity.user.Address in project openmeetings by apache.

the class AbstractJUnitDefaults method getUser.

public static User getUser(String uuid) throws Exception {
    User u = new User();
    // add user
    u.setFirstname("firstname" + uuid);
    u.setLastname("lastname" + uuid);
    u.setLogin(getLogin(uuid));
    u.setAddress(new Address());
    u.getAddress().setEmail(getEmail(uuid));
    u.setRights(UserDao.getDefaultRights());
    u.setTimeZoneId("Asia/Bangkok");
    // NO SIP
    u.updatePassword(null, createPass());
    u.setLanguageId(1L);
    return u;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Address(org.apache.openmeetings.db.entity.user.Address)

Example 7 with Address

use of org.apache.openmeetings.db.entity.user.Address in project openmeetings by apache.

the class UserDao method delete.

@Override
public void delete(User u, Long userId) {
    if (u != null && u.getId() != null) {
        u.setGroupUsers(new ArrayList<>());
        u.setDeleted(true);
        u.setUpdated(new Date());
        u.setSipUser(null);
        Address adr = u.getAddress();
        if (adr != null) {
            adr.setDeleted(true);
        }
        update(u, userId);
    }
}
Also used : Address(org.apache.openmeetings.db.entity.user.Address) Date(java.util.Date)

Example 8 with Address

use of org.apache.openmeetings.db.entity.user.Address in project openmeetings by apache.

the class UserManager method registerUserInit.

/**
 * @param rights - {@link Right} to be assigned to the user
 * @param login - user login
 * @param password - user password
 * @param lastname - user last name
 * @param firstname - user first name
 * @param email - user email
 * @param age - user birthday
 * @param street - user address street
 * @param additionalname - user additional name
 * @param fax - user fax
 * @param zip - user zip code
 * @param country - user country code
 * @param town - user town
 * @param languageId - language id
 * @param sendWelcomeMessage - should confirmation email be sent
 * @param groups - ids of user groups
 * @param phone - user phone
 * @param sendSMS - should SMS be sent to this user
 * @param sendConfirmation - should confirmation be sent
 * @param timezone - the name of the time zone
 * @param forceTimeZoneCheck - should time zone be verified by user
 * @param userOffers - what user offers
 * @param userSearchs - what user searches
 * @param showContactData - is contact data publicly visible
 * @param showContactDataToContacts - is contact data visible to contacts
 * @param activatedHash - activation hash
 * @return {@link User} of code of error as {@link String}
 * @throws NoSuchAlgorithmException in case password hashing algorithm is not found
 * @throws OmException in case of any issues with provided data
 */
@Override
public Object registerUserInit(Set<Right> rights, String login, String password, String lastname, String firstname, String email, Date age, String street, String additionalname, String fax, String zip, String country, String town, long languageId, boolean sendWelcomeMessage, List<Long> groups, String phone, boolean sendSMS, Boolean sendConfirmation, TimeZone timezone, Boolean forceTimeZoneCheck, String userOffers, String userSearchs, Boolean showContactData, Boolean showContactDataToContacts, String activatedHash) throws OmException, NoSuchAlgorithmException {
    // Check for required data
    if (login.length() >= getMinLoginLength(cfgDao)) {
        // Check for duplicates
        boolean checkName = userDao.checkLogin(login, User.Type.user, null, null);
        boolean checkEmail = Strings.isEmpty(email) || userDao.checkEmail(email, User.Type.user, null, null);
        if (checkName && checkEmail) {
            String hash = Strings.isEmpty(activatedHash) ? UUID.randomUUID().toString() : activatedHash;
            if (sendWelcomeMessage && email.length() != 0) {
                emailManager.sendMail(login, email, hash, sendConfirmation, languageId);
            }
            Address a = new Address();
            a.setStreet(street);
            a.setZip(zip);
            a.setTown(town);
            a.setCountry(country);
            a.setAdditionalname(additionalname);
            a.setComment("");
            a.setFax(fax);
            a.setPhone(phone);
            a.setEmail(email);
            // code then set the status to 0
            if (sendConfirmation && rights.contains(Right.Login)) {
                rights.remove(Right.Login);
            }
            User u = new User();
            u.setFirstname(firstname);
            u.setLogin(login);
            u.setLastname(lastname);
            u.setAge(age);
            u.setAddress(a);
            u.setSendSMS(sendSMS);
            u.setRights(rights);
            u.setLastlogin(new Date());
            u.setSalutation(Salutation.mr);
            u.setActivatehash(hash);
            u.setTimeZoneId(timezone.getID());
            u.setForceTimeZoneCheck(forceTimeZoneCheck);
            if (!Strings.isEmpty(u.getExternalType())) {
                u.setType(Type.external);
            }
            u.setUserOffers(userOffers);
            u.setUserSearchs(userSearchs);
            u.setShowContactData(showContactData);
            u.setShowContactDataToContacts(showContactDataToContacts);
            // this is needed cause the language is not a needed data at registering
            u.setLanguageId(languageId != 0 ? languageId : 1);
            if (!Strings.isEmpty(password)) {
                u.updatePassword(cfgDao, password);
            }
            if (groups != null) {
                for (Long grpId : groups) {
                    u.getGroupUsers().add(new GroupUser(groupDao.get(grpId), u));
                }
            }
            u = userDao.update(u, null);
            log.debug("Added user-Id " + u.getId());
            if (a.getId() != null && u.getId() != null) {
                return u;
            }
        } else {
            if (!checkName) {
                return "error.login.inuse";
            } else {
                return "error.email.inuse";
            }
        }
    } else {
        return "error.short.login";
    }
    return UNKNOWN.getKey();
}
Also used : User(org.apache.openmeetings.db.entity.user.User) OAuthUser(org.apache.openmeetings.db.dto.user.OAuthUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Address(org.apache.openmeetings.db.entity.user.Address) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Date(java.util.Date)

Aggregations

Address (org.apache.openmeetings.db.entity.user.Address)8 User (org.apache.openmeetings.db.entity.user.User)6 Date (java.util.Date)4 ExternalUserDTO (org.apache.openmeetings.db.dto.user.ExternalUserDTO)2 UserDTO (org.apache.openmeetings.db.dto.user.UserDTO)2 JQueryIcon (com.googlecode.wicket.jquery.ui.JQueryIcon)1 AjaxButton (com.googlecode.wicket.jquery.ui.form.button.AjaxButton)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 WebMethod (javax.jws.WebMethod)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Form (javax.ws.rs.core.Form)1 StrongPasswordValidator (org.apache.openmeetings.core.util.StrongPasswordValidator)1 FileItemDao (org.apache.openmeetings.db.dao.file.FileItemDao)1 RoomDao (org.apache.openmeetings.db.dao.room.RoomDao)1