use of org.olat.modules.gotomeeting.GoToMeeting in project openolat by klemens.
the class GoToMeetingsEditController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (addTrainingButton == source) {
doAddTraining(ureq);
} else if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("delete".equals(se.getCommand())) {
GoToMeeting meeting = tableModel.getObject(se.getIndex());
doConfirmDelete(ureq, meeting);
} else if ("edit".equals(se.getCommand())) {
GoToMeeting meeting = tableModel.getObject(se.getIndex());
doEditTraining(ureq, meeting);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.gotomeeting.GoToMeeting in project openolat by klemens.
the class GoToMeetingsAdminController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("delete".equals(se.getCommand())) {
GoToMeeting meeting = tableModel.getObject(se.getIndex());
doConfirmDelete(ureq, meeting);
} else if ("resource".equals(se.getCommand())) {
GoToMeeting meeting = tableModel.getObject(se.getIndex());
doOpenResource(ureq, meeting);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.gotomeeting.GoToMeeting 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.GoToMeeting in project openolat by klemens.
the class GoToMeetingManagerImpl method scheduleTraining.
@Override
public GoToMeeting scheduleTraining(GoToOrganizer organizer, String name, String externalId, String description, Date start, Date end, RepositoryEntry resourceOwner, String subIdentifier, BusinessGroup businessGroup, GoToError error) {
// GoToMeeting scheduledMeeting = meetingDao.createTraining(name, externalId, description, UUID.randomUUID().toString(), start, end, organizer, resourceOwner, subIdentifier, businessGroup);
GoToMeeting scheduledMeeting = null;
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
String url = gotoTrainingUrl + "/organizers/" + organizer.getOrganizerKey() + "/trainings";
HttpPost post = new HttpPost(url);
post.addHeader("Accept", "application/json");
post.addHeader("Authorization", "OAuth oauth_token=" + organizer.getAccessToken());
post.addHeader("Content-type", "application/json");
String timeZoneId = goToMeetingModule.getGoToTimeZoneId();
JSONObject trainingJson = GoToJsonUtil.training(Long.parseLong(organizer.getOrganizerKey()), name, description, timeZoneId, start, end);
String objectStr = trainingJson.toString();
post.setEntity(new StringEntity(objectStr, ContentType.APPLICATION_JSON));
HttpResponse response = httpClient.execute(post);
int status = response.getStatusLine().getStatusCode();
if (status == 201) {
// created
String trainingKey = EntityUtils.toString(response.getEntity());
trainingKey = trainingKey.replace("\"", "");
scheduledMeeting = meetingDao.createTraining(name, externalId, description, trainingKey, start, end, organizer, resourceOwner, subIdentifier, businessGroup);
dbInstance.commit();
} else {
logGoToError("scheduleTraining", response, error);
}
} catch (Exception e) {
log.error("", e);
}
return scheduledMeeting;
}
Aggregations