Search in sources :

Example 31 with GoToOrganizer

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

the class GoToOrganizerDAOTest method createOrganizer_withOwner.

@Test
public void createOrganizer_withOwner() {
    Identity org = JunitTestHelper.createAndPersistIdentityAsRndUser("organizer-1");
    String username = UUID.randomUUID().toString();
    String accessToken = UUID.randomUUID().toString();
    String organizerKey = UUID.randomUUID().toString();
    GoToOrganizer organizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Albrecht", "Durer", "albert@openolat.com", "account-key", 1200l, org);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(organizer);
    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(username, reloadedOrganizer.getUsername());
    Assert.assertEquals(accessToken, reloadedOrganizer.getAccessToken());
    Assert.assertEquals(organizerKey, reloadedOrganizer.getOrganizerKey());
    Assert.assertEquals(org, reloadedOrganizer.getOwner());
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 32 with GoToOrganizer

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

the class GoToOrganizerDAOTest method organizerExists.

@Test
public void organizerExists() {
    String username = UUID.randomUUID().toString();
    String accessToken = UUID.randomUUID().toString();
    String organizerKey = UUID.randomUUID().toString();
    GoToOrganizer organizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Johann", "Amerbach", null, null, 10l, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(organizer);
    boolean exists = organizerDao.organizerExists(username);
    Assert.assertTrue(exists);
    boolean notExists = organizerDao.organizerExists(accessToken);
    Assert.assertFalse(notExists);
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Test(org.junit.Test)

Example 33 with GoToOrganizer

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

the class GoToOrganizerDAOTest method getOrganizers.

@Test
public void getOrganizers() {
    String username = UUID.randomUUID().toString();
    String accessToken = UUID.randomUUID().toString();
    String organizerKey = UUID.randomUUID().toString();
    GoToOrganizer organizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Martin", "Schongauer", null, null, 10l, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(organizer);
    // load by user name
    List<GoToOrganizer> organizers = organizerDao.getOrganizers();
    Assert.assertNotNull(organizers);
    Assert.assertFalse(organizers.isEmpty());
    Assert.assertTrue(organizers.contains(organizer));
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Test(org.junit.Test)

Example 34 with GoToOrganizer

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

the class GoToOrganizerDAO method deleteOrganizer.

public void deleteOrganizer(GoToOrganizer organizer) {
    GoToOrganizer organizerRef = dbInstance.getCurrentEntityManager().getReference(GoToOrganizerImpl.class, organizer.getKey());
    dbInstance.getCurrentEntityManager().remove(organizerRef);
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer)

Example 35 with GoToOrganizer

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

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;
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) GoToTrainingG2T(org.olat.modules.gotomeeting.model.GoToTrainingG2T) 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