Search in sources :

Example 1 with Invitation

use of org.apache.openmeetings.db.entity.room.Invitation in project openmeetings by apache.

the class InvitationDao method getByHash.

public Invitation getByHash(String hash, boolean hidePass, boolean markUsed) {
    List<Invitation> list = em.createNamedQuery("getInvitationByHashCode", Invitation.class).setParameter("hashCode", hash).getResultList();
    Invitation i = list != null && list.size() == 1 ? list.get(0) : null;
    if (i != null) {
        switch(i.getValid()) {
            case OneTime:
                // one-time invitation
                i.setAllowEntry(!i.isUsed());
                if (markUsed) {
                    i.setUsed(true);
                    update(i);
                    // flash is required to eliminate 'detach' effect
                    em.flush();
                }
                break;
            case Period:
                String tzId = i.getInvitee().getTimeZoneId();
                if (Strings.isEmpty(tzId) && i.getAppointment() != null) {
                    log.warn("User with NO timezone found: {}", i.getInvitee().getId());
                    tzId = i.getAppointment().getOwner().getTimeZoneId();
                }
                if (Strings.isEmpty(tzId)) {
                    log.warn("Unable to obtain valid timezone, setting SYSTEM TZ");
                    tzId = TimeZone.getDefault().getID();
                }
                LocalDateTime now = ZonedDateTime.now(getZoneId(tzId)).toLocalDateTime();
                LocalDateTime from = CalendarHelper.getDateTime(i.getValidFrom(), tzId);
                LocalDateTime to = CalendarHelper.getDateTime(i.getValidTo(), tzId);
                i.setAllowEntry(now.isAfter(from) && now.isBefore(to));
                break;
            case Endless:
            default:
                i.setAllowEntry(true);
                break;
        }
        // required to disable password update
        em.detach(i);
        if (hidePass) {
            i.setPassword(null);
        }
    }
    return i;
}
Also used : LocalDateTime(java.time.LocalDateTime) Invitation(org.apache.openmeetings.db.entity.room.Invitation)

Example 2 with Invitation

use of org.apache.openmeetings.db.entity.room.Invitation in project openmeetings by apache.

the class InvitationDTO method get.

public Invitation get(Long userId, UserDao userDao, RoomDao roomDao) {
    Invitation i = new Invitation();
    i.setHash(UUID.randomUUID().toString());
    i.setPasswordProtected(passwordProtected);
    if (passwordProtected) {
        i.setPassword(CryptProvider.get().hash(password));
    }
    i.setUsed(false);
    i.setValid(valid);
    try {
        // valid period of Invitation
        switch(valid) {
            case Period:
                i.setValidFrom(new Date(SDF.parse(validFrom).getTime() - (5 * 60 * 1000)));
                i.setValidTo(SDF.parse(validTo));
                break;
            case Endless:
            case OneTime:
            default:
                break;
        }
    } catch (ParseException e) {
        log.error("Unexpected error while creating invitation", e);
        throw new RuntimeException(e);
    }
    i.setDeleted(false);
    i.setInvitedBy(userDao.get(userId));
    i.setInvitee(userDao.getContact(email, firstname, lastname, userId));
    if (Type.contact == i.getInvitee().getType()) {
        i.getInvitee().setLanguageId(languageId);
    }
    i.setRoom(roomDao.get(roomId));
    i.setInserted(new Date());
    i.setAppointment(null);
    return i;
}
Also used : Invitation(org.apache.openmeetings.db.entity.room.Invitation) ParseException(java.text.ParseException) Date(java.util.Date)

Example 3 with Invitation

use of org.apache.openmeetings.db.entity.room.Invitation in project openmeetings by apache.

the class MessageDialog method onSubmit.

