Search in sources :

Example 1 with ComponentsSelectionType

use of org.oasis_open.docs.ws_calendar.ns.soap.ComponentsSelectionType in project bw-calendar-engine by Bedework.

the class BwUpdates method applyUpdate.

private UpdateResult applyUpdate(final EventInfo ei, final ComponentSelectionType selPar) throws WebdavException {
    /* First two selects just get us in to the events */
    ComponentSelectionType sel = selPar;
    // Top level must be "vcalendar"
    if ((sel == null) || (sel.getVcalendar() == null)) {
        return new UpdateResult("Not \"vcalendar\"");
    }
    // Next - expect "components"
    ComponentsSelectionType csel = sel.getComponents();
    if (csel == null) {
        return new UpdateResult("Not \"component\"");
    }
    for (ComponentReferenceType c : csel.getRemove()) {
        UpdateResult ur = removeOverride(ei, c);
        if (!ur.getOk()) {
            return ur;
        }
    }
    for (ComponentReferenceType c : csel.getAdd()) {
        UpdateResult ur = addOverride(ei, c);
        if (!ur.getOk()) {
            return ur;
        }
    }
    /* Updates may be applied to the master or any overrides selected by uid and
     * recurrence-id
     */
    for (ComponentSelectionType cs : csel.getComponent()) {
        BaseComponentType ent = cs.getBaseComponent().getValue();
        // Must be a component matching the current one.
        if (ent == null) {
            return new UpdateResult("Missing component to match");
        }
        Integer entType = entTypes.get(ent.getClass());
        if (entType == null) {
            return new UpdateResult("Unknown entity type: " + ent.getClass());
        }
        if (entType != ei.getEvent().getEntityType()) {
            return new UpdateResult("No matching entity");
        }
        List<EventInfo> entities = new ArrayList<EventInfo>();
        entities.add(ei);
        entities.addAll(ei.getOverrides());
        entities = match(// sel,
        entities, ent);
        if ((entities == null) || (entities.size() == 0)) {
            return new UpdateResult("No matching entity");
        }
        if ((cs.getProperties() == null) && (cs.getComponents() == null)) {
            // No properties or components - error
            return new UpdateResult("Must select \"components\" and/or \"properties\"");
        }
        /* At this point we either select properties to change or nested components
       */
        if (cs.getComponents() != null) {
            UpdateResult ur = applySubCompUpdates(ei, cs.getComponents());
            if (!ur.getOk()) {
                return ur;
            }
        }
        if (cs.getProperties() != null) {
            // Updating properties
            UpdateResult ur = updateEventsProperties(entities, cs.getProperties());
            if (!ur.getOk()) {
                return ur;
            }
        }
    }
    return UpdateResult.getOkResult();
}
Also used : BaseComponentType(ietf.params.xml.ns.icalendar_2.BaseComponentType) ComponentSelectionType(org.oasis_open.docs.ws_calendar.ns.soap.ComponentSelectionType) EventInfo(org.bedework.calfacade.svc.EventInfo) ComponentsSelectionType(org.oasis_open.docs.ws_calendar.ns.soap.ComponentsSelectionType) ArrayList(java.util.ArrayList) ComponentReferenceType(org.oasis_open.docs.ws_calendar.ns.soap.ComponentReferenceType) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Aggregations

BaseComponentType (ietf.params.xml.ns.icalendar_2.BaseComponentType)1 ArrayList (java.util.ArrayList)1 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)1 EventInfo (org.bedework.calfacade.svc.EventInfo)1 ComponentReferenceType (org.oasis_open.docs.ws_calendar.ns.soap.ComponentReferenceType)1 ComponentSelectionType (org.oasis_open.docs.ws_calendar.ns.soap.ComponentSelectionType)1 ComponentsSelectionType (org.oasis_open.docs.ws_calendar.ns.soap.ComponentsSelectionType)1