Search in sources :

Example 31 with ZProperty

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());
    }
}
Also used : Element(com.zimbra.common.soap.Element) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty)

Example 32 with ZProperty

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;
}
Also used : Element(com.zimbra.common.soap.Element) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty)

Example 33 with ZProperty

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;
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) ZParameter(com.zimbra.common.calendar.ZCalendar.ZParameter)

Example 34 with ZProperty

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);
}
Also used : ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty)

Example 35 with ZProperty

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;
}
Also used : CalendarAttach(com.zimbra.soap.mail.type.CalendarAttach) DateAttr(com.zimbra.soap.mail.type.DateAttr) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty) AlarmInfo(com.zimbra.soap.mail.type.AlarmInfo) AlarmTriggerInfo(com.zimbra.soap.mail.type.AlarmTriggerInfo) DurationInfo(com.zimbra.soap.mail.type.DurationInfo)

Aggregations

ZProperty (com.zimbra.common.calendar.ZCalendar.ZProperty)49 ZParameter (com.zimbra.common.calendar.ZCalendar.ZParameter)19 ZComponent (com.zimbra.common.calendar.ZCalendar.ZComponent)18 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)13 ArrayList (java.util.ArrayList)12 Account (com.zimbra.cs.account.Account)10 ICalTok (com.zimbra.common.calendar.ZCalendar.ICalTok)9 ZVCalendar (com.zimbra.common.calendar.ZCalendar.ZVCalendar)9 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)8 Invite (com.zimbra.cs.mailbox.calendar.Invite)8 ParsedDuration (com.zimbra.common.calendar.ParsedDuration)7 ZOrganizer (com.zimbra.cs.mailbox.calendar.ZOrganizer)7 TimeZoneMap (com.zimbra.common.calendar.TimeZoneMap)6 ServiceException (com.zimbra.common.service.ServiceException)6 ParseException (java.text.ParseException)6 IRecurrence (com.zimbra.cs.mailbox.calendar.Recurrence.IRecurrence)5 AccountAddressMatcher (com.zimbra.cs.util.AccountUtil.AccountAddressMatcher)5 Element (com.zimbra.common.soap.Element)4 IOException (java.io.IOException)4 Geo (com.zimbra.common.calendar.Geo)3