Search in sources :

Example 16 with GoToError

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();
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Response(javax.ws.rs.core.Response) GoToError(org.olat.modules.gotomeeting.model.GoToError) GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting)

Aggregations

GoToError (org.olat.modules.gotomeeting.model.GoToError)16 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)4 GoToOrganizer (org.olat.modules.gotomeeting.GoToOrganizer)4 Date (java.util.Date)2 Response (javax.ws.rs.core.Response)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 UserRequest (org.olat.core.gui.UserRequest)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 Controller (org.olat.core.gui.control.Controller)2 WindowControl (org.olat.core.gui.control.WindowControl)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 GoToMeeting (org.olat.modules.gotomeeting.GoToMeeting)2 GoToRecordingsG2T (org.olat.modules.gotomeeting.model.GoToRecordingsG2T)2