Search in sources :

Example 21 with IndexException

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

the class EntityBuilder method restoreBwStringSet.

private Set<? extends BwStringBase> restoreBwStringSet(final PropertyInfoIndex pi, final boolean longStrings) throws CalFacadeException {
    final List<Object> vals = getFieldValues(pi);
    if (Util.isEmpty(vals)) {
        return null;
    }
    final Set<BwStringBase> ss = new TreeSet<>();
    for (final Object o : vals) {
        try {
            pushFields(o);
            ss.add(restoreBwString(longStrings));
        } catch (final IndexException ie) {
            throw new CalFacadeException(ie);
        } finally {
            popFields();
        }
    }
    return ss;
}
Also used : IndexException(org.bedework.util.indexing.IndexException) BwStringBase(org.bedework.calfacade.base.BwStringBase) TreeSet(java.util.TreeSet) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 22 with IndexException

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

the class EntityBuilder method restoreXprops.

private List<BwXproperty> restoreXprops() throws CalFacadeException {
    /* Convert our special fields back to xprops */
    final Set<String> xpnames = DocBuilder.interestingXprops.keySet();
    final List<BwXproperty> xprops = new ArrayList<>();
    if (!Util.isEmpty(xpnames)) {
        for (final String xpname : xpnames) {
            @SuppressWarnings("unchecked") final Collection<String> xvals = (Collection) getFieldValues(DocBuilder.interestingXprops.get(xpname));
            if (!Util.isEmpty(xvals)) {
                for (final String xval : xvals) {
                    final int pos = xval.indexOf("\t");
                    String pars = null;
                    if (pos > 0) {
                        pars = xval.substring(0, pos);
                    }
                    final BwXproperty xp = new BwXproperty(xpname, pars, xval.substring(pos + 1));
                    xprops.add(xp);
                }
            }
        }
    }
    /* Now restore the rest of the xprops */
    final List<Object> xpropFields = getFieldValues(PropertyInfoIndex.XPROP);
    if (Util.isEmpty(xpropFields)) {
        return xprops;
    }
    for (final Object o : xpropFields) {
        try {
            pushFields(o);
            final BwXproperty xp = new BwXproperty();
            xp.setName(getString(PropertyInfoIndex.NAME));
            xp.setPars(getString(PropertyInfoIndex.PARAMETERS));
            xp.setValue(getString(PropertyInfoIndex.VALUE));
            xprops.add(xp);
        } catch (final IndexException ie) {
            throw new CalFacadeException(ie);
        } finally {
            popFields();
        }
    }
    return xprops;
}
Also used : IndexException(org.bedework.util.indexing.IndexException) ArrayList(java.util.ArrayList) BwString(org.bedework.calfacade.BwString) BwLongString(org.bedework.calfacade.BwLongString) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) BwXproperty(org.bedework.calfacade.BwXproperty) Collection(java.util.Collection)

Example 23 with IndexException

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

the class EntityBuilder method restoreProperties.

private void restoreProperties(final BwCalendar col) throws CalFacadeException {
    final Collection<Object> vals = getFieldValues(PropertyInfoIndex.COL_PROPERTIES);
    if (Util.isEmpty(vals)) {
        return;
    }
    final Set<BwProperty> props = new TreeSet<>();
    for (final Object o : vals) {
        try {
            pushFields(o);
            final String name = getString(PropertyInfoIndex.NAME);
            final String val = getString(PropertyInfoIndex.VALUE);
            props.add(new BwProperty(name, val));
        } catch (final IndexException ie) {
            throw new CalFacadeException(ie);
        } finally {
            popFields();
        }
    }
    col.setProperties(props);
}
Also used : IndexException(org.bedework.util.indexing.IndexException) TreeSet(java.util.TreeSet) BwString(org.bedework.calfacade.BwString) BwLongString(org.bedework.calfacade.BwLongString) BwProperty(org.bedework.calfacade.BwProperty) 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