use of com.zimbra.cs.mailbox.Metadata in project zm-mailbox by Zimbra.
the class SetCalendarItem method deserializeData.
@Override
protected void deserializeData(RedoLogInput in) throws IOException {
mFolderId = in.readInt();
if (getVersion().atLeast(1, 0)) {
in.readShort();
}
mCalendarItemId = in.readInt();
if (getVersion().atLeast(1, 1)) {
mCalendarItemPartStat = in.readUTF();
}
if (getVersion().atLeast(1, 2)) {
mAttachmentIndexingEnabled = in.readBoolean();
} else {
mAttachmentIndexingEnabled = false;
}
if (getVersion().atLeast(1, 11)) {
mFlags = in.readInt();
if (getVersion().atLeast(1, 33)) {
mTags = in.readUTFArray();
} else {
mTagBitmask = in.readLong();
}
}
Invite tzmapInv = null;
boolean hasDefaultInvite = true;
if (getVersion().atLeast(1, 17)) {
hasDefaultInvite = in.readBoolean();
}
try {
if (hasDefaultInvite) {
mDefaultInvite = deserializeSetCalendarItemData(in, mAttachmentIndexingEnabled);
tzmapInv = mDefaultInvite.invite;
}
int numExceptions = in.readInt();
if (numExceptions > 0) {
mExceptions = new Mailbox.SetCalendarItemData[numExceptions];
for (int i = 0; i < numExceptions; i++) {
mExceptions[i] = deserializeSetCalendarItemData(in, mAttachmentIndexingEnabled);
if (tzmapInv == null) {
tzmapInv = mExceptions[i].invite;
}
}
}
} catch (MessagingException ex) {
ex.printStackTrace();
throw new IOException("Cannot read serialized entry for SetCalendarItem" + ex.toString());
}
if (getVersion().atLeast(1, 15)) {
int num = in.readInt();
if (num > 10000 && !getVersion().atLeast(1, 24)) {
// exception.
throw new IOException("Replies count > 10000. Looks like a corrupted pre-v1.24 redo entry. Skipping");
}
if (num < 0) {
// no replies list
mReplies = null;
} else {
mReplies = new ArrayList<ReplyInfo>(num);
TimeZoneMap tzMap = tzmapInv.getTimeZoneMap();
for (int i = 0; i < num; i++) {
String data = in.readUTF();
try {
Metadata md = new Metadata(data);
ReplyInfo reply = ReplyInfo.decodeFromMetadata(md, tzMap);
mReplies.add(reply);
} catch (ServiceException e) {
IOException ioe = new IOException("Cannot read serialized entry for ReplyInfo");
ioe.initCause(e);
throw ioe;
}
}
}
}
if (getVersion().atLeast(1, 21)) {
mNextAlarm = in.readLong();
}
}
use of com.zimbra.cs.mailbox.Metadata 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.cs.mailbox.Metadata 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.cs.mailbox.Metadata in project zm-mailbox by Zimbra.
the class InstanceData method encodeMetadata.
Metadata encodeMetadata() {
Metadata meta = new Metadata();
meta.put(FN_RECURRENCE_ID_Z, mRecurIdZ);
if (mDtStart != null)
meta.put(FN_DTSTART, mDtStart.longValue());
if (mDuration != null)
meta.put(FN_DURATION, mDuration.longValue());
if (mAlarmAt != null)
meta.put(FN_ALARM_AT, mAlarmAt.longValue());
if (mTZOffset != null)
meta.put(FN_TZOFFSET, mTZOffset.longValue());
meta.put(FN_PARTSTAT, mPartStat);
meta.put(FN_FREEBUSY_ACTUAL, mFreeBusyActual);
meta.put(FN_PERCENT_COMPLETE, mPercentComplete);
return meta;
}
use of com.zimbra.cs.mailbox.Metadata in project zm-mailbox by Zimbra.
the class FileStore method saveCalendarData.
static void saveCalendarData(int mboxId, CalendarData calData) throws ServiceException {
File file = getCalFolderFile(mboxId, calData.getFolderId());
try {
FileUtil.ensureDirExists(file.getParentFile());
} catch (IOException e) {
throw ServiceException.FAILURE("Unable to create directory " + file.getParentFile().getAbsolutePath(), e);
}
Metadata meta = new Metadata();
meta.put(FN_VERSION, CURRENT_VERSION);
meta.put(FN_MODSEQ, calData.getModSeq());
meta.put(FN_CALDATA, calData.encodeMetadata());
String encoded = meta.toString();
saveToFile(file, encoded);
}
Aggregations