Search in sources :

Example 1 with Xpar

use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.

the class BwAlarm method getXicalProperties.

/**
 * Find x-properties storing the value of the named ical property
 *
 * @param val - name to match
 * @return list of matching properties - never null
 *  @throws CalFacadeException
 */
@NoProxy
@NoDump
public List<BwXproperty> getXicalProperties(final String val) throws CalFacadeException {
    List<BwXproperty> res = new ArrayList<>();
    List<BwXproperty> xs = getXproperties();
    if (xs == null) {
        return res;
    }
    for (BwXproperty x : xs) {
        if (x.getName().equals(BwXproperty.bedeworkIcalProp)) {
            List<Xpar> xpars = x.getParameters();
            Xpar xp = xpars.get(0);
            if (xp.getName().equals(val)) {
                res.add(x);
            }
        }
    }
    return res;
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) ArrayList(java.util.ArrayList) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 2 with Xpar

use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.

the class BwEvent method getXicalProperties.

/**
 * Find x-properties storing the value of the named ical property
 *
 * @param val - name to match
 * @return list of matching properties - never null
 *  @throws CalFacadeException
 */
@NoProxy
@NoDump
public List<BwXproperty> getXicalProperties(final String val) throws CalFacadeException {
    List<BwXproperty> res = new ArrayList<>();
    List<BwXproperty> xs = getXproperties();
    if (xs == null) {
        return res;
    }
    for (BwXproperty x : xs) {
        if (x.getName().equals(BwXproperty.bedeworkIcalProp)) {
            List<Xpar> xpars = x.getParameters();
            Xpar xp = xpars.get(0);
            if (xp.getName().equals(val)) {
                res.add(x);
            }
        }
    }
    return res;
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) ArrayList(java.util.ArrayList) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 3 with Xpar

use of org.bedework.calfacade.BwXproperty.Xpar 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 4 with Xpar

use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.

the class IcalUtil method xpropertiesToIcal.

/**
 * @param pl
 * @param xprops
 * @throws Throwable
 */
@SuppressWarnings("deprecation")
public static void xpropertiesToIcal(final PropertyList pl, final List<BwXproperty> xprops) throws Throwable {
    for (BwXproperty x : xprops) {
        String xname = x.getName();
        if (xname.equals(BwXproperty.bedeworkIcalProp)) {
            // Some get squirreled away in here -mostly for alarms
            List<Xpar> params = x.getParameters();
            String pname = params.get(0).getValue();
            if (params.size() == 1) {
                params = null;
            } else {
                params = new ArrayList<Xpar>(params);
                params.remove(0);
            }
            // XXX Need to be able to do this in ical4j - create property by name
            if (pname.equals("UID")) {
                pl.add(new Uid(makeXparlist(params), x.getValue()));
            }
        }
        if (x.getSkip()) {
            continue;
        }
        // Skip any timezone we saved in the event.
        if (xname.startsWith(BwXproperty.bedeworkTimezonePrefix)) {
            continue;
        }
        addXproperty(pl, xname, x.getParameters(), x.getValue());
    }
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) Uid(net.fortuna.ical4j.model.property.Uid) BwXproperty(org.bedework.calfacade.BwXproperty)

Example 5 with Xpar

use of org.bedework.calfacade.BwXproperty.Xpar in project bw-calendar-engine by Bedework.

the class IcalUtil method makeXparlist.

/**
 * @param pars
 * @return par list - always non-null
 * @throws Throwable
 */
public static ParameterList makeXparlist(final List<BwXproperty.Xpar> pars) throws Throwable {
    ParameterList xparl = new ParameterList();
    if (pars == null) {
        return xparl;
    }
    for (BwXproperty.Xpar xpar : pars) {
        String xval = xpar.getValue();
        if ((xval.indexOf(":") >= 0) || (xval.indexOf(";") >= 0) || (xval.indexOf(",") >= 0)) {
            xval = "\"" + xval + "\"";
        }
        xparl.add(ParameterFactoryImpl.getInstance().createParameter(xpar.getName().toUpperCase(), xval));
    }
    return xparl;
}
Also used : BwXproperty(org.bedework.calfacade.BwXproperty) ParameterList(net.fortuna.ical4j.model.ParameterList) Xpar(org.bedework.calfacade.BwXproperty.Xpar)

Aggregations

Xpar (org.bedework.calfacade.BwXproperty.Xpar)6 BwXproperty (org.bedework.calfacade.BwXproperty)4 ArrayList (java.util.ArrayList)2 NoDump (org.bedework.calfacade.annotations.NoDump)2 NoProxy (org.bedework.calfacade.annotations.ical.NoProxy)2 ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)1 BaseParameterType (ietf.params.xml.ns.icalendar_2.BaseParameterType)1 TextPropertyType (ietf.params.xml.ns.icalendar_2.TextPropertyType)1 XBedeworkExsynchEndtzidPropType (ietf.params.xml.ns.icalendar_2.XBedeworkExsynchEndtzidPropType)1 XBedeworkExsynchLastmodPropType (ietf.params.xml.ns.icalendar_2.XBedeworkExsynchLastmodPropType)1 XBedeworkExsynchStarttzidPropType (ietf.params.xml.ns.icalendar_2.XBedeworkExsynchStarttzidPropType)1 XBedeworkMaxTicketsPerUserPropType (ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPerUserPropType)1 XBedeworkMaxTicketsPropType (ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPropType)1 XBedeworkRegistrationEndPropType (ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationEndPropType)1 XBedeworkRegistrationStartPropType (ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationStartPropType)1 XBedeworkWaitListLimitPropType (ietf.params.xml.ns.icalendar_2.XBedeworkWaitListLimitPropType)1 XBedeworkWrappedNameParamType (ietf.params.xml.ns.icalendar_2.XBedeworkWrappedNameParamType)1 XBedeworkWrapperPropType (ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType)1 XBwCategoriesPropType (ietf.params.xml.ns.icalendar_2.XBwCategoriesPropType)1 XBwContactPropType (ietf.params.xml.ns.icalendar_2.XBwContactPropType)1