better logging for moodle access
This commit is contained in:
parent
1dadca2eae
commit
40b0426129
1 changed files with 38 additions and 17 deletions
|
@ -336,6 +336,7 @@ class MoodleRestTemplateFactory {
|
||||||
|
|
||||||
private void requestAccessToken() {
|
private void requestAccessToken() {
|
||||||
|
|
||||||
|
try {
|
||||||
final ResponseEntity<String> response = super.exchange(
|
final ResponseEntity<String> response = super.exchange(
|
||||||
this.serverURL + this.tokenPath,
|
this.serverURL + this.tokenPath,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
|
@ -344,6 +345,10 @@ class MoodleRestTemplateFactory {
|
||||||
this.tokenReqURIVars);
|
this.tokenReqURIVars);
|
||||||
|
|
||||||
if (response.getStatusCode() != HttpStatus.OK) {
|
if (response.getStatusCode() != HttpStatus.OK) {
|
||||||
|
log.error("Failed to gain access token for LMS (Moodle): lmsSetup: {} response: {} : {}",
|
||||||
|
MoodleRestTemplateFactory.this.lmsSetup,
|
||||||
|
response.getStatusCode(),
|
||||||
|
response.getBody());
|
||||||
throw new RuntimeException("Failed to gain access token for LMS (Moodle): lmsSetup: " +
|
throw new RuntimeException("Failed to gain access token for LMS (Moodle): lmsSetup: " +
|
||||||
MoodleRestTemplateFactory.this.lmsSetup + " response: " + response.getBody());
|
MoodleRestTemplateFactory.this.lmsSetup + " response: " + response.getBody());
|
||||||
}
|
}
|
||||||
|
@ -353,11 +358,27 @@ class MoodleRestTemplateFactory {
|
||||||
response.getBody(),
|
response.getBody(),
|
||||||
MoodleToken.class);
|
MoodleToken.class);
|
||||||
|
|
||||||
|
if (moodleToken == null || moodleToken.token == null) {
|
||||||
|
throw new RuntimeException("Access Token request with 200 but no or invalid token body");
|
||||||
|
}
|
||||||
|
|
||||||
this.accessToken = moodleToken.token;
|
this.accessToken = moodleToken.token;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
log.error("Failed to gain access token for LMS (Moodle): lmsSetup: {} response: {} : {}",
|
||||||
|
MoodleRestTemplateFactory.this.lmsSetup,
|
||||||
|
response.getStatusCode(),
|
||||||
|
response.getBody());
|
||||||
throw new RuntimeException("Failed to gain access token for LMS (Moodle): lmsSetup: " +
|
throw new RuntimeException("Failed to gain access token for LMS (Moodle): lmsSetup: " +
|
||||||
MoodleRestTemplateFactory.this.lmsSetup + " response: " + response.getBody(), e);
|
MoodleRestTemplateFactory.this.lmsSetup + " response: " + response.getBody(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (final Exception e) {
|
||||||
|
log.error("Failed to gain access token for LMS (Moodle): lmsSetup: {} :",
|
||||||
|
MoodleRestTemplateFactory.this.lmsSetup,
|
||||||
|
e);
|
||||||
|
throw new RuntimeException("Failed to gain access token for LMS (Moodle): lmsSetup: " +
|
||||||
|
MoodleRestTemplateFactory.this.lmsSetup + " cause: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue