use of org.bedework.util.opensearch.EsDocInfo in project bw-calendar-engine by Bedework.
the class BwIndexEsImpl method index.
/* Return the response after indexing */
private IndexResponse index(final Object rec, final boolean waitForIt, final boolean forTouch) throws CalFacadeException {
EsDocInfo di = null;
try {
if (rec instanceof EventInfo) {
mustBe(docTypeEvent);
return indexEvent((EventInfo) rec, waitForIt);
}
final DocBuilder db = getDocBuilder();
if (rec instanceof BwCalendar) {
mustBe(docTypeCollection);
di = db.makeDoc((BwCalendar) rec);
}
if (rec instanceof BwCategory) {
mustBe(docTypeCategory);
di = db.makeDoc((BwCategory) rec);
}
if (rec instanceof BwContact) {
mustBe(docTypeContact);
di = db.makeDoc((BwContact) rec);
}
if (rec instanceof BwLocation) {
mustBe(docTypeLocation);
di = db.makeDoc((BwLocation) rec);
}
if (rec instanceof BwPrincipal) {
mustBe(docTypePrincipal);
di = db.makeDoc((BwPrincipal) rec);
}
if (rec instanceof BwPreferences) {
mustBe(docTypePreferences);
di = db.makeDoc((BwPreferences) rec);
}
if (rec instanceof BwResource) {
mustBe(docTypeResource);
di = db.makeDoc((BwResource) rec);
}
if (rec instanceof BwResourceContent) {
mustBe(docTypeResourceContent);
di = db.makeDoc((BwResourceContent) rec);
}
if (rec instanceof BwFilterDef) {
mustBe(docTypeFilter);
di = db.makeDoc((BwFilterDef) rec);
}
if (di != null) {
return indexDoc(di, waitForIt);
}
throw new CalFacadeException(new IndexException(IndexException.unknownRecordType, rec.getClass().getName()));
} catch (final CalFacadeException cfe) {
throw cfe;
} catch (final VersionConflictEngineException vcee) {
if (forTouch) {
// Ignore - already touched
return null;
}
error(vcee);
throw new CalFacadeException(vcee);
/* Can't do this any more
if (vcee.currentVersion() == vcee.getProvidedVersion()) {
warn("Failed index with equal version for type " +
di.getType() +
" and id " + di.getId());
}
return null;
*/
} catch (final Throwable t) {
throw new CalFacadeException(t);
}
}
Aggregations