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;
}
}
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);
}
}
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();
}
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();
}
}
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();
}
}
Aggregations