Search in sources :

Example 16 with BwContact

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

the class BwIndexEsImpl method restoreEvProps.

private boolean restoreEvProps(final Response resp, final EventInfo ei) {
    final BwEvent ev = ei.getEvent();
    try {
        final Set<String> catUids = ev.getCategoryUids();
        if (!Util.isEmpty(catUids)) {
            for (final String uid : catUids) {
                BwCategory evprop = categories.get(uid);
                if (evprop == null) {
                    evprop = fetchCat(uid, PropertyInfoIndex.UID);
                    if (evprop == null) {
                        warn("Unable to fetch category " + uid + " for event " + ev.getHref());
                        errorReturn(resp, "Unable to fetch category " + uid);
                        continue;
                    }
                }
                ev.addCategory(evprop);
            }
        }
        final Set<String> contactUids = ev.getContactUids();
        if (!Util.isEmpty(contactUids)) {
            for (final String uid : contactUids) {
                BwContact evprop = contacts.get(uid);
                if (evprop == null) {
                    evprop = fetchContact(uid, PropertyInfoIndex.UID);
                    if (evprop == null) {
                        warn("Unable to fetch contact " + uid + " for event " + ev.getHref());
                        errorReturn(resp, "Unable to fetch contact " + uid);
                        continue;
                    }
                }
                ev.addContact(evprop);
            }
        }
        final String uid = ev.getLocationUid();
        if (uid != null) {
            BwLocation evprop = locations.get(uid);
            if (evprop == null) {
                evprop = fetchLocation(uid, PropertyInfoIndex.UID);
                if (evprop == null) {
                    warn("Unable to fetch location " + uid + " for event " + ev.getHref());
                    errorReturn(resp, "Unable to fetch location " + uid);
                }
            }
            if (evprop != null) {
                ev.setLocation(evprop);
            }
        }
        return resp.getStatus() == ok;
    } catch (final Throwable t) {
        errorReturn(resp, t);
        return false;
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) BwCategory(org.bedework.calfacade.BwCategory) BwEvent(org.bedework.calfacade.BwEvent) BwContact(org.bedework.calfacade.BwContact)

Example 17 with BwContact

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

the class DocBuilder method indexContacts.

private void indexContacts(final Set<BwContact> val) throws CalFacadeException {
    try {
        if (Util.isEmpty(val)) {
            return;
        }
        // Only index enough to retrieve the actual contact
        startArray(getJname(PropertyInfoIndex.CONTACT));
        for (final BwContact c : val) {
            c.fixNames(basicSysprops, principal);
            startObject();
            makeField(PropertyInfoIndex.HREF, c.getHref());
            makeField(PropertyInfoIndex.CN, c.getCn());
            makeField(ParameterInfoIndex.UID.getJname(), c.getUid());
            makeField(ParameterInfoIndex.ALTREP.getJname(), c.getLink());
            endObject();
        }
        endArray();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) BwContact(org.bedework.calfacade.BwContact) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 18 with BwContact

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

the class PrincipalsAndPrefsDAO method removeFromAllPrefs.

public void removeFromAllPrefs(final BwShareableDbentity val) throws CalFacadeException {
    final HibSession sess = getSess();
    final String q;
    if (val instanceof BwCategory) {
        q = getCategoryPrefForAllQuery;
    } else if (val instanceof BwCalendar) {
        q = removeCalendarPrefForAllQuery;
    } else if (val instanceof BwContact) {
        q = removeContactPrefForAllQuery;
    } else if (val instanceof BwLocation) {
        q = removeLocationPrefForAllQuery;
    } else {
        throw new CalFacadeException("Can't handle " + val);
    }
    sess.createQuery(q);
    sess.setInt("id", val.getId());
    sess.executeUpdate();
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwLocation(org.bedework.calfacade.BwLocation) BwCategory(org.bedework.calfacade.BwCategory) BwCalendar(org.bedework.calfacade.BwCalendar) BwContact(org.bedework.calfacade.BwContact) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 19 with BwContact

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

the class Restorer method restoreContacts.

protected void restoreContacts() throws CalFacadeException {
    try {
        final Path p = openDir(Defs.contactsDirName);
        if (p == null) {
            return;
        }
        final DirRestore<BwContact> dirRestore = new DirRestore<>(p, restoreCtct);
        final EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
        Files.walkFileTree(p, opts, Integer.MAX_VALUE, dirRestore);
    } catch (final IOException ie) {
        throw new CalFacadeException(ie);
    } finally {
        popPath();
    }
}
Also used : Path(java.nio.file.Path) FileVisitOption(java.nio.file.FileVisitOption) BwContact(org.bedework.calfacade.BwContact) IOException(java.io.IOException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 20 with BwContact

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

the class Dumper method dumpContacts.

protected void dumpContacts(final boolean publick) throws CalFacadeException {
    try {
        makeDir(Defs.contactsDirName, false);
        final Collection<BwContact> ents;
        if (publick) {
            ents = getSvc().getContactsHandler().getPublic();
        } else {
            ents = getSvc().getContactsHandler().get();
        }
        for (final BwContact ent : ents) {
            incCount(DumpGlobals.contacts);
            final File f = makeFile(ent.getUid() + ".xml");
            ent.dump(f);
        }
    } finally {
        popPath();
    }
}
Also used : BwContact(org.bedework.calfacade.BwContact) File(java.io.File)

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