return null;
}
public void updateAttendee(HttpServletRequest request, HttpServletResponse response,
ModelFacade modelFacade, int mode) {
Person person = SecurityHandler.getInstance().getLoggedInPerson(request);
if (person == null) {
// This is an error condition -- ignore
return;
}
String sxEventId = request.getParameter("socialEventID");
if (sxEventId == null) {
throw new RuntimeException("Couldnot find event with socialEventID = " +
sxEventId);
}
try {
int eventId = Integer.parseInt(sxEventId);
SocialEvent event = modelFacade.getSocialEvent(eventId);
if (event == null) {
throw new RuntimeException("Couldnot find event with socialEventID = " +
eventId);
}
boolean attending = event.isAttending(person);
boolean already = false;
String status = "success";
if (mode == UPDATE_MODE_ADD_ATTENDEE && attending) {
already = true;
status = "attending";
}
if (!attending && mode == UPDATE_MODE_DELETE_ATTENDEE) {
already = true;
status = "not_attending";
}
if (!already) {
if (mode == UPDATE_MODE_ADD_ATTENDEE) {
event.getAttendees().add(person);
person.getSocialEvents().add(event);
status = "added";
} else {
event.getAttendees().remove(person);
person.getSocialEvents().remove(event);
status = "deleted";
}
modelFacade.updateSocialEvent(event);
}