Search in sources :

Example 1 with Organizer

use of net.fortuna.ical4j.model.property.Organizer in project openmeetings by apache.

the class IcalUtils method addVEventpropsfromAppointment.

/**
 * Adds the Appointment Properties to the given VEvent
 *
 * @param appointment Appointment whose properties are taken
 * @param meeting     VEvent of the Appointment
 * @return Updated VEvent
 */
private static VEvent addVEventpropsfromAppointment(Appointment appointment, VEvent meeting) {
    if (appointment.getLocation() != null) {
        meeting.getProperties().add(new Location(appointment.getLocation()));
    }
    meeting.getProperties().add(new Description(appointment.getDescription()));
    meeting.getProperties().add(new Sequence(0));
    meeting.getProperties().add(Transp.OPAQUE);
    String uid = appointment.getIcalId();
    Uid ui;
    if (uid == null || uid.length() < 1) {
        UUID uuid = UUID.randomUUID();
        appointment.setIcalId(uuid.toString());
        ui = new Uid(uuid.toString());
    } else {
        ui = new Uid(uid);
    }
    meeting.getProperties().add(ui);
    if (appointment.getMeetingMembers() != null) {
        for (MeetingMember meetingMember : appointment.getMeetingMembers()) {
            Attendee attendee = new Attendee(URI.create("mailto:" + meetingMember.getUser().getAddress().getEmail()));
            attendee.getParameters().add(Role.REQ_PARTICIPANT);
            attendee.getParameters().add(new Cn(meetingMember.getUser().getLogin()));
            meeting.getProperties().add(attendee);
        }
    }
    URI orgUri = URI.create("mailto:" + appointment.getOwner().getAddress().getEmail());
    Attendee orgAtt = new Attendee(orgUri);
    orgAtt.getParameters().add(Role.CHAIR);
    Cn orgCn = new Cn(appointment.getOwner().getLogin());
    orgAtt.getParameters().add(orgCn);
    meeting.getProperties().add(orgAtt);
    Organizer organizer = new Organizer(orgUri);
    organizer.getParameters().add(orgCn);
    meeting.getProperties().add(organizer);
    return meeting;
}
Also used : Uid(net.fortuna.ical4j.model.property.Uid) Description(net.fortuna.ical4j.model.property.Description) Organizer(net.fortuna.ical4j.model.property.Organizer) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Sequence(net.fortuna.ical4j.model.property.Sequence) Cn(net.fortuna.ical4j.model.parameter.Cn) UUID(java.util.UUID) URI(java.net.URI) Attendee(net.fortuna.ical4j.model.property.Attendee) Location(net.fortuna.ical4j.model.property.Location)

Example 2 with Organizer

use of net.fortuna.ical4j.model.property.Organizer in project openmeetings by apache.

the class IcalHandler method addNewMeeting.

/**
 * @param startDate
 *            use standard TimeZone!!
 * @param endDate
 *            use standard time zone!!
 * @param name
 *            meeting name
 * @param attendees
 *            List of attendees (use getAttendeeData to retrieve valid records)
 * @param description
 *            containing the meeting description
 * @param organizer
 *            organizer
 * @param uid
 *            (maybe null)
 * @param javaTzId ID of owner's java time zone
 * @return UID of Meeting
 */
