diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java index 87a6dbb0..8f7e10ce 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java @@ -426,7 +426,7 @@ public final class Exam implements GrantEntity { builder.append(", name="); builder.append(this.name); builder.append(", description="); - builder.append(this.getDescription()); + builder.append(Utils.truncateText(this.getDescription(), 255)); builder.append(", startTime="); builder.append(this.startTime); builder.append(", endTime="); diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java index dc6f696a..7e0d736b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java @@ -821,6 +821,18 @@ public final class Utils { return false; } + public static boolean isEqualsWithEmptyCheckTruncated(final String s1, final String s2) { + if (s2 == null || s1 == null) { + return false; + } + + if (s1.endsWith("...")) { + return Objects.equals(truncateText(s1, 1000), truncateText(s2, 1000)); + } else { + return Objects.equals(s1, s2); + } + } + public static Long toLong(final String longValue) { try { return Long.valueOf(longValue); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 80178cc5..d49e8c4d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -467,15 +467,15 @@ public class ExamSessionServiceImpl implements ExamSessionService { final Set connectionIds) { this.duplicateCheck.clear(); - this.duplicates.clear(); + final Set duplicates = new HashSet<>(); return this.clientConnectionDAO .getConnectionTokens(examId) .map(tokens -> tokens.stream() - .map(this::getForTokenAndCheckDuplication) + .map(token -> this.getForTokenAndCheckDuplication(token, duplicates)) .filter(ccd -> connectionIds.contains(ccd.clientConnection.id)) .map(ccd -> ccd.clientStaticData) .collect(Collectors.toList())) - .map(staticData -> new MonitoringStaticClientData(staticData, this.duplicates)); + .map(staticData -> new MonitoringStaticClientData(staticData, duplicates)); } @Override @@ -633,17 +633,19 @@ public class ExamSessionServiceImpl implements ExamSessionService { } private final Map duplicateCheck = new HashMap<>(); - private final Set duplicates = new HashSet<>(); - private ClientConnectionDataInternal getForTokenAndCheckDuplication(final String token) { + private ClientConnectionDataInternal getForTokenAndCheckDuplication( + final String token, + final Set duplicates) { + final ClientConnectionDataInternal cc = this.examSessionCacheService.getClientConnection(token); if (cc.clientConnection.status.duplicateCheckStatus) { final Long id = this.duplicateCheck.put( cc.clientConnection.userSessionId, cc.getConnectionId()); if (id != null) { - this.duplicates.add(id); - this.duplicates.add(cc.getConnectionId()); + duplicates.add(id); + duplicates.add(cc.getConnectionId()); } } return cc; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java index f76b3a67..665e9400 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java @@ -355,22 +355,21 @@ class ExamUpdateHandler { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name) || !Objects.equals(exam.startTime, quizData.startTime) || !Objects.equals(exam.endTime, quizData.endTime) || - !Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description) || + !Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description) || !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name)) { - log.info("Update name difference from LMS. Exam:{}, QuizData: {}", exam.name, quizData.name); + log.info("Update name difference from LMS. Exam: {}, QuizData: {}", exam.name, quizData.name); } if (!Objects.equals(exam.startTime, quizData.startTime)) { - log.info("Update startTime difference from LMS. Exam:{}, QuizData: {}", exam.startTime, + log.info("Update startTime difference from LMS. Exam: {}, QuizData: {}", exam.startTime, quizData.startTime); } if (!Objects.equals(exam.endTime, quizData.endTime)) { - log.info("Update endTime difference from LMS. Exam:{}, QuizData: {}", exam.endTime, quizData.endTime); + log.info("Update endTime difference from LMS. Exam: {}, QuizData: {}", exam.endTime, quizData.endTime); } - if (!Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description)) { - log.info("Update description difference from LMS. Exam:{}, QuizData: {}", exam.getDescription(), - quizData.description); + if (!Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description)) { + log.info("Update description difference from LMS. Exam: {}", exam); } if (!Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { log.info("Update startURL difference from LMS. Exam:{}, QuizData: {}",