Search in sources :

Example 1 with IndexException

use of org.bedework.util.indexing.IndexException 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 2 with IndexException

use of org.bedework.util.indexing.IndexException in project bw-calendar-engine by Bedework.

the class DocBuilder method indexGeo.

private void indexGeo(final BwGeo val) throws CalFacadeException {
    try {
        if (val == null) {
            return;
        }
        startObject(getJname(PropertyInfoIndex.GEO));
        makeField("lat", val.getLatitude().toPlainString());
        makeField("lon", val.getLongitude().toPlainString());
        endObject();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with IndexException

use of org.bedework.util.indexing.IndexException in project bw-calendar-engine by Bedework.

the class DocBuilder method indexXprops.

private void indexXprops(final XpropsEntity ent) throws CalFacadeException {
    try {
        if (Util.isEmpty(ent.getXproperties())) {
            return;
        }
        /* First output ones we know about with our own name */
        for (final String nm : interestingXprops.keySet()) {
            final List<BwXproperty> props = ent.getXproperties(nm);
            if (Util.isEmpty(props)) {
                continue;
            }
            startArray(interestingXprops.get(nm));
            for (final BwXproperty xp : props) {
                if (xp.getName().equals(BwXproperty.bedeworkSuggestedTo)) {
                    final String val = xp.getValue();
                    // Find the second ":" delimiter
                    final int pos = val.indexOf(":", 2);
                    if (pos < 0) {
                        // Bad value
                        continue;
                    }
                    value(val.substring(0, pos));
                    continue;
                }
                String pars = xp.getPars();
                if (pars == null) {
                    pars = "";
                }
                value(pars + "\t" + xp.getValue());
            }
            endArray();
        }
        /* Now ones we don't know or care about */
        startArray(getJname(PropertyInfoIndex.XPROP));
        for (final BwXproperty xp : ent.getXproperties()) {
            final String nm = interestingXprops.get(xp.getName());
            if (nm != null) {
                continue;
            }
            startObject();
            makeField(PropertyInfoIndex.NAME, xp.getName());
            if (xp.getPars() != null) {
                makeField(getJname(PropertyInfoIndex.PARAMETERS), xp.getPars());
            }
            makeField(getJname(PropertyInfoIndex.VALUE), xp.getValue());
            endObject();
        }
        endArray();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) BwXproperty(org.bedework.calfacade.BwXproperty) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 4 with IndexException

use of org.bedework.util.indexing.IndexException in project bw-calendar-engine by Bedework.

the class DocBuilder method indexProperties.

private void indexProperties(final Set<BwProperty> props) throws CalFacadeException {
    if (props == null) {
        return;
    }
    try {
        startArray(getJname(PropertyInfoIndex.COL_PROPERTIES));
        for (final BwProperty prop : props) {
            startObject();
            makeField(PropertyInfoIndex.NAME, prop.getName());
            makeField(PropertyInfoIndex.VALUE, prop.getValue());
            endObject();
        }
        endArray();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) BwProperty(org.bedework.calfacade.BwProperty) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 5 with IndexException

use of org.bedework.util.indexing.IndexException in project bw-calendar-engine by Bedework.

the class DocBuilder method indexDate.

private void indexDate(final PropertyInfoIndex dtype, final BwDateTime dt) throws CalFacadeException {
    try {
        if (dt == null) {
            return;
        }
        if (dtype == null) {
            startObject();
        } else {
            startObject(getJname(dtype));
        }
        makeField(PropertyInfoIndex.UTC, dt.getDate());
        makeField(PropertyInfoIndex.LOCAL, dt.getDtval());
        makeField(PropertyInfoIndex.TZID, dt.getTzid());
        makeField(PropertyInfoIndex.FLOATING, String.valueOf(dt.getFloating()));
        endObject();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : IndexException(org.bedework.util.indexing.IndexException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)23 IndexException (org.bedework.util.indexing.IndexException)23 TreeSet (java.util.TreeSet)7 BwLongString (org.bedework.calfacade.BwLongString)5 BwString (org.bedework.calfacade.BwString)5 BwXproperty (org.bedework.calfacade.BwXproperty)3 BwAlarm (org.bedework.calfacade.BwAlarm)2 BwAttendee (org.bedework.calfacade.BwAttendee)2 BwDateTime (org.bedework.calfacade.BwDateTime)2 BwProperty (org.bedework.calfacade.BwProperty)2 BwStringBase (org.bedework.calfacade.base.BwStringBase)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 BwCategory (org.bedework.calfacade.BwCategory)1 BwContact (org.bedework.calfacade.BwContact)1 BwLocation (org.bedework.calfacade.BwLocation)1 BwRequestStatus (org.bedework.calfacade.BwRequestStatus)1 PropertyInfoIndex (org.bedework.util.calendar.PropertyIndex.PropertyInfoIndex)1