@Override
protected void onSubmit(AjaxRequestTarget target) {
    PrivateMessage m = getModelObject();
    m.setInserted(new Date());
    User owner = userDao.get(getUserId());
    if (m.isBookedRoom()) {
        Room r = m.getRoom();
        r.setName(m.getSubject());
        r.setComment("");
        r.setCapacity(100L);
        r.setAppointment(true);
        r.setAllowUserQuestions(true);
        r = roomDao.update(r, getUserId());
        Appointment a = new Appointment();
        a.setTitle(m.getSubject());
        a.setDescription(m.getMessage());
        a.setRoom(r);
        a.setStart(CalendarWebHelper.getDate(start.getModelObject()));
        a.setEnd(CalendarWebHelper.getDate(end.getModelObject()));
        List<MeetingMember> attendees = new ArrayList<>();
        for (User to : modelTo.getObject()) {
            MeetingMember mm = new MeetingMember();
            mm.setUser(to);
            mm.setDeleted(false);
            mm.setInserted(a.getInserted());
            mm.setUpdated(a.getUpdated());
            mm.setAppointment(a);
            attendees.add(mm);
        }
        a.setOwner(owner);
        a.setMeetingMembers(attendees);
        apptDao.update(a, getUserId(), false);
        m.setRoom(r);
    } else {
        m.setRoom(null);
    }
    for (User to : modelTo.getObject()) {
        if (to.getId() == null) {
            userDao.update(to, getUserId());
        }
        // to send
        PrivateMessage p = new PrivateMessage(m);
        p.setTo(to);
        p.setFolderId(SENT_FOLDER_ID);
        msgDao.update(p, getUserId());
        // to inbox
        p = new PrivateMessage(m);
        p.setOwner(to);
        p.setFolderId(INBOX_FOLDER_ID);
        msgDao.update(p, getUserId());
        if (to.getAddress() != null) {
            String aLinkHTML = (isPrivate && to.getType() == Type.user) ? "<br/><br/>" + "<a href='" + getContactsLink() + "'>" + Application.getString("1302", to.getLanguageId()) + "</a><br/>" : "";
            String invitationLink = "";
            if (p.isBookedRoom()) {
                Invitation i = inviteManager.getInvitation(to, p.getRoom(), false, null, Valid.Period, owner, to.getLanguageId(), CalendarHelper.getDate(start.getModelObject(), to.getTimeZoneId()), CalendarHelper.getDate(end.getModelObject(), to.getTimeZoneId()), null);
                invitationLink = getInvitationLink(i, WebSession.get().getExtendedProperties().getBaseUrl());
                if (invitationLink == null) {
                    invitationLink = "";
                } else {
                    invitationLink = // 
                    "<br/>" + Application.getString("503", to.getLanguageId()) + "<br/><a href='" + invitationLink + "'>" + Application.getString("504", to.getLanguageId()) + "</a><br/>";
                }
            }
            String subj = p.getSubject() == null ? "" : p.getSubject();
            handler.send(to.getAddress().getEmail(), Application.getString("1301", to.getLanguageId()) + subj, (p.getMessage() == null ? "" : p.getMessage().replaceAll("\\<.*?>", "")) + aLinkHTML + invitationLink);
        }
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) ArrayList(java.util.ArrayList) Invitation(org.apache.openmeetings.db.entity.room.Invitation) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Room(org.apache.openmeetings.db.entity.room.Room) Date(java.util.Date)

Example 4 with Invitation

use of org.apache.openmeetings.db.entity.room.Invitation in project openmeetings by apache.

the class RoomInvitationForm method updateModel.

@Override
public void updateModel(AjaxRequestTarget target) {
    super.updateModel(target);
    Invitation i = getModelObject();
    i.setRoom(roomDao.get(roomId));
    if (i.getRoom() != null) {
        target.add(sipContainer.replace(new Label("room.confno", i.getRoom().getConfno())).setVisible(i.getRoom().isSipEnabled()));
    }
    groups.setModelObject(new ArrayList<Group>());
    groups.setEnabled(false);
    rdi.setModelObject(InviteeType.user);
}
Also used : RadioGroup(org.apache.wicket.markup.html.form.RadioGroup) Group(org.apache.openmeetings.db.entity.user.Group) Invitation(org.apache.openmeetings.db.entity.room.Invitation) Label(org.apache.wicket.markup.html.basic.Label)

Example 5 with Invitation

use of org.apache.openmeetings.db.entity.room.Invitation 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)

Aggregations

Invitation (org.apache.openmeetings.db.entity.room.Invitation)16 Date (java.util.Date)3 User (org.apache.openmeetings.db.entity.user.User)3 LocalDateTime (java.time.LocalDateTime)2 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)2 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)2 Room (org.apache.openmeetings.db.entity.room.Room)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 RadioGroup (org.apache.wicket.markup.html.form.RadioGroup)2 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 TimeZone (java.util.TimeZone)1 WebMethod (javax.jws.WebMethod)1 POST (javax.ws.rs.POST)1