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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations