use of com.zimbra.common.calendar.ParsedDateTime in project zm-mailbox by Zimbra.
the class Invite method sanitize.
public void sanitize(boolean throwException) throws ServiceException {
if ((mUid == null || mUid.length() == 0)) {
if (throwException)
throw ServiceException.INVALID_REQUEST("missing UID; subject=" + mName, null);
else
ZimbraLog.calendar.warn("UID missing; subject=" + mName);
}
mUid = fixupIfOutlookUid(mUid);
// Don't let a task have DTSTART without DUE.
if (isTodo() && mStart != null && mEnd == null)
mStart = null;
// Keep all-day flag and DTSTART/DTEND/DUE in sync.
// Use DTSTART if given. Fall back to DTEND/DUE.
ParsedDateTime dt = mStart != null ? mStart : mEnd;
if (dt == null) {
// No DTSTART. Force non-all-day.
setIsAllDayEvent(false);
} else if (!dt.hasTime()) {
// DTSTART has no time part. Force all-day.
setIsAllDayEvent(true);
} else if (!dt.hasZeroTime()) {
// Time part is not T000000. Force non-all-day.
setIsAllDayEvent(false);
} else {
// Time part is T000000. Strictly speaking presence of any time part implies non-all-day,
// but Outlook compatibility dictates we allow T000000 in an all-day appointment.
// Leave current all-day flag as is.
}
// ORGANIZER is required if there is at least one ATTENDEE.
if (isOrganizerMethod(mMethod) && hasOtherAttendees() && !hasOrganizer()) {
if (throwException) {
throw ServiceException.INVALID_REQUEST("ORGANIZER missing when ATTENDEEs are present; UID=" + mUid + ", subject=" + mName, null);
} else {
// If we don't know who the organizer is, remove attendees. Some clients will assume missing
// organizer means current user is the organizer. If attendees were kept, these clients will
// send cancel notice to the attendees when appointment is deleted. The attendees will get
// confused because the cancel notice came from someone other than the organizer.
ZimbraLog.calendar.warn("ORGANIZER missing; clearing ATTENDEEs to avoid confusing clients; UID=" + mUid + ", subject=" + mName);
clearAttendees();
}
}
// DTEND or DUE, if specified, can't be earlier than DTSTART.
if (mStart != null && mEnd != null && mEnd.compareTo(mStart) < 0)
mEnd = (ParsedDateTime) mStart.clone();
// Recurrence rule can't be set without DTSTART.
if (mRecurrence != null && mStart == null) {
if (throwException) {
throw ServiceException.INVALID_REQUEST("recurrence used without DTSTART; UID=" + mUid + ", subject=" + mName, null);
} else {
ZimbraLog.calendar.warn("recurrence used without DTSTART; removing recurrence; UID=" + mUid + ", subject=" + mName);
mRecurrence = null;
}
}
// Don't allow using different time zones in DTSTART and DTEND for a recurrence. (prevents future problems)
if (isRecurrence() && mStart != null && mEnd != null && !mStart.getTimeZone().equals(mEnd.getTimeZone())) {
ZimbraLog.calendar.warn("recurrence uses different time zones in DTSTART and DTEND; forcing DTEND to DTSTART time zone; UID=" + mUid + ", subject=" + mName);
mEnd.toTimeZone(mStart.getTimeZone());
}
mPercentComplete = limitIntegerRange(mPercentComplete, 0, 100, null);
mPriority = limitIntegerRange(mPriority, 0, 9, null);
// Clean up the time zone map to remove unreferenced TZs.
Set<String> tzids = getReferencedTZIDs();
mTzMap.reduceTo(tzids);
// Set LAST-MODIFIED to DTSTAMP if unset.
if (mLastModified == 0)
mLastModified = mDTStamp;
}
Aggregations