Search in sources :

Example 1 with BaseParameterType

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

the class ToXEvent method makeOrganizer.

/**
 * @param val
 * @return Organizer
 * @throws Throwable
 */
public static OrganizerPropType makeOrganizer(final BwOrganizer val) throws Throwable {
    OrganizerPropType prop = new OrganizerPropType();
    prop.setCalAddress(val.getOrganizerUri());
    ArrayOfParameters pars = new ArrayOfParameters();
    JAXBElement<? extends BaseParameterType> param;
    prop.setParameters(pars);
    String temp = val.getScheduleStatus();
    if (temp != null) {
        ScheduleStatusParamType ss = new ScheduleStatusParamType();
        ss.setText(temp);
        param = of.createScheduleStatus(ss);
        pars.getBaseParameter().add(param);
    }
    temp = val.getCn();
    if (temp != null) {
        CnParamType cn = new CnParamType();
        cn.setText(temp);
        param = of.createCn(cn);
        pars.getBaseParameter().add(param);
    }
    temp = val.getDir();
    if (temp != null) {
        DirParamType d = new DirParamType();
        d.setUri(temp);
        param = of.createDir(d);
        pars.getBaseParameter().add(param);
    }
    temp = val.getLanguage();
    if (temp != null) {
        LanguageParamType l = new LanguageParamType();
        l.setText(temp);
        param = of.createLanguage(l);
        pars.getBaseParameter().add(param);
    }
    temp = val.getSentBy();
    if (temp != null) {
        SentByParamType sb = new SentByParamType();
        sb.setCalAddress(temp);
        param = of.createSentBy(sb);
        pars.getBaseParameter().add(param);
    }
    return prop;
}
Also used : DirParamType(ietf.params.xml.ns.icalendar_2.DirParamType) LanguageParamType(ietf.params.xml.ns.icalendar_2.LanguageParamType) ScheduleStatusParamType(ietf.params.xml.ns.icalendar_2.ScheduleStatusParamType) OrganizerPropType(ietf.params.xml.ns.icalendar_2.OrganizerPropType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) BwString(org.bedework.calfacade.BwString) SentByParamType(ietf.params.xml.ns.icalendar_2.SentByParamType) CnParamType(ietf.params.xml.ns.icalendar_2.CnParamType)

Example 2 with BaseParameterType

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

the class ToXEvent method makeAttendee.

/* ====================================================================
                      Private methods
     ==================================================================== */
/**
 * make an attendee
 *
 * @param val
 * @return Attendee
 * @throws Throwable
 */
