Search in sources :

Example 56 with ICalTimeZone

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

the class Util method newICalTimeZone.

private static ICalTimeZone newICalTimeZone(String tzId, Metadata meta) throws ServiceException {
    int standardOffset = (int) meta.getLong(FN_STANDARD_OFFSET, 0);
    String dayToStdDtStart = meta.get(FN_DAYTOSTD_DTSTART, null);
    String dayToStdRule = meta.get(FN_DAYTOSTD_RULE, null);
    String standardTzname = meta.get(FN_STANDARD_TZNAME, null);
    int daylightOffset = (int) meta.getLong(FN_DAYLIGHT_OFFSET, 0);
    String stdToDayDtStart = meta.get(FN_STDTODAY_DTSTART, ICalTimeZone.DEFAULT_DTSTART);
    String stdToDayRule = meta.get(FN_STDTODAY_RULE, null);
    String daylightTzname = meta.get(FN_DAYLIGHT_TZNAME, null);
    ICalTimeZone tz = new ICalTimeZone(tzId, standardOffset, dayToStdDtStart, dayToStdRule, standardTzname, daylightOffset, stdToDayDtStart, stdToDayRule, daylightTzname);
    tz.initFromICalData(true);
    return tz;
}
Also used : ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 57 with ICalTimeZone

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

the class Invite method createFromCalendar.

private static void createFromCalendar(List<Invite> toAdd, Account account, String fragment, ZVCalendar cal, boolean sentByMe, Mailbox mbx, int mailItemId, boolean continueOnError, InviteVisitor visitor) throws ServiceException {
    String method = cal.getPropVal(ICalTok.METHOD, ICalTok.PUBLISH.toString());
    // process the TIMEZONE's first: everything depends on them being there...
    TimeZoneMap tzmap = new TimeZoneMap(Util.getAccountTimeZone(account));
    Map<String, String> tzidRenames = Maps.newHashMap();
    List<ZComponent> components = Lists.newArrayList(cal.getComponentIterator());
    for (ZComponent comp : components) {
        if (ICalTok.VTIMEZONE.equals(comp.getTok())) {
            ICalTimeZone tz = ICalTimeZone.fromVTimeZone(comp, false, /* skipLookup */
            ICalTimeZone.TZID_NAME_ASSIGNMENT_BEHAVIOR.KEEP_IF_DOESNT_CLASH);
            tzmap.add(tz);
            String origTZID = comp.getPropVal(ICalTok.TZID, null);
            if ((null != origTZID) && (origTZID != tz.getID())) {
                tzidRenames.put(origTZID, tz.getID());
            }
        }
    }
    adjustTZIDnames(components, tzidRenames);
    createFromCalendar(toAdd, account, fragment, method, tzmap, cal.getComponentIterator(), sentByMe, mbx, mailItemId, continueOnError, visitor);
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) TimeZoneMap(com.zimbra.common.calendar.TimeZoneMap) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 58 with ICalTimeZone

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

the class SetCalendarItem method serializeSetCalendarItemData.

private void serializeSetCalendarItemData(RedoLogOutput out, Mailbox.SetCalendarItemData data) throws IOException {
    // keep this for backward compatibility with when SetCalendarItemData
    out.writeBoolean(true);
    // used to have mForce field
    ICalTimeZone localTz = data.invite.getTimeZoneMap().getLocalTimeZone();
    out.writeUTF(Util.encodeAsMetadata(localTz).toString());
    out.writeUTF(Invite.encodeMetadata(data.invite).toString());
    if (getVersion().atLeast(1, 24)) {
        out.writeBoolean(data.message != null);
    }
    // If version is earlier than 1.24, we always have non-null data.mPm.
    if (data.message != null) {
        out.writeLong(data.message.getReceivedDate());
        byte[] pmData = data.message.getRawData();
        out.writeInt(pmData.length);
        out.write(pmData);
    }
}
Also used : ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 59 with ICalTimeZone

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

the class FixCalendarItemTZ method serializeData.

@Override
protected void serializeData(RedoLogOutput out) throws IOException {
    out.writeInt(mId);
    if (mReplacementMap != null) {
        out.writeInt(mReplacementMap.size());
        for (Entry<String, ICalTimeZone> entry : mReplacementMap.entrySet()) {
            String tzid = entry.getKey();
            ICalTimeZone newTZ = entry.getValue();
            String newTZMeta = null;
            if (newTZ != null)
                newTZMeta = Util.encodeAsMetadata(newTZ).toString();
            out.writeUTF(tzid);
            out.writeUTF(newTZMeta);
        }
    } else {
        // map size == 0
        out.writeInt(0);
    }
}
Also used : ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 60 with ICalTimeZone

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

the class FixCalendarItemTZ method getPrintableData.

@Override
protected String getPrintableData() {
    StringBuilder sb = new StringBuilder("id=");
    sb.append(mId);
    if (mReplacementMap != null) {
        sb.append(", replacementMap=[");
        for (Entry<String, ICalTimeZone> entry : mReplacementMap.entrySet()) {
            String tzid = entry.getKey();
            ICalTimeZone newTZ = entry.getValue();
            sb.append("\n");
            sb.append("oldTZID=\"").append(tzid).append("\"\n==> newTZ: ").append(newTZ.toString()).append(",");
        }
        sb.append("]");
    }
    return sb.toString();
}
Also used : ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Aggregations

ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)62 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)17 ZComponent (com.zimbra.common.calendar.ZCalendar.ZComponent)14 TimeZoneMap (com.zimbra.common.calendar.TimeZoneMap)12 Element (com.zimbra.common.soap.Element)11 ZVCalendar (com.zimbra.common.calendar.ZCalendar.ZVCalendar)10 ServiceException (com.zimbra.common.service.ServiceException)10 ArrayList (java.util.ArrayList)10 ZProperty (com.zimbra.common.calendar.ZCalendar.ZProperty)8 Account (com.zimbra.cs.account.Account)8 Invite (com.zimbra.cs.mailbox.calendar.Invite)8 Mailbox (com.zimbra.cs.mailbox.Mailbox)7 IOException (java.io.IOException)7 Metadata (com.zimbra.cs.mailbox.Metadata)6 ItemId (com.zimbra.cs.service.util.ItemId)6 ParseException (java.text.ParseException)6 OperationContext (com.zimbra.cs.mailbox.OperationContext)5 RecurId (com.zimbra.cs.mailbox.calendar.RecurId)5 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)5 GregorianCalendar (java.util.GregorianCalendar)5