Search in sources :

Example 36 with ZProperty

use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.

the class CalendarUser method toProperty.

public ZProperty toProperty() throws ServiceException {
    String addr = getAddress();
    if (addr != null && addr.indexOf(':') < 0)
        addr = "mailto:" + addr;
    ZProperty prop = new ZProperty(getPropertyName(), addr);
    setProperty(prop);
    // x-param
    for (ZParameter xparam : mXParams) {
        prop.addParameter(xparam);
    }
    return prop;
}
Also used : ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ZParameter(com.zimbra.common.calendar.ZCalendar.ZParameter)

Example 37 with ZProperty

use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.

the class TextCalendarHandler method analyze.

private void analyze(boolean needCal) throws MimeHandlerException {
    if (mContent != null)
        return;
    DataSource source = getDataSource();
    if (source == null) {
        mContent = "";
        return;
    }
    InputStream is = null;
    try {
        is = source.getInputStream();
        String charset = MimeConstants.P_CHARSET_UTF8;
        String ctStr = source.getContentType();
        if (ctStr != null) {
            String cs = Mime.getCharset(ctStr);
            if (cs != null)
                charset = cs;
        }
        if (needCal) {
            miCalendar = ZCalendarBuilder.build(is, charset);
            StringBuilder buf = new StringBuilder(1024);
            int maxLength = MimeHandlerManager.getIndexedTextLimit();
            for (Iterator<ZComponent> compIter = miCalendar.getComponentIterator(); compIter.hasNext() && buf.length() < maxLength; ) {
                ZComponent comp = compIter.next();
                for (Iterator<ZProperty> propIter = comp.getPropertyIterator(); propIter.hasNext(); ) {
                    ZProperty prop = propIter.next();
                    if (sIndexedProps.contains(prop.getName())) {
                        String value = prop.getValue();
                        if (value != null && value.length() > 0) {
                            if (buf.length() > 0)
                                buf.append(' ');
                            buf.append(value);
                        }
                    }
                }
            }
            mContent = buf.toString();
        } else {
            IcsParseHandler handler = new IcsParseHandler();
            ZCalendarBuilder.parse(is, charset, handler);
            mContent = handler.getContent();
        }
    } catch (Exception e) {
        mContent = "";
        ZimbraLog.index.warn("error reading text/calendar mime part", e);
        throw new MimeHandlerException(e);
    } finally {
        ByteUtil.closeStream(is);
    }
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) MimeHandlerException(com.zimbra.cs.mime.MimeHandlerException) InputStream(java.io.InputStream) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ParserException(net.fortuna.ical4j.data.ParserException) MimeHandlerException(com.zimbra.cs.mime.MimeHandlerException) DataSource(javax.activation.DataSource)

Example 38 with ZProperty

use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.

the class TestCalDav method makeFreeBusyRequestIcal.

public String makeFreeBusyRequestIcal(Account organizer, List<Account> attendees, Date start, Date end) throws IOException {
    ZVCalendar vcal = new ZVCalendar();
    vcal.addVersionAndProdId();
    vcal.addProperty(new ZProperty(ICalTok.METHOD, ICalTok.REQUEST.toString()));
    ZComponent vfreebusy = new ZComponent(ICalTok.VFREEBUSY);
    ParsedDateTime dtstart = ParsedDateTime.fromUTCTime(start.getTime());
    vfreebusy.addProperty(dtstart.toProperty(ICalTok.DTSTART, false));
    ParsedDateTime dtend = ParsedDateTime.fromUTCTime(end.getTime());
    vfreebusy.addProperty(dtend.toProperty(ICalTok.DTEND, false));
    vfreebusy.addProperty(new ZProperty(ICalTok.DTSTAMP, "20140108T224700Z"));
    vfreebusy.addProperty(new ZProperty(ICalTok.UID, "d123f102-42a7-4283-b025-3376dabe53b3"));
    vfreebusy.addProperty(organizer(organizer));
    for (Account attendee : attendees) {
        vfreebusy.addProperty(new ZProperty(ICalTok.ATTENDEE, "mailto:" + attendee.getName()));
    }
    vcal.addComponent(vfreebusy);
    StringWriter calWriter = new StringWriter();
    vcal.toICalendar(calWriter);
    String icalString = calWriter.toString();
    Closeables.closeQuietly(calWriter);
    return icalString;
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) Account(com.zimbra.cs.account.Account) ZVCalendar(com.zimbra.common.calendar.ZCalendar.ZVCalendar) StringWriter(java.io.StringWriter) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ParsedDateTime(com.zimbra.common.calendar.ParsedDateTime)

Example 39 with ZProperty

use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.

the class TestCalDav method exampleCancelIcal.

