use of com.zimbra.cs.mailbox.calendar.Invite in project zm-mailbox by Zimbra.
the class UrlNamespace method getCalendarItemForMessage.
private static DavResource getCalendarItemForMessage(DavContext ctxt, Message msg) throws ServiceException {
Mailbox mbox = msg.getMailbox();
if (msg.isInvite() && msg.hasCalendarItemInfos()) {
Message.CalendarItemInfo calItemInfo = msg.getCalendarItemInfo(0);
try {
Invite invite = calItemInfo.getInvite();
if (invite == null && calItemInfo.calItemCreated()) {
// Pre-6.0 data
CalendarItem item = mbox.getCalendarItemById(ctxt.getOperationContext(), calItemInfo.getCalendarItemId());
invite = calItemInfo.getInvite();
int compNum = calItemInfo.getComponentNo();
invite = item.getInvite(msg.getId(), compNum);
}
if (invite != null) {
String path = CalendarObject.CalendarPath.generate(ctxt, msg.getPath(), invite.getUid(), mbox.getId(), msg.getId(), msg.getId());
return new CalendarObject.ScheduleMessage(ctxt, path, ctxt.getUser(), invite, msg);
}
} catch (MailServiceException.NoSuchItemException e) {
// the appt must have been cancelled or deleted.
// bug 26315
}
}
return null;
}
use of com.zimbra.cs.mailbox.calendar.Invite in project zm-mailbox by Zimbra.
the class CalendarItem method decodeMetadata.
@Override
void decodeMetadata(Metadata meta) throws ServiceException {
super.decodeMetadata(meta);
mUid = Invite.fixupIfOutlookUid(meta.get(Metadata.FN_UID, null));
mInvites = new ArrayList<Invite>();
ICalTimeZone accountTZ = Util.getAccountTimeZone(getMailbox().getAccount());
if (meta.containsKey(Metadata.FN_TZMAP)) {
try {
Set<String> tzids = new HashSet<String>();
mTzMap = Util.decodeFromMetadata(meta.getMap(Metadata.FN_TZMAP), accountTZ);
// appointment/task start and end
mStartTime = meta.getLong(Metadata.FN_CALITEM_START, 0);
mEndTime = meta.getLong(Metadata.FN_CALITEM_END, 0);
// invite ID's
long numComp = meta.getLong(Metadata.FN_NUM_COMPONENTS);
for (int i = 0; i < numComp; i++) {
Metadata md = meta.getMap(Metadata.FN_INV + i);
Invite inv = Invite.decodeMetadata(getMailboxId(), md, this, accountTZ);
mInvites.add(inv);
tzids.addAll(inv.getReferencedTZIDs());
mTzMap.add(inv.getTimeZoneMap());
}
Metadata metaRecur = meta.getMap(FN_CALITEM_RECURRENCE, true);
if (metaRecur != null) {
mRecurrence = Recurrence.decodeMetadata(metaRecur, mTzMap);
if (mRecurrence != null) {
tzids.addAll(Recurrence.getReferencedTZIDs(mRecurrence));
}
}
if (meta.containsKey(Metadata.FN_REPLY_LIST)) {
mReplyList = ReplyList.decodeFromMetadata(meta.getMap(Metadata.FN_REPLY_LIST), mTzMap);
// Get all TZIDs referenced by replies.
for (ReplyInfo ri : mReplyList.mReplies) {
if (ri.mRecurId != null) {
ParsedDateTime dt = ri.mRecurId.getDt();
if (dt != null && dt.hasTime()) {
ICalTimeZone tz = dt.getTimeZone();
if (tz != null)
tzids.add(tz.getID());
}
}
}
} else {
mReplyList = new ReplyList();
}
Metadata metaAlarmData = meta.getMap(Metadata.FN_ALARM_DATA, true);
if (metaAlarmData != null)
mAlarmData = AlarmData.decodeMetadata(metaAlarmData);
// Reduce tzmap to minimal set of TZIDs referenced by invites, recurrence, and replies.
mTzMap.reduceTo(tzids);
} catch (ServiceException se) {
if (ServiceException.INVALID_REQUEST.equals(se.getCode()) && this.getChangeDate() < new GregorianCalendar(2006, 0, 1).getTimeInMillis()) {
//could have been metadata version 3, 4 or 5.
//All of those versions have FN_TZMAP, but different format for other fields
//these are edge cases that should only appear in dev/df/cf
mStartTime = 0;
mEndTime = 0;
} else {
throw se;
}
}
} else {
//version 2 or earlier
mStartTime = 0;
mEndTime = 0;
}
}
use of com.zimbra.cs.mailbox.calendar.Invite in project zm-mailbox by Zimbra.
the class CalendarItem method requirePrivateCheck.
// If we're adding a private invite, we must make sure the authenticated user has permission to
// access private data. If we're adding a public invite but the appointment currently has
// some private data, private access permission is not needed as long as the instance(s) being
// updated aren't currently private.
private boolean requirePrivateCheck(Invite newInvite) {
if (!newInvite.isPublic()) {
// adding a private invite
return true;
}
if (!isPublic()) {
RecurId rid = newInvite.getRecurId();
// If canceling whole series, requester must have private access permission.
if (rid == null && newInvite.isCancel())
return true;
Invite current = getInvite(rid);
// If no matching recurrence-id was found, look at the current series.
if (current == null && rid != null)
current = getInvite((RecurId) null);
if (current != null && !current.isPublic()) {
// updating a currently private invite to public
return true;
} else {
// no matching rid found, or current is public
return false;
}
} else {
// Both old and new are public.
return false;
}
}
use of com.zimbra.cs.mailbox.calendar.Invite in project zm-mailbox by Zimbra.
the class CalendarItem method createPseudoExceptionForSingleInstanceReplyIfNecessary.
/**
* Bug 94018 - Need an exception to represent a reply to a single instance of an exception, otherwise a decline
* to a single instance gets forgotten in some cases where the series partstat is used instead.
* Assumption - already checked that there isn't a matching exception instance already
* Caller is responsible for ensuring changed MetaData is written through to SQL sending notification of change.
*/
private void createPseudoExceptionForSingleInstanceReplyIfNecessary(Invite reply) throws ServiceException {
if ((reply == null) || reply.getRecurId() == null) {
// reply isn't to a single instance
return;
}
Recurrence.RecurrenceRule recurrenceRule = null;
if ((mRecurrence == null) || !(mRecurrence instanceof Recurrence.RecurrenceRule)) {
return;
}
recurrenceRule = (Recurrence.RecurrenceRule) mRecurrence;
Collection<Instance> instancesNear = instancesNear(reply.getRecurId());
if (!instancesNear.isEmpty()) {
/* we need a new exception to handle the difference in attendee status */
for (int i = 0; i < numInvites(); i++) {
Invite cur = getInvite(i);
if (cur.getRecurId() == null) {
try {
ParsedDateTime pdt = ParsedDateTime.parseUtcOnly(reply.getRecurId().getDtZ());
Invite localException = cur.makeInstanceInvite(pdt);
localException.setDtStamp(System.currentTimeMillis());
localException.updateMatchingAttendeesFromReply(reply);
// flag as organizer change
localException.setClassPropSetByMe(true);
mInvites.add(localException);
// create a fake ExceptionRule wrapper around the single-instance
recurrenceRule.addException(new Recurrence.ExceptionRule(reply.getRecurId(), localException.getStartTime(), localException.getEffectiveDuration(), new InviteInfo(localException)));
} catch (ParseException e) {
sLog.debug("Unexpected exception - not updating calendar invite with pseudo exception", e);
}
break;
}
}
}
}
use of com.zimbra.cs.mailbox.calendar.Invite in project zm-mailbox by Zimbra.
the class Appointment method makeReplyInvite.
private Invite makeReplyInvite(Account account, Account authAccount, Locale lc, boolean onBehalfOf, boolean allowPrivateAccess, Invite inv, RecurId rid, Verb verb) throws ServiceException {
boolean hidePrivate = !inv.isPublic() && !allowPrivateAccess;
String subject;
if (hidePrivate)
subject = L10nUtil.getMessage(MsgKey.calendarSubjectWithheld, lc);
else
subject = inv.getName();
String replySubject = CalendarMailSender.getReplySubject(verb, subject, lc);
ParsedDateTime ridDt = rid != null ? rid.getDt() : null;
Invite replyInv = CalendarMailSender.replyToInvite(account, authAccount, onBehalfOf, allowPrivateAccess, inv, verb, replySubject, ridDt);
return replyInv;
}
Aggregations