Merge remote-tracking branch 'origin/dev-1.3' into development
This commit is contained in:
parent
74b2c358c6
commit
a79a5f87a0
1 changed files with 41 additions and 34 deletions
|
@ -44,6 +44,8 @@ public class OlatLmsRestTemplate extends RestTemplate {
|
||||||
final byte[] body,
|
final byte[] body,
|
||||||
final ClientHttpRequestExecution execution) throws IOException {
|
final ClientHttpRequestExecution execution) throws IOException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
// if there's no token, authenticate first
|
// if there's no token, authenticate first
|
||||||
if (OlatLmsRestTemplate.this.token == null) {
|
if (OlatLmsRestTemplate.this.token == null) {
|
||||||
authenticate();
|
authenticate();
|
||||||
|
@ -74,8 +76,7 @@ public class OlatLmsRestTemplate extends RestTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get a 401, re-authenticate and try once more
|
// If we get a 401, re-authenticate and try once more
|
||||||
if (response.getStatusCode() == HttpStatus.UNAUTHORIZED
|
if (response.getStatusCode() == HttpStatus.UNAUTHORIZED) {
|
||||||
/* || response.getStatusCode() == HttpStatus.FORBIDDEN */) {
|
|
||||||
|
|
||||||
authenticate();
|
authenticate();
|
||||||
request.getHeaders().set("X-OLAT-TOKEN", OlatLmsRestTemplate.this.token);
|
request.getHeaders().set("X-OLAT-TOKEN", OlatLmsRestTemplate.this.token);
|
||||||
|
@ -93,6 +94,12 @@ public class OlatLmsRestTemplate extends RestTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
|
} catch (final Exception e) {
|
||||||
|
// TODO find a way to better deal with Olat temporary unavailability
|
||||||
|
log.error("Unexpected error: ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue