Search in sources :

Example 26 with User

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

the class InvitationForm method updateModel.

public void updateModel(AjaxRequestTarget target) {
    Invitation i = new Invitation();
    User u = userDao.get(getUserId());
    i.setInvitedBy(u);
    i.setRoom(null);
    from.setModelObject(LocalDateTime.now());
    to.setModelObject(LocalDateTime.now().plusDays(1));
    i.setPassword(null);
    i.setHash(null);
    subject.setModelObject(null);
    message.setModelObject(null);
    timeZoneId.setModelObject(u.getTimeZoneId());
    lang.setModelObject(u.getLanguageId());
    url.setModelObject(null);
    setModelObject(i);
    recipients.setModelObject(new ArrayList<User>());
    recipients.setEnabled(true);
    passwd.setEnabled(false);
    final boolean isPeriod = i.getValid() == Valid.Period;
    from.setEnabled(isPeriod);
    to.setEnabled(isPeriod);
    timeZoneId.setEnabled(isPeriod);
    target.add(this);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Invitation(org.apache.openmeetings.db.entity.room.Invitation)

Example 27 with User

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

the class ImportInitvalues method loadInitUserAndGroup.

public void loadInitUserAndGroup(InstallationConfig cfg) throws Exception {
    // Add default group
    Group org = new Group();
    org.setName(cfg.getGroup());
    org.setInsertedby(1L);
    org.setDeleted(false);
    org.setInserted(new Date());
    org = groupDao.update(org, null);
    User u = userDao.getNewUserInstance(null);
    u.setType(User.Type.user);
    u.getRights().add(Right.Admin);
    u.getRights().add(Right.Soap);
    u.setLogin(cfg.getUsername());
    u.setFirstname("firstname");
    u.setLastname("lastname");
    u.getAddress().setEmail(cfg.getEmail());
    u.getGroupUsers().add(new GroupUser(org, u));
    u = userDao.update(u, cfg.getPassword(), -1L);
    log.debug("Installation - User Added user-Id " + u.getId());
    if (u.getId() == null) {
        throw new InstallException("Unable to add user");
    }
}
Also used : RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) Group(org.apache.openmeetings.db.entity.user.Group) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Date(java.util.Date)

Example 28 with User

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

the class UserConverter method read.

@Override
public User read(InputNode node) throws Exception {
    long oldId = toLong(node.getValue());
    Long newId = idMap.containsKey(oldId) ? idMap.get(oldId) : oldId;
    User u = userDao.get(newId);
    return u == null ? new User() : u;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) NumberUtils.toLong(org.apache.commons.lang3.math.NumberUtils.toLong)

Example 29 with User

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

the class Admin method checkAdminDetails.

private void checkAdminDetails() throws Exception {
    cfg.setUsername(cmdl.getOptionValue("user"));
    cfg.setEmail(cmdl.getOptionValue("email"));
    cfg.setGroup(cmdl.getOptionValue("group"));
    if (cfg.getUsername() == null || cfg.getUsername().length() < USER_LOGIN_MINIMUM_LENGTH) {
        log("User login was not provided, or too short, should be at least " + USER_LOGIN_MINIMUM_LENGTH + " character long.");
        throw new ExitException();
    }
    if (!MailUtil.isValid(cfg.getEmail())) {
        log(String.format("Please provide non-empty valid email: '%s' is not valid.", cfg.getEmail()));
        throw new ExitException();
    }
    if (Strings.isEmpty(cfg.getGroup())) {
        log(String.format("User group was not provided, or too short, should be at least 1 character long: %s", cfg.getGroup()));
        throw new ExitException();
    }
    if (cmdl.hasOption("password")) {
        cfg.setPassword(cmdl.getOptionValue("password"));
    }
    ConfigurationDao cfgDao = getApplicationContext().getBean(ConfigurationDao.class);
    IValidator<String> passValidator = new StrongPasswordValidator(false, getMinPasswdLength(cfgDao), new User());
    Validatable<String> passVal;
    do {
        passVal = new Validatable<>(cfg.getPassword());
        passValidator.validate(passVal);
        if (!passVal.isValid()) {
            log(String.format("Please enter password for the user '%s':", cfg.getUsername()));
            cfg.setPassword(new BufferedReader(new InputStreamReader(System.in, UTF_8)).readLine());
        }
    } while (!passVal.isValid());
    Map<String, String> tzMap = ImportHelper.getAllTimeZones(TimeZone.getAvailableIDs());
    cfg.setTimeZone(null);
    if (cmdl.hasOption("tz")) {
        String tz = cmdl.getOptionValue("tz");
        cfg.setTimeZone(tzMap.containsKey(tz) ? tz : null);
    }
    if (cfg.getTimeZone() == null) {
        log("Please enter timezone, Possible timezones are:");
        for (Map.Entry<String, String> me : tzMap.entrySet()) {
            log(String.format("%1$-25s%2$s", "\"" + me.getKey() + "\"", me.getValue()));
        }
        throw new ExitException();
    }
}
Also used : ConfigurationDao(org.apache.openmeetings.db.dao.basic.ConfigurationDao) User(org.apache.openmeetings.db.entity.user.User) InputStreamReader(java.io.InputStreamReader) StrongPasswordValidator(org.apache.openmeetings.core.util.StrongPasswordValidator) BufferedReader(java.io.BufferedReader) Map(java.util.Map)

Example 30 with User

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

the class CleanupHelper method getProfileUnit.

public static CleanupEntityUnit getProfileUnit(final UserDao udao) {
    File parent = OmFileHelper.getUploadProfilesDir();
    List<File> invalid = new ArrayList<>();
    List<File> deleted = new ArrayList<>();
    int missing = 0;
    for (File profile : list(parent, null)) {
        long userId = getUserIdByProfile(profile.getName());
        User u = udao.get(userId);
        if (profile.isFile() || userId < 0 || u == null) {
            invalid.add(profile);
        } else if (u.isDeleted()) {
            deleted.add(profile);
        }
    }
    for (User u : udao.getAllBackupUsers()) {
        if (!u.isDeleted() && u.getPictureuri() != null && !new File(OmFileHelper.getUploadProfilesUserDir(u.getId()), u.getPictureuri()).exists()) {
            missing++;
        }
    }
    return new CleanupEntityUnit(parent, invalid, deleted, missing);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) ArrayList(java.util.ArrayList) File(java.io.File)

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