Search in sources :

Example 6 with BwContact

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

the class XbwContactPropUpdater method checkContact.

private boolean checkContact(final UpdateInfo ui, final BwEvent ev, final Set<BwContact> contacts, final String lang, final String val) throws CalFacadeException {
    final BwString sval = new BwString(lang, val);
    final BwContact contact = ui.getIcalCallback().findContact(sval);
    if (contact == null) {
        return false;
    }
    for (final BwContact c : contacts) {
        if (c.getCn().equals(sval)) {
            // Already present
            return true;
        }
    }
    ev.addContact(contact);
    ui.getCte(PropertyIndex.PropertyInfoIndex.CONTACT).addAddedValue(contact);
    return true;
}
Also used : BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact)

Example 7 with BwContact

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

the class AccessUtil method getAclChars.

/* ====================================================================
   *                   Private methods
   * ==================================================================== */
/* If the entity is not a collection we merge the access in with the container
   * access then return the merged aces. We do this because we call getPathInfo
   * with a collection entity. That method will recurse up to the root.
   *
   * For a calendar we just use the access for the calendar.
   *
   * The calendar/container access might be cached in the pathInfoTable.
   */
private char[] getAclChars(final BwShareableDbentity<?> ent) throws CalFacadeException {
    if ((!(ent instanceof BwEventProperty)) && (ent instanceof BwShareableContainedDbentity)) {
        BwCalendar container;
        if (ent instanceof BwCalendar) {
            container = (BwCalendar) ent;
        } else {
            container = getParent((BwShareableContainedDbentity<?>) ent);
        }
        if (container == null) {
            return null;
        }
        final String path = container.getPath();
        CalendarWrapper wcol = (CalendarWrapper) container;
        String aclStr;
        char[] aclChars = null;
        /* Get access for the parent first if we have one */
        BwCalendar parent = getParent(wcol);
        if (parent != null) {
            aclStr = new String(merged(getAclChars(parent), parent.getPath(), wcol.getAccess()));
        } else if (wcol.getAccess() != null) {
            aclStr = wcol.getAccess();
        } else {
            // At root
            throw new CalFacadeException("Collections must have default access set at root");
        }
        if (aclStr != null) {
            aclChars = aclStr.toCharArray();
        }
        if (ent instanceof BwCalendar) {
            return aclChars;
        }
        return merged(aclChars, path, ent.getAccess());
    }
    /* This is a way of making other objects sort of shareable.
     * The objects are locations, sponsors and categories.
     * (also calsuite)
     *
     * We store the default access in the owner principal and manipulate that to give
     * us some degree of sharing.
     *
     * In effect, the owner becomes the container for the object.
     */
    String aclString = null;
    String entAccess = ent.getAccess();
    BwPrincipal owner = (BwPrincipal) cb.getPrincipal(ent.getOwnerHref());
    if (ent instanceof BwCategory) {
        aclString = owner.getCategoryAccess();
    } else if (ent instanceof BwLocation) {
        aclString = owner.getLocationAccess();
    } else if (ent instanceof BwContact) {
        aclString = owner.getContactAccess();
    }
    if (aclString == null) {
        if (entAccess == null) {
            if (ent.getPublick()) {
                return Access.getDefaultPublicAccess().toCharArray();
            }
            return Access.getDefaultPersonalAccess().toCharArray();
        }
        return entAccess.toCharArray();
    }
    if (entAccess == null) {
        return aclString.toCharArray();
    }
    try {
        Acl acl = Acl.decode(entAccess.toCharArray());
        acl = acl.merge(aclString.toCharArray(), "/owner");
        return acl.getEncoded();
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) BwShareableContainedDbentity(org.bedework.calfacade.base.BwShareableContainedDbentity) BwCategory(org.bedework.calfacade.BwCategory) BwEventProperty(org.bedework.calfacade.BwEventProperty) BwCalendar(org.bedework.calfacade.BwCalendar) BwContact(org.bedework.calfacade.BwContact) Acl(org.bedework.access.Acl) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) BwPrincipal(org.bedework.calfacade.BwPrincipal) CalendarWrapper(org.bedework.calfacade.wrappers.CalendarWrapper)

Example 8 with BwContact

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

the class EntityBuilder method makeContact.

BwContact makeContact() throws CalFacadeException {
    final BwContact ent = new BwContact();
    restoreSharedEntity(ent);
    ent.setUid(getString(PropertyInfoIndex.UID));
    ent.setCn((BwString) restoreBwString(PropertyInfoIndex.CN, false));
    ent.setPhone(getString(PropertyInfoIndex.PHONE));
    ent.setEmail(getString(PropertyInfoIndex.EMAIL));
    ent.setLink(getString(PropertyInfoIndex.URL));
    return ent;
}
Also used : BwContact(org.bedework.calfacade.BwContact)

Example 9 with BwContact

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

the class BwIndexEsImpl method fetchContact.

@Override
public BwContact fetchContact(final String val, final PropertyInfoIndex... index) throws CalFacadeException {
    final EntityBuilder eb = fetchEntity(docTypeContact, val, index);
    if (eb == null) {
        return null;
    }
    final BwContact entity = eb.makeContact();
    if (entity == null) {
        return null;
    }
    contacts.put(entity);
    return entity;
}
Also used : BwContact(org.bedework.calfacade.BwContact)

Example 10 with BwContact

use of org.bedework.calfacade.BwContact 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)

Aggregations

BwContact (org.bedework.calfacade.BwContact)25 BwCategory (org.bedework.calfacade.BwCategory)11 BwString (org.bedework.calfacade.BwString)11 BwEvent (org.bedework.calfacade.BwEvent)10 BwLocation (org.bedework.calfacade.BwLocation)9 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)9 BwXproperty (org.bedework.calfacade.BwXproperty)5 BwAttendee (org.bedework.calfacade.BwAttendee)4 BwCalendar (org.bedework.calfacade.BwCalendar)4 BwDateTime (org.bedework.calfacade.BwDateTime)4 EventInfo (org.bedework.calfacade.svc.EventInfo)4 Period (net.fortuna.ical4j.model.Period)3 BwEventProxy (org.bedework.calfacade.BwEventProxy)3 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)2 BwAttachment (org.bedework.calfacade.BwAttachment)2 BwFreeBusyComponent (org.bedework.calfacade.BwFreeBusyComponent)2 BwGeo (org.bedework.calfacade.BwGeo)2 BwLongString (org.bedework.calfacade.BwLongString)2 BwOrganizer (org.bedework.calfacade.BwOrganizer)2 BwRelatedTo (org.bedework.calfacade.BwRelatedTo)2