use of org.bedework.calsvci.EventsI in project bw-calendar-engine by Bedework.
the class ImplicitSchedulingHandler method implicitSchedule.
@Override
public void implicitSchedule(final EventInfo ei, final boolean noInvites) throws CalFacadeException {
UpdateResult uer = ei.getUpdResult();
if (debug) {
dump(uer);
}
BwEvent ev = ei.getEvent();
boolean organizerSchedulingObject = ev.getOrganizerSchedulingObject();
boolean attendeeSchedulingObject = ev.getAttendeeSchedulingObject();
if (ev.getSuppressed()) {
if (!Util.isEmpty(ei.getOverrides())) {
for (EventInfo oei : ei.getOverrides()) {
uer = oei.getUpdResult();
if (debug) {
dump(uer);
}
BwEvent oev = oei.getEvent();
if (oev.getOrganizerSchedulingObject()) {
organizerSchedulingObject = true;
}
if (oev.getAttendeeSchedulingObject()) {
attendeeSchedulingObject = true;
}
}
}
}
if (!organizerSchedulingObject && !attendeeSchedulingObject) {
// Not a scheduling event
if (debug) {
trace("No a scheduling object: just return");
}
return;
}
if (ev.getOrganizer() == null) {
throw new CalFacadeBadRequest(CalFacadeException.missingEventProperty);
}
if (ev.getOriginator() == null) {
ev.setOriginator(ev.getOrganizer().getOrganizerUri());
}
if (uer.reply) {
int meth;
if (ei.getReplyAttendeeURI() != null) {
meth = ScheduleMethods.methodTypeRefresh;
} else {
meth = ScheduleMethods.methodTypeReply;
}
ev.setScheduleMethod(meth);
uer.schedulingResult = attendeeRespond(ei, meth);
return;
}
if (uer.deleting) {
if (organizerSchedulingObject) {
// if (schedMethod == Icalendar.methodTypeCancel) {
// /* We already canceled this one */
// return;
// }
ev.setScheduleMethod(ScheduleMethods.methodTypeCancel);
} else {
// Reply from attendee setting partstat
ev.setScheduleMethod(ScheduleMethods.methodTypeReply);
}
} else {
ev.setScheduleMethod(ScheduleMethods.methodTypeRequest);
}
if (!noInvites) {
uer.schedulingResult = schedule(ei, ei.getReplyAttendeeURI(), uer.fromAttUri, false);
}
if (!uer.adding && !Util.isEmpty(uer.deletedAttendees)) {
/* Send cancel to removed attendees */
for (BwAttendee att : uer.deletedAttendees) {
if (Util.compareStrings(att.getPartstat(), IcalDefs.partstats[IcalDefs.partstatDeclined]) == 0) {
// Already declined - send nothing
continue;
}
/* Clone is adequate here. For a CANCEL we just send either the master
* or the particular instance.
*/
BwEvent cncl = (BwEvent) ev.clone();
cncl.setAttendees(null);
cncl.addAttendee((BwAttendee) att.clone());
cncl.setRecipients(null);
cncl.addRecipient(att.getAttendeeUri());
cncl.setScheduleMethod(ScheduleMethods.methodTypeCancel);
cncl.setOrganizerSchedulingObject(true);
cncl.setAttendeeSchedulingObject(false);
EventInfo cei = new EventInfo(cncl);
ScheduleResult cnclr = schedule(cei, null, null, false);
if (debug) {
trace(cnclr.toString());
}
}
}
if (ei.getInboxEventName() != null) {
// Delete the given event from the inbox.
EventsI events = getSvc().getEventsHandler();
BwCalendar inbox = getSvc().getCalendarsHandler().getSpecial(BwCalendar.calTypeInbox, true);
final EventInfo inboxei = events.get(inbox.getPath(), ei.getInboxEventName());
if (inboxei != null) {
events.delete(inboxei, false);
}
}
}
Aggregations