From f53243e0016a93b4662a4dee345d1b524de7bc53 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 6 Jun 2019 10:43:04 +0200 Subject: [PATCH] fix bugs --- findbugs-excludes.xml | 2 +- .../seb/sebserver/gbl/model/user/UserMod.java | 4 ++-- .../examconfig/impl/PassworFieldBuilder.java | 3 +-- .../AuthorizationServiceImpl.java | 2 ++ .../dao/impl/ConfigurationDAOImpl.java | 20 +++++++++---------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/findbugs-excludes.xml b/findbugs-excludes.xml index 5a42f5e0..f6a7fde0 100644 --- a/findbugs-excludes.xml +++ b/findbugs-excludes.xml @@ -13,7 +13,7 @@ - + diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserMod.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserMod.java index 77e1b7dd..c35896d7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserMod.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/user/UserMod.java @@ -79,11 +79,11 @@ public final class UserMod implements UserAccount { public final Set roles; @NotNull(message = "user:newPassword:notNull") - @Size(min = 8, max = 255, message = "user:password:size:{min}:{max}:${validatedValue}") + @Size(min = 8, max = 255, message = "user:newPassword:size:{min}:{max}:${validatedValue}") @JsonProperty(PasswordChange.ATTR_NAME_NEW_PASSWORD) private final String newPassword; - @NotNull(message = "user:retypedNewPassword:notNull") + @NotNull(message = "user:confirmNewPassword:notNull") @JsonProperty(PasswordChange.ATTR_NAME_CONFIRM_NEW_PASSWORD) private final String confirmNewPassword; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PassworFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PassworFieldBuilder.java index 8d84850e..d069b5f7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PassworFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PassworFieldBuilder.java @@ -81,12 +81,12 @@ public class PassworFieldBuilder implements InputFieldBuilder { InputFieldBuilder.createErrorLabel(innerGrid)); final Listener valueChangeEventListener = event -> { + passwordInputField.clearError(); final String pwd = passwordInput.getText(); final String confirm = confirmInput.getText(); if (passwordInputField.initValue != null && passwordInputField.initValue.equals(pwd)) { - System.out.println("*********************************** ignore Password set"); return; } @@ -103,7 +103,6 @@ public class PassworFieldBuilder implements InputFieldBuilder { final String hashedPWD = passwordInputField.getValue(); if (hashedPWD != null) { - passwordInputField.clearError(); viewContext.getValueChangeListener().valueChanged( viewContext, attribute, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/AuthorizationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/AuthorizationServiceImpl.java index 014e5bdc..a04957d7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/AuthorizationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/AuthorizationServiceImpl.java @@ -83,6 +83,8 @@ public class AuthorizationServiceImpl implements AuthorizationService { .withBasePrivilege(PrivilegeType.WRITE) .andForRole(UserRole.INSTITUTIONAL_ADMIN) .withInstitutionalPrivilege(PrivilegeType.WRITE) + .andForRole(UserRole.EXAM_ADMIN) + .withInstitutionalPrivilege(PrivilegeType.WRITE) .create(); // grants for lms setup diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ConfigurationDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ConfigurationDAOImpl.java index 5680e627..19893822 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ConfigurationDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ConfigurationDAOImpl.java @@ -294,6 +294,15 @@ public class ConfigurationDAOImpl implements ConfigurationDAO { // get follow-up configuration id final ConfigurationRecord followup = getFollowupConfigurationRecord(configurationNodeId); + // delete all values of the follow-up + this.configurationValueRecordMapper + .deleteByExample() + .where( + ConfigurationValueRecordDynamicSqlSupport.configurationId, + isEqualTo(followup.getId())) + .build() + .execute(); + // restore all current values of the follow-up with historic values // TODO batch here for better performance historicValues.stream() @@ -304,16 +313,7 @@ public class ConfigurationDAOImpl implements ConfigurationDAO { historicValRec.getConfigurationAttributeId(), historicValRec.getListIndex(), historicValRec.getValue())) - .forEach(newValRec -> this.configurationValueRecordMapper - .updateByExample(newValRec) - .where( - ConfigurationValueRecordDynamicSqlSupport.configurationId, - isEqualTo(followup.getId())) - .and( - ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId, - isEqualTo(newValRec.getConfigurationAttributeId())) - .build() - .execute()); + .forEach(newValRec -> this.configurationValueRecordMapper.insert(newValRec)); return followup; })