Search in sources :

Example 46 with ZProperty

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

the class Invite method newToICalendar.

public ZVCalendar newToICalendar(boolean useOutlookCompatMode, boolean includePrivateData) throws ServiceException {
    ZVCalendar vcal = new ZVCalendar();
    vcal.addVersionAndProdId();
    vcal.addProperty(new ZProperty(ICalTok.METHOD, mMethod.toString()));
    // timezones
    if (!isAllDayEvent() || useOutlookCompatMode) {
        // Don't write any VTIMEZONE for all-day appointments.
        for (Iterator<ICalTimeZone> iter = mTzMap.tzIterator(); iter.hasNext(); ) {
            ICalTimeZone cur = iter.next();
            vcal.addComponent(cur.newToVTimeZone());
        }
    }
    vcal.addComponent(newToVComponent(useOutlookCompatMode, includePrivateData));
    return vcal;
}
Also used : ZVCalendar(com.zimbra.common.calendar.ZCalendar.ZVCalendar) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 47 with ZProperty

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

the class Invite method toVComponents.

public static ZComponent[] toVComponents(Invite[] invites, boolean includePrivateData, boolean useOutlookCompatAllDayEvents, boolean convertCanceledInstancesToExdates, boolean includeAttaches) throws ServiceException {
    List<ZComponent> comps = new ArrayList<ZComponent>(invites.length);
    if (!convertCanceledInstancesToExdates || invites.length <= 1) {
        for (Invite inv : invites) {
            ZComponent comp = inv.newToVComponent(useOutlookCompatAllDayEvents, includePrivateData, includeAttaches);
            comps.add(comp);
        }
    } else {
        // Activate the hack that converts standalone VEVENT/VTODO components with STATUS:CANCELLED
        // into EXDATEs on the series component. (bug 36434)
        Invite seriesInv = null;
        ZComponent seriesComp = null;
        // Find the series invite.
        for (Invite inv : invites) {
            if (inv.isRecurrence()) {
                ZComponent comp = inv.newToVComponent(useOutlookCompatAllDayEvents, includePrivateData, includeAttaches);
                seriesComp = comp;
                comps.add(seriesComp);
                seriesInv = inv;
                break;
            }
        }
        for (Invite inv : invites) {
            if (inv != seriesInv) {
                // We already handled the series invite in the previous loop.
                if (inv.hasRecurId() && inv.isCancel()) {
                    // as a standalone component.
                    if (seriesComp != null) {
                        RecurId rid = inv.getRecurId();
                        ZProperty ridProp = rid.toProperty(false);
                        // EXDATE and RECURRENCE-ID have same value types and parameter list.  Just copy over.
                        ZProperty exdateProp = new ZProperty(ICalTok.EXDATE, ridProp.getValue());
                        for (Iterator<ZParameter> paramsIter = ridProp.parameterIterator(); paramsIter.hasNext(); ) {
                            ZParameter param = paramsIter.next();
                            exdateProp.addParameter(param);
                        }
                        seriesComp.addProperty(exdateProp);
                    } else {
                        // But if there is no series component, let the canceled instance be a component.
                        ZComponent comp = inv.newToVComponent(useOutlookCompatAllDayEvents, includePrivateData, includeAttaches);
                        if (comp != null)
                            comps.add(comp);
                    }
                } else {
                    // Modified instances are added as standalone components.
                    ZComponent comp = inv.newToVComponent(useOutlookCompatAllDayEvents, includePrivateData, includeAttaches);
                    if (comp != null)
                        comps.add(comp);
                }
            }
        }
    }
    return comps.toArray(new ZComponent[0]);
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) ArrayList(java.util.ArrayList) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ZParameter(com.zimbra.common.calendar.ZCalendar.ZParameter)

Example 48 with ZProperty

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

the class RecurId method toProperty.

public ZProperty toProperty(boolean useOutlookCompatMode) {
    //        ZProperty toRet = new ZProperty(ICalTok.RECURRENCE_ID, toString());
    //        return toRet;
    ZProperty toRet = mDateTime.toProperty(ICalTok.RECURRENCE_ID, useOutlookCompatMode);
    String range = getRangeStr();
    if (range != null)
        toRet.addParameter(new ZParameter(ICalTok.RANGE, range));
    return toRet;
}
Also used : ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ZParameter(com.zimbra.common.calendar.ZCalendar.ZParameter)

Example 49 with ZProperty

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

the class Invite method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{ ");
    sb.append("mboxid: ").append(this.mMailboxId);
    sb.append(", mailitem: ").append(this.mMailItemId);
    sb.append(", compnum: ").append(this.mComponentNum);
    sb.append(", uid: ").append(this.mUid);
    sb.append(", status: ").append(getStatus());
    sb.append(", partStat: ").append(getPartStat());
    sb.append(", rsvp: ").append(getRsvp());
    sb.append(", freeBusy: ").append(mFreeBusy);
    sb.append(", transp: ").append(getTransparency());
    sb.append(", class: ").append(getClassProp());
    sb.append(", classSetByMe: ").append(classPropSetByMe());
    sb.append(", sentByMe: ").append(sentByMe());
    sb.append(", start: ").append(this.mStart);
    sb.append(", end: ").append(this.mEnd);
    sb.append(", duration: ").append(this.mDuration);
    sb.append(", organizer: ");
    if (hasOrganizer())
        sb.append(getOrganizer().getAddress());
    else
        sb.append("(not specified)");
    sb.append(", name: ").append(this.mName);
    sb.append(", location: ").append(this.mLocation);
    sb.append(", allDay: ").append(isAllDayEvent());
    sb.append(", otherAts: ").append(hasOtherAttendees());
    sb.append(", hasAlarm: ").append(hasAlarm());
    sb.append(", isRecur: ").append(isRecurrence());
    sb.append(", recurId: ").append(getRecurId());
    sb.append(", DTStamp: ").append(mDTStamp);
    sb.append(", lastMod: ").append(mLastModified);
    sb.append(", mSeqNo ").append(mSeqNo);
    sb.append(", mLastFullSeqNo ").append(mLastFullSeqNo);
    if (isDraft())
        sb.append(", draft: ").append(true);
    if (isNeverSent())
        sb.append(", neverSent: ").append(true);
    for (Alarm alarm : mAlarms) {
        sb.append(", alarm: ").append(alarm.toString());
    }
    for (ZProperty xprop : mXProps) {
        sb.append(", ").append(xprop.toString());
    }
    sb.append("}");
    return sb.toString();
}
Also used : ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty)

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