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);
}
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");
}
}
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;
}
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();
}
}
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);
}
Aggregations