Search in sources :

Example 51 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project openolat by klemens.

the class EditTrainingController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean isOrganizer = false;
    String[] organizerKeys = new String[availablesOrganizers.size()];
    String[] organizerValues = new String[availablesOrganizers.size()];
    for (int i = availablesOrganizers.size(); i-- > 0; ) {
        GoToOrganizer organizer = availablesOrganizers.get(i);
        organizerKeys[i] = Integer.toString(i);
        String label = organizer.getName();
        if (!StringHelper.containsNonWhitespace(label)) {
            label = organizer.getUsername();
        }
        organizerValues[i] = label;
        if (organizer.getOwner() != null) {
            isOrganizer = true;
        }
    }
    organizersEl = uifactory.addDropdownSingleselect("organizers", "organizers", formLayout, organizerKeys, organizerValues, null);
    organizersEl.setMandatory(true);
    if (meeting != null && meeting.getOrganizer() != null) {
        organizersEl.setVisible(false);
        isOrganizer = true;
    }
    if (!isOrganizer) {
        addMeAsOrganizerButton = uifactory.addFormLink("add.my.account", formLayout, Link.BUTTON);
    }
    String name = meeting == null ? "" : meeting.getName();
    nameEl = uifactory.addTextElement("training.name", "training.name", 128, name, formLayout);
    nameEl.setMandatory(true);
    String description = meeting == null ? "" : meeting.getDescription();
    descriptionEl = uifactory.addTextAreaElement("training.description", "training.description", 2000, 8, 72, false, description, formLayout);
    Date startDate = meeting == null ? null : meeting.getStartDate();
    startDateEl = uifactory.addDateChooser("training.start", "training.start", startDate, formLayout);
    startDateEl.setMandatory(true);
    startDateEl.setDateChooserTimeEnabled(true);
    Date endDate = meeting == null ? null : meeting.getEndDate();
    endDateEl = uifactory.addDateChooser("training.end", "training.end", endDate, formLayout);
    endDateEl.setMandatory(true);
    endDateEl.setDateChooserTimeEnabled(true);
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add("buttons", buttonLayout);
    uifactory.addFormSubmitButton("ok", buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Example 52 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project openolat by klemens.

the class EditTrainingController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String name = nameEl.getValue();
    String description = descriptionEl.getValue();
    Date start = startDateEl.getDate();
    Date end = endDateEl.getDate();
    GoToError error = new GoToError();
    if (meeting == null) {
        String selectedKeyStr = organizersEl.getSelectedKey();
        int selectedIndex = Integer.parseInt(selectedKeyStr);
        GoToOrganizer organizer = availablesOrganizers.get(selectedIndex);
        meetingManager.scheduleTraining(organizer, name, null, description, start, end, entry, subIdent, businessGroup, error);
    } else {
        meetingManager.updateTraining(meeting, name, description, start, end, error);
    }
    if (error.hasError()) {
        fireEvent(ureq, new GoToErrorEvent(error));
    } else {
        fireEvent(ureq, Event.DONE_EVENT);
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) GoToError(org.olat.modules.gotomeeting.model.GoToError) Date(java.util.Date)

Example 53 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer 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)

Example 54 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project openolat by klemens.

the class GoToMeetingManagerImpl method getRecordings.

@Override
public List<GoToRecordingsG2T> getRecordings(GoToMeeting meeting, GoToError error) {
    try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
        GoToOrganizer organizer = meeting.getOrganizer();
        String url = gotoTrainingUrl + "/trainings/" + meeting.getMeetingKey() + "/recordings";
        HttpGet get = new HttpGet(url);
        get.addHeader("Accept", "application/json");
        get.addHeader("Authorization", "OAuth oauth_token=" + organizer.getAccessToken());
        get.addHeader("Content-type", "application/json");
        HttpResponse response = httpClient.execute(get);
        int status = response.getStatusLine().getStatusCode();
        if (status == 200) {
            // deleted
            String content = EntityUtils.toString(response.getEntity());
            List<GoToRecordingsG2T> recordings = GoToJsonUtil.parseRecordings(content);
            return recordings;
        } else {
            logGoToError("getRecordings", response, error);
            return null;
        }
    } catch (Exception e) {
        log.error("", e);
        return null;
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) GoToRecordingsG2T(org.olat.modules.gotomeeting.model.GoToRecordingsG2T) IOException(java.io.IOException)

Example 55 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project openolat by klemens.

the class GoToMeetingManagerImpl method getTraining.

private GoToTrainingG2T getTraining(GoToMeeting meeting, GoToError error) {
    try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
        GoToOrganizer organizer = meeting.getOrganizer();
        String url = gotoTrainingUrl + "/organizers/" + organizer.getOrganizerKey() + "/trainings/" + meeting.getMeetingKey();
        HttpGet get = new HttpGet(url);
        get.addHeader("Accept", "application/json");
        get.addHeader("Authorization", "OAuth oauth_token=" + organizer.getAccessToken());
        get.addHeader("Content-type", "application/json");
        HttpResponse response = httpClient.execute(get);
        int status = response.getStatusLine().getStatusCode();
        if (status == 200) {
            // deleted
            String content = EntityUtils.toString(response.getEntity());
            GoToTrainingG2T trainingVo = GoToJsonUtil.parseTraining(content);
            return trainingVo;
        } else {
            logGoToError("getTraining", response, error);
            return null;
        }
    } catch (Exception e) {
        log.error("", e);
        return null;
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) GoToTrainingG2T(org.olat.modules.gotomeeting.model.GoToTrainingG2T) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException)

Aggregations

GoToOrganizer (org.olat.modules.gotomeeting.GoToOrganizer)60 Test (org.junit.Test)28 Date (java.util.Date)22 GoToMeeting (org.olat.modules.gotomeeting.GoToMeeting)18 IOException (java.io.IOException)16 HttpResponse (org.apache.http.HttpResponse)16 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)16 RepositoryEntry (org.olat.repository.RepositoryEntry)10 HttpGet (org.apache.http.client.methods.HttpGet)8 Identity (org.olat.core.id.Identity)8 StringEntity (org.apache.http.entity.StringEntity)6 GoToRegistrant (org.olat.modules.gotomeeting.GoToRegistrant)6 HttpPut (org.apache.http.client.methods.HttpPut)4 GoToError (org.olat.modules.gotomeeting.model.GoToError)4 GoToErrorG2T (org.olat.modules.gotomeeting.model.GoToErrorG2T)4 GoToRegistrantG2T (org.olat.modules.gotomeeting.model.GoToRegistrantG2T)4 Calendar (java.util.Calendar)2 Response (javax.ws.rs.core.Response)2 HttpDelete (org.apache.http.client.methods.HttpDelete)2 HttpPost (org.apache.http.client.methods.HttpPost)2