From ae9fd0636a555be326cef450224b209274ce6580 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 27 Jun 2022 13:01:09 +0200 Subject: [PATCH] code cleanup --- .../gbl/api/authorization/PrivilegeType.java | 2 +- .../seb/sebserver/gbl/async/AsyncService.java | 4 +- .../gbl/async/MemoizingCircuitBreaker.java | 2 +- .../gbl/client/ClientCredentialService.java | 4 +- .../ethz/seb/sebserver/gbl/model/Entity.java | 2 +- ...InstitutionalAuthenticationEntryPoint.java | 2 +- .../SEBExamConfigBatchStateChangePopup.java | 2 +- .../ch/ethz/seb/sebserver/gui/form/Form.java | 2 +- .../examconfig/impl/TableFieldBuilder.java | 2 +- .../gui/service/i18n/I18nSupport.java | 14 +- .../seb/sebserver/gui/table/EntityTable.java | 6 +- .../sebserver/webservice/WebserviceInfo.java | 2 +- .../servicelayer/PaginationService.java | 2 +- .../bulkaction/BulkActionService.java | 2 +- .../dao/ClientInstructionDAO.java | 4 +- .../servicelayer/dao/ConfigurationDAO.java | 2 +- .../servicelayer/dao/EntityDAO.java | 6 +- .../webservice/servicelayer/dao/ExamDAO.java | 2 +- .../dao/impl/CertificateDAOImpl.java | 2 +- .../servicelayer/dao/impl/ExamDAOImpl.java | 4 +- .../exam/impl/ExamTemplateServiceImpl.java | 2 +- .../servicelayer/lms/LmsAPIService.java | 4 +- .../servicelayer/lms/LmsAPITemplate.java | 1 - .../servicelayer/lms/SEBRestrictionAPI.java | 2 +- .../lms/impl/AbstractCourseAccess.java | 188 ------------------ .../session/impl/ExamSessionControlTask.java | 2 +- .../session/impl/ExamUpdateHandler.java | 2 +- 27 files changed, 40 insertions(+), 229 deletions(-) delete mode 100644 src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/api/authorization/PrivilegeType.java b/src/main/java/ch/ethz/seb/sebserver/gbl/api/authorization/PrivilegeType.java index e4bc9c20..2e8abfde 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/api/authorization/PrivilegeType.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/api/authorization/PrivilegeType.java @@ -29,7 +29,7 @@ public enum PrivilegeType { * and so on. * * @param type the PrivilegeType - * @return true if given PrivilegeType is implicit form this PrivilegeType */ + * @return true if given PrivilegeType is implicit from this PrivilegeType */ public boolean hasImplicit(final PrivilegeType type) { if (type == null) { return false; diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/async/AsyncService.java b/src/main/java/ch/ethz/seb/sebserver/gbl/async/AsyncService.java index 17f9f816..a6a1d46e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/async/AsyncService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/async/AsyncService.java @@ -36,7 +36,7 @@ public class AsyncService { * * @param maxFailingAttempts maximal number of attempts the CircuitBreaker allows before going onto open state. * @param maxBlockingTime maximal time since call CircuitBreaker waits for a response before going onto open state. - * @param timeToRecover the time the CircuitBreaker takes to recover form open state. + * @param timeToRecover the time the CircuitBreaker takes to recover from open state. * @param the type of the CircuitBreaker * @return a CircuitBreaker of specified type */ public CircuitBreaker createCircuitBreaker( @@ -57,7 +57,7 @@ public class AsyncService { * @param blockingSupplier the blocking result supplier that the MemoizingCircuitBreaker must call * @param maxFailingAttempts maximal number of attempts the CircuitBreaker allows before going onto open state. * @param maxBlockingTime maximal time since call CircuitBreaker waits for a response before going onto open state. - * @param timeToRecover the time the CircuitBreaker takes to recover form open state. + * @param timeToRecover the time the CircuitBreaker takes to recover from open state. * @param momoized whether the memoizing functionality is on or off * @param maxMemoizingTime the maximal time memorized data is valid * @param the type of the CircuitBreaker diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java b/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java index 5a236a5d..f32f3a62 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java @@ -94,7 +94,7 @@ public final class MemoizingCircuitBreaker implements Supplier> { * * @param asyncRunner the AsyncRunner used to create asynchronous calls on the given supplier function * @param supplier The Supplier function that can fail or block for a long time - * @param maxFailingAttempts the number of maximal failing attempts before go form CLOSE into HALF_OPEN state + * @param maxFailingAttempts the number of maximal failing attempts before go from CLOSE into HALF_OPEN state * @param maxBlockingTime the maximal time that an call attempt can block until an error is responded * @param timeToRecover the time the circuit breaker needs to cool-down on OPEN-STATE before going back to HALF_OPEN * state diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java index d28e6664..a61e8b39 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/client/ClientCredentialService.java @@ -55,13 +55,13 @@ public interface ClientCredentialService { return encryptClientCredentials(clientIdPlaintext, secretPlaintext, null); } - /** Use this to get a decrypted plain text secret form given ClientCredentials + /** Use this to get a decrypted plain text secret from given ClientCredentials * * @param credentials ClientCredentials containing the secret to decrypt * @return decrypted plain text secret */ Result getPlainClientSecret(ClientCredentials credentials); - /** Use this to get a decrypted plain text accessToken form given ClientCredentials + /** Use this to get a decrypted plain text accessToken from given ClientCredentials * * @param credentials ClientCredentials containing the accessToken to decrypt * @return decrypted plain text accessToken */ diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/Entity.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/Entity.java index ada4b1ae..451913f3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/Entity.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/Entity.java @@ -48,7 +48,7 @@ public interface Entity extends ModelIdAware { /** Creates an EntityName instance from this Entity instance. * - * @return EntityName instance created form given Entity */ + * @return EntityName instance created from given Entity */ default EntityName toName() { return new EntityName( this.getModelId(), diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java b/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java index 8971254b..12d24351 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java @@ -231,7 +231,7 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati final Object attribute = RWT.getUISession().getHttpSession().getAttribute(INST_SUFFIX_ATTRIBUTE); return (attribute != null) ? String.valueOf(attribute) : null; } catch (final Exception e) { - log.warn("Failed to extract institutional endpoint form user session: {}", e.getMessage()); + log.warn("Failed to extract institutional endpoint from user session: {}", e.getMessage()); return null; } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigBatchStateChangePopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigBatchStateChangePopup.java index ecb21abd..9842a03a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigBatchStateChangePopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigBatchStateChangePopup.java @@ -108,7 +108,7 @@ public class SEBExamConfigBatchStateChangePopup extends AbstractBatchActionWizar final String targetStateName = pageContext.getAttribute(ATTR_SELECTED_TARGET_STATE); if (StringUtils.isBlank(targetStateName)) { - throw new IllegalArgumentException("missing " + ATTR_SELECTED_TARGET_STATE + " form pageContext"); + throw new IllegalArgumentException("missing " + ATTR_SELECTED_TARGET_STATE + " from pageContext"); } batchActionRequestBuilder.withFormParam(BatchAction.ACTION_ATTRIBUT_TARGET_STATE, targetStateName); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/form/Form.java b/src/main/java/ch/ethz/seb/sebserver/gui/form/Form.java index cd44d9ab..02a90892 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/form/Form.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/form/Form.java @@ -70,7 +70,7 @@ public final class Form implements FormBinding { flush(); return this.jsonMapper.writeValueAsString(this.objectRoot); } catch (final Exception e) { - throw new RuntimeException("Unexpected error while trying to create json form Form post: ", e); + throw new RuntimeException("Unexpected error while trying to create json from form post: ", e); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java index 9b529c7b..c65b4623 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java @@ -168,7 +168,7 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder { private void addRow() { final int index = this.values.size(); - // create new values form default values + // create new values from default values final Map rowValues = this.tableContext.getRowAttributes() .stream() .map(attr -> new TableValue(attr.id, index, attr.defaultValue)) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/I18nSupport.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/I18nSupport.java index fe7b70a4..80a35e0c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/I18nSupport.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/i18n/I18nSupport.java @@ -43,7 +43,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.date.display format' * or the Constants.DEFAULT_DISPLAY_DATE_FORMAT * - * Adds time-zone offset information if the currents user time-zone is different form UTC + * Adds time-zone offset information if the currents user time-zone is different from UTC * * @param date the DateTime instance * @return date formatted date String to display */ @@ -53,7 +53,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.date.display format' * or the Constants.DEFAULT_DISPLAY_DATE_FORMAT * - * Adds time-zone offset information if the currents user time-zone is different form UTC + * Adds time-zone offset information if the currents user time-zone is different from UTC * * @param date the DateTime instance * @return date formatted date String to display */ @@ -65,7 +65,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.date.display format' * or the Constants.DEFAULT_DISPLAY_DATE_FORMAT * - * Adds time-zone information if the currents user time-zone is different form UTC + * Adds time-zone information if the currents user time-zone is different from UTC * * @param timestamp the unix-timestamp in milliseconds * @return date formatted date String to display */ @@ -77,7 +77,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.datetime.display format' * or the Constants.DEFAULT_DISPLAY_DATE_TIME_FORMAT * - * Adds time-zone information if the currents user time-zone is different form UTC + * Adds time-zone information if the currents user time-zone is different from UTC * * @param date the DateTime instance * @return date formatted date time String to display */ @@ -87,7 +87,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.datetime.display format' * or the Constants.DEFAULT_DISPLAY_DATE_TIME_FORMAT * - * Adds time-zone information if the currents user time-zone is different form UTC + * Adds time-zone information if the currents user time-zone is different from UTC * * @param timestamp the unix-timestamp in milliseconds * @return date formatted date time String to display */ @@ -99,7 +99,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.time.display format' * or the Constants.DEFAULT_DISPLAY_TIME_FORMAT * - * Adds time-zone information if the currents user time-zone is different form UTC + * Adds time-zone information if the currents user time-zone is different from UTC * * @param date the DateTime instance * @return date formatted time String to display */ @@ -109,7 +109,7 @@ public interface I18nSupport { * This uses the date-format defined by either the attribute 'sebserver.gui.time.display format' * or the Constants.DEFAULT_DISPLAY_TIME_FORMAT * - * Adds time-zone information if the currents user time-zone is different form UTC + * Adds time-zone information if the currents user time-zone is different from UTC * * @param timestamp the unix-timestamp in milliseconds * @return date formatted time String to display */ diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index 8eb9a1d7..152a8706 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -716,7 +716,7 @@ public class EntityTable { return 1; } } catch (final Exception e) { - log.error("Failed to get sort attribute form current user attributes", e); + log.error("Failed to get sort attribute from current user attributes", e); return 1; } } @@ -757,7 +757,7 @@ public class EntityTable { setTableSort(); } catch (final Exception e) { - log.error("Failed to get sort attribute form current user attributes", e); + log.error("Failed to get sort attribute from current user attributes", e); } } @@ -794,7 +794,7 @@ public class EntityTable { .getCurrentUser() .getAttribute(this.filterAttrName)); } catch (final Exception e) { - log.error("Failed to get filter attributes form current user attributes", e); + log.error("Failed to get filter attributes from current user attributes", e); } } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java index ed4557aa..c52d0b19 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java @@ -233,7 +233,7 @@ public class WebserviceInfo { return InetAddress.getLoopbackAddress().getHostAddress(); } - /** Get the server URL prefix in form of; + /** Get the server URL prefix in the form of; * [scheme{http|https}]://[server-address{DNS-name|IP}]:[port] * * E.g.: https://seb.server.ch:8080 diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java index 6212f1d6..fbf24ec2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java @@ -19,7 +19,7 @@ import ch.ethz.seb.sebserver.gbl.model.Entity; import ch.ethz.seb.sebserver.gbl.model.Page; import ch.ethz.seb.sebserver.gbl.util.Result; -/** A service to apply pagination functionality within collection results form data access layer. +/** A service to apply pagination functionality within collection results from data access layer. * The default implementation uses Mybatis-PageHelper to apply the pagination on SQL level where possible: * https://github.com/pagehelper/Mybatis-PageHelper */ diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/bulkaction/BulkActionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/bulkaction/BulkActionService.java index 57e063fa..6787f2cb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/bulkaction/BulkActionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/bulkaction/BulkActionService.java @@ -56,7 +56,7 @@ public interface BulkActionService { * If the given BulkAction has not already been executed, it will be executed first * * @param action the BulkAction of a concrete type - * @return EntityProcessingReport extracted form an executed BulkAction */ + * @return EntityProcessingReport extracted from an executed BulkAction */ Result createReport(BulkAction action); } \ No newline at end of file diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientInstructionDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientInstructionDAO.java index 795a801f..c18c4e53 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientInstructionDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ClientInstructionDAO.java @@ -45,7 +45,7 @@ public interface ClientInstructionDAO { * @return Collection of all active instructions for specified connection token */ Result> getAllActive(String connectionToken); - /** Deletes all old instructions form the persistent storage to clean-up. + /** Deletes all old instructions from the persistent storage to clean-up. * Old in this case means the timestamp is older then one minute or a configured time interval * * @param timestamp the time-stamp (milliseconds) of the time in the past from that earlier instructions are @@ -53,7 +53,7 @@ public interface ClientInstructionDAO { * @return Result collection of keys of deleted entities or refer to an error when happened */ Result> deleteAllInactive(long timestamp); - /** Deletes the specified instruction form the data base + /** Deletes the specified instruction from the data base * * @param id the identifier (PK) if the ClientInstruction to delete * @return Void Result refer to an error if happened */ diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ConfigurationDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ConfigurationDAO.java index 51c1449e..a04e67a4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ConfigurationDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ConfigurationDAO.java @@ -38,7 +38,7 @@ public interface ConfigurationDAO extends EntityDAO saveToHistory(Long configurationNodeId); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/EntityDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/EntityDAO.java index c6743587..b1b57af5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/EntityDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/EntityDAO.java @@ -148,14 +148,14 @@ public interface EntityDAO { * @return Result referring to collection of all matching entities or an error if happened */ Result> allMatching(FilterMap filterMap, Predicate predicate); - /** Context based utility method to extract an expected single resource entry form a Collection of specified type. - * Gets a Result refer to an expected single resource entry form a Collection of specified type or refer + /** Context based utility method to extract an expected single resource entry from a Collection of specified type. + * Gets a Result refer to an expected single resource entry from a Collection of specified type or refer * to a ResourceNotFoundException if specified collection is null or empty or refer to a * unexpected RuntimeException if there are more then the expected single element in the given collection * * @param id The resource id to wrap within a ResourceNotFoundException if needed * @param resources the collection of resource entries - * @return Result refer to an expected single resource entry form a Collection of specified type or refer to an + * @return Result refer to an expected single resource entry from a Collection of specified type or refer to an * error if happened */ default Result getSingleResource(final String id, final Collection resources) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java index 370cbfa1..7c6b77c9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java @@ -89,7 +89,7 @@ public interface ExamDAO extends ActivatableEntityDAO, BulkActionSup final Predicate predicate, final ExamStatus... status); - /** Gets all for active and none archived exams within the system, independently form institution and LMSSetup. + /** Gets all for active and none archived exams within the system, independently from institution and LMSSetup. * * @return Result refer to all exams for LMS update or to an error when happened */ Result> allForLMSUpdate(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java index 52aeacec..88455581 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java @@ -239,7 +239,7 @@ public class CertificateDAOImpl implements CertificateDAO { return dn.replace(" ", "_").toLowerCase(); } } catch (final CertificateEncodingException e) { - log.warn("Error while trying to get alias form certificate subject name. Use serial number as alias"); + log.warn("Error while trying to get alias from certificate subject name. Use serial number as alias"); return String.valueOf(certificate.getSerialNumber()); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java index 448ed0af..80b880ed 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java @@ -187,9 +187,9 @@ public class ExamDAOImpl implements ExamDAO { public void markLMSAvailability(final String externalQuizId, final boolean available, final String updateId) { if (!available) { - log.info("Mark exam quiz data not available form LMS: {}", externalQuizId); + log.info("Mark exam quiz data not available from LMS: {}", externalQuizId); } else { - log.info("Mark exam quiz data back again form LMS: {}", externalQuizId); + log.info("Mark exam quiz data back again from LMS: {}", externalQuizId); } this.examRecordDAO.idByExternalQuizId(externalQuizId) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/impl/ExamTemplateServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/impl/ExamTemplateServiceImpl.java index 535af44d..cd0f88a0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/impl/ExamTemplateServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/exam/impl/ExamTemplateServiceImpl.java @@ -127,7 +127,7 @@ public class ExamTemplateServiceImpl implements ExamTemplateService { if (exam.examTemplateId != null) { if (log.isDebugEnabled()) { - log.debug("Init exam: {} with additional attributes form exam template: {}", + log.debug("Init exam: {} with additional attributes from exam template: {}", exam.externalId, exam.examTemplateId); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPIService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPIService.java index 8ca736fd..285a185e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPIService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPIService.java @@ -60,7 +60,7 @@ public interface LmsAPIService { * @param pageSize the page size * @param sort the sort parameter * @param filterMap the FilterMap containing all filter criteria - * @return the specified Page of QuizData form all active LMS Setups of the current users institution */ + * @return the specified Page of QuizData from all active LMS Setups of the current users institution */ Result> requestQuizDataPage( final int pageNumber, final int pageSize, @@ -139,7 +139,7 @@ public interface LmsAPIService { * @param sortAttribute the sort attribute for the new Page * @param pageNumber the number of the Page to build * @param pageSize the size of the Page to build - * @return A Page of QuizData extracted form a given list of QuizData */ + * @return A Page of QuizData extracted from a given list of QuizData */ static Function, Page> quizzesToPageFunction( final String sortAttribute, final int pageNumber, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java index f6b7d4ee..d739dd40 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/LmsAPITemplate.java @@ -12,7 +12,6 @@ import ch.ethz.seb.sebserver.gbl.async.CircuitBreaker; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.AbstractCachedCourseAccess; -import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.AbstractCourseAccess; /** Defines an LMS API access template to build SEB Server LMS integration. *

diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java index ada09e56..a88786ee 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java @@ -23,7 +23,7 @@ public interface SEBRestrictionAPI { * @return {@link LmsSetupTestResult } instance with the test result report */ LmsSetupTestResult testCourseRestrictionAPI(); - /** Get SEB restriction data form LMS within a {@link SEBRestrictionData } instance. The available restriction + /** Get SEB restriction data from LMS within a {@link SEBRestrictionData } instance. The available restriction * details * depends on the type of LMS but shall at least contains the config-key(s) and the browser-exam-key(s). * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java deleted file mode 100644 index b374eb59..00000000 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/AbstractCourseAccess.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET) - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl; - -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.function.Supplier; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.env.Environment; - -import ch.ethz.seb.sebserver.gbl.Constants; -import ch.ethz.seb.sebserver.gbl.async.AsyncService; -import ch.ethz.seb.sebserver.gbl.async.CircuitBreaker; -import ch.ethz.seb.sebserver.gbl.model.exam.Chapters; -import ch.ethz.seb.sebserver.gbl.model.exam.QuizData; -import ch.ethz.seb.sebserver.gbl.model.user.ExamineeAccountDetails; -import ch.ethz.seb.sebserver.gbl.util.Result; -import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap; - -/** A partial course access API implementation that uses CircuitBreaker to apply LMS - * API requests in a protected environment. - * - * Extend this to implement a concrete course access API for a given type of LMS. */ -public abstract class AbstractCourseAccess { - - private static final Logger log = LoggerFactory.getLogger(AbstractCourseAccess.class); - - /** CircuitBreaker for protected quiz and course data requests */ - protected final CircuitBreaker> allQuizzesRequest; - /** CircuitBreaker for protected quiz and course data requests */ - protected final CircuitBreaker> quizzesRequest; - /** CircuitBreaker for protected quiz and course data requests */ - protected final CircuitBreaker quizRequest; - /** CircuitBreaker for protected chapter data requests */ - protected final CircuitBreaker chaptersRequest; - /** CircuitBreaker for protected examinee account details requests */ - protected final CircuitBreaker accountDetailRequest; - - protected AbstractCourseAccess( - final AsyncService asyncService, - final Environment environment) { - - this.allQuizzesRequest = asyncService.createCircuitBreaker( - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.attempts", - Integer.class, - 3), - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.blockingTime", - Long.class, - Constants.MINUTE_IN_MILLIS), - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.timeToRecover", - Long.class, - Constants.MINUTE_IN_MILLIS)); - - this.quizzesRequest = asyncService.createCircuitBreaker( - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.attempts", - Integer.class, - 3), - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.blockingTime", - Long.class, - Constants.SECOND_IN_MILLIS * 10), - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.timeToRecover", - Long.class, - Constants.MINUTE_IN_MILLIS)); - - this.quizRequest = asyncService.createCircuitBreaker( - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.attempts", - Integer.class, - 3), - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.blockingTime", - Long.class, - Constants.SECOND_IN_MILLIS * 10), - environment.getProperty( - "sebserver.webservice.circuitbreaker.quizzesRequest.timeToRecover", - Long.class, - Constants.MINUTE_IN_MILLIS)); - - this.chaptersRequest = asyncService.createCircuitBreaker( - environment.getProperty( - "sebserver.webservice.circuitbreaker.chaptersRequest.attempts", - Integer.class, - 3), - environment.getProperty( - "sebserver.webservice.circuitbreaker.chaptersRequest.blockingTime", - Long.class, - Constants.SECOND_IN_MILLIS * 10), - environment.getProperty( - "sebserver.webservice.circuitbreaker.chaptersRequest.timeToRecover", - Long.class, - Constants.SECOND_IN_MILLIS * 30)); - - this.accountDetailRequest = asyncService.createCircuitBreaker( - environment.getProperty( - "sebserver.webservice.circuitbreaker.accountDetailRequest.attempts", - Integer.class, - 2), - environment.getProperty( - "sebserver.webservice.circuitbreaker.accountDetailRequest.blockingTime", - Long.class, - Constants.SECOND_IN_MILLIS * 10), - environment.getProperty( - "sebserver.webservice.circuitbreaker.accountDetailRequest.timeToRecover", - Long.class, - Constants.SECOND_IN_MILLIS * 30)); - } - - public Result> protectedQuizzesRequest(final FilterMap filterMap) { - return this.allQuizzesRequest.protectedRun(allQuizzesSupplier(filterMap)) - .onError(error -> log.error( - "Failed to run protectedQuizzesRequest: {}", - error.getMessage())); - } - - public Result> protectedQuizzesRequest(final Set ids) { - return this.quizzesRequest.protectedRun(quizzesSupplier(ids)) - .onError(error -> log.error( - "Failed to run protectedQuizzesRequest: {}", - error.getMessage())); - } - - public Result protectedQuizRequest(final String id) { - return this.quizRequest.protectedRun(quizSupplier(id)) - .onError(error -> log.error( - "Failed to run protectedQuizRequest: {}", - error.getMessage())); - } - - public Result getExamineeAccountDetails(final String examineeSessionId) { - final Supplier accountDetailsSupplier = accountDetailsSupplier(examineeSessionId); - return this.accountDetailRequest.protectedRun(() -> { - try { - return accountDetailsSupplier.get(); - } catch (final Exception e) { - log.error("Unexpected error while trying to get examinee account details: ", e); - throw e; - } - }); - } - - /** Default implementation that uses getExamineeAccountDetails to geht the examinee name - * - * @param examineeSessionId - * @return The examinee account name for the given examineeSessionId */ - public String getExamineeName(final String examineeSessionId) { - return getExamineeAccountDetails(examineeSessionId) - .map(ExamineeAccountDetails::getDisplayName) - .onError(error -> log.warn("Failed to request user-name for ID: {}", error.getMessage(), error)) - .getOr(examineeSessionId); - } - - public Result getCourseChapters(final String courseId) { - return this.chaptersRequest.protectedRun(getCourseChaptersSupplier(courseId)) - .onError(error -> log.error( - "Failed to run getCourseChapters: {}", - error.getMessage())); - } - - protected abstract Supplier accountDetailsSupplier(final String examineeSessionId); - - /** Provides a supplier to supply request to use within the circuit breaker */ - protected abstract Supplier> allQuizzesSupplier(final FilterMap filterMap); - - /** Provides a supplier for the quiz data request to use within the circuit breaker */ - protected abstract Supplier> quizzesSupplier(final Set ids); - - /** Provides a supplier for the quiz data request to use within the circuit breaker */ - protected abstract Supplier quizSupplier(final String id); - - /** Provides a supplier for the course chapter data request to use within the circuit breaker */ - protected abstract Supplier getCourseChaptersSupplier(final String courseId); - -} diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java index 6b72916f..e028ef35 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java @@ -151,7 +151,7 @@ public class ExamSessionControlTask implements DisposableBean { private void controlExamLMSUpdate() { if (log.isTraceEnabled()) { - log.trace("Start update exams form LMS"); + log.trace("Start update exams from LMS"); } try { 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 e3730943..83f1b9ba 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 @@ -91,7 +91,7 @@ class ExamUpdateHandler { .getLmsAPITemplate(lmsSetupId) .flatMap(template -> template.getQuizzes(new HashSet<>(exams.keySet()))) .onError(error -> log.warn( - "Failed to get quizzes form LMS Setup: {} cause: {}", + "Failed to get quizzes from LMS Setup: {} cause: {}", lmsSetupId, error.getMessage())) .getOr(Collections.emptyList())