use of org.olat.modules.gotomeeting.GoToOrganizer in project openolat by klemens.
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 klemens.
the class GoToOrganizerDAO method deleteOrganizer.
public void deleteOrganizer(GoToOrganizer organizer) {
GoToOrganizer organizerRef = dbInstance.getCurrentEntityManager().getReference(GoToOrganizerImpl.class, organizer.getKey());
dbInstance.getCurrentEntityManager().remove(organizerRef);
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToRegistrantDAOTest method createRegistrant.
@Test
public void createRegistrant() {
String token = UUID.randomUUID().toString();
Identity trainee = JunitTestHelper.createAndPersistIdentityAsRndUser("trainee-2");
GoToOrganizer organizer = organizerDao.createOrganizer(null, token, token, token, null, null, null, null, 10l, null);
Assert.assertNotNull(organizer);
Date start = new Date();
Date end = new Date();
String trainingKey = Long.toString(CodeHelper.getForeverUniqueID());
GoToMeeting training = meetingDao.createTraining("New training", null, "Very interessant", trainingKey, start, end, organizer, null, null, null);
dbInstance.commit();
// create registrant
String registrantKey = Long.toString(CodeHelper.getForeverUniqueID());
String joinUrl = "http://openolat.com/join/" + registrantKey;
String confirmUrl = "http://openolat.com/confirm/" + registrantKey;
GoToRegistrant registrant = registrantDao.createRegistrant(training, trainee, registrantKey, joinUrl, confirmUrl);
Assert.assertNotNull(registrant);
dbInstance.commit();
// load
GoToRegistrant reloadRegistrant = registrantDao.getRegistrant(training, trainee);
Assert.assertNotNull(reloadRegistrant);
Assert.assertEquals(registrant, reloadRegistrant);
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToOrganizerDAOTest method createOrganizer_withoutOwner.
@Test
public void createOrganizer_withoutOwner() {
String username = UUID.randomUUID().toString();
String accessToken = UUID.randomUUID().toString();
String organizerKey = UUID.randomUUID().toString();
GoToOrganizer organizer = organizerDao.createOrganizer("Our account", username, accessToken, organizerKey, null, null, null, null, 10l, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(organizer);
Assert.assertNotNull(organizer.getKey());
Assert.assertNotNull(organizer.getCreationDate());
Assert.assertNotNull(organizer.getLastModified());
Assert.assertEquals(username, organizer.getUsername());
GoToOrganizer reloadedOrganizer = organizerDao.loadOrganizerByKey(organizer.getKey());
Assert.assertNotNull(reloadedOrganizer);
Assert.assertEquals(organizer.getKey(), reloadedOrganizer.getKey());
Assert.assertNotNull(organizer.getCreationDate());
Assert.assertNotNull(organizer.getLastModified());
Assert.assertEquals("Our account", reloadedOrganizer.getName());
Assert.assertEquals(username, reloadedOrganizer.getUsername());
Assert.assertEquals(accessToken, reloadedOrganizer.getAccessToken());
Assert.assertEquals(organizerKey, reloadedOrganizer.getOrganizerKey());
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToOrganizerDAOTest method getOrganizersFor.
@Test
public void getOrganizersFor() {
Identity org = JunitTestHelper.createAndPersistIdentityAsRndUser("organizer-2");
Identity trainee = JunitTestHelper.createAndPersistIdentityAsRndUser("trainee-1");
String username = UUID.randomUUID().toString();
String accessToken = UUID.randomUUID().toString();
String organizerKey = UUID.randomUUID().toString();
GoToOrganizer myOrganizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Martin", "Schongauer", null, null, 10l, org);
GoToOrganizer systemOrganizer = organizerDao.createOrganizer(null, username + "_w", accessToken + "_w", organizerKey + "_w", "System", "Wide", null, null, 10l, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(myOrganizer);
// load available organizers
List<GoToOrganizer> organizers = organizerDao.getOrganizersFor(org);
Assert.assertNotNull(organizers);
Assert.assertFalse(organizers.isEmpty());
Assert.assertTrue(organizers.contains(myOrganizer));
Assert.assertTrue(organizers.contains(systemOrganizer));
// trainee has only system wide organizers
List<GoToOrganizer> traineeOrganizers = organizerDao.getOrganizersFor(trainee);
Assert.assertNotNull(traineeOrganizers);
Assert.assertFalse(traineeOrganizers.isEmpty());
Assert.assertFalse(traineeOrganizers.contains(myOrganizer));
Assert.assertTrue(traineeOrganizers.contains(systemOrganizer));
}
Aggregations