event.setEndDate(calendar.getTime());
}
@Override
public ModelAndView onSubmit(Object command) throws ServletException {
Event cmd = (Event) command;
Event event = retrieveEvent(cmd.getId());
AppEngineUserService userService = new AppEngineUserService();
if (event == null) {
String errorText = "Failed to update event with ID \"" + cmd.getId() +
"\" -- event not found.";
return new ModelAndView("admin_error", "errorText", errorText);
}
Chapter chapter = retrieveChapter(event.getChapterId());
if (chapter == null) {
String errorText = "Failed to retrieve chapter with ID \"" +
event.getChapterId() + "\" -- chapter not found.";
return new ModelAndView("admin_error", "errorText", errorText);
}
if (!hasAccess(userService, chapter)) {
String errorText = "You are not listed as an organizer for the " +
"chapter associated with this event. Please sign in with an " +
"organizer's account to access this page.";
return new ModelAndView("error", "errorText", errorText);
}
event.setName(cmd.getName());
event.setTimeZone(cmd.getTimeZone());
event.setStartDate(cmd.getStartDate());
event.setEndDate(cmd.getEndDate());
event.setStreetAddress(cmd.getStreetAddress());
event.setRoom(cmd.getRoom());
event.setCity(cmd.getCity());
event.setState(cmd.getState());
event.setZipCode(cmd.getZipCode());
event.setCountry(cmd.getCountry());
event.setLatitude(cmd.getLatitude());
event.setLongitude(cmd.getLongitude());
event.setUrl(cmd.getUrl());
event.setDescription(cmd.getDescription());
event.setAttendeeCount(cmd.getAttendeeCount());
event.setNotes(cmd.getNotes());
event.getTopics().clear();
if (cmd.getOnAndroid()) {
event.addTopic(Topic.ANDROID);
}
if (cmd.getOnGoogleAjaxApis()) {
event.addTopic(Topic.GOOGLE_AJAX_APIS);
}
if (cmd.getOnGoogleAppEngine()) {
event.addTopic(Topic.GOOGLE_APP_ENGINE);
}
if (cmd.getOnGoogleChromeExtensions()) {
event.addTopic(Topic.GOOGLE_CHROME_EXTENSIONS);
}
if (cmd.getOnGoogleEarthApis()) {
event.addTopic(Topic.GOOGLE_EARTH_APIS);
}
if (cmd.getOnGoogleMapsApis()) {
event.addTopic(Topic.GOOGLE_MAPS_APIS);
}
if (cmd.getOnGoogleWaveApis()) {
event.addTopic(Topic.GOOGLE_WAVE_APIS);
}
if (cmd.getOnGoogleWebToolkit()) {
event.addTopic(Topic.GOOGLE_WEB_TOOLKIT);
}
if (cmd.getOnOpenSocial()) {
event.addTopic(Topic.OPENSOCIAL);
}
if (cmd.getOnOther() && cmd.getCustomTopic() != null &&
!cmd.getCustomTopic().equals("")) {
event.addTopic(cmd.getCustomTopic());
}
eventManager.storeEvent(event);
return new ModelAndView(new RedirectView(getSuccessView() + "?id=" +