public static AttendeePropType makeAttendee(final BwAttendee val) throws Throwable {
    AttendeePropType prop = new AttendeePropType();
    prop.setCalAddress(val.getAttendeeUri());
    ArrayOfParameters pars = new ArrayOfParameters();
    JAXBElement<? extends BaseParameterType> param;
    prop.setParameters(pars);
    if (val.getRsvp()) {
        RsvpParamType r = new RsvpParamType();
        r.setBoolean(true);
        param = of.createRsvp(r);
        pars.getBaseParameter().add(param);
    }
    String temp = val.getCn();
    if (temp != null) {
        CnParamType cn = new CnParamType();
        cn.setText(temp);
        param = of.createCn(cn);
        pars.getBaseParameter().add(param);
    }
    temp = val.getPartstat();
    if (temp == null) {
        temp = IcalDefs.partstatValNeedsAction;
    }
    PartstatParamType partstat = new PartstatParamType();
    partstat.setText(temp);
    param = of.createPartstat(partstat);
    pars.getBaseParameter().add(param);
    temp = val.getScheduleStatus();
    if (temp != null) {
        ScheduleStatusParamType ss = new ScheduleStatusParamType();
        ss.setText(temp);
        param = of.createScheduleStatus(ss);
        pars.getBaseParameter().add(param);
    }
    temp = val.getCuType();
    if (temp != null) {
        /*
      CutypeValueType cp;
      try {
        cp = CutypeValueType.fromValue(temp);
      } catch (Throwable t) {
        cp = CutypeValueType.UNKNOWN;
      }
      CutypeParamType c = new CutypeParamType();
      c.setText(cp.name());
      */
        CutypeParamType c = new CutypeParamType();
        c.setText(val.getCuType());
        param = of.createCutype(c);
        pars.getBaseParameter().add(param);
    }
    temp = val.getDelegatedFrom();
    if (temp != null) {
        DelegatedFromParamType df = new DelegatedFromParamType();
        df.getCalAddress().add(temp);
        param = of.createDelegatedFrom(df);
        pars.getBaseParameter().add(param);
    }
    temp = val.getDelegatedTo();
    if (temp != null) {
        DelegatedToParamType dt = new DelegatedToParamType();
        dt.getCalAddress().add(temp);
        param = of.createDelegatedTo(dt);
        pars.getBaseParameter().add(param);
    }
    temp = val.getDir();
    if (temp != null) {
        DirParamType d = new DirParamType();
        d.setUri(temp);
        param = of.createDir(d);
        pars.getBaseParameter().add(param);
    }
    temp = val.getLanguage();
    if (temp != null) {
        LanguageParamType l = new LanguageParamType();
        l.setText(temp);
        param = of.createLanguage(l);
        pars.getBaseParameter().add(param);
    }
    temp = val.getMember();
    if (temp != null) {
        MemberParamType m = new MemberParamType();
        m.getCalAddress().add(temp);
        param = of.createMember(m);
        pars.getBaseParameter().add(param);
    }
    /*
    temp = val.getRole();
    if (temp != null) {
      RoleValueType role;
      try {
        role = RoleValueType.fromValue(temp);
      } catch (Throwable t) {
        role = RoleValueType.REQ_PARTICIPANT;
      }

      RoleParamType r = new RoleParamType();
      r.setText(val.getRole());
      param = of.createRole(r);
      pars.getBaseParameter().add(param);
    }*/
    temp = val.getRole();
    if (temp != null) {
        RoleParamType r = new RoleParamType();
        r.setText(val.getRole());
        param = of.createRole(r);
        pars.getBaseParameter().add(param);
    }
    temp = val.getSentBy();
    if (temp != null) {
        SentByParamType sb = new SentByParamType();
        sb.setCalAddress(temp);
        param = of.createSentBy(sb);
        pars.getBaseParameter().add(param);
    }
    return prop;
}
Also used : DirParamType(ietf.params.xml.ns.icalendar_2.DirParamType) LanguageParamType(ietf.params.xml.ns.icalendar_2.LanguageParamType) PartstatParamType(ietf.params.xml.ns.icalendar_2.PartstatParamType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) CutypeParamType(ietf.params.xml.ns.icalendar_2.CutypeParamType) BwString(org.bedework.calfacade.BwString) RoleParamType(ietf.params.xml.ns.icalendar_2.RoleParamType) CnParamType(ietf.params.xml.ns.icalendar_2.CnParamType) MemberParamType(ietf.params.xml.ns.icalendar_2.MemberParamType) ScheduleStatusParamType(ietf.params.xml.ns.icalendar_2.ScheduleStatusParamType) RsvpParamType(ietf.params.xml.ns.icalendar_2.RsvpParamType) DelegatedToParamType(ietf.params.xml.ns.icalendar_2.DelegatedToParamType) AttendeePropType(ietf.params.xml.ns.icalendar_2.AttendeePropType) SentByParamType(ietf.params.xml.ns.icalendar_2.SentByParamType) DelegatedFromParamType(ietf.params.xml.ns.icalendar_2.DelegatedFromParamType)

Example 3 with BaseParameterType

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

the class XbwLocPropUpdater method applyUpdate.

