use of org.olat.modules.gotomeeting.model.GoToError in project openolat by klemens.
the class GoToTrainingWebService method saveTraining.
private Response saveTraining(GoToTrainingVO training) {
try {
GoToMeeting meeting = null;
GoToError error = new GoToError();
if (training.getKey() == null) {
boolean organizerFound = false;
List<GoToOrganizer> organizers = meetingManager.getSystemOrganizers();
for (GoToOrganizer organizer : organizers) {
boolean available = meetingManager.checkOrganizerAvailability(organizer, training.getStart(), training.getEnd());
if (available) {
meeting = meetingManager.scheduleTraining(organizer, training.getName(), training.getExternalId(), "-", training.getStart(), training.getEnd(), entry, subIdentifier, null, error);
organizerFound = true;
if (!error.hasError()) {
break;
}
}
}
if (!organizerFound) {
error.setError(GoToErrors.OrganizerOverlap);
}
} else {
meeting = meetingManager.getMeetingByExternalId(training.getExternalId());
if (meeting == null) {
List<GoToOrganizer> organizers = meetingManager.getSystemOrganizers();
for (GoToOrganizer organizer : organizers) {
meeting = meetingManager.scheduleTraining(organizer, training.getName(), training.getExternalId(), "-", training.getStart(), training.getEnd(), entry, subIdentifier, null, error);
if (!error.hasError()) {
break;
}
}
} else {
meetingManager.updateTraining(meeting, training.getName(), "-", training.getStart(), training.getEnd(), error);
}
}
Response response;
if (error.hasError()) {
response = handleGoToTrainingError(error);
} else if (meeting == null) {
response = handleUnexpectedException();
} else {
response = Response.ok(new GoToTrainingVO(meeting)).build();
}
return response;
} catch (Exception e) {
log.error("", e);
return handleUnexpectedException();
}
}
Aggregations