Skip to content

Commit 38630b7

Browse files
committed
SEBSERV-652 mitigate Moodle bug by retry failed moodle calls with no name filter
1 parent 4c3affc commit 38630b7

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPIService.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ static Predicate<QuizData> quizFilterPredicate(final FilterMap filterMap) {
9494
if (filterMap == null) {
9595
return q -> true;
9696
}
97+
9798
final String name = filterMap.getQuizName();
9899
final DateTime from = filterMap.getQuizFromTime();
99100
final DateTime now = DateTime.now(DateTimeZone.UTC);
100-
System.out.println("************ name filter: " + name);
101+
101102
return q -> {
102103
final boolean nameFilter = StringUtils.isBlank(name) || (q.name != null && q.name.contains(name));
103104
final boolean startTimeFilter = from == null || (q.startTime != null && (q.startTime.isEqual(from) || q.startTime.isAfter(from)));

src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleRestTemplateFactoryImpl.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,20 @@ private String doRequest(
478478
final UriComponentsBuilder queryParam,
479479
final boolean usePOST,
480480
final HttpEntity<?> functionReqEntity) {
481-
482-
log.info("*** Call Moodle: {} BODY: {}", queryParam, functionReqEntity.getBody());
481+
482+
if (log.isDebugEnabled()) {
483+
log.debug("*** Call Moodle: {} BODY: {}", queryParam.toUriString(), functionReqEntity.getBody());
484+
}
483485

484486
final ResponseEntity<String> response = super.exchange(
485487
queryParam.toUriString(),
486488
usePOST ? HttpMethod.POST : HttpMethod.GET,
487489
functionReqEntity,
488490
String.class);
489-
490-
log.info("*** Moodle Response: {}", response);
491+
492+
if (log.isDebugEnabled()) {
493+
log.debug("*** Moodle Response: {}", response);
494+
}
491495

492496
final LmsSetup lmsSetup = this.apiTemplateDataSupplier.getLmsSetup();
493497
if (response.getStatusCode() != HttpStatus.OK) {

src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java

+4
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ private String getCoursePageFromMoodle(
509509

510510
// SEBSERV-652 mitigation (can be removed when Moodle bug is fixed
511511
if (responseBody == null) {
512+
513+
log.warn("*** Moodle respond with empty body on request with attributes: {}", attributes);
514+
log.info("*** Apply SEBSERV-652 mitigation...");
515+
512516
attributes.remove(PARAM_SQL_CONDITIONS);
513517
attributes.add(PARAM_SQL_CONDITIONS, getSQLCondition(null, cutoffDate, filterDate));
514518
responseBody = restTemplate.callMoodleAPIFunction(COURSES_API_FUNCTION_NAME, attributes);

0 commit comments

Comments
 (0)