Search in sources :

Example 91 with CalFacadeException

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

the class BwIndexEsImpl method indexEvent.

private IndexResponse indexEvent(final EventInfo ei, final ItemKind kind, final BwDateTime start, final BwDateTime end, final String recurid, final DateLimits dl) throws CalFacadeException {
    final BwEvent ev = ei.getEvent();
    try {
        final DocBuilder db = getDocBuilder();
        final EsDocInfo di = db.makeDoc(ei, kind, start, end, recurid);
        if (dl != null) {
            dl.checkMin(start);
            dl.checkMax(end);
        }
        return indexDoc(di);
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final VersionConflictEngineException vcee) {
        if (vcee.getCurrentVersion() == vcee.getProvidedVersion()) {
            warn("Failed index with equal version for kind " + kind + " and href " + ev.getHref());
        }
        return null;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : VersionConflictEngineException(org.elasticsearch.index.engine.VersionConflictEngineException) EsDocInfo(org.bedework.util.elasticsearch.EsDocInfo) BwEvent(org.bedework.calfacade.BwEvent) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 92 with CalFacadeException

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

the class BwIndexEsImpl method markUpdated.

private void markUpdated(final String docType) throws CalFacadeException {
    UpdateInfo ui = updateInfo.get(targetIndex);
    if (ui == null) {
        currentChangeToken();
    }
    ui = updateInfo.get(targetIndex);
    if (ui == null) {
        throw new CalFacadeException("Unable to set updateInfo");
    }
    if ((docType == null) || docType.equals(docTypeUnknown)) {
        categories.clear();
        contacts.clear();
        locations.clear();
    } else if (docType.equals(docTypeCategory)) {
        categories.clear();
    } else if (docType.equals(docTypeContact)) {
        contacts.clear();
    } else if (docType.equals(docTypeLocation)) {
        locations.clear();
    }
    ui.setUpdate(true);
}
Also used : UpdateInfo(org.bedework.util.elasticsearch.DocBuilderBase.UpdateInfo) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 93 with CalFacadeException

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

the class DocBuilder method makeDoc.

/* Return the docinfo for the indexer */
EsDocInfo makeDoc(final BwLocation ent) throws CalFacadeException {
    try {
        /* We don't have real collections. It's been the practice to
         create "/" delimited names to emulate a hierarchy. Look out
         for these and try to create a real path based on them.
       */
        ent.fixNames(basicSysprops, principal);
        startObject();
        makeShareableContained(ent);
        makeField(PropertyInfoIndex.NAME, ent.getAddressField());
        makeField(PropertyInfoIndex.UID, ent.getUid());
        makeField(PropertyInfoIndex.HREF, ent.getHref());
        // These 2 fields are composite fields
        makeField(PropertyInfoIndex.ADDRESS, ent.getAddress());
        makeField(PropertyInfoIndex.SUBADDRESS, ent.getSubaddress());
        // These fields are part of the address field
        makeField(PropertyInfoIndex.ADDRESS_FLD, ent.getAddressField());
        makeField(PropertyInfoIndex.ROOM_FLD, ent.getRoomField());
        makeField(PropertyInfoIndex.SUB1_FLD, ent.getSubField1());
        makeField(PropertyInfoIndex.SUB2_FLD, ent.getSubField2());
        makeField(PropertyInfoIndex.ACCESSIBLE_FLD, ent.getAccessible());
        makeField(PropertyInfoIndex.GEOURI_FLD, ent.getGeouri());
        makeField(PropertyInfoIndex.STATUS, ent.getStatus());
        // These fields are part of the subaddress field
        makeField(PropertyInfoIndex.STREET_FLD, ent.getStreet());
        makeField(PropertyInfoIndex.CITY_FLD, ent.getCity());
        makeField(PropertyInfoIndex.STATE_FLD, ent.getState());
        makeField(PropertyInfoIndex.ZIP_FLD, ent.getZip());
        makeField(PropertyInfoIndex.ALTADDRESS_FLD, ent.getAlternateAddress());
        makeField(PropertyInfoIndex.CODEIDX_FLD, ent.getCode());
        makeField(PropertyInfoIndex.LOC_KEYS_FLD, ent.getKeys());
        makeField(PropertyInfoIndex.URL, ent.getLink());
        endObject();
        return makeDocInfo(BwIndexer.docTypeLocation, 0, ent.getHref());
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 94 with CalFacadeException

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

the class DocBuilder method indexAlarms.

private void indexAlarms(final BwDateTime start, final Set<BwAlarm> alarms) throws CalFacadeException {
    try {
        if (Util.isEmpty(alarms)) {
            return;
        }
        startArray(getJname(PropertyInfoIndex.VALARM));
        for (final BwAlarm al : alarms) {
            startObject();
            makeField(PropertyInfoIndex.OWNER, al.getOwnerHref());
            makeField(PropertyInfoIndex.PUBLIC, al.getPublick());
            final int atype = al.getAlarmType();
            final String action;
            if (atype != BwAlarm.alarmTypeOther) {
                action = BwAlarm.alarmTypes[atype];
            } else {
                final List<BwXproperty> xps = al.getXicalProperties("ACTION");
                action = xps.get(0).getValue();
            }
            makeField(PropertyInfoIndex.ACTION, action);
            try {
                final Set<String> triggerTimes = new TreeSet<>();
                Date dt = null;
                for (int i = 0; i < 100; i++) {
                    // Arb limit
                    dt = al.getNextTriggerDate(start, dt);
                    if (dt == null) {
                        break;
                    }
                    triggerTimes.add(DateTimeUtil.isoDateTimeUTC(dt));
                }
                if (!Util.isEmpty(triggerTimes)) {
                    makeField(PropertyInfoIndex.NEXT_TRIGGER_DATE_TIME, triggerTimes);
                }
            } catch (final Throwable t) {
                error("Exception calculating next trigger");
                error(t);
            }
            makeField(PropertyInfoIndex.TRIGGER, al.getTrigger());
            if (al.getTriggerDateTime()) {
                makeField(PropertyInfoIndex.TRIGGER_DATE_TIME, true);
            } else if (!al.getTriggerStart()) {
                makeField(ParameterInfoIndex.RELATED.getJname(), Related.END.getValue());
            }
            if (al.getDuration() != null) {
                makeField(PropertyInfoIndex.DURATION, al.getDuration());
                makeField(PropertyInfoIndex.REPEAT, al.getRepeat());
            }
            if (atype == BwAlarm.alarmTypeAudio) {
                makeField(PropertyInfoIndex.ATTACH, al.getAttach());
            } else if (atype == BwAlarm.alarmTypeDisplay) {
                /* This is required but somehow we got a bunch of alarms with no description
           * Is it possibly because of the rollback issue I (partially) fixed?
           */
                makeField(PropertyInfoIndex.DESCRIPTION, al.getDescription());
            } else if (atype == BwAlarm.alarmTypeEmail) {
                makeField(PropertyInfoIndex.ATTACH, al.getAttach());
                makeField(PropertyInfoIndex.DESCRIPTION, al.getDescription());
                makeField(PropertyInfoIndex.SUMMARY, al.getSummary());
                if (al.getNumAttendees() > 0) {
                    indexAttendees(al.getAttendees(), false);
                }
            } else if (atype == BwAlarm.alarmTypeProcedure) {
                makeField(PropertyInfoIndex.ATTACH, al.getAttach());
                makeField(PropertyInfoIndex.DESCRIPTION, al.getDescription());
            } else {
                makeField(PropertyInfoIndex.DESCRIPTION, al.getDescription());
            }
            indexXprops(al);
            endObject();
        }
        endArray();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) BwXproperty(org.bedework.calfacade.BwXproperty) TreeSet(java.util.TreeSet) BwAlarm(org.bedework.calfacade.BwAlarm) Date(java.util.Date) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 95 with CalFacadeException

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

the class DocBuilder method getHref.

/* ===================================================================
   *                   package private methods
   * =================================================================== */
String getHref(final BwShareableContainedDbentity val) throws CalFacadeException {
    if (val instanceof BwEvent) {
        return ((BwEvent) val).getHref();
    }
    if (val instanceof BwCalendar) {
        return ((BwCalendar) val).getPath();
    }
    if (val instanceof FixNamesEntity) {
        final FixNamesEntity ent = (FixNamesEntity) val;
        ent.fixNames(basicSysprops, principal);
        return ent.getHref();
    }
    throw new CalFacadeException("Unhandled class " + val);
}
Also used : FixNamesEntity(org.bedework.calfacade.base.FixNamesEntity) BwEvent(org.bedework.calfacade.BwEvent) BwCalendar(org.bedework.calfacade.BwCalendar) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)298 BwCalendar (org.bedework.calfacade.BwCalendar)55 BwEvent (org.bedework.calfacade.BwEvent)55 EventInfo (org.bedework.calfacade.svc.EventInfo)37 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)32 ArrayList (java.util.ArrayList)28 BwString (org.bedework.calfacade.BwString)26 BwDateTime (org.bedework.calfacade.BwDateTime)24 IndexException (org.bedework.util.indexing.IndexException)23 BwPrincipal (org.bedework.calfacade.BwPrincipal)22 TreeSet (java.util.TreeSet)19 BwAttendee (org.bedework.calfacade.BwAttendee)18 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)16 Calendar (net.fortuna.ical4j.model.Calendar)15 DateTime (net.fortuna.ical4j.model.DateTime)15 Period (net.fortuna.ical4j.model.Period)13 BwCategory (org.bedework.calfacade.BwCategory)13 StringReader (java.io.StringReader)12 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)12 BwEventProxy (org.bedework.calfacade.BwEventProxy)12