use of org.bedework.calfacade.ScheduleResult in project bw-calendar-engine by Bedework.
the class AttendeeSchedulingHandler method scheduleResponse.
/* (non-Javadoc)
* @see org.bedework.calsvci.SchedulingI#processCancel(org.bedework.calfacade.svc.EventInfo, org.bedework.calfacade.svc.EventInfo)
* /
public ScheduleResult processCancel(final EventInfo ei) throws CalFacadeException {
/* We, as an attendee, received a CANCEL from the organizer.
*
* /
ScheduleResult sr = new ScheduleResult();
BwEvent ev = ei.getEvent();
BwCalendar inbox = getSvc().getCalendarsHandler().get(ev.getColPath());
boolean forceDelete = true;
check: {
if (inbox.getCalType() != BwCalendar.calTypeInbox) {
sr.errorCode = CalFacadeException.schedulingBadSourceCalendar;
break check;
}
if (ev.getOriginator() == null) {
sr.errorCode = CalFacadeException.schedulingNoOriginator;
break check;
}
BwPreferences prefs = getSvc().getPrefsHandler().get();
EventInfo colEi = getStoredMeeting(ei.getEvent());
if (colEi == null) {
break check;
}
BwEvent colEv = colEi.getEvent();
if (prefs.getScheduleAutoCancelAction() ==
BwPreferences.scheduleAutoCancelSetStatus) {
if (colEv.getSuppressed()) {
if (colEi.getOverrides() != null) {
for (EventInfo oei: colEi.getOverrides()) {
oei.getEvent().setStatus(BwEvent.statusCancelled);
}
}
} else {
colEv.setStatus(BwEvent.statusCancelled);
}
getSvc().getEventsHandler().update(colEi, true, null);
} else {
getSvc().getEventsHandler().delete(colEi, false);
}
forceDelete = false;
}
updateInbox(ei, inbox.getOwnerHref(),
false, // attendeeAccepting
forceDelete); // forceDelete
return sr;
}
*/
/* (non-Javadoc)
* @see org.bedework.calsvci.SchedulingI#scheduleResponse(org.bedework.calfacade.BwEvent)
*/
@Override
public ScheduleResult scheduleResponse(final EventInfo ei) throws CalFacadeException {
/* As an attendee, respond to a scheduling request.
*
* Copy event
* remove all attendees and readd this user
* Add to organizers inbox if internal
* Put in outbox if external.
*/
ScheduleResult sr = new ScheduleResult();
try {
int smethod = ei.getEvent().getScheduleMethod();
if (!Icalendar.itipReplyMethodType(smethod)) {
sr.errorCode = CalFacadeException.schedulingBadMethod;
return sr;
}
/* For each recipient within this system add the event to their inbox.
*
* If there are any external users add it to the outbox and it will be
* mailed to the recipients.
*/
int outAccess = PrivilegeDefs.privScheduleReply;
/* There should only be one attendee for a reply */
if (!ei.getEvent().getSuppressed()) {
BwEvent ev = ei.getEvent();
if (ev.getNumAttendees() != 1) {
sr.errorCode = CalFacadeException.schedulingBadAttendees;
return sr;
}
}
if (ei.getNumOverrides() > 0) {
for (EventInfo oei : ei.getOverrides()) {
BwEvent ev = oei.getEvent();
if (ev.getNumAttendees() != 1) {
sr.errorCode = CalFacadeException.schedulingBadAttendees;
return sr;
}
}
}
if (!initScheduleEvent(ei, true, false)) {
return sr;
}
/* Do this here to check we have access. We might need the outbox later
*/
BwCalendar outBox = getSpecialCalendar(getPrincipal(), BwCalendar.calTypeOutbox, true, outAccess);
sendSchedule(sr, ei, null, null, false);
if (sr.ignored) {
return sr;
}
if (!sr.externalRcs.isEmpty()) {
sr.errorCode = addToOutBox(ei, outBox, sr.externalRcs);
}
return sr;
} catch (Throwable t) {
getSvc().rollbackTransaction();
if (t instanceof CalFacadeException) {
throw (CalFacadeException) t;
}
throw new CalFacadeException(t);
}
}
use of org.bedework.calfacade.ScheduleResult in project bw-calendar-engine by Bedework.
the class AttendeeSchedulingHandler method requestRefresh.
@Override
public ScheduleResult requestRefresh(final EventInfo ei, final String comment) throws CalFacadeException {
ScheduleResult sr = new ScheduleResult();
BwEvent ev = ei.getEvent();
if (ev.getScheduleMethod() != ScheduleMethods.methodTypeRequest) {
sr.errorCode = CalFacadeException.schedulingBadMethod;
return sr;
}
BwAttendee att = findUserAttendee(ev);
if (att == null) {
throw new CalFacadeException(CalFacadeException.schedulingNotAttendee);
}
BwEvent outEv = new BwEventObj();
EventInfo outEi = new EventInfo(outEv);
outEv.setScheduleMethod(ScheduleMethods.methodTypeRefresh);
outEv.addRecipient(ev.getOrganizer().getOrganizerUri());
outEv.setOriginator(att.getAttendeeUri());
outEv.updateDtstamp();
outEv.setOrganizer((BwOrganizer) ev.getOrganizer().clone());
outEv.getOrganizer().setDtstamp(outEv.getDtstamp());
outEv.addAttendee((BwAttendee) att.clone());
outEv.setUid(ev.getUid());
outEv.setRecurrenceId(ev.getRecurrenceId());
outEv.setDtstart(ev.getDtstart());
outEv.setDtend(ev.getDtend());
outEv.setDuration(ev.getDuration());
outEv.setNoStart(ev.getNoStart());
outEv.setRecurring(false);
if (comment != null) {
outEv.addComment(new BwString(null, comment));
}
sr = scheduleResponse(outEi);
outEv.setScheduleState(BwEvent.scheduleStateProcessed);
return sr;
}
use of org.bedework.calfacade.ScheduleResult in project bw-calendar-engine by Bedework.
the class AttendeeSchedulingHandler method attendeeRespond.
@Override
public ScheduleResult attendeeRespond(final EventInfo ei, final int method) throws CalFacadeException {
ScheduleResult sr = new ScheduleResult();
final BwEvent ev = ei.getEvent();
check: {
/* Check that the current user is actually the only attendee of the event.
* Note we may have a suppressed master and/or multiple overrides
*/
BwAttendee att = null;
if (!ev.getSuppressed()) {
att = findUserAttendee(ev);
if (att == null) {
sr.errorCode = CalFacadeException.schedulingNotAttendee;
break check;
}
}
if (ei.getNumOverrides() > 0) {
for (final EventInfo oei : ei.getOverrides()) {
att = findUserAttendee(oei.getEvent());
if (att == null) {
sr.errorCode = CalFacadeException.schedulingNotAttendee;
break check;
}
}
}
if (ev.getOriginator() == null) {
sr.errorCode = CalFacadeException.schedulingNoOriginator;
break check;
}
// EventInfo outEi = makeReplyEventInfo(ei, getUser().getPrincipalRef());
final EventInfo outEi = copyEventInfo(ei, getPrincipal());
final BwEvent outEv = outEi.getEvent();
if (!Util.isEmpty(outEv.getRecipients())) {
outEv.getRecipients().clear();
}
if (!Util.isEmpty(outEv.getAttendees())) {
outEv.getAttendees().clear();
}
// XXX we should get a comment from non db field in event
// if (comment != null) {
// // Just add for the moment
// outEv.addComment(null, comment);
// }
outEv.addRecipient(outEv.getOrganizer().getOrganizerUri());
outEv.setOriginator(att.getAttendeeUri());
outEv.updateDtstamp();
outEv.getOrganizer().setDtstamp(outEv.getDtstamp());
String delegate = att.getDelegatedTo();
if (delegate != null) {
/* RFC 2446 4.2.5 - Delegating an event
*
* When delegating an event request to another "Calendar User", the
* "Delegator" must both update the "Organizer" with a "REPLY" and send
* a request to the "Delegate". There is currently no protocol
* limitation to delegation depth. It is possible for the original
* delegate to delegate the meeting to someone else, and so on. When a
* request is delegated from one CUA to another there are a number of
* responsibilities required of the "Delegator". The "Delegator" MUST:
*
* . Send a "REPLY" to the "Organizer" with the following updates:
* . The "Delegator's" "ATTENDEE" property "partstat" parameter set
* to "delegated" and the "delegated-to" parameter is set to the
* address of the "Delegate"
* . Add an additional "ATTENDEE" property for the "Delegate" with
* the "delegated-from" property parameter set to the "Delegator"
* . Indicate whether they want to continue to receive updates when
* the "Organizer" sends out updated versions of the event.
* Setting the "rsvp" property parameter to "TRUE" will cause the
* updates to be sent, setting it to "FALSE" causes no further
* updates to be sent. Note that in either case, if the "Delegate"
* declines the invitation the "Delegator" will be notified.
* . The "Delegator" MUST also send a copy of the original "REQUEST"
* method to the "Delegate".
*/
// outEv is the reply
outEv.setScheduleMethod(ScheduleMethods.methodTypeReply);
// Additional attendee
BwAttendee delAtt = new BwAttendee();
delAtt.setAttendeeUri(delegate);
delAtt.setDelegatedFrom(att.getAttendeeUri());
delAtt.setPartstat(IcalDefs.partstatValNeedsAction);
delAtt.setRsvp(true);
delAtt.setRole(att.getRole());
outEv.addAttendee(delAtt);
// ei is 'original "REQUEST"'. */
EventInfo delegateEi = copyEventInfo(ei, getPrincipal());
BwEvent delegateEv = delegateEi.getEvent();
delegateEv.addRecipient(delegate);
// Not in RFC
delegateEv.addAttendee((BwAttendee) delAtt.clone());
delegateEv.setScheduleMethod(ScheduleMethods.methodTypeRequest);
att.setPartstat(IcalDefs.partstatValDelegated);
att.setRsvp(false);
att.setDelegatedTo(delegate);
// XXX Not sure if this is correct
schedule(delegateEi, null, null, false);
} else if (method == ScheduleMethods.methodTypeReply) {
// Only attendee should be us
ei.setOnlyAttendee(outEi, att.getAttendeeUri());
if (ev.getEntityType() == IcalDefs.entityTypeVpoll) {
setPollResponse(outEi, ei, att.getAttendeeUri());
}
outEv.setScheduleMethod(ScheduleMethods.methodTypeReply);
} else if (method == ScheduleMethods.methodTypeCounter) {
// Only attendee should be us
ei.setOnlyAttendee(outEi, att.getAttendeeUri());
/* Not sure how much we can change - at least times of the meeting.
*/
outEv.setScheduleMethod(ScheduleMethods.methodTypeCounter);
} else {
throw new RuntimeException("Never get here");
}
outEv.addRequestStatus(new BwRequestStatus(IcalDefs.requestStatusSuccess.getCode(), IcalDefs.requestStatusSuccess.getDescription()));
sr = scheduleResponse(outEi);
outEv.setScheduleState(BwEvent.scheduleStateProcessed);
ev.getOrganizer().setScheduleStatus(IcalDefs.deliveryStatusDelivered);
}
return sr;
}
use of org.bedework.calfacade.ScheduleResult in project bw-calendar-engine by Bedework.
the class SchedAttendeeUpdate method attendeeRespond.
private ScheduleResult attendeeRespond(final EventInfo ei, final int method) throws CalFacadeException {
ScheduleResult sr = new ScheduleResult();
final BwEvent ev = ei.getEvent();
final SchedulingIntf sched = (SchedulingIntf) getSvc().getScheduler();
final String attUri = getSvc().getDirectories().principalToCaladdr(getSvc().getPrincipal());
check: {
/* Check that the current user is actually an attendee of the event.
* Note we may have a suppressed master and/or multiple overrides
*/
BwAttendee att = null;
if (!ev.getSuppressed()) {
att = ev.findAttendee(attUri);
if (att == null) {
sr.errorCode = CalFacadeException.schedulingNotAttendee;
break check;
}
}
if (ei.getNumOverrides() > 0) {
for (final EventInfo oei : ei.getOverrides()) {
att = oei.getEvent().findAttendee(attUri);
if (att == null) {
sr.errorCode = CalFacadeException.schedulingNotAttendee;
break check;
}
}
}
if (ev.getOriginator() == null) {
sr.errorCode = CalFacadeException.schedulingNoOriginator;
break check;
}
// EventInfo outEi = makeReplyEventInfo(ei, getUser().getPrincipalRef());
final EventInfo outEi = sched.copyEventInfo(ei, getPrincipal());
final BwEvent outEv = outEi.getEvent();
if (!Util.isEmpty(outEv.getRecipients())) {
outEv.getRecipients().clear();
}
if (!Util.isEmpty(outEv.getAttendees())) {
outEv.getAttendees().clear();
}
// XXX we should get a comment from non db field in event
// if (comment != null) {
// // Just add for the moment
// outEv.addComment(null, comment);
// }
outEv.addRecipient(outEv.getOrganizer().getOrganizerUri());
outEv.setOriginator(att.getAttendeeUri());
outEv.updateDtstamp();
outEv.getOrganizer().setDtstamp(outEv.getDtstamp());
final String delegate = att.getDelegatedTo();
if (delegate != null) {
/* RFC 2446 4.2.5 - Delegating an event
*
* When delegating an event request to another "Calendar User", the
* "Delegator" must both update the "Organizer" with a "REPLY" and send
* a request to the "Delegate". There is currently no protocol
* limitation to delegation depth. It is possible for the original
* delegate to delegate the meeting to someone else, and so on. When a
* request is delegated from one CUA to another there are a number of
* responsibilities required of the "Delegator". The "Delegator" MUST:
*
* . Send a "REPLY" to the "Organizer" with the following updates:
* . The "Delegator's" "ATTENDEE" property "partstat" parameter set
* to "delegated" and the "delegated-to" parameter is set to the
* address of the "Delegate"
* . Add an additional "ATTENDEE" property for the "Delegate" with
* the "delegated-from" property parameter set to the "Delegator"
* . Indicate whether they want to continue to receive updates when
* the "Organizer" sends out updated versions of the event.
* Setting the "rsvp" property parameter to "TRUE" will cause the
* updates to be sent, setting it to "FALSE" causes no further
* updates to be sent. Note that in either case, if the "Delegate"
* declines the invitation the "Delegator" will be notified.
* . The "Delegator" MUST also send a copy of the original "REQUEST"
* method to the "Delegate".
*/
// outEv is the reply
outEv.setScheduleMethod(Icalendar.methodTypeReply);
// Additional attendee
final BwAttendee delAtt = new BwAttendee();
delAtt.setAttendeeUri(delegate);
delAtt.setDelegatedFrom(att.getAttendeeUri());
delAtt.setPartstat(IcalDefs.partstatValNeedsAction);
delAtt.setRsvp(true);
delAtt.setRole(att.getRole());
outEv.addAttendee(delAtt);
// ei is 'original "REQUEST"'. */
final EventInfo delegateEi = sched.copyEventInfo(ei, getPrincipal());
final BwEvent delegateEv = delegateEi.getEvent();
delegateEv.addRecipient(delegate);
// Not in RFC
delegateEv.addAttendee((BwAttendee) delAtt.clone());
delegateEv.setScheduleMethod(Icalendar.methodTypeRequest);
att.setPartstat(IcalDefs.partstatValDelegated);
att.setRsvp(false);
att.setDelegatedTo(delegate);
// XXX Not sure if this is correct
sched.schedule(delegateEi, null, null, false);
} else if (method == Icalendar.methodTypeReply) {
// Only attendee should be us
ei.setOnlyAttendee(outEi, att.getAttendeeUri());
outEv.setScheduleMethod(Icalendar.methodTypeReply);
} else if (method == Icalendar.methodTypeCounter) {
// Only attendee should be us
ei.setOnlyAttendee(outEi, att.getAttendeeUri());
/* Not sure how much we can change - at least times of the meeting.
*/
outEv.setScheduleMethod(Icalendar.methodTypeCounter);
} else {
throw new RuntimeException("Never get here");
}
outEv.addRequestStatus(new BwRequestStatus(IcalDefs.requestStatusSuccess.getCode(), IcalDefs.requestStatusSuccess.getDescription()));
sr = sched.scheduleResponse(outEi);
outEv.setScheduleState(BwEvent.scheduleStateProcessed);
ev.getOrganizer().setScheduleStatus(IcalDefs.deliveryStatusDelivered);
}
return sr;
}
Aggregations