Search in sources :

Example 26 with GoToOrganizer

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;
    }
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) GoToErrorG2T(org.olat.modules.gotomeeting.model.GoToErrorG2T) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpDelete(org.apache.http.client.methods.HttpDelete) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException)

Example 27 with GoToOrganizer

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);
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer)

Example 28 with GoToOrganizer

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);
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) GoToMeeting(org.olat.modules.gotomeeting.GoToMeeting) GoToRegistrant(org.olat.modules.gotomeeting.GoToRegistrant) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 29 with GoToOrganizer

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());
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Test(org.junit.Test)

Example 30 with GoToOrganizer

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));
}
Also used : GoToOrganizer(org.olat.modules.gotomeeting.GoToOrganizer) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

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