Search in sources :

Example 1 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.

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 2 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.

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 3 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.

the class GoToOrganizerListAdminController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addOrganizerButton == source) {
        doAddOrganizer(ureq);
    } else if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("renew".equals(se.getCommand())) {
                GoToOrganizer organizer = tableModel.getObject(se.getIndex());
                doRenewOrganizer(ureq, organizer);
            } else if ("remove".equals(se.getCommand())) {
                GoToOrganizer organizer = tableModel.getObject(se.getIndex());
                doConfirmRemove(ureq, organizer);
            } else if ("owner".equals(se.getCommand())) {
                GoToOrganizer organizer = tableModel.getObject(se.getIndex());
                doOpenOwner(ureq, organizer);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)

Example 4 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.

the class GoToMeetingManagerImpl method deleteTraining.

private boolean deleteTraining(GoToMeeting meeting, GoToError error) {
    try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
        GoToOrganizer organizer = meeting.getOrganizer();
        String url = gotoTrainingUrl + "/organizers/" + organizer.getOrganizerKey() + "/trainings/" + meeting.getMeetingKey();
        HttpDelete delete = new HttpDelete(url);
        delete.addHeader("Accept", "application/json");
        delete.addHeader("Authorization", "OAuth oauth_token=" + organizer.getAccessToken());
        delete.addHeader("Content-type", "application/json");
        HttpResponse response = httpClient.execute(delete);
        int status = response.getStatusLine().getStatusCode();
        if (status == 204) {
            // deleted
            return true;
        } else if (status == 404 || status == 400) {
            String content = EntityUtils.toString(response.getEntity());
            GoToErrorG2T errorVo = GoToJsonUtil.parseError(content);
            if (errorVo.getErrorCode() == GoToErrors.NoSuchTraining || errorVo.getErrorCode() == GoToErrors.InvalidRequest) {
                error.setError(errorVo.getErrorCode());
                error.setDescription(errorVo.getDescription());
            } else {
                log.error("deleteTraining return " + status + ": " + content);
            }
        } else {
            logGoToError("deleteTraining", response, error);
        }
        return false;
    } catch (Exception e) {
        log.error("", e);
        return false;
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) GoToErrorG2T(org.olat.modules.gotomeeting.model.GoToErrorG2T) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpDelete(org.apache.http.client.methods.HttpDelete) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException)

Example 5 with GoToOrganizer

use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.

the class GoToMeetingManagerImpl method getRegistrant.

private GoToRegistrantG2T getRegistrant(String registrantKey, GoToMeeting meeting, GoToError error) {
    try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
        GoToOrganizer organizer = meeting.getOrganizer();
        String url = gotoTrainingUrl + "/organizers/" + organizer.getOrganizerKey() + "/trainings/" + meeting.getMeetingKey() + "/registrants/" + registrantKey;
        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) {
            String content = EntityUtils.toString(response.getEntity());
            GoToRegistrantG2T registrantVo = GoToJsonUtil.parseAddRegistrant(content);
            return registrantVo;
        } else {
            logGoToError("getRegistrant", 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) GoToRegistrantG2T(org.olat.modules.gotomeeting.model.GoToRegistrantG2T) 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