SEBSERV-287 some fixes with privileges and unique indicator name

This commit is contained in:
anhefti 2022-04-28 12:41:51 +02:00
parent 0dfde290ca
commit 8b9eebfe5b
4 changed files with 13 additions and 12 deletions

View file

@ -45,7 +45,6 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetIndicator
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.NewExamTemplate; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.NewExamTemplate;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveExamTemplate; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveExamTemplate;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.EntityGrantCheck;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck;
import ch.ethz.seb.sebserver.gui.table.ColumnDefinition; import ch.ethz.seb.sebserver.gui.table.ColumnDefinition;
import ch.ethz.seb.sebserver.gui.table.EntityTable; import ch.ethz.seb.sebserver.gui.table.EntityTable;
@ -192,7 +191,7 @@ public class ExamTemplateForm implements TemplateComposer {
? this.restService.getRestCall(NewExamTemplate.class) ? this.restService.getRestCall(NewExamTemplate.class)
: this.restService.getRestCall(SaveExamTemplate.class)); : this.restService.getRestCall(SaveExamTemplate.class));
final boolean proctoringEnabled = this.restService final boolean proctoringEnabled = !isNew && this.restService
.getBuilder(GetExamTemplateProctoringSettings.class) .getBuilder(GetExamTemplateProctoringSettings.class)
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
.call() .call()
@ -200,8 +199,8 @@ public class ExamTemplateForm implements TemplateComposer {
.getOr(false); .getOr(false);
final GrantCheck userGrant = currentUser.grantCheck(EntityType.EXAM_TEMPLATE); final GrantCheck userGrant = currentUser.grantCheck(EntityType.EXAM_TEMPLATE);
final EntityGrantCheck userGrantCheck = currentUser.entityGrantCheck(examTemplate); // final EntityGrantCheck userGrantCheck = currentUser.entityGrantCheck(examTemplate);
final boolean modifyGrant = userGrantCheck.m(); // final boolean modifyGrant = userGrantCheck.m();
// propagate content actions to action-pane // propagate content actions to action-pane
this.pageService.pageActionBuilder(formContext.clearEntityKeys()) this.pageService.pageActionBuilder(formContext.clearEntityKeys())
@ -228,13 +227,13 @@ public class ExamTemplateForm implements TemplateComposer {
.newAction(ActionDefinition.EXAM_TEMPLATE_PROCTORING_ON) .newAction(ActionDefinition.EXAM_TEMPLATE_PROCTORING_ON)
.withEntityKey(entityKey) .withEntityKey(entityKey)
.withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant)) .withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, userGrant.im()))
.noEventPropagation() .noEventPropagation()
.publishIf(() -> proctoringEnabled && readonly) .publishIf(() -> proctoringEnabled && readonly)
.newAction(ActionDefinition.EXAM_TEMPLATE_PROCTORING_OFF) .newAction(ActionDefinition.EXAM_TEMPLATE_PROCTORING_OFF)
.withEntityKey(entityKey) .withEntityKey(entityKey)
.withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant)) .withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, userGrant.im()))
.noEventPropagation() .noEventPropagation()
.publishIf(() -> !proctoringEnabled && readonly); .publishIf(() -> !proctoringEnabled && readonly);

View file

@ -129,7 +129,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
.forRole(UserRole.SEB_SERVER_ADMIN) .forRole(UserRole.SEB_SERVER_ADMIN)
.withBasePrivilege(PrivilegeType.READ) .withBasePrivilege(PrivilegeType.READ)
.andForRole(UserRole.INSTITUTIONAL_ADMIN) .andForRole(UserRole.INSTITUTIONAL_ADMIN)
.withInstitutionalPrivilege(PrivilegeType.READ) .withInstitutionalPrivilege(PrivilegeType.WRITE)
.andForRole(UserRole.EXAM_ADMIN) .andForRole(UserRole.EXAM_ADMIN)
.withInstitutionalPrivilege(PrivilegeType.WRITE) .withInstitutionalPrivilege(PrivilegeType.WRITE)
.create(); .create();

View file

@ -69,8 +69,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle.legacy.Mood
@WebServiceProfile @WebServiceProfile
public class ExamDAOImpl implements ExamDAO { public class ExamDAOImpl implements ExamDAO {
//public static final String FAILED_TO_LOAD_QUIZ_DATA_MARK = "[FAILED TO LOAD DATA FROM LMS]";
private final ExamRecordMapper examRecordMapper; private final ExamRecordMapper examRecordMapper;
private final ExamRecordDAO examRecordDAO; private final ExamRecordDAO examRecordDAO;
private final ApplicationEventPublisher applicationEventPublisher; private final ApplicationEventPublisher applicationEventPublisher;
@ -979,7 +977,9 @@ public class ExamDAOImpl implements ExamDAO {
.collect(Utils.toSingleton()) .collect(Utils.toSingleton())
.getValue(); .getValue();
} catch (final Exception e) { } catch (final Exception e) {
log.error("Failed to get former name: examId: {} error: {}", id, e.getMessage()); if (log.isDebugEnabled()) {
log.warn("Failed to get former name: examId: {} error: {}", id, e.getMessage());
}
return null; return null;
} }
} }

View file

@ -534,11 +534,13 @@ public class ExamTemplateDAOImpl implements ExamTemplateDAO {
} }
} }
private void checkUniqueIndicatorName(final IndicatorTemplate indicatorTemplate, private void checkUniqueIndicatorName(
final IndicatorTemplate indicatorTemplate,
final Collection<IndicatorTemplate> indicators) { final Collection<IndicatorTemplate> indicators) {
// check unique name // check unique name
indicators.stream() indicators.stream()
.filter(it -> Objects.equals(it.name, indicatorTemplate.name)) .filter(it -> !Objects.equals(it, indicatorTemplate) && Objects.equals(it.name, indicatorTemplate.name))
.findAny() .findAny()
.ifPresent(it -> { .ifPresent(it -> {
throw new FieldValidationException( throw new FieldValidationException(