Search in sources :

Example 11 with BwLocation

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

the class BwStringRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    if (name.equals("bwstring")) {
        // 3.5 onwards we wrapped with a tag. Do nothing
        return;
    }
    BwString entity = (BwString) pop();
    if (top() instanceof BwRequestStatus) {
        BwRequestStatus rs = (BwRequestStatus) top();
        rs.setDescription(entity);
        return;
    }
    if (top() instanceof BwCategory) {
        BwCategory cat = (BwCategory) top();
        if (name.equals("keyword")) {
            cat.setWord(entity);
        } else if (name.equals("desc")) {
            cat.setDescription(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwContact) {
        BwContact ent = (BwContact) top();
        if (name.equals("value")) {
            ent.setCn(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwLocation) {
        BwLocation loc = (BwLocation) top();
        if (name.equals("addr")) {
            loc.setAddress(entity);
        } else if (name.equals("subaddr")) {
            loc.setSubaddress(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwFilterDef) {
        BwFilterDef f = (BwFilterDef) top();
        if (name.equals("display-name")) {
            f.addDisplayName(entity);
        } else if (name.equals("subaddr")) {
            f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwAlarm) {
        BwAlarm a = (BwAlarm) top();
        if (name.equals("description")) {
            a.addDescription(entity);
            if (entity.getLang() != null) {
                a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
            } else {
                a.addDescription(entity);
            }
            return;
        }
        if (name.equals("summary")) {
            a.addSummary(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    EventInfo ei = (EventInfo) top();
    BwEvent e = ei.getEvent();
    if (e instanceof BwEventProxy) {
        e = ((BwEventProxy) e).getRef();
    }
    if (name.equals("comment")) {
        e.addComment(entity);
    } else if (name.equals("description")) {
        e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
    } else if (name.equals("resource")) {
        e.addResource(entity);
    } else if (name.equals("summary")) {
        e.addSummary(entity);
    } else {
        unknownTag(name);
    }
}
Also used : BwLongString(org.bedework.calfacade.BwLongString) BwLocation(org.bedework.calfacade.BwLocation) BwRequestStatus(org.bedework.calfacade.BwRequestStatus) EventInfo(org.bedework.calfacade.svc.EventInfo) BwXproperty(org.bedework.calfacade.BwXproperty) BwCategory(org.bedework.calfacade.BwCategory) BwFilterDef(org.bedework.calfacade.BwFilterDef) BwEvent(org.bedework.calfacade.BwEvent) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 12 with BwLocation

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

the class SchedulingBase method copyEvent.

protected BwEvent copyEvent(final BwEvent origEv, final BwEvent masterEv, final BwPrincipal owner) throws CalFacadeException {
    final BwEvent newEv;
    BwEventProxy proxy = null;
    final String ownerHref = owner.getPrincipalRef();
    if (origEv instanceof BwEventProxy) {
        proxy = (BwEventProxy) origEv;
        if (masterEv == null) {
            /* we are being asked to copy an instance of a recurring event - rather than
         * a complete recurring event + all overrides - clone the master
         */
            newEv = new BwEventObj();
            origEv.copyTo(newEv);
            newEv.setRecurring(false);
            // Return the instance copy
            proxy = null;
        } else {
            // Clone the annotation and set the master and target to our new master
            // ANNOTATION
            proxy = proxy.clone(masterEv, masterEv);
            newEv = proxy.getRef();
        }
    } else {
        // getSvc().reAttach(origEv);
        newEv = (BwEvent) origEv.clone();
    }
    if (!Util.isEmpty(newEv.getAttendees())) {
        for (BwAttendee att : newEv.getAttendees()) {
            att.setScheduleStatus(null);
        }
    }
    if (newEv.getOrganizer() != null) {
        newEv.getOrganizer().setScheduleStatus(null);
    }
    newEv.setOwnerHref(ownerHref);
    newEv.setCreatorHref(ownerHref);
    newEv.setDtstamps(getCurrentTimestamp());
    if (owner.equals(getPrincipal())) {
        if (proxy != null) {
            return proxy;
        }
        return newEv;
    }
    /* Copy event entities */
    BwLocation loc = newEv.getLocation();
    if (loc != null) {
        loc = (BwLocation) loc.clone();
        loc.setOwnerHref(ownerHref);
        loc.setCreatorHref(ownerHref);
        loc.initUid();
        newEv.setLocation(loc);
    }
    BwContact contact = newEv.getContact();
    if (contact != null) {
        contact = (BwContact) contact.clone();
        contact.setOwnerHref(ownerHref);
        contact.setCreatorHref(ownerHref);
        contact.initUid();
        newEv.setContact(contact);
    }
    if (proxy != null) {
        return proxy;
    }
    return newEv;
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) BwEvent(org.bedework.calfacade.BwEvent) BwContact(org.bedework.calfacade.BwContact) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAttendee(org.bedework.calfacade.BwAttendee) BwEventObj(org.bedework.calfacade.BwEventObj)

Example 13 with BwLocation

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

the class ProcessSetstatus method setStatusLocation.

private boolean setStatusLocation(final String uid, final String status) throws Throwable {
    try {
        if (uid == null) {
            error("Expected a uid");
            return false;
        }
        open();
        final BwLocation ent = getSvci().getLocationsHandler().getPersistent(uid);
        if (ent == null) {
            error("No entity with uid " + uid);
            return false;
        }
        ent.setStatus(status);
        getSvci().getLocationsHandler().update(ent);
        return true;
    } finally {
        close();
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation)

Example 14 with BwLocation

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

the class ProcessUpdate method updateLocation.

private boolean updateLocation() {
    try {
        open();
        final BwLocation loc = getPersistentLoc();
        if (loc == null) {
            return true;
        }
        while (true) {
            final String upname = word();
            if (upname == null) {
                break;
            }
            switch(upname) {
                case "addkey":
                    {
                        final String name = qstringFor("key name");
                        final String val = qstringFor("key value");
                        loc.addKey(name, val);
                        break;
                    }
                case "updkey":
                    {
                        final String name = qstringFor("key name");
                        final String val = qstringFor("key value");
                        loc.updKey(name, val);
                        break;
                    }
                case "delkey":
                    {
                        final String name = qstringFor("key name");
                        loc.delKey(name);
                        break;
                    }
            }
        }
        getSvci().getLocationsHandler().update(loc);
        return true;
    } catch (final Throwable t) {
        error(t);
        return false;
    } finally {
        close();
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation)

Example 15 with BwLocation

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

the class CmdUtilHelper method getPersistentLoc.

/* expect a quoted uid next
   */
protected BwLocation getPersistentLoc() throws Throwable {
    final String uid = quotedVal();
    if (uid == null) {
        error("Expected a quoted uid");
        return null;
    }
    final BwLocation loc = getSvci().getLocationsHandler().getPersistent(uid);
    if (loc == null) {
        error("Unable to access location " + uid);
    }
    return loc;
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) BwString(org.bedework.calfacade.BwString)

Aggregations

BwLocation (org.bedework.calfacade.BwLocation)28 BwString (org.bedework.calfacade.BwString)11 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)10 BwContact (org.bedework.calfacade.BwContact)9 BwEvent (org.bedework.calfacade.BwEvent)9 BwCategory (org.bedework.calfacade.BwCategory)8 BwXproperty (org.bedework.calfacade.BwXproperty)4 Period (net.fortuna.ical4j.model.Period)3 BwAttendee (org.bedework.calfacade.BwAttendee)3 EventInfo (org.bedework.calfacade.svc.EventInfo)3 File (java.io.File)2 Parameter (net.fortuna.ical4j.model.Parameter)2 XParameter (net.fortuna.ical4j.model.parameter.XParameter)2 BwAttachment (org.bedework.calfacade.BwAttachment)2 BwDateTime (org.bedework.calfacade.BwDateTime)2 BwEventProxy (org.bedework.calfacade.BwEventProxy)2 BwFreeBusyComponent (org.bedework.calfacade.BwFreeBusyComponent)2 BwGeo (org.bedework.calfacade.BwGeo)2 BwOrganizer (org.bedework.calfacade.BwOrganizer)2 BwRelatedTo (org.bedework.calfacade.BwRelatedTo)2