public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    try {
        final ChangeTableEntry cte = ui.getCte();
        final BwEvent ev = ui.getEvent();
        final List<BwXproperty> xlocs = ev.getXproperties(xBedeworkLocation);
        // Should only be one or zero
        final BwXproperty xloc;
        if (Util.isEmpty(xlocs)) {
            xloc = null;
        } else {
            xloc = xlocs.get(0);
        }
        final String lang = UpdaterUtil.getLang(ui.getProp());
        final String xval = ((TextPropertyType) ui.getProp()).getText();
        final BaseParameterType keyParam = XcalUtil.findParam(ui.getProp(), XcalTags.xBedeworkLocationKey);
        final String keyName;
        if (keyParam != null) {
            keyName = ((TextParameterType) keyParam).getText();
        } else {
            keyName = null;
        }
        final BwLocation evLoc = ev.getLocation();
        if (ui.isRemove()) {
            if (xlocs == null) {
                // Nothing to remove
                return UpdateResult.getOkResult();
            }
            // TODO - match values?
            ev.removeXproperty(xloc);
            cte.addRemovedValue(xloc);
            if (evLoc != null) {
                ev.setLocation(null);
                cte.addRemovedValue(evLoc);
            }
            return UpdateResult.getOkResult();
        }
        if (ui.isAdd()) {
            if (xloc != null) {
                return new UpdateResult("Entity already has " + ui.getPropName() + " property - cannot add");
            }
            if (!checkLocation(ui, ev, lang, xval, null)) {
                final BwXproperty xp = makeXprop(lang, xval);
                ev.addXproperty(xp);
                cte.addAddedValue(xp);
            }
            return UpdateResult.getOkResult();
        }
        if (ui.isChange()) {
            if (xloc == null) {
                return new UpdateResult("Entity has no " + ui.getPropName() + " property - cannot change");
            }
            if (CalFacadeUtil.cmpObjval(xval, xloc.getValue()) != 0) {
                return new UpdateResult("Values don't match for update to " + ui.getPropName());
            }
            ev.removeXproperty(xloc);
            cte.addRemovedValue(xloc);
            final String nlang = UpdaterUtil.getLang(ui.getUpdprop());
            final String nxval = ((TextPropertyType) ui.getUpdprop()).getText();
            if (!checkLocation(ui, ev, nlang, nxval, keyName)) {
                final BwXproperty nxp = makeXprop(nlang, nxval);
                if (keyName != null) {
                    nxp.getParameters().add(new Xpar(XcalTags.xBedeworkLocationKey.getLocalPart(), keyName));
                }
                ev.addXproperty(nxp);
                cte.addAddedValue(nxp);
            }
        }
        return UpdateResult.getOkResult();
    } catch (final CalFacadeException cfe) {
        throw new WebdavException(cfe);
    }
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) BaseParameterType(ietf.params.xml.ns.icalendar_2.BaseParameterType) BwLocation(org.bedework.calfacade.BwLocation) BwXproperty(org.bedework.calfacade.BwXproperty) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry) BwString(org.bedework.calfacade.BwString) TextPropertyType(ietf.params.xml.ns.icalendar_2.TextPropertyType) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

BwString (org.bedework.calfacade.BwString)3 ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)2 CnParamType (ietf.params.xml.ns.icalendar_2.CnParamType)2 DirParamType (ietf.params.xml.ns.icalendar_2.DirParamType)2 LanguageParamType (ietf.params.xml.ns.icalendar_2.LanguageParamType)2 ScheduleStatusParamType (ietf.params.xml.ns.icalendar_2.ScheduleStatusParamType)2 SentByParamType (ietf.params.xml.ns.icalendar_2.SentByParamType)2 AttendeePropType (ietf.params.xml.ns.icalendar_2.AttendeePropType)1 BaseParameterType (ietf.params.xml.ns.icalendar_2.BaseParameterType)1 CutypeParamType (ietf.params.xml.ns.icalendar_2.CutypeParamType)1 DelegatedFromParamType (ietf.params.xml.ns.icalendar_2.DelegatedFromParamType)1 DelegatedToParamType (ietf.params.xml.ns.icalendar_2.DelegatedToParamType)1 MemberParamType (ietf.params.xml.ns.icalendar_2.MemberParamType)1 OrganizerPropType (ietf.params.xml.ns.icalendar_2.OrganizerPropType)1 PartstatParamType (ietf.params.xml.ns.icalendar_2.PartstatParamType)1 RoleParamType (ietf.params.xml.ns.icalendar_2.RoleParamType)1 RsvpParamType (ietf.params.xml.ns.icalendar_2.RsvpParamType)1 TextPropertyType (ietf.params.xml.ns.icalendar_2.TextPropertyType)1 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)1 BwEvent (org.bedework.calfacade.BwEvent)1