use of org.olat.modules.gotomeeting.model.GoToTrainingG2T in project OpenOLAT by OpenOLAT.
the class GoToJsonUtil method parseTraining.
/*
{
"trainingId": "string",
"name": "string",
"description": "string",
"timeZone": "string",
"times": [
{
"startDate": "2016-03-24T10:00:00Z",
"endDate": "2016-03-24T11:00:00Z"
}
],
"organizers": [
{
"organizerKey": "string",
"email": "string",
"givenName": "string",
"surname": "string"
}
],
"registrationSettings": {
"disableConfirmationEmail": true,
"disableWebRegistration": true
},
"trainingKey": "string"
}
*/
protected static final GoToTrainingG2T parseTraining(String content) {
try {
JSONObject json = new JSONObject(content);
GoToTrainingG2T training = new GoToTrainingG2T();
training.setName(json.optString("name"));
training.setDescription(json.optString("description"));
training.setTrainingKey(json.optString("trainingKey", null));
training.setTimeZoneId(json.optString("timeZone", null));
JSONArray times = json.getJSONArray("times");
JSONObject time = times.getJSONObject(0);
String startDate = time.optString("startDate", null);
Date start = parseDateTime(startDate);
training.setStart(start);
String endDate = time.optString("endDate", null);
Date end = parseDateTime(endDate);
training.setEnd(end);
return training;
} catch (Exception e) {
log.error("", e);
return null;
}
}
use of org.olat.modules.gotomeeting.model.GoToTrainingG2T in project openolat by klemens.
the class GoToJsonUtil method parseTraining.
/*
{
"trainingId": "string",
"name": "string",
"description": "string",
"timeZone": "string",
"times": [
{
"startDate": "2016-03-24T10:00:00Z",
"endDate": "2016-03-24T11:00:00Z"
}
],
"organizers": [
{
"organizerKey": "string",
"email": "string",
"givenName": "string",
"surname": "string"
}
],
"registrationSettings": {
"disableConfirmationEmail": true,
"disableWebRegistration": true
},
"trainingKey": "string"
}
*/
protected static final GoToTrainingG2T parseTraining(String content) {
try {
JSONObject json = new JSONObject(content);
GoToTrainingG2T training = new GoToTrainingG2T();
training.setName(json.optString("name"));
training.setDescription(json.optString("description"));
training.setTrainingKey(json.optString("trainingKey", null));
training.setTimeZoneId(json.optString("timeZone", null));
JSONArray times = json.getJSONArray("times");
JSONObject time = times.getJSONObject(0);
String startDate = time.optString("startDate", null);
Date start = parseDateTime(startDate);
training.setStart(start);
String endDate = time.optString("endDate", null);
Date end = parseDateTime(endDate);
training.setEnd(end);
return training;
} catch (Exception e) {
log.error("", e);
return null;
}
}
use of org.olat.modules.gotomeeting.model.GoToTrainingG2T 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;
}
}
use of org.olat.modules.gotomeeting.model.GoToTrainingG2T 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