From 4c40af35845c859503b94bb5ef201e88496708d6 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 5 May 2020 08:54:57 +0200 Subject: [PATCH 1/8] removed quit password from exam. Not used yet --- .../ch/ethz/seb/sebserver/gbl/model/exam/Exam.java | 14 -------------- .../servicelayer/dao/impl/ExamDAOImpl.java | 4 +--- .../lms/impl/SebRestrictionServiceImpl.java | 2 +- .../gui/integration/UseCasesIntegrationTest.java | 2 +- .../integration/api/admin/ExamAPITest.java | 2 -- 5 files changed, 3 insertions(+), 21 deletions(-) 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 8361ce45..a5881ee4 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 @@ -46,7 +46,6 @@ public final class Exam implements GrantEntity { ExamType.UNDEFINED, null, null, - null, ExamStatus.FINISHED, // Boolean.FALSE, null, @@ -104,9 +103,6 @@ public final class Exam implements GrantEntity { @NotNull public final ExamType type; - @JsonProperty(EXAM.ATTR_QUIT_PASSWORD) - public final String quitPassword; - @JsonProperty(EXAM.ATTR_OWNER) public final String owner; @@ -138,7 +134,6 @@ public final class Exam implements GrantEntity { @JsonProperty(QuizData.QUIZ_ATTR_END_TIME) final DateTime endTime, @JsonProperty(QuizData.QUIZ_ATTR_START_URL) final String startURL, @JsonProperty(EXAM.ATTR_TYPE) final ExamType type, - @JsonProperty(EXAM.ATTR_QUIT_PASSWORD) final String quitPassword, @JsonProperty(EXAM.ATTR_OWNER) final String owner, @JsonProperty(EXAM.ATTR_SUPPORTER) final Collection supporter, @JsonProperty(EXAM.ATTR_STATUS) final ExamStatus status, @@ -156,7 +151,6 @@ public final class Exam implements GrantEntity { this.endTime = endTime; this.startURL = startURL; this.type = type; - this.quitPassword = quitPassword; this.owner = owner; this.status = (status != null) ? status : getStatusFromDate(startTime, endTime); this.browserExamKeys = browserExamKeys; @@ -180,7 +174,6 @@ public final class Exam implements GrantEntity { this.endTime = quizData.endTime; this.startURL = quizData.startURL; this.type = mapper.getEnum(EXAM.ATTR_TYPE, ExamType.class, ExamType.UNDEFINED); - this.quitPassword = mapper.getString(EXAM.ATTR_QUIT_PASSWORD); this.owner = mapper.getString(EXAM.ATTR_OWNER); this.status = mapper.getEnum( EXAM.ATTR_STATUS, @@ -208,7 +201,6 @@ public final class Exam implements GrantEntity { this.endTime = null; this.startURL = null; this.type = null; - this.quitPassword = null; this.owner = null; this.status = (status != null) ? status : getStatusFromDate(this.startTime, this.endTime); this.browserExamKeys = null; @@ -300,10 +292,6 @@ public final class Exam implements GrantEntity { return this.startURL; } - public String getQuitPassword() { - return this.quitPassword; - } - public ExamStatus getStatus() { return this.status; } @@ -339,8 +327,6 @@ public final class Exam implements GrantEntity { builder.append(this.startURL); builder.append(", type="); builder.append(this.type); - builder.append(", quitPassword="); - builder.append(this.quitPassword); builder.append(", owner="); builder.append(this.owner); builder.append(", supporter="); 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 40275d18..3194a66d 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 @@ -224,7 +224,7 @@ public class ExamDAOImpl implements ExamDAO { (exam.type != null) ? exam.type.name() : null, - exam.quitPassword, + null, exam.browserExamKeys, (exam.status != null) ? exam.status.name() @@ -769,11 +769,9 @@ public class ExamDAOImpl implements ExamDAO { (quizData != null) ? quizData.endTime : null, (quizData != null) ? quizData.startURL : Constants.EMPTY_NOTE, ExamType.valueOf(record.getType()), - record.getQuitPassword(), record.getOwner(), supporter, status, -// BooleanUtils.toBooleanObject((quizData != null) ? record.getLmsSebRestriction() : null), record.getBrowserKeys(), BooleanUtils.toBooleanObject((quizData != null) ? record.getActive() : null), record.getLastupdate()); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java index 3823c9a4..d312092c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SebRestrictionServiceImpl.java @@ -131,7 +131,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService { final Collection browserExamKeys = sebRestriction.getBrowserExamKeys(); final Exam newExam = new Exam( exam.id, - null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, exam.supporter, exam.status, (browserExamKeys != null && !browserExamKeys.isEmpty()) diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index 6bbbd703..da4bcfbe 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -806,7 +806,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { newExam.endTime, newExam.startURL, ExamType.MANAGED, - null, null, + null, Utils.immutableCollectionOf(userId), ExamStatus.RUNNING, null, diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java index bbad5db8..0c84221c 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/ExamAPITest.java @@ -61,7 +61,6 @@ public class ExamAPITest extends AdministrationAPIIntegrationTester { exam.endTime, exam.startURL, exam.type, - exam.quitPassword, exam.owner, Arrays.asList("user5"), null, @@ -92,7 +91,6 @@ public class ExamAPITest extends AdministrationAPIIntegrationTester { exam.endTime, exam.startURL, exam.type, - exam.quitPassword, exam.owner, Arrays.asList("user2"), null, From bc490612cf5c2592c9281bde9a97488e0486061a Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 5 May 2020 13:33:13 +0200 Subject: [PATCH 2/8] fixed equals --- .../sebserver/gui/service/session/ClientConnectionTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java index 98ee362e..9c305b40 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java @@ -554,7 +554,7 @@ public final class ClientConnectionTable { if (getClass() != obj.getClass()) return false; final UpdatableTableItem other = (UpdatableTableItem) obj; - if (!getOuterType().equals(other.getOuterType())) + if (getOuterType() != other.getOuterType()) return false; return compareTo(other) == 0; } From 4f34898e79cfa1471dc4f4088b6b38b513d6b153 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 5 May 2020 13:36:06 +0200 Subject: [PATCH 3/8] SEBSERV-123 fixed validation --- .../ethz/seb/sebserver/gbl/model/institution/Institution.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java index 1383a377..2338b5ae 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java @@ -36,7 +36,7 @@ public final class Institution implements GrantEntity, Activatable { public final String name; @JsonProperty(INSTITUTION.ATTR_URL_SUFFIX) - @Pattern(regexp = "(^$|.{3,255})", message = "institution:urlSuffix:size:3:255:${validatedValue}") + @Pattern(regexp = "(^$|.{3,45})", message = "institution:urlSuffix:size:3:255:${validatedValue}") public final String urlSuffix; @JsonProperty(INSTITUTION.ATTR_LOGO_IMAGE) From 7fe3e5f6db4ee9287c7fdeae56ccc3aa34ea7b63 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 5 May 2020 15:40:19 +0200 Subject: [PATCH 4/8] SEBSERV-127 fix --- .../gui/content/MonitoringRunningExam.java | 10 +-- .../gui/content/action/ActionPane.java | 65 ++++++++++--------- .../remote/webservice/api/RestCall.java | 4 +- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java index 2f0ac924..11f4775b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java @@ -137,11 +137,11 @@ public class MonitoringRunningExam implements TemplateComposer { clientTable .withDefaultAction( - actionBuilder - .newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION) - .withParentEntityKey(entityKey) - .create(), - this.pageService) + actionBuilder + .newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION) + .withParentEntityKey(entityKey) + .create(), + this.pageService) .withSelectionListener(this.pageService.getSelectionPublisher( pageContext, ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java index 40cf50e5..39edd4e3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java @@ -8,17 +8,10 @@ package ch.ethz.seb.sebserver.gui.content.action; -import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey; -import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService; -import ch.ethz.seb.sebserver.gui.service.page.PageContext; -import ch.ethz.seb.sebserver.gui.service.page.PageService; -import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer; -import ch.ethz.seb.sebserver.gui.service.page.event.ActionActivationEventListener; -import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEventListener; -import ch.ethz.seb.sebserver.gui.service.page.event.PageEventListener; -import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction; -import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; -import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.template.ImageCell; @@ -38,9 +31,17 @@ import org.eclipse.swt.widgets.TreeItem; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey; +import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService; +import ch.ethz.seb.sebserver.gui.service.page.PageContext; +import ch.ethz.seb.sebserver.gui.service.page.PageService; +import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer; +import ch.ethz.seb.sebserver.gui.service.page.event.ActionActivationEventListener; +import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEventListener; +import ch.ethz.seb.sebserver.gui.service.page.event.PageEventListener; +import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction; +import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; +import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant; @Lazy @Component @@ -52,8 +53,6 @@ public class ActionPane implements TemplateComposer { private final PageService pageService; private final WidgetFactory widgetFactory; - private final Map actionTrees = new HashMap<>(); - protected ActionPane(final PageService pageService) { this.pageService = pageService; this.widgetFactory = pageService.getWidgetFactory(); @@ -61,7 +60,7 @@ public class ActionPane implements TemplateComposer { @Override public void compose(final PageContext pageContext) { - + final Map actionTrees = new HashMap<>(); final Label label = this.widgetFactory.labelLocalized( pageContext.getParent(), CustomVariant.TEXT_H2, @@ -79,7 +78,7 @@ public class ActionPane implements TemplateComposer { PageEventListener.LISTENER_ATTRIBUTE_KEY, (ActionPublishEventListener) event -> { final Composite parent = pageContext.getParent(); - final Tree treeForGroup = getTreeForGroup(parent, event.action.definition, true); + final Tree treeForGroup = getTreeForGroup(actionTrees, parent, event.action.definition, true); final TreeItem actionItem = ActionPane.this.widgetFactory.treeItemLocalized( treeForGroup, event.action.definition.title); @@ -110,7 +109,7 @@ public class ActionPane implements TemplateComposer { (ActionActivationEventListener) event -> { final Composite parent = pageContext.getParent(); for (final ActionDefinition ad : event.actions) { - final TreeItem actionItem = findAction(parent, ad); + final TreeItem actionItem = findAction(actionTrees, parent, ad); if (actionItem == null) { continue; } @@ -128,7 +127,7 @@ public class ActionPane implements TemplateComposer { } if (event.decoration != null) { - final TreeItem actionItemToDecorate = findAction(parent, event.decoration._1); + final TreeItem actionItemToDecorate = findAction(actionTrees, parent, event.decoration._1); if (actionItemToDecorate != null && event.decoration._2 != null) { actionItemToDecorate.setImage(0, event.decoration._2.icon.getImage(parent.getDisplay())); @@ -140,8 +139,11 @@ public class ActionPane implements TemplateComposer { }); } - private TreeItem findAction(final Composite parent, final ActionDefinition actionDefinition) { - final Tree treeForGroup = getTreeForGroup(parent, actionDefinition, false); + private TreeItem findAction( + final Map actionTrees, + final Composite parent, + final ActionDefinition actionDefinition) { + final Tree treeForGroup = getTreeForGroup(actionTrees, parent, actionDefinition, false); if (treeForGroup == null) { return null; } @@ -166,19 +168,20 @@ public class ActionPane implements TemplateComposer { } private Tree getTreeForGroup( + final Map actionTrees, final Composite parent, final ActionDefinition actionDefinition, - boolean create) { + final boolean create) { - clearDisposedTrees(); + clearDisposedTrees(actionTrees); final ActionCategory category = actionDefinition.category; - if (!this.actionTrees.containsKey(category.name()) && create) { + if (!actionTrees.containsKey(category.name()) && create) { final Tree actionTree = createActionTree(parent, actionDefinition.category); - this.actionTrees.put(category.name(), actionTree); + actionTrees.put(category.name(), actionTree); } - return this.actionTrees.get(category.name()); + return actionTrees.get(category.name()); } private Tree createActionTree(final Composite parent, final ActionCategory category) { @@ -257,19 +260,19 @@ public class ActionPane implements TemplateComposer { return actions; } - private void clearDisposedTrees() { - new ArrayList<>(this.actionTrees.entrySet()) + private void clearDisposedTrees(final Map actionTrees) { + new ArrayList<>(actionTrees.entrySet()) .forEach(entry -> { final Control c = entry.getValue(); // of tree is already disposed.. remove it if (c.isDisposed()) { - this.actionTrees.remove(entry.getKey()); + actionTrees.remove(entry.getKey()); } // check access from current thread try { c.getBounds(); } catch (final Exception e) { - this.actionTrees.remove(entry.getKey()); + actionTrees.remove(entry.getKey()); } }); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java index 12a896da..4940fb07 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java @@ -191,8 +191,8 @@ public abstract class RestCall { } log.debug( - "Webservice answered with well defined error- or validation-failure-response: ", - restCallError); + "Webservice answered with well defined error- or validation-failure-response: {}", + restCallError.toString()); return Result.ofError(restCallError); } From 29c09adff98ff8d4a74f2f460a84de8ec6cd2b70 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 5 May 2020 16:26:07 +0200 Subject: [PATCH 5/8] Fixed monitoring update bug --- .../sebserver/gui/content/MonitoringRunningExam.java | 2 ++ .../gui/service/session/ClientConnectionTable.java | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java index 11f4775b..9eb2419d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/MonitoringRunningExam.java @@ -324,6 +324,7 @@ public class MonitoringRunningExam implements TemplateComposer { action.pageContext()); clientTable.removeSelection(); + clientTable.forceUpdateAll(); return action; } @@ -340,6 +341,7 @@ public class MonitoringRunningExam implements TemplateComposer { action.pageContext()); clientTable.removeSelection(); + clientTable.forceUpdateAll(); return action; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java index 9c305b40..90536b3c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java @@ -106,6 +106,8 @@ public final class ClientConnectionTable { private final Color darkFontColor; private final Color lightFontColor; + private boolean forceUpdateAll = false; + public ClientConnectionTable( final PageService pageService, final Composite tableRoot, @@ -289,13 +291,17 @@ public final class ClientConnectionTable { updatableTableItem.connectionData.clientConnection.connectionToken); } + public void forceUpdateAll() { + this.forceUpdateAll = true; + } + public void updateValues() { if (this.statusFilterChanged) { this.toDelete.clear(); this.toDelete.addAll(this.tableMapping.keySet()); } this.restCallBuilder - .withHeader(API.EXAM_MONITORING_STATE_FILTER, this.statusFilterParam) + .withHeader(API.EXAM_MONITORING_STATE_FILTER, (this.forceUpdateAll) ? "" : this.statusFilterParam) .call() .get(error -> { log.error("Error poll connection data: ", error); @@ -321,6 +327,8 @@ public final class ClientConnectionTable { }); this.statusFilterChanged = false; } + + this.forceUpdateAll = false; } public void updateGUI() { From bebb4094b6c6775b478f37d1e4f8e5c38afc57c8 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 6 May 2020 11:19:11 +0200 Subject: [PATCH 6/8] SEBSERV-125 fix --- .../sebserver/webservice/WebserviceConfig.java | 8 +++++++- .../servicelayer/PaginationService.java | 10 +++++++++- .../dao/impl/UserActivityLogDAOImpl.java | 15 +++++---------- .../config/application-dev-ws.properties | 4 +++- src/main/resources/config/application.properties | 1 + 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceConfig.java b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceConfig.java index 7952243e..febe709a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceConfig.java @@ -11,6 +11,7 @@ package ch.ethz.seb.sebserver.webservice; import org.cryptonode.jncryptor.AES256JNCryptor; import org.cryptonode.jncryptor.JNCryptor; import org.flywaydb.core.Flyway; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -24,6 +25,9 @@ import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; @WebServiceProfile public class WebserviceConfig { + @Value("${sebserver.webservice.clean-db-on-startup:false}") + boolean cleanDBOnStartup; + @Lazy @Bean public JNCryptor jnCryptor() { @@ -42,7 +46,9 @@ public class WebserviceConfig { final FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() { @Override public void migrate(final Flyway flyway) { - flyway.clean(); + if (WebserviceConfig.this.cleanDBOnStartup) { + flyway.clean(); + } flyway.migrate(); } }; 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 6bad52a1..8799ab75 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 @@ -53,7 +53,15 @@ public interface PaginationService { /** Get a Page of specified domain models from given pagination attributes within collection supplier delegate. * - * + * NOTE: Paging always depends on SQL level. It depends on the collection given by the SQL select statement + * that is executed within MyBatis by using the MyBatis page service. + * Be aware that if the delegate that is given here applies an additional filter to the filtering done + * on SQL level, this will lead to paging with not fully filled pages or even to empty pages if the filter + * filters a lot of the entries given by the SQL statement away. + * So we recommend to apply as much of the filtering as possible on the SQL level and only if necessary and + * not avoidable, apply a additional filter on software-level that eventually filter one or two entities + * for a page. + * * @param pageNumber the current page number * @param pageSize the (full) size of the page * @param sort the name of the sort column with a leading '-' for descending sort order diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java index 98d586c9..48ca1015 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java @@ -294,7 +294,7 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO { return all( filterMap.getInstitutionId(), - filterMap.getString(UserActivityLog.FILTER_ATTR_USER_NAME), + filterMap.getSQLWildcard(UserActivityLog.FILTER_ATTR_USER_NAME), filterMap.getUserLogFrom(), filterMap.getUserLofTo(), filterMap.getString(UserActivityLog.FILTER_ATTR_ACTIVITY_TYPES), @@ -321,14 +321,6 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO { ? Arrays.asList(StringUtils.split(entityTypes, Constants.LIST_SEPARATOR)) : null; - Predicate _predicate = (predicate != null) - ? predicate - : model -> true; - - if (StringUtils.isNotBlank(userName)) { - _predicate = _predicate.and(model -> model.getUsername().contains(userName)); - } - final List records = this.userLogRecordMapper .selectByExample() .leftJoin(UserRecordDynamicSqlSupport.userRecord) @@ -338,6 +330,9 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO { .where( UserRecordDynamicSqlSupport.institutionId, SqlBuilder.isEqualToWhenPresent(institutionId)) + .and( + UserRecordDynamicSqlSupport.username, + SqlBuilder.isLikeWhenPresent(userName)) .and( UserActivityLogRecordDynamicSqlSupport.timestamp, SqlBuilder.isGreaterThanOrEqualToWhenPresent(from)) @@ -355,7 +350,7 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO { return this.toDomainModel(institutionId, records) .stream() - .filter(_predicate) + .filter(predicate) .collect(Collectors.toList()); }); } diff --git a/src/main/resources/config/application-dev-ws.properties b/src/main/resources/config/application-dev-ws.properties index 5ec2c44f..5f63b1b0 100644 --- a/src/main/resources/config/application-dev-ws.properties +++ b/src/main/resources/config/application-dev-ws.properties @@ -10,7 +10,7 @@ spring.datasource.url=jdbc:mariadb://localhost:3306/SEBServer?createDatabaseIfNo spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.flyway.enabled=true spring.flyway.locations=classpath:config/sql/base,classpath:config/sql/dev -spring.flyway.baselineOnMigrate=true +spring.flyway.cleanDisabled=false spring.datasource.hikari.initializationFailTimeout=30000 spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.idleTimeout=600000 @@ -20,6 +20,8 @@ sebserver.http.client.connect-timeout=15000 sebserver.http.client.connection-request-timeout=10000 sebserver.http.client.read-timeout=20000 +sebserver.webservice.clean-db-on-startup=false + # webservice configuration sebserver.init.adminaccount.gen-on-init=false sebserver.webservice.distributed=false diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index abc6595c..54584a1c 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -72,6 +72,7 @@ spring.datasource.initialization-mode=always spring.datasource.url=jdbc:mariadb://${datastore.mariadb.server.address}:${datastore.mariadb.server.port}/SEBServer?useSSL=false&createDatabaseIfNotExist=true spring.flyway.enabled=true spring.flyway.locations=classpath:config/sql/base +spring.flyway.cleanDisabled=true spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.datasource.hikari.initializationFailTimeout=3000 spring.datasource.hikari.connectionTimeout=30000 From dbb4689d6a8ebce210cbf37434cafe7c26aa99e4 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 6 May 2020 11:57:41 +0200 Subject: [PATCH 7/8] SEBSERV-123 fix --- .../ethz/seb/sebserver/gbl/model/institution/Institution.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java index 2338b5ae..da2f73ce 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java @@ -36,7 +36,7 @@ public final class Institution implements GrantEntity, Activatable { public final String name; @JsonProperty(INSTITUTION.ATTR_URL_SUFFIX) - @Pattern(regexp = "(^$|.{3,45})", message = "institution:urlSuffix:size:3:255:${validatedValue}") + @Pattern(regexp = "(^$|.{3,45})", message = "institution:urlSuffix:size:3:45:${validatedValue}") public final String urlSuffix; @JsonProperty(INSTITUTION.ATTR_LOGO_IMAGE) From a65c4356b89e497edf190eea17c995cc2044f968 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 6 May 2020 12:08:40 +0200 Subject: [PATCH 8/8] SEBSERV-126 fix --- .../java/ch/ethz/seb/sebserver/gui/content/LmsSetupList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupList.java index ea8e2221..781759e5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupList.java @@ -186,7 +186,7 @@ public class LmsSetupList implements TemplateComposer { action -> LmsSetupForm.testLmsSetup(action, null, restService)), EMPTY_SELECTION_TEXT_KEY) .withConfirm(this.pageService.confirmDeactivation(table)) - .publishIf(() -> userGrant.im() && table.hasAnyContent(), false); + .publishIf(() -> userGrant.iw() && table.hasAnyContent(), false); }