Search in sources :

Example 6 with BasePropertyType

use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.

the class Xutil method xpropertiesToXcal.

/**
 * @param pl
 * @param xprops
 * @param pattern
 * @param masterClass
 * @param wrapXprops wrap x-properties in bedework object - allows
 *                   us to push them through soap
 * @throws Throwable
 */
@SuppressWarnings("deprecation")
public static void xpropertiesToXcal(final List<JAXBElement<? extends BasePropertyType>> pl, final List<BwXproperty> xprops, final BaseComponentType pattern, final Class masterClass, final boolean wrapXprops) throws Throwable {
    for (final BwXproperty x : xprops) {
        // Skip any timezone we saved in the event.
        final String xname = x.getName();
        final String val = x.getValue();
        if (xname.startsWith(BwXproperty.bedeworkTimezonePrefix)) {
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchEndtzid)) {
            if (!emit(pattern, masterClass, XBedeworkExsynchEndtzidPropType.class)) {
                continue;
            }
            final XBedeworkExsynchEndtzidPropType p = new XBedeworkExsynchEndtzidPropType();
            p.setText(val);
            pl.add(of.createXBedeworkExsynchEndtzid(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchLastmod)) {
            if (!emit(pattern, masterClass, XBedeworkExsynchLastmodPropType.class)) {
                continue;
            }
            final XBedeworkExsynchLastmodPropType p = new XBedeworkExsynchLastmodPropType();
            p.setText(val);
            pl.add(of.createXBedeworkExsynchLastmod(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchOrganizer)) {
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchStarttzid)) {
            if (!emit(pattern, masterClass, XBedeworkExsynchStarttzidPropType.class)) {
                continue;
            }
            final XBedeworkExsynchStarttzidPropType p = new XBedeworkExsynchStarttzidPropType();
            p.setText(val);
            pl.add(of.createXBedeworkExsynchStarttzid(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegStart)) {
            if (!emit(pattern, masterClass, XBedeworkRegistrationStartPropType.class)) {
                continue;
            }
            final XBedeworkRegistrationStartPropType p = new XBedeworkRegistrationStartPropType();
            String tzid = null;
            for (final Xpar xp : x.getParameters()) {
                if (xp.getName().equalsIgnoreCase("TZID")) {
                    tzid = xp.getValue();
                    break;
                }
            }
            XcalUtil.initDt(p, val, tzid);
            pl.add(of.createXBedeworkRegistrationStart(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegEnd)) {
            if (!emit(pattern, masterClass, XBedeworkRegistrationEndPropType.class)) {
                continue;
            }
            final XBedeworkRegistrationEndPropType p = new XBedeworkRegistrationEndPropType();
            String tzid = null;
            for (final Xpar xp : x.getParameters()) {
                if (xp.getName().equalsIgnoreCase("TZID")) {
                    tzid = xp.getValue();
                    break;
                }
            }
            XcalUtil.initDt(p, val, tzid);
            pl.add(of.createXBedeworkRegistrationEnd(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegMaxTickets)) {
            if (!emit(pattern, masterClass, XBedeworkMaxTicketsPropType.class)) {
                continue;
            }
            final XBedeworkMaxTicketsPropType p = new XBedeworkMaxTicketsPropType();
            p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
            pl.add(of.createXBedeworkMaxTickets(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegMaxTicketsPerUser)) {
            if (!emit(pattern, masterClass, XBedeworkMaxTicketsPerUserPropType.class)) {
                continue;
            }
            final XBedeworkMaxTicketsPerUserPropType p = new XBedeworkMaxTicketsPerUserPropType();
            p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
            pl.add(of.createXBedeworkMaxTicketsPerUser(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegWaitListLimit)) {
            if (!emit(pattern, masterClass, XBedeworkWaitListLimitPropType.class)) {
                continue;
            }
            final XBedeworkWaitListLimitPropType p = new XBedeworkWaitListLimitPropType();
            p.setText(val);
            pl.add(of.createXBedeworkWaitListLimit(p));
            continue;
        }
        if (xname.equals(BwXproperty.xBedeworkCategories)) {
            if (!emit(pattern, masterClass, XBwCategoriesPropType.class)) {
                continue;
            }
            final XBwCategoriesPropType p = new XBwCategoriesPropType();
            p.getText().add(val);
            pl.add(of.createXBedeworkCategories(p));
            continue;
        }
        if (xname.equals(BwXproperty.xBedeworkContact)) {
            if (!emit(pattern, masterClass, XBwContactPropType.class)) {
                continue;
            }
            final XBwContactPropType p = new XBwContactPropType();
            p.setText(val);
            pl.add(of.createXBedeworkContact(p));
            continue;
        }
        if (xname.equals(BwXproperty.xBedeworkLocation)) {
            if (!emit(pattern, masterClass, XBwLocationPropType.class)) {
                continue;
            }
            final XBwLocationPropType p = new XBwLocationPropType();
            p.setText(val);
            pl.add(of.createXBedeworkLocation(p));
            continue;
        }
        if (!wrapXprops) {
            if (getLog().isDebugEnabled()) {
                warn("Not handing x-property " + xname);
            }
            continue;
        }
        final XBedeworkWrapperPropType wrapper = new XBedeworkWrapperPropType();
        if (x.getParameters() != null) {
            for (final Xpar xp : x.getParameters()) {
                xparam(wrapper, xp);
            }
        }
        final XBedeworkWrappedNameParamType wnp = new XBedeworkWrappedNameParamType();
        wnp.setText(x.getName());
        if (wrapper.getParameters() == null) {
            wrapper.setParameters(new ArrayOfParameters());
        }
        wrapper.getParameters().getBaseParameter().add(of.createXBedeworkWrappedName(wnp));
        wrapper.setText(val);
        pl.add(of.createXBedeworkWrapper(wrapper));
    }
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) XBedeworkRegistrationEndPropType(ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationEndPropType) XBwContactPropType(ietf.params.xml.ns.icalendar_2.XBwContactPropType) XBwCategoriesPropType(ietf.params.xml.ns.icalendar_2.XBwCategoriesPropType) XBedeworkExsynchStarttzidPropType(ietf.params.xml.ns.icalendar_2.XBedeworkExsynchStarttzidPropType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) XBedeworkMaxTicketsPropType(ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPropType) XBedeworkWaitListLimitPropType(ietf.params.xml.ns.icalendar_2.XBedeworkWaitListLimitPropType) XBedeworkExsynchEndtzidPropType(ietf.params.xml.ns.icalendar_2.XBedeworkExsynchEndtzidPropType) XBedeworkExsynchLastmodPropType(ietf.params.xml.ns.icalendar_2.XBedeworkExsynchLastmodPropType) XBwLocationPropType(ietf.params.xml.ns.icalendar_2.XBwLocationPropType) BwXproperty(org.bedework.calfacade.BwXproperty) XBedeworkMaxTicketsPerUserPropType(ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPerUserPropType) XBedeworkWrapperPropType(ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType) XBedeworkRegistrationStartPropType(ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationStartPropType) XBedeworkWrappedNameParamType(ietf.params.xml.ns.icalendar_2.XBedeworkWrappedNameParamType)

Example 7 with BasePropertyType

use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.

the class Xutil method uidProp.

protected static BasePropertyType uidProp(final BasePropertyType prop, final String uid) {
    if (uid == null) {
        return prop;
    }
    ArrayOfParameters pars = getAop(prop);
    XBedeworkUidParamType x = new XBedeworkUidParamType();
    x.setText(uid);
    JAXBElement<XBedeworkUidParamType> param = of.createXBedeworkUid(x);
    pars.getBaseParameter().add(param);
    return prop;
}
Also used : XBedeworkUidParamType(ietf.params.xml.ns.icalendar_2.XBedeworkUidParamType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters)

Example 8 with BasePropertyType

use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.

the class IcalTranslator method toXMLIcalendar.

/**
 * @param val
 * @param methodType
 * @param pattern
 * @return XML IcalendarType
 * @throws CalFacadeException
 */
public IcalendarType toXMLIcalendar(final EventInfo val, final int methodType, final IcalendarType pattern, final boolean wrapXprops) throws CalFacadeException {
    IcalendarType ical = new IcalendarType();
    VcalendarType vcal = new VcalendarType();
    ical.getVcalendar().add(vcal);
    vcal.setProperties(new ArrayOfProperties());
    List<JAXBElement<? extends BasePropertyType>> pl = vcal.getProperties().getBasePropertyOrTzid();
    ProdidPropType prod = new ProdidPropType();
    prod.setText(prodId);
    pl.add(Xutil.of.createProdid(prod));
    VersionPropType vers = new VersionPropType();
    vers.setText("2.0");
    pl.add(Xutil.of.createVersion(vers));
    if ((methodType > ScheduleMethods.methodTypeNone) && (methodType < ScheduleMethods.methodTypeUnknown)) {
        MethodPropType m = new MethodPropType();
        m.setText(ScheduleMethods.methods[methodType]);
        pl.add(Xutil.of.createMethod(m));
    }
    ArrayOfComponents aoc = vcal.getComponents();
    if (aoc == null) {
        aoc = new ArrayOfComponents();
        vcal.setComponents(aoc);
    }
    BwEvent ev = val.getEvent();
    JAXBElement<? extends BaseComponentType> el = null;
    VcalendarType vc = null;
    if ((pattern != null) && !pattern.getVcalendar().isEmpty()) {
        vc = pattern.getVcalendar().get(0);
    }
    BaseComponentType bc = matches(vc, ev.getEntityType());
    if ((vc != null) && (bc == null)) {
        return ical;
    }
    if (!ev.getSuppressed()) {
        if (ev.getEntityType() == IcalDefs.entityTypeFreeAndBusy) {
            el = ToXEvent.toComponent(ev, false, wrapXprops, bc);
        } else {
            el = ToXEvent.toComponent(ev, false, wrapXprops, bc);
        }
        if (el != null) {
            aoc.getBaseComponent().add(el);
        }
    }
    if (val.getNumOverrides() == 0) {
        return ical;
    }
    for (EventInfo oei : val.getOverrides()) {
        ev = oei.getEvent();
        el = ToXEvent.toComponent(ev, true, wrapXprops, bc);
        if (el != null) {
            aoc.getBaseComponent().add(el);
        }
    }
    if (val.getNumContainedItems() > 0) {
        for (EventInfo aei : val.getContainedItems()) {
            ev = aei.getEvent();
            el = ToXEvent.toComponent(ev, true, wrapXprops, bc);
            if (el != null) {
                aoc.getBaseComponent().add(el);
            }
        }
    }
    return ical;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) JAXBElement(javax.xml.bind.JAXBElement) ArrayOfProperties(ietf.params.xml.ns.icalendar_2.ArrayOfProperties) ProdidPropType(ietf.params.xml.ns.icalendar_2.ProdidPropType) VcalendarType(ietf.params.xml.ns.icalendar_2.VcalendarType) BaseComponentType(ietf.params.xml.ns.icalendar_2.BaseComponentType) BasePropertyType(ietf.params.xml.ns.icalendar_2.BasePropertyType) IcalendarType(ietf.params.xml.ns.icalendar_2.IcalendarType) MethodPropType(ietf.params.xml.ns.icalendar_2.MethodPropType) ArrayOfComponents(ietf.params.xml.ns.icalendar_2.ArrayOfComponents) VersionPropType(ietf.params.xml.ns.icalendar_2.VersionPropType)

Example 9 with BasePropertyType

use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.

the class BwUpdates method addRemove.

private UpdateResult addRemove(final EventInfo ei, final Component subComponent, final boolean add, final List<PropertyReferenceType> refs, final IcalCallback cb) throws WebdavException {
    for (PropertyReferenceType r : refs) {
        BasePropertyType bprop;
        QName pname;
        if (r.getBaseProperty() == null) {
            return new UpdateResult("No new value for add");
        }
        bprop = r.getBaseProperty().getValue();
        pname = r.getBaseProperty().getName();
        PropertyUpdater pu = getUpdater(bprop);
        if (pu == null) {
            return new UpdateResult("No updater for property: " + pname);
        }
        PropertyUpdateInfo ui = new PropertyUpdateInfo(bprop, pname, cb, ei, subComponent, state, userHref);
        UpdateResult ur;
        if (add) {
            ur = ui.setAdd(r);
        } else {
            ur = ui.setRemove(r);
        }
        if (ur != null) {
            return ur;
        }
        ur = pu.applyUpdate(ui);
        if (!ur.getOk()) {
            return ur;
        }
    }
    return UpdateResult.getOkResult();
}
Also used : BasePropertyType(ietf.params.xml.ns.icalendar_2.BasePropertyType) QName(javax.xml.namespace.QName) PropertyReferenceType(org.oasis_open.docs.ws_calendar.ns.soap.PropertyReferenceType) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 10 with BasePropertyType

use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.

the class BwUpdates method getCompSelector.

private CompSelector getCompSelector(final BaseComponentType selComp) throws WebdavException {
    CompSelector cs = new CompSelector();
    for (JAXBElement<? extends BasePropertyType> prop : selComp.getProperties().getBasePropertyOrTzid()) {
        if (prop.getName().equals(XcalTags.uid)) {
            cs.uid = ((UidPropType) prop.getValue()).getText();
            if ((cs.uid != null) && (cs.recurrenceId != null)) {
                return cs;
            }
            continue;
        }
        if (prop.getName().equals(XcalTags.recurrenceId)) {
            RecurrenceIdPropType rid = (RecurrenceIdPropType) prop.getValue();
            XcalUtil.DtTzid dtTzid = XcalUtil.getDtTzid(rid);
            try {
                cs.recurrenceId = BwDateTime.makeBwDateTime(dtTzid.dateOnly, dtTzid.dt, dtTzid.tzid);
            } catch (CalFacadeException cfe) {
                throw new WebdavException(cfe);
            }
            if ((cs.uid != null) && (cs.recurrenceId != null)) {
                return cs;
            }
            continue;
        }
    }
    return cs;
}
Also used : RecurrenceIdPropType(ietf.params.xml.ns.icalendar_2.RecurrenceIdPropType) XcalUtil(org.bedework.util.calendar.XcalUtil) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)9 BasePropertyType (ietf.params.xml.ns.icalendar_2.BasePropertyType)5 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 ArrayOfProperties (ietf.params.xml.ns.icalendar_2.ArrayOfProperties)3 DescriptionPropType (ietf.params.xml.ns.icalendar_2.DescriptionPropType)3 DurationPropType (ietf.params.xml.ns.icalendar_2.DurationPropType)3 SummaryPropType (ietf.params.xml.ns.icalendar_2.SummaryPropType)3 JAXBElement (javax.xml.bind.JAXBElement)3 BwAttendee (org.bedework.calfacade.BwAttendee)3 ActionPropType (ietf.params.xml.ns.icalendar_2.ActionPropType)2 AttachPropType (ietf.params.xml.ns.icalendar_2.AttachPropType)2 BaseComponentType (ietf.params.xml.ns.icalendar_2.BaseComponentType)2 RecurrenceIdPropType (ietf.params.xml.ns.icalendar_2.RecurrenceIdPropType)2 RelatedParamType (ietf.params.xml.ns.icalendar_2.RelatedParamType)2 BwString (org.bedework.calfacade.BwString)2 AltrepParamType (ietf.params.xml.ns.icalendar_2.AltrepParamType)1 ArrayOfComponents (ietf.params.xml.ns.icalendar_2.ArrayOfComponents)1 AttendeePropType (ietf.params.xml.ns.icalendar_2.AttendeePropType)1 CategoriesPropType (ietf.params.xml.ns.icalendar_2.CategoriesPropType)1 ClassPropType (ietf.params.xml.ns.icalendar_2.ClassPropType)1