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