SEBSERV-492 fixed PATCH instead of POST

This commit is contained in:
anhefti 2023-11-21 13:03:10 +01:00
parent 7a3ccdbb34
commit 491715aea9

View file

@ -27,6 +27,8 @@ import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.joda.time.Interval; import org.joda.time.Interval;
@ -40,7 +42,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails;
@ -565,6 +567,10 @@ public class ZoomProctoringService implements ExamProctoringService {
meetingPwd, meetingPwd,
this.enableWaitingRoom); this.enableWaitingRoom);
if (createMeeting.getStatusCodeValue() >= 400) {
throw new RuntimeException("Failed to create new Zoom room: " + createMeeting.getBody());
}
final MeetingResponse meetingResponse = this.jsonMapper.readValue( final MeetingResponse meetingResponse = this.jsonMapper.readValue(
createMeeting.getBody(), createMeeting.getBody(),
MeetingResponse.class); MeetingResponse.class);
@ -822,7 +828,12 @@ public class ZoomProctoringService implements ExamProctoringService {
final HttpHeaders headers = getHeaders(); final HttpHeaders headers = getHeaders();
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
final ResponseEntity<String> exchange = exchange(url, HttpMethod.POST, body, headers); final ResponseEntity<String> exchange = exchange(url, HttpMethod.PATCH, body, headers);
final int statusCodeValue = exchange.getStatusCodeValue();
if (statusCodeValue >= 400) {
log.warn("Failed to apply user settings for Zoom user: {} response: {}", userId, exchange);
}
return exchange; return exchange;
} catch (final Exception e) { } catch (final Exception e) {
log.error("Failed to apply user settings for Zoom user: {}", userId, e); log.error("Failed to apply user settings for Zoom user: {}", userId, e);
@ -1007,8 +1018,12 @@ public class ZoomProctoringService implements ExamProctoringService {
this.resource.setGrantType("account_credentials"); this.resource.setGrantType("account_credentials");
this.resource.setId(this.proctoringSettings.accountId); this.resource.setId(this.proctoringSettings.accountId);
final SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setOutputStreaming(false); final HttpClient httpClient = HttpClientBuilder.create()
.disableCookieManagement()
.useSystemProperties()
.build();
requestFactory.setHttpClient(httpClient);
final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(this.resource); final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(this.resource);
oAuth2RestTemplate.setRequestFactory(requestFactory); oAuth2RestTemplate.setRequestFactory(requestFactory);
oAuth2RestTemplate.setAccessTokenProvider(new ZoomCredentialsAccessTokenProvider()); oAuth2RestTemplate.setAccessTokenProvider(new ZoomCredentialsAccessTokenProvider());