SEBSERV-262: Implemented default settings for Zoom user.
This commit is contained in:
parent
95c3f31cb9
commit
8c6ffee2a9
2 changed files with 53 additions and 0 deletions
|
@ -75,6 +75,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.RemoteProctoringRoomDAO
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamProctoringService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamProctoringService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientInstructionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientInstructionService;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.ApplyUserSettingsRequest;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.CreateMeetingRequest;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.CreateMeetingRequest;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.CreateUserRequest;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.CreateUserRequest;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.MeetingResponse;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.proctoring.ZoomRoomRequestResponse.MeetingResponse;
|
||||||
|
@ -553,6 +554,11 @@ public class ZoomProctoringService implements ExamProctoringService {
|
||||||
createUser.getBody(),
|
createUser.getBody(),
|
||||||
UserResponse.class);
|
UserResponse.class);
|
||||||
|
|
||||||
|
this.zoomRestTemplate.applyUserSettings(
|
||||||
|
proctoringSettings.serverURL,
|
||||||
|
credentials,
|
||||||
|
userResponse.id);
|
||||||
|
|
||||||
// Then create new meeting with the ad-hoc user/host
|
// Then create new meeting with the ad-hoc user/host
|
||||||
final CharSequence meetingPwd = UUID.randomUUID().toString().subSequence(0, 9);
|
final CharSequence meetingPwd = UUID.randomUUID().toString().subSequence(0, 9);
|
||||||
final ResponseEntity<String> createMeeting = this.zoomRestTemplate.createMeeting(
|
final ResponseEntity<String> createMeeting = this.zoomRestTemplate.createMeeting(
|
||||||
|
@ -779,6 +785,7 @@ public class ZoomProctoringService implements ExamProctoringService {
|
||||||
private static final int LIZENSED_USER = 2;
|
private static final int LIZENSED_USER = 2;
|
||||||
private static final String API_TEST_ENDPOINT = "v2/users";
|
private static final String API_TEST_ENDPOINT = "v2/users";
|
||||||
private static final String API_CREATE_USER_ENDPOINT = "v2/users";
|
private static final String API_CREATE_USER_ENDPOINT = "v2/users";
|
||||||
|
private static final String API_APPLY_USER_SETTINGS_ENDPOINT = "v2/users/{userId}/settings";
|
||||||
private static final String API_DELETE_USER_ENDPOINT = "v2/users/{userid}?action=delete";
|
private static final String API_DELETE_USER_ENDPOINT = "v2/users/{userid}?action=delete";
|
||||||
private static final String API_USER_CUST_CREATE = "custCreate";
|
private static final String API_USER_CUST_CREATE = "custCreate";
|
||||||
private static final String API_ZOOM_ROOM_USER = "SEBProctoringRoomUser";
|
private static final String API_ZOOM_ROOM_USER = "SEBProctoringRoomUser";
|
||||||
|
@ -856,6 +863,32 @@ public class ZoomProctoringService implements ExamProctoringService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<String> applyUserSettings(
|
||||||
|
final String zoomServerUrl,
|
||||||
|
final ClientCredentials credentials,
|
||||||
|
final String userId) {
|
||||||
|
try {
|
||||||
|
final String url = UriComponentsBuilder
|
||||||
|
.fromUriString(zoomServerUrl)
|
||||||
|
.path(API_APPLY_USER_SETTINGS_ENDPOINT)
|
||||||
|
.buildAndExpand(userId)
|
||||||
|
.normalize()
|
||||||
|
.toUriString();
|
||||||
|
final String host = new URL(zoomServerUrl).getHost();
|
||||||
|
final ApplyUserSettingsRequest applySettingsRequest = new ApplyUserSettingsRequest();
|
||||||
|
final String body = this.zoomProctoringService.jsonMapper.writeValueAsString(applySettingsRequest);
|
||||||
|
final HttpHeaders headers = getHeaders(credentials);
|
||||||
|
|
||||||
|
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
|
||||||
|
return exchange(url, HttpMethod.PATCH, body, headers);
|
||||||
|
|
||||||
|
} catch (final Exception e) {
|
||||||
|
log.error("Failed to apply user settings for Zoom user: {}", userId, e);
|
||||||
|
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ResponseEntity<String> createMeeting(
|
public ResponseEntity<String> createMeeting(
|
||||||
final String zoomServerUrl,
|
final String zoomServerUrl,
|
||||||
final ClientCredentials credentials,
|
final ClientCredentials credentials,
|
||||||
|
|
|
@ -87,6 +87,26 @@ public interface ZoomRoomRequestResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
static class ApplyUserSettingsRequest {
|
||||||
|
@JsonProperty final InMeetingSettings in_meeting;
|
||||||
|
public ApplyUserSettingsRequest() {
|
||||||
|
this.in_meeting = new InMeetingSettings(true, 1);
|
||||||
|
}
|
||||||
|
public ApplyUserSettingsRequest(final InMeetingSettings in_meeting) {
|
||||||
|
this.in_meeting = in_meeting;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class InMeetingSettings {
|
||||||
|
@JsonProperty final boolean auto_saving_chat;
|
||||||
|
@JsonProperty final int allow_users_save_chats;
|
||||||
|
public InMeetingSettings(boolean auto_saving_chat, int allow_users_save_chats) {
|
||||||
|
this.auto_saving_chat = auto_saving_chat;
|
||||||
|
this.allow_users_save_chats = allow_users_save_chats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
static class UserResponse {
|
static class UserResponse {
|
||||||
final String id;
|
final String id;
|
||||||
|
|
Loading…
Reference in a new issue