Search in sources :

Example 6 with EsDocInfo

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);
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) BwPreferences(org.bedework.calfacade.svc.BwPreferences) EventInfo(org.bedework.calfacade.svc.EventInfo) IndexException(org.bedework.util.indexing.IndexException) BwResource(org.bedework.calfacade.BwResource) BwCategory(org.bedework.calfacade.BwCategory) BwResourceContent(org.bedework.calfacade.BwResourceContent) BwCalendar(org.bedework.calfacade.BwCalendar) BwContact(org.bedework.calfacade.BwContact) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) BwPrincipal(org.bedework.calfacade.BwPrincipal) VersionConflictEngineException(org.opensearch.index.engine.VersionConflictEngineException) EsDocInfo(org.bedework.util.opensearch.EsDocInfo) BwFilterDef(org.bedework.calfacade.BwFilterDef)

Aggregations

EsDocInfo (org.bedework.util.opensearch.EsDocInfo)6 EventInfo (org.bedework.calfacade.svc.EventInfo)3 DeleteIndexRequest (org.opensearch.action.admin.indices.delete.DeleteIndexRequest)3 IndexRequest (org.opensearch.action.index.IndexRequest)3 CreateIndexRequest (org.opensearch.client.indices.CreateIndexRequest)3 BwEvent (org.bedework.calfacade.BwEvent)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 VersionConflictEngineException (org.opensearch.index.engine.VersionConflictEngineException)2 HashMap (java.util.HashMap)1 Period (net.fortuna.ical4j.model.Period)1 BwCalendar (org.bedework.calfacade.BwCalendar)1 BwCategory (org.bedework.calfacade.BwCategory)1 BwContact (org.bedework.calfacade.BwContact)1 BwDateTime (org.bedework.calfacade.BwDateTime)1 BwEventProperty (org.bedework.calfacade.BwEventProperty)1 BwFilterDef (org.bedework.calfacade.BwFilterDef)1 BwLocation (org.bedework.calfacade.BwLocation)1 BwPrincipal (org.bedework.calfacade.BwPrincipal)1 BwResource (org.bedework.calfacade.BwResource)1 BwResourceContent (org.bedework.calfacade.BwResourceContent)1