public String exampleCancelIcal(Account organizer, Account attendee1, Account attendee2) throws IOException {
    ZVCalendar vcal = new ZVCalendar();
    vcal.addVersionAndProdId();
    vcal.addProperty(new ZProperty(ICalTok.METHOD, ICalTok.CANCEL.toString()));
    ICalTimeZone tz = ICalTimeZone.lookupByTZID("Africa/Harare");
    vcal.addComponent(tz.newToVTimeZone());
    ZComponent vevent = new ZComponent(ICalTok.VEVENT);
    ParsedDateTime dtstart = parsedDateTime(2020, java.util.Calendar.APRIL, 1, 9, 0, tz);
    vevent.addProperty(dtstart.toProperty(ICalTok.DTSTART, false));
    ParsedDateTime dtend = parsedDateTime(2020, java.util.Calendar.APRIL, 1, 13, 0, tz);
    vevent.addProperty(dtend.toProperty(ICalTok.DTEND, false));
    vevent.addProperty(new ZProperty(ICalTok.DTSTAMP, "20140108T224700Z"));
    vevent.addProperty(new ZProperty(ICalTok.SUMMARY, "Meeting for fun"));
    vevent.addProperty(new ZProperty(ICalTok.UID, "d123f102-42a7-4283-b025-3376dabe53b3"));
    vevent.addProperty(new ZProperty(ICalTok.STATUS, ICalTok.CANCELLED.toString()));
    vevent.addProperty(new ZProperty(ICalTok.SEQUENCE, "1"));
    vevent.addProperty(organizer(organizer));
    vevent.addProperty(attendee(attendee1, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.NEEDS_ACTION));
    vevent.addProperty(attendee(attendee2, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.NEEDS_ACTION));
    vcal.addComponent(vevent);
    StringWriter calWriter = new StringWriter();
    vcal.toICalendar(calWriter);
    String icalString = calWriter.toString();
    Closeables.closeQuietly(calWriter);
    return icalString;
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) ZVCalendar(com.zimbra.common.calendar.ZCalendar.ZVCalendar) StringWriter(java.io.StringWriter) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ParsedDateTime(com.zimbra.common.calendar.ParsedDateTime) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 40 with ZProperty

use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.

the class TestCalDav method simpleMeeting.

public ZVCalendar simpleMeeting(Account organizer, List<MailTarget> attendees, String uid, String seq, int startHour) throws IOException {
    ZVCalendar vcal = new ZVCalendar();
    vcal.addVersionAndProdId();
    vcal.addProperty(new ZProperty(ICalTok.METHOD, ICalTok.PUBLISH.toString()));
    ICalTimeZone tz = ICalTimeZone.lookupByTZID("Africa/Harare");
    vcal.addComponent(tz.newToVTimeZone());
    ZComponent vevent = new ZComponent(ICalTok.VEVENT);
    ParsedDateTime dtstart = parsedDateTime(2020, java.util.Calendar.APRIL, 1, startHour, 0, tz);
    vevent.addProperty(dtstart.toProperty(ICalTok.DTSTART, false));
    ParsedDateTime dtend = parsedDateTime(2020, java.util.Calendar.APRIL, 1, startHour + 4, 0, tz);
    vevent.addProperty(dtend.toProperty(ICalTok.DTEND, false));
    vevent.addProperty(new ZProperty(ICalTok.DTSTAMP, "20150108T224700Z"));
    vevent.addProperty(new ZProperty(ICalTok.SUMMARY, "Simple Meeting"));
    vevent.addProperty(new ZProperty(ICalTok.UID, uid));
    vevent.addProperty(new ZProperty(ICalTok.STATUS, ICalTok.CONFIRMED.toString()));
    vevent.addProperty(new ZProperty(ICalTok.SEQUENCE, seq));
    vevent.addProperty(organizer(organizer));
    for (MailTarget att : attendees) {
        if (att.getId().equals(organizer.getId())) {
            vevent.addProperty(attendee(att, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.ACCEPTED));
        } else {
            vevent.addProperty(attendee(att, ICalTok.REQ_PARTICIPANT, ICalTok.INDIVIDUAL, ICalTok.NEEDS_ACTION));
        }
    }
    vcal.addComponent(vevent);
    return vcal;
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) ZVCalendar(com.zimbra.common.calendar.ZCalendar.ZVCalendar) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ParsedDateTime(com.zimbra.common.calendar.ParsedDateTime) MailTarget(com.zimbra.cs.account.MailTarget) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Aggregations

ZProperty (com.zimbra.common.calendar.ZCalendar.ZProperty)49 ZParameter (com.zimbra.common.calendar.ZCalendar.ZParameter)19 ZComponent (com.zimbra.common.calendar.ZCalendar.ZComponent)18 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)13 ArrayList (java.util.ArrayList)12 Account (com.zimbra.cs.account.Account)10 ICalTok (com.zimbra.common.calendar.ZCalendar.ICalTok)9 ZVCalendar (com.zimbra.common.calendar.ZCalendar.ZVCalendar)9 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)8 Invite (com.zimbra.cs.mailbox.calendar.Invite)8 ParsedDuration (com.zimbra.common.calendar.ParsedDuration)7 ZOrganizer (com.zimbra.cs.mailbox.calendar.ZOrganizer)7 TimeZoneMap (com.zimbra.common.calendar.TimeZoneMap)6 ServiceException (com.zimbra.common.service.ServiceException)6 ParseException (java.text.ParseException)6 IRecurrence (com.zimbra.cs.mailbox.calendar.Recurrence.IRecurrence)5 AccountAddressMatcher (com.zimbra.cs.util.AccountUtil.AccountAddressMatcher)5 Element (com.zimbra.common.soap.Element)4 IOException (java.io.IOException)4 Geo (com.zimbra.common.calendar.Geo)3