From 80af47e14e051525649b6ad8b93daa3532c05cc7 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 8 Feb 2023 09:29:27 +0100 Subject: [PATCH] SEBSERV-378 --- .../lms/impl/ans/AnsLmsAPITemplate.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java index fc74b1f6..96cb92f6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java @@ -331,9 +331,26 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms attrs); } + private ExamineeAccountDetails tryGetExamineeById(final RestTemplate restTemplate, final String id) { + try { + ExamineeAccountDetails examineeAccountDetails = getExamineeById(restTemplate, id); + + // SEBSERV-378: If there is no first and last name set, try once again to get the user data + if (StringUtils.isBlank(examineeAccountDetails.getDisplayName())) { + log.warn("Failed to get ExamineeAccountDetails from Ans. No DisplayName, try once again"); + examineeAccountDetails = getExamineeById(restTemplate, id); + } + + return examineeAccountDetails; + } catch (final Exception e) { + log.error("Failed to get ExamineeAccountDetails from Ans, try once again: ", e); + return getExamineeById(restTemplate, id); + } + } + @Override public Result getExamineeAccountDetails(final String examineeUserId) { - return getRestTemplate().map(t -> this.getExamineeById(t, examineeUserId)); + return getRestTemplate().map(t -> this.tryGetExamineeById(t, examineeUserId)); } @Override