use of org.bedework.calfacade.BwEventProxy in project bw-calendar-engine by Bedework.
the class InRequest method initAttendeeCopy.
private boolean initAttendeeCopy(final CalSvcI svci, final String newColPath, final BwEvent ev, final String uri) throws CalFacadeException {
ev.setColPath(newColPath);
ev.setAttendeeSchedulingObject(true);
ev.setOrganizerSchedulingObject(false);
if (!(ev instanceof BwEventProxy) && ev.getSuppressed()) {
return true;
}
BwAttendee att = ev.findAttendee(uri);
if (att == null) {
// Error?
if (debug) {
trace("Schedule - no attendee with uri " + uri + " for " + svci.getPrincipal().getPrincipalRef());
}
return false;
}
// att.setScheduleStatus(IcalDefs.deliveryStatusSuccess);
if ((att.getPartstat() == null) || att.getPartstat().equals(IcalDefs.partstatValNeedsAction)) {
if (att.getPartstat() == null) {
att.setPartstat(IcalDefs.partstatValNeedsAction);
}
ev.setTransparency(IcalDefs.transparencyTransparent);
// Apple ical seems to expect an x-prop.
// ev.addXproperty(new BwXproperty(BwXproperty.appleNeedsReply,
// null, "TRUE"));
}
return true;
}
use of org.bedework.calfacade.BwEventProxy in project bw-calendar-engine by Bedework.
the class InRequest method updateAttendeeCopy.
/**
* Update our (the attendees) copy of the event from the inbox copy. We
* should have received cancellations for any instances we are no longer
* attending. This could include extra instances (fewer exdates) for which we
* have received no notifications.
*
* <p>The partstat on those instances should be currently set to NEEDS-ACTION
* and we need to add some information to the event to allow us to highlight
* those instances.
*
* <p>This may be why Apple is adding a needs reply x-prop?
*
* @param ourCopy
* @param inCopy
* @param attUri - our attendee uri
* @return boolean true for OK
* @throws CalFacadeException
*/
private boolean updateAttendeeCopy(final EventInfo ourCopy, final EventInfo inCopy, final String attUri) throws CalFacadeException {
/* Update from an incoming inbox event. The incoming event may be a partial
* recurring event, that is we may have a suppressed master and an incomplete
* set of overrides.
*
* If the master is suppressed we simply update from each supplied override.
*
* We do not remove overrides if they are not in the incoming event. We need
* an explicit CANCEL.
*/
BwEvent ourEv = ourCopy.getEvent();
BwEvent inEv = inCopy.getEvent();
boolean ourMaster = !(ourEv instanceof BwEventProxy);
boolean inMaster = !(inEv instanceof BwEventProxy);
if (ourMaster != inMaster) {
throw new CalFacadeException("Only one master event for updateAttendeeCopy");
}
boolean ourRecurMaster = ourMaster && ourEv.getRecurring();
if (!inMaster || !inEv.getSuppressed()) {
if (debug) {
trace("Update the master event or single recurrence");
}
if (!updateAttendeeFields(ourCopy, inCopy, attUri)) {
return false;
}
}
if (!ourRecurMaster) {
return true;
}
if (inCopy.getOverrides() != null) {
// Go through all the overrides
Collection<Recurrence> recurrences = null;
for (EventInfo inOvei : inCopy.getOverrides()) {
BwEvent inOv = inOvei.getEvent();
String rid = inOv.getRecurrenceId();
EventInfo ourOvei = findOverride(ourCopy, rid);
if (ourOvei.getEvent().unsaved()) {
if (recurrences == null) {
recurrences = getRecurrences(ourCopy);
}
Recurrence rec = null;
for (Recurrence r : recurrences) {
if (rid.equals(r.recurrenceId)) {
rec = r;
break;
}
}
if (rec == null) {
// Not in set
BwDateTime bwrdt = BwDateTime.fromUTC(rid.length() == 8, rid);
ourEv.addRdate(bwrdt);
}
}
if (!updateAttendeeCopy(ourOvei, inOvei, attUri)) {
return false;
}
}
}
/* The incoming event may have exdates that are not in the
attendee copy. Remove each of those and add an override cancelling
that instance.
*/
final Set<BwDateTime> inExdates = inCopy.getEvent().getExdates();
if (!Util.isEmpty(inExdates)) {
final Set<BwDateTime> ourExdates = ourCopy.getEvent().getExdates();
for (final BwDateTime exdt : inExdates) {
if (!Util.isEmpty(ourExdates) && ourExdates.contains(exdt)) {
continue;
}
final EventInfo ourOvei = findOverride(ourCopy, exdt.getDate());
ourOvei.getEvent().setStatus(BwEvent.statusCancelled);
}
}
return true;
}
Aggregations