// ---------------------------------------------------------------------------------------
public String addNewMeeting(Date startDate, Date endDate, String name, List<Map<String, String>> attendees, String description, Map<String, String> organizer, String uid, String javaTzId) {
    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    TimeZone timeZone = registry.getTimeZone(javaTzId);
    if (timeZone == null) {
        throw new NoSuchElementException("Unable to get time zone by id provided: " + javaTzId);
    }
    DateTime start = new DateTime(startDate);
    start.setTimeZone(timeZone);
    DateTime end = new DateTime(endDate);
    end.setTimeZone(timeZone);
    VEvent meeting = new VEvent(start, end, name);
    meeting.getProperties().add(new Description(description));
    meeting.getProperties().add(new Sequence(0));
    meeting.getProperties().add(new Location(""));
    meeting.getProperties().add(Transp.OPAQUE);
    // generate unique identifier (if not submitted)
    Uid ui;
    if (Strings.isEmpty(uid)) {
        ui = new Uid(UUID.randomUUID().toString());
        log.debug("Generating Meeting UID : " + ui.getValue());
    } else {
        ui = new Uid(uid);
        log.debug("Using Meeting UID : " + ui.getValue());
    }
    meeting.getProperties().add(ui);
    for (Map<String, String> att : attendees) {
        Attendee uno = new Attendee(URI.create(att.get("uri")));
        String chair = att.get("chair");
        uno.getParameters().add("0".equals(chair) ? Role.REQ_PARTICIPANT : Role.CHAIR);
        uno.getParameters().add(new Cn(att.get("cn")));
        meeting.getProperties().add(uno);
    }
    Organizer orger = new Organizer(URI.create(organizer.get("uri")));
    orger.getParameters().add(new Cn(organizer.get("cn")));
    meeting.getProperties().add(orger);
    icsCalendar.getComponents().add(timeZone.getVTimeZone());
    icsCalendar.getComponents().add(meeting);
    return ui.getValue();
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) Description(net.fortuna.ical4j.model.property.Description) Organizer(net.fortuna.ical4j.model.property.Organizer) TimeZoneRegistry(net.fortuna.ical4j.model.TimeZoneRegistry) Sequence(net.fortuna.ical4j.model.property.Sequence) Cn(net.fortuna.ical4j.model.parameter.Cn) DateTime(net.fortuna.ical4j.model.DateTime) Attendee(net.fortuna.ical4j.model.property.Attendee) Uid(net.fortuna.ical4j.model.property.Uid) TimeZone(net.fortuna.ical4j.model.TimeZone) NoSuchElementException(java.util.NoSuchElementException) Location(net.fortuna.ical4j.model.property.Location)

Example 3 with Organizer

use of net.fortuna.ical4j.model.property.Organizer in project bw-calendar-engine by Bedework.

the class IcalUtil method setOrganizer.

/**
 * @param val
 * @return Organizer
 * @throws Throwable
 */
public static Organizer setOrganizer(final BwOrganizer val) throws Throwable {
    ParameterList pars = new ParameterList();
    String temp = val.getScheduleStatus();
    if (temp != null) {
        pars.add(new ScheduleStatus(temp));
    }
    temp = val.getCn();
    if (temp != null) {
        pars.add(new Cn(temp));
    }
    temp = val.getDir();
    if (temp != null) {
        pars.add(new Dir(temp));
    }
    temp = val.getLanguage();
    if (temp != null) {
        pars.add(new Language(temp));
    }
    temp = val.getSentBy();
    if (temp != null) {
        pars.add(new SentBy(temp));
    }
    Organizer prop = new Organizer(pars, val.getOrganizerUri());
    return prop;
}
Also used : Language(net.fortuna.ical4j.model.parameter.Language) BwOrganizer(org.bedework.calfacade.BwOrganizer) Organizer(net.fortuna.ical4j.model.property.Organizer) ParameterList(net.fortuna.ical4j.model.ParameterList) SentBy(net.fortuna.ical4j.model.parameter.SentBy) Cn(net.fortuna.ical4j.model.parameter.Cn) Dir(net.fortuna.ical4j.model.parameter.Dir) ScheduleStatus(net.fortuna.ical4j.model.parameter.ScheduleStatus)

Example 4 with Organizer

use of net.fortuna.ical4j.model.property.Organizer in project ofbiz-framework by apache.

the class ICalConverter method createOrganizer.

protected static Organizer createOrganizer(GenericValue partyValue, Map<String, Object> context) {
    Organizer organizer = new Organizer();
    loadPartyAssignment(organizer, partyValue, context);
    return organizer;
}
Also used : Organizer(net.fortuna.ical4j.model.property.Organizer)

Example 5 with Organizer

use of net.fortuna.ical4j.model.property.Organizer in project zm-mailbox by Zimbra.

the class DefaultTnefToICalendar method addAttendees.

/**
 * @param icalOutput
 * @param mimeMsg
 * @param partstat
 * @param replyWanted
 * @throws ParserException
 * @throws URISyntaxException
 * @throws IOException
 * @throws ParseException
 * @throws MessagingException
 */
