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());
}
}
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);
}
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;
}
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;
}
}
}
}
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);
}
Aggregations