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());
}
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);
}
}
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);
}
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;
}
}
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;
}
}
Aggregations