Search in sources :

Example 6 with ICalTimeZone

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

the class TestCalDav method testLondonTimeZoneCalledGMT.

@Test
public void testLondonTimeZoneCalledGMT() throws Exception {
    try (ByteArrayInputStream bais = new ByteArrayInputStream(LOTUS_NOTES_WITH_BAD_GMT_TZID.getBytes())) {
        ZVCalendar tzcal = ZCalendar.ZCalendarBuilder.build(bais, MimeConstants.P_CHARSET_UTF8);
        assertNotNull("tzcal", tzcal);
        ZComponent tzcomp = tzcal.getComponent(ICalTok.VTIMEZONE);
        assertNotNull("tzcomp", tzcomp);
        ICalTimeZone tz = ICalTimeZone.fromVTimeZone(tzcomp, false, /* skipLookup */
        ICalTimeZone.TZID_NAME_ASSIGNMENT_BEHAVIOR.KEEP_IF_DOESNT_CLASH);
        assertEquals("ID that London Timezone originally with TZID=GMT maps to", "Europe/London", tz.getID());
        assertEquals("that London Timezone originally with TZID=GMT maps to this daylightTzname", "GMT/BST", tz.getDaylightTzname());
    }
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) ZVCalendar(com.zimbra.common.calendar.ZCalendar.ZVCalendar) ByteArrayInputStream(java.io.ByteArrayInputStream) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone) Test(org.junit.Test)

Example 7 with ICalTimeZone

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

the class TestCalDav method simpleEvent.

public byte[] simpleEvent(Account organizer) 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, 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, "Simple Event"));
    vevent.addProperty(new ZProperty(ICalTok.UID, "d1102-42a7-4283-b025-3376dabe53b3"));
    vevent.addProperty(new ZProperty(ICalTok.STATUS, ICalTok.CONFIRMED.toString()));
    vevent.addProperty(new ZProperty(ICalTok.SEQUENCE, "1"));
    // vevent.addProperty(organizer(organizer));
    vcal.addComponent(vevent);
    return zvcalendarToBytes(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) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 8 with ICalTimeZone

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

the class SetCalendarItem method deserializeSetCalendarItemData.

private Mailbox.SetCalendarItemData deserializeSetCalendarItemData(RedoLogInput in, boolean attachmentIndexingEnabled) throws IOException, MessagingException {
    Mailbox.SetCalendarItemData toRet = new Mailbox.SetCalendarItemData();
    int mboxId = getMailboxId();
    try {
        // keep this for backward compatibility with when SetCalendarItemData
        in.readBoolean();
        // used to have mForce field
        ICalTimeZone localTz = Util.decodeTimeZoneFromMetadata(new Metadata(in.readUTF()));
        toRet.invite = Invite.decodeMetadata(mboxId, new Metadata(in.readUTF()), null, localTz);
        boolean hasPm;
        if (getVersion().atLeast(1, 24)) {
            hasPm = in.readBoolean();
        } else {
            hasPm = true;
        }
        // If version is earlier than 1.24, we always have ParsedMessage array.
        if (hasPm) {
            long receivedDate = in.readLong();
            int dataLen = in.readInt();
            byte[] rawPmData = new byte[dataLen];
            in.readFully(rawPmData, 0, dataLen);
            InputStream is = new SharedByteArrayInputStream(rawPmData);
            MimeMessage mm = new Mime.FixedMimeMessage(JMSession.getSession(), is);
            toRet.message = new ParsedMessage(mm, receivedDate, attachmentIndexingEnabled);
        }
    } catch (ServiceException ex) {
        ex.printStackTrace();
        throw new IOException("Cannot read serialized entry for CreateInvite " + ex.toString());
    }
    return toRet;
}
Also used : SharedByteArrayInputStream(javax.mail.util.SharedByteArrayInputStream) InputStream(java.io.InputStream) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) Metadata(com.zimbra.cs.mailbox.Metadata) IOException(java.io.IOException) SharedByteArrayInputStream(javax.mail.util.SharedByteArrayInputStream) Mailbox(com.zimbra.cs.mailbox.Mailbox) ServiceException(com.zimbra.common.service.ServiceException) MimeMessage(javax.mail.internet.MimeMessage) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 9 with ICalTimeZone

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

the class FixCalendarItemTZ method deserializeData.

@Override
protected void deserializeData(RedoLogInput in) throws IOException {
    mId = in.readInt();
    int numReplacements = in.readInt();
    if (numReplacements > 0) {
        mReplacementMap = new HashMap<String, ICalTimeZone>(numReplacements);
        for (int i = 0; i < numReplacements; i++) {
            String tzid = in.readUTF();
            String newTZMeta = in.readUTF();
            try {
                ICalTimeZone newTZ = null;
                if (newTZMeta != null)
                    newTZ = Util.decodeTimeZoneFromMetadata(new Metadata(newTZMeta));
                mReplacementMap.put(tzid, newTZ);
            } catch (ServiceException e) {
                IOException ioe = new IOException("Error deserializing timezone");
                ioe.initCause(e);
                throw ioe;
            }
        }
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) Metadata(com.zimbra.cs.mailbox.Metadata) IOException(java.io.IOException) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone)

Example 10 with ICalTimeZone

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

the class ICalReply method serializeData.

@Override
protected void serializeData(RedoLogOutput out) throws IOException {
    ICalTimeZone localTz = mInvite.getTimeZoneMap().getLocalTimeZone();
    out.writeUTF(Util.encodeAsMetadata(localTz).toString());
    out.writeUTF(Invite.encodeMetadata(mInvite).toString());
    out.writeUTF(mSender);
}
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