Search in sources :

Example 1 with InvitationMessage

use of org.activityinfo.server.mail.InvitationMessage in project activityinfo by bedatadriven.

the class UpdateUserPermissionsHandler method createNewUser.

private User createNewUser(User executingUser, UserPermissionDTO dto) {
    if (executingUser.getId() == 0) {
        throw new AssertionError("executingUser.id == 0!");
    }
    if (executingUser.getName() == null) {
        throw new AssertionError("executingUser.name == null!");
    }
    User user = UserDAOImpl.createNewUser(dto.getEmail(), dto.getName(), executingUser.getLocale());
    user.setInvitedBy(executingUser);
    userDAO.persist(user);
    try {
        Message message = mailSender.createMessage(new InvitationMessage(user, executingUser));
        message.replyTo(executingUser.getEmail(), executingUser.getName());
        mailSender.send(message);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Could not send invitation mail", e);
        throw new CommandException("Failed to send invitation email");
    }
    return user;
}
Also used : User(org.activityinfo.server.database.hibernate.entity.User) InvitationMessage(org.activityinfo.server.mail.InvitationMessage) Message(org.activityinfo.server.mail.Message) InvitationMessage(org.activityinfo.server.mail.InvitationMessage) IllegalAccessCommandException(org.activityinfo.legacy.shared.exception.IllegalAccessCommandException) CommandException(org.activityinfo.legacy.shared.exception.CommandException) IllegalAccessCommandException(org.activityinfo.legacy.shared.exception.IllegalAccessCommandException) UserExistsException(org.activityinfo.legacy.shared.command.result.UserExistsException) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Aggregations

UserExistsException (org.activityinfo.legacy.shared.command.result.UserExistsException)1 CommandException (org.activityinfo.legacy.shared.exception.CommandException)1 IllegalAccessCommandException (org.activityinfo.legacy.shared.exception.IllegalAccessCommandException)1 User (org.activityinfo.server.database.hibernate.entity.User)1 InvitationMessage (org.activityinfo.server.mail.InvitationMessage)1 Message (org.activityinfo.server.mail.Message)1