private void addAttendees(ContentHandler icalOutput, MimeMessage mimeMsg, PartStat partstat, boolean replyWanted) throws ParserException, URISyntaxException, IOException, ParseException, MessagingException {
    // ATTENDEEs
    InternetAddress firstFromIA = null;
    String firstFromEmailAddr = null;
    // Use for SENT-BY if applicable
    String senderMailto = null;
    String senderCn = null;
    javax.mail.Address[] toRecips = null;
    javax.mail.Address[] ccRecips = null;
    javax.mail.Address[] bccRecips = null;
    javax.mail.Address[] msgFroms = null;
    javax.mail.Address msgSender = null;
    if (mimeMsg != null) {
        toRecips = mimeMsg.getRecipients(javax.mail.Message.RecipientType.TO);
        ccRecips = mimeMsg.getRecipients(javax.mail.Message.RecipientType.CC);
        bccRecips = mimeMsg.getRecipients(javax.mail.Message.RecipientType.BCC);
        msgFroms = mimeMsg.getFrom();
        msgSender = mimeMsg.getSender();
    }
    if (msgFroms != null) {
        if (msgFroms.length != 1) {
            sLog.debug(msgFroms.length + " From: recipients for " + method.getValue());
        }
        if (msgFroms.length >= 1) {
            firstFromIA = (InternetAddress) msgFroms[0];
            firstFromEmailAddr = firstFromIA.getAddress();
        }
        if (msgSender != null) {
            String senderAddr = msgSender.toString();
            if (msgSender instanceof InternetAddress) {
                InternetAddress senderIA = (InternetAddress) msgSender;
                senderAddr = senderIA.getAddress();
                senderCn = senderIA.getPersonal();
                if (!firstFromIA.equals(senderIA)) {
                    senderMailto = "Mailto:" + senderAddr;
                }
            }
        }
    }
    if (method.equals(Method.REPLY) || method.equals(Method.COUNTER)) {
        // from ATTENDEE to ORGANIZER
        if (toRecips != null) {
            if (toRecips.length != 1) {
                sLog.debug(toRecips.length + " To: recipients for " + method.getValue());
            }
            if (toRecips.length >= 1) {
                InternetAddress ia = (InternetAddress) toRecips[0];
                String email = ia.getAddress();
                String displayName = ia.getPersonal();
                icalOutput.startProperty(Property.ORGANIZER);
                icalOutput.propertyValue("Mailto:" + email);
                if (displayName != null) {
                    icalOutput.parameter(Parameter.CN, displayName);
                }
                icalOutput.endProperty(Property.ORGANIZER);
            }
        }
        if (firstFromEmailAddr != null) {
            String displayName = firstFromIA.getPersonal();
            icalOutput.startProperty(Property.ATTENDEE);
            icalOutput.propertyValue("Mailto:" + firstFromEmailAddr);
            if (displayName != null) {
                icalOutput.parameter(Parameter.CN, displayName);
            }
            icalOutput.parameter(Parameter.CUTYPE, CuType.INDIVIDUAL.getValue());
            if (partstat != null) {
                icalOutput.parameter(Parameter.PARTSTAT, partstat.getValue());
            }
            if (senderMailto != null) {
                icalOutput.parameter(Parameter.SENT_BY, senderMailto);
            }
            icalOutput.endProperty(Property.ATTENDEE);
        }
    } else {
        // ORGANIZER to ATTENDEEs - REQUEST or CANCEL
        InternetAddress organizerEmail = null;
        if (firstFromEmailAddr != null) {
            SentBy sentBy = null;
            Cn cn = null;
            if (senderMailto != null) {
                sentBy = new SentBy(senderMailto);
            }
            organizerEmail = firstFromIA;
            String displayName = firstFromIA.getPersonal();
            if ((displayName != null) && (!displayName.equals(firstFromEmailAddr))) {
                cn = new Cn(displayName);
            }
            Organizer organizer = new Organizer();
            organizer.setValue("Mailto:" + firstFromEmailAddr);
            if (cn != null) {
                organizer.getParameters().add(cn);
            }
            if (sentBy != null) {
                organizer.getParameters().add(sentBy);
            }
            IcalUtil.addProperty(icalOutput, organizer);
            if (icalType == ICALENDAR_TYPE.VEVENT) {
                // Assumption - ORGANIZER is an attendee and is attending.
                Attendee attendee = new Attendee("Mailto:" + firstFromEmailAddr);
                if (cn != null) {
                    attendee.getParameters().add(cn);
                }
                attendee.getParameters().add(CuType.INDIVIDUAL);
                attendee.getParameters().add(Role.REQ_PARTICIPANT);
                if (!method.equals(Method.CANCEL)) {
                    PartStat orgPartstat = PartStat.ACCEPTED;
                    if (ccRecips != null) {
                        for (Address a : ccRecips) {
                            InternetAddress ia = (InternetAddress) a;
                            if (organizerEmail.equals(ia)) {
                                orgPartstat = PartStat.TENTATIVE;
                                break;
                            }
                        }
                    }
                    attendee.getParameters().add(orgPartstat);
                }
                // Was including SENT-BY but probably not appropriate
                // for a request
                IcalUtil.addProperty(icalOutput, attendee);
            }
        }
        if (toRecips != null) {
            for (Address a : toRecips) {
                InternetAddress ia = (InternetAddress) a;
                if ((organizerEmail != null) && organizerEmail.equals(ia)) {
                    // No need to add the information twice
                    continue;
                }
                addAttendee(icalOutput, ia, Role.REQ_PARTICIPANT, CuType.INDIVIDUAL, partstat, replyWanted);
            }
        }
        if (ccRecips != null) {
            for (Address a : ccRecips) {
                InternetAddress ia = (InternetAddress) a;
                if ((organizerEmail != null) && organizerEmail.equals(ia)) {
                    // No need to add the information twice
                    continue;
                }
                addAttendee(icalOutput, ia, Role.OPT_PARTICIPANT, CuType.INDIVIDUAL, partstat, replyWanted);
            }
        }
        if (bccRecips != null) {
            for (Address a : bccRecips) {
                InternetAddress ia = (InternetAddress) a;
                addAttendee(icalOutput, ia, Role.NON_PARTICIPANT, CuType.RESOURCE, partstat, replyWanted);
            }
        }
    }
    if (senderMailto != null) {
        XProperty msOlkSender = new XProperty("X-MS-OLK-SENDER", senderMailto);
        if (senderCn != null) {
            Cn cn = new Cn(senderCn);
            msOlkSender.getParameters().add(cn);
        }
        IcalUtil.addProperty(icalOutput, msOlkSender);
    }
}
Also used : Address(javax.mail.Address) InternetAddress(javax.mail.internet.InternetAddress) XProperty(net.fortuna.ical4j.model.property.XProperty) Address(javax.mail.Address) InternetAddress(javax.mail.internet.InternetAddress) Organizer(net.fortuna.ical4j.model.property.Organizer) SentBy(net.fortuna.ical4j.model.parameter.SentBy) PartStat(net.fortuna.ical4j.model.parameter.PartStat) Cn(net.fortuna.ical4j.model.parameter.Cn) Attendee(net.fortuna.ical4j.model.property.Attendee)

Aggregations

Organizer (net.fortuna.ical4j.model.property.Organizer)8 Cn (net.fortuna.ical4j.model.parameter.Cn)6 DateTime (net.fortuna.ical4j.model.DateTime)4 VEvent (net.fortuna.ical4j.model.component.VEvent)4 Attendee (net.fortuna.ical4j.model.property.Attendee)4 Description (net.fortuna.ical4j.model.property.Description)4 Uid (net.fortuna.ical4j.model.property.Uid)4 Location (net.fortuna.ical4j.model.property.Location)3 URI (java.net.URI)2 ParameterList (net.fortuna.ical4j.model.ParameterList)2 TimeZone (net.fortuna.ical4j.model.TimeZone)2 TimeZoneRegistry (net.fortuna.ical4j.model.TimeZoneRegistry)2 SentBy (net.fortuna.ical4j.model.parameter.SentBy)2 Sequence (net.fortuna.ical4j.model.property.Sequence)2 SuppressLint (android.annotation.SuppressLint)1 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1