Search in sources :

Example 1 with TzidParamType

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

the class Xutil method tzidProp.

protected static BasePropertyType tzidProp(final BasePropertyType prop, final String val) {
    if (val == null) {
        return prop;
    }
    final ArrayOfParameters pars = getAop(prop);
    final TzidParamType tzid = new TzidParamType();
    tzid.setText(val);
    final JAXBElement<TzidParamType> t = of.createTzid(tzid);
    pars.getBaseParameter().add(t);
    return prop;
}
Also used : ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) TzidParamType(ietf.params.xml.ns.icalendar_2.TzidParamType)

Example 2 with TzidParamType

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

the class DateDatetimePropUpdater method makeDt.

protected UpdateResult makeDt(final BwDateTime evdt, final Holder<BwDateTime> resdt, final UpdateInfo ui) throws WebdavException {
    try {
        String tzid = evdt.getTzid();
        String dtval = evdt.getDtval();
        boolean dateOnly = evdt.getDateType();
        BwDateTime newdt = null;
        /* New or changed tzid? */
        for (ParameterUpdater.UpdateInfo parui : ui.getParamUpdates()) {
            if (parui.getParam() instanceof TzidParamType) {
                if (parui.isRemove()) {
                    tzid = null;
                    break;
                }
                if (parui.isAdd()) {
                    if (tzid != null) {
                        return new UpdateResult(ui.getPropName().toString() + " already has tzid");
                    }
                    tzid = ((TzidParamType) parui.getParam()).getText();
                    break;
                }
                if (tzid == null) {
                    return new UpdateResult(ui.getPropName().toString() + " has no tzid to change");
                }
                tzid = ((TzidParamType) parui.getUpdparam()).getText();
                break;
            }
        }
        if (ui.getUpdprop() != null) {
            // Has new value
            DateDatetimePropertyType newdts = (DateDatetimePropertyType) ui.getUpdprop();
            dateOnly = newdts.getDate() != null;
            newdt = BwDateTime.makeBwDateTime(newdts, tzid);
        }
        if ((newdt == null) && (!Util.equalsString(tzid, evdt.getTzid()))) {
            // Tzid changed
            newdt = BwDateTime.makeBwDateTime(dateOnly, dtval, tzid);
        }
        if (newdt != null) {
            // Validate
            int res = newdt.validate();
            if (res == BwDateTime.dtBadDtval) {
                return new UpdateResult("Bad date value for " + ui.getPropName());
            }
            if (res == BwDateTime.dtBadTz) {
                return new UpdateResult("Bad tzid for " + ui.getPropName());
            }
        }
        resdt.value = newdt;
        return UpdateResult.getOkResult();
    } catch (CalFacadeException cfe) {
        throw new WebdavException(cfe);
    }
}
Also used : BwDateTime(org.bedework.calfacade.BwDateTime) DateDatetimePropertyType(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) TzidParamType(ietf.params.xml.ns.icalendar_2.TzidParamType) ParameterUpdater(org.bedework.caldav.bwserver.ParameterUpdater) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with TzidParamType

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

the class Xutil method xparam.

/**
 * Convert a parameter
 * @param prop - parameters go here
 * @param xp - a parameter
 * @throws Throwable
 */
protected static void xparam(final BasePropertyType prop, final Xpar xp) throws Throwable {
    ArrayOfParameters aop = prop.getParameters();
    if (aop == null) {
        aop = new ArrayOfParameters();
        prop.setParameters(aop);
    }
    if (xp.getName().equalsIgnoreCase("tzid")) {
        final TzidParamType tz = new TzidParamType();
        tz.setText(xp.getValue());
        aop.getBaseParameter().add(of.createTzid(tz));
        return;
    }
}
Also used : ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) TzidParamType(ietf.params.xml.ns.icalendar_2.TzidParamType)

Aggregations

TzidParamType (ietf.params.xml.ns.icalendar_2.TzidParamType)3 ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)2 DateDatetimePropertyType (ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType)1 ParameterUpdater (org.bedework.caldav.bwserver.ParameterUpdater)1 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)1 BwDateTime (org.bedework.calfacade.BwDateTime)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)1