use of org.bedework.calfacade.ical.BwIcalPropertyInfo.BwIcalPropertyInfoEntry in project bw-calendar-engine by Bedework.
the class Filters method match.
private boolean match(final FilterBase f, final BwEvent ev, final String userHref) throws CalFacadeException {
if (f == null) {
return true;
}
if (debug) {
debug("match " + f);
}
if ((f instanceof AndFilter) || (f instanceof OrFilter)) {
boolean itsAnd = (f instanceof AndFilter);
for (FilterBase flt : f.getChildren()) {
if (match(flt, ev, userHref)) {
if (!itsAnd) {
// Success for OR
if (debug) {
debug("match true");
}
return true;
}
} else if (itsAnd) {
debug("match true");
return false;
}
}
// For AND all matched, for OR nothing matched
debug("match " + itsAnd);
return itsAnd;
}
if (f instanceof EntityTimeRangeFilter) {
// Matched in db query
return true;
}
if (!(f instanceof PropertyFilter)) {
/* We assume we can't handle this one as a query.
*/
throw new CalFacadeException("org.bedework.filters.unknownfilter", String.valueOf(f));
}
PropertyFilter pf = (PropertyFilter) f;
BwIcalPropertyInfoEntry pi = BwIcalPropertyInfo.getPinfo(pf.getPropertyIndex());
if (pi == null) {
throw new CalFacadeException("org.bedework.filters.unknownproperty", String.valueOf(pf.getPropertyIndex()));
}
String fieldName = pi.getDbFieldName();
boolean param = pi.getParam();
if (param) {
BwIcalPropertyInfoEntry parentPi = BwIcalPropertyInfo.getPinfo(pf.getParentPropertyIndex());
fieldName = parentPi.getDbFieldName() + "." + fieldName;
}
try {
if (pf instanceof BwCategoryFilter) {
return traceMatch(pf.match(ev, userHref));
}
if (f instanceof PresenceFilter) {
return traceMatch(matchPresence(pf.getPropertyIndex(), ev, userHref));
}
if (pf instanceof TimeRangeFilter) {
return traceMatch(match((TimeRangeFilter) pf, ev));
}
if (pf instanceof BwObjectFilter) {
return traceMatch(pf.match(ev, userHref));
}
} catch (WebdavException wde) {
throw new CalFacadeException(wde);
}
throw new CalFacadeException("org.bedework.filters.unknownfilter", String.valueOf(f));
}
use of org.bedework.calfacade.ical.BwIcalPropertyInfo.BwIcalPropertyInfoEntry in project bw-calendar-engine by Bedework.
the class Events method checkChanges.
@SuppressWarnings("unchecked")
private boolean checkChanges(final EventInfo ei, final boolean organizerSchedulingObject, final boolean attendeeSchedulingObject) throws CalFacadeException {
final UpdateResult updResult = ei.getUpdResult();
if (ei.getChangeset(getPrincipalHref()).isEmpty()) {
// Forced update?
updResult.hasChanged = true;
if (attendeeSchedulingObject) {
// Attendee replying?
/* XXX We should really check to see if the value changed here -
*/
updResult.reply = true;
}
return true;
}
if (debug) {
ei.getChangeset(getPrincipalHref()).dumpEntries();
}
final ChangeTable ct = ei.getChangeset(getPrincipalHref());
final Collection<ChangeTableEntry> ctes = ct.getEntries();
updResult.sequenceChange = ct.getSequenceChangeNeeded();
for (final ChangeTableEntry cte : ctes) {
if (!cte.getChanged()) {
continue;
}
updResult.hasChanged = true;
final PropertyInfoIndex pi = cte.getIndex();
if (!organizerSchedulingObject && pi.equals(PropertyInfoIndex.ORGANIZER)) {
final BwOrganizer oldOrg = (BwOrganizer) cte.getOldVal();
final BwOrganizer newOrg = (BwOrganizer) cte.getNewVal();
if ((oldOrg == null) || (newOrg == null) || !oldOrg.getOrganizerUri().equals(newOrg.getOrganizerUri())) {
// Never valid
throw new CalFacadeForbidden(CaldavTags.attendeeAllowed, "Cannot change organizer");
}
}
if (pi.equals(PropertyInfoIndex.ATTENDEE) || pi.equals(PropertyInfoIndex.VOTER)) {
updResult.addedAttendees = cte.getAddedValues();
updResult.deletedAttendees = cte.getRemovedValues();
if (attendeeSchedulingObject) {
// Attendee replying?
/* XXX We should really check to see if the value changed here -
*/
updResult.reply = true;
} else {
if (!Util.isEmpty(updResult.deletedAttendees)) {
// Bump sequence as we are sending out cancels
updResult.sequenceChange = true;
}
}
}
if (pi.equals(PropertyInfoIndex.POLL_WINNER)) {
if (!attendeeSchedulingObject) {
// Attendee replying?
/* XXX We should really check to see if the value changed here -
*/
updResult.pollWinner = ei.getEvent().getPollWinner();
}
}
if (pi.equals(PropertyInfoIndex.POLL_ITEM)) {
if (attendeeSchedulingObject) {
// Attendee replying?
/* XXX We should really check to see if the value changed here -
*/
updResult.reply = true;
}
}
if (organizerSchedulingObject) {
final BwIcalPropertyInfoEntry pie = BwIcalPropertyInfo.getPinfo(cte.getIndex());
if (pie.getReschedule()) {
updResult.doReschedule = true;
}
}
}
return updResult.hasChanged;
}
Aggregations