use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class ToXML method encodeXProps.
/**
* Use {@link jaxbXProps} where possible instead of this
*/
public static void encodeXProps(Element parent, Iterator<ZProperty> xpropsIterator) {
while (xpropsIterator.hasNext()) {
ZProperty xprop = xpropsIterator.next();
String propName = xprop.getName();
if (propName == null) {
continue;
}
String propValue = xprop.getValue();
Element propElem = parent.addElement(MailConstants.E_CAL_XPROP);
propElem.addAttribute(MailConstants.A_NAME, propName);
if (propValue != null) {
propElem.addAttribute(MailConstants.A_VALUE, propValue);
}
CalendarUtil.encodeXParams(propElem, xprop.parameterIterator());
}
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class Alarm method toXml.
public Element toXml(Element parent) {
Element alarm = parent.addElement(MailConstants.E_CAL_ALARM);
Action action;
List<ZProperty> useXprops = xProps;
if ((Action.AUDIO.equals(mAction) || Action.PROCEDURE.equals(mAction)) && DebugConfig.calendarConvertNonDisplayAlarm) {
action = Action.DISPLAY;
useXprops = xpropsWithoutXWRAlarmUID();
} else
action = mAction;
alarm.addAttribute(MailConstants.A_CAL_ALARM_ACTION, action.toString());
Element trigger = alarm.addElement(MailConstants.E_CAL_ALARM_TRIGGER);
if (TriggerType.ABSOLUTE.equals(mTriggerType)) {
Element absolute = trigger.addElement(MailConstants.E_CAL_ALARM_ABSOLUTE);
absolute.addAttribute(MailConstants.A_DATE, mTriggerAbsolute.getDateTimePartString(false));
} else {
Element relative = mTriggerRelative.toXml(trigger, MailConstants.E_CAL_ALARM_RELATIVE);
if (mTriggerRelated != null)
relative.addAttribute(MailConstants.A_CAL_ALARM_RELATED, mTriggerRelated.toString());
}
if (mRepeatDuration != null) {
Element repeat = mRepeatDuration.toXml(alarm, MailConstants.E_CAL_ALARM_REPEAT);
repeat.addAttribute(MailConstants.A_CAL_ALARM_COUNT, mRepeatCount);
}
if (!Action.AUDIO.equals(action)) {
Element desc = alarm.addElement(MailConstants.E_CAL_ALARM_DESCRIPTION);
if (mDescription != null)
desc.setText(mDescription);
}
if (!Action.DISPLAY.equals(action) && mAttach != null)
mAttach.toXml(alarm);
if (Action.EMAIL.equals(mAction) || Action.X_YAHOO_CALENDAR_ACTION_IM.equals(mAction) || Action.X_YAHOO_CALENDAR_ACTION_MOBILE.equals(mAction)) {
Element summary = alarm.addElement(MailConstants.E_CAL_ALARM_SUMMARY);
if (mSummary != null)
summary.setText(mSummary);
if (mAttendees != null) {
for (ZAttendee attendee : mAttendees) {
attendee.toXml(alarm);
}
}
}
// x-prop
ToXML.encodeXProps(alarm, useXprops.iterator());
return alarm;
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class Alarm method toZComponent.
public ZComponent toZComponent() throws ServiceException {
ZComponent comp = new ZComponent(ICalTok.VALARM);
ZProperty action = new ZProperty(ICalTok.ACTION, mAction.toString());
comp.addProperty(action);
ZProperty trigger = new ZProperty(ICalTok.TRIGGER);
if (TriggerType.ABSOLUTE.equals(mTriggerType)) {
ZParameter vt = new ZParameter(ICalTok.VALUE, ICalTok.DATE_TIME.toString());
trigger.addParameter(vt);
trigger.setValue(mTriggerAbsolute.getDateTimePartString(false));
} else {
if (mTriggerRelated != null) {
ZParameter related = new ZParameter(ICalTok.RELATED, mTriggerRelated.toString());
trigger.addParameter(related);
}
trigger.setValue(mTriggerRelative.toString());
}
comp.addProperty(trigger);
if (mRepeatDuration != null) {
ZProperty duration = new ZProperty(ICalTok.DURATION, mRepeatDuration.toString());
comp.addProperty(duration);
ZProperty repeat = new ZProperty(ICalTok.REPEAT, mRepeatCount);
comp.addProperty(repeat);
}
if (!Action.AUDIO.equals(mAction)) {
String d = mDescription;
// DESCRIPTION is required in DISPLAY and EMAIL alarms.
if (d == null && !Action.PROCEDURE.equals(mAction))
d = "Reminder";
ZProperty desc = new ZProperty(ICalTok.DESCRIPTION, d);
comp.addProperty(desc);
}
if (mAttach != null)
comp.addProperty(mAttach.toZProperty());
if (Action.EMAIL.equals(mAction) || Action.X_YAHOO_CALENDAR_ACTION_IM.equals(mAction) || Action.X_YAHOO_CALENDAR_ACTION_MOBILE.equals(mAction)) {
String s = mSummary;
if (s == null)
s = "Reminder";
ZProperty summary = new ZProperty(ICalTok.SUMMARY, s);
comp.addProperty(summary);
// if somehow the object didn't have any attendee.
if (mAttendees != null) {
for (ZAttendee attendee : mAttendees) {
comp.addProperty(attendee.toProperty());
}
}
}
// x-prop
for (ZProperty xprop : xProps) {
comp.addProperty(xprop);
}
return comp;
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class Alarm method xpropsWithoutXWRAlarmUID.
/**
* Return a copy of the X properties, excluding X-WR-ALARMUID because for Outlook and ZWC, we usually convert
* AUDIO and PROCEDURE alarms to be DISPLAY alarms and iCal.app does not like X-WR-ALARMUID set for DISPLAY alarms.
* @return Immutable list of X properties excluding iCal.app special property X-WR-ALARMUID
*/
private List<ZProperty> xpropsWithoutXWRAlarmUID() {
// Bug 80533 Return a copy rather than deleting an entry from mXProps. Avoids race conditions if
// some clients are iterating over the list during the removal.
List<ZProperty> xprops = xProps;
ZProperty prop = getXProperty(XWRALARMUID);
if (prop != null) {
xprops = Lists.newArrayList();
xprops.addAll(xProps);
xprops.remove(prop);
}
return ImmutableList.copyOf(xprops);
}
use of com.zimbra.common.calendar.ZCalendar.ZProperty in project zm-mailbox by Zimbra.
the class Alarm method toJaxb.
public AlarmInfo toJaxb() {
Action action;
List<ZProperty> useXprops = xProps;
if ((Action.AUDIO.equals(mAction) || Action.PROCEDURE.equals(mAction)) && DebugConfig.calendarConvertNonDisplayAlarm) {
action = Action.DISPLAY;
useXprops = xpropsWithoutXWRAlarmUID();
} else {
action = mAction;
}
AlarmInfo alarm = new AlarmInfo(action.toString());
AlarmTriggerInfo trigger = new AlarmTriggerInfo();
alarm.setTrigger(trigger);
if (TriggerType.ABSOLUTE.equals(mTriggerType)) {
trigger.setAbsolute(new DateAttr(mTriggerAbsolute.getDateTimePartString(false)));
} else {
DurationInfo relative = new DurationInfo(mTriggerRelative);
trigger.setRelative(relative);
if (mTriggerRelated != null)
relative.setRelated(mTriggerRelated.toString());
}
if (mRepeatDuration != null) {
DurationInfo repeat = new DurationInfo(mRepeatDuration);
alarm.setRepeat(repeat);
repeat.setRepeatCount(mRepeatCount);
}
if (!Action.AUDIO.equals(action)) {
alarm.setDescription(mDescription);
}
if (!Action.DISPLAY.equals(action) && mAttach != null)
alarm.setAttach(new CalendarAttach(mAttach));
if (Action.EMAIL.equals(mAction) || Action.X_YAHOO_CALENDAR_ACTION_IM.equals(mAction) || Action.X_YAHOO_CALENDAR_ACTION_MOBILE.equals(mAction)) {
alarm.setSummary(mSummary);
if (mAttendees != null) {
for (ZAttendee attendee : mAttendees) {
alarm.addAttendee(attendee.toJaxb());
}
}
}
// x-prop
alarm.setXProps(ToXML.jaxbXProps(useXprops.iterator()));
return alarm;
}
Aggregations