Merge remote-tracking branch 'origin/dev-1.2' into development

Conflicts:
	src/main/java/ch/ethz/seb/sebserver/gui/content/ExamDeletePopup.java
	src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java
	src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/EntityController.java
This commit is contained in:
anhefti 2021-09-22 17:07:24 +02:00
commit 6fc54e5310
7 changed files with 57 additions and 12 deletions

View file

@ -26,16 +26,20 @@ import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.api.API.BulkActionType;
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage;
import ch.ethz.seb.sebserver.gbl.model.EntityDependency;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gbl.util.Utils;
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
import ch.ethz.seb.sebserver.gui.service.page.PageService;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent;
import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputWizard;
@ -43,6 +47,7 @@ import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputWizard.WizardAction
import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputWizard.WizardPage;
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteExam;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExam;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamDependencies;
@ -76,6 +81,8 @@ public class ExamDeletePopup {
private final static LocTextKey DELETE_CONFIRM_TITLE =
new LocTextKey("sebserver.exam.delete.confirm.title");
private final static LocTextKey DELETE_ERROR_CONSISTENCY =
new LocTextKey("sebserver.exam.action.delete.consistency.error");
private final PageService pageService;
@ -126,7 +133,23 @@ public class ExamDeletePopup {
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
.withQueryParam(API.PARAM_BULK_ACTION_TYPE, BulkActionType.HARD_DELETE.name());
final EntityProcessingReport report = restCallBuilder.call().getOrThrow();
final Result<EntityProcessingReport> deleteCall = restCallBuilder.call();
if (deleteCall.hasError()) {
final Exception error = deleteCall.getError();
if (error instanceof RestCallError) {
final APIMessage message = ((RestCallError) error)
.getAPIMessages()
.stream()
.findFirst()
.orElse(null);
if (message != null && ErrorMessage.INTEGRITY_VALIDATION.isOf(message)) {
pageContext.publishPageMessage(new PageMessageException(DELETE_ERROR_CONSISTENCY));
return false;
}
}
}
final EntityProcessingReport report = deleteCall.getOrThrow();
final PageAction action = this.pageService.pageActionBuilder(pageContext)
.newAction(ActionDefinition.EXAM_VIEW_LIST)

View file

@ -293,8 +293,13 @@ public final class ClientConnectionTable {
final Set<EntityKey> result = new HashSet<>();
for (int i = 0; i < selectionIndices.length; i++) {
final UpdatableTableItem updatableTableItem =
new ArrayList<>(this.tableMapping.values()).get(selectionIndices[0]);
result.add(new EntityKey(updatableTableItem.connectionId, EntityType.CLIENT_CONNECTION));
new ArrayList<>(this.tableMapping.values())
.stream()
.findFirst()
.orElse(null);
if (updatableTableItem != null) {
result.add(new EntityKey(updatableTableItem.connectionId, EntityType.CLIENT_CONNECTION));
}
}
return result;
}

View file

@ -166,8 +166,8 @@ public class BulkActionServiceImpl implements BulkActionService {
final Exception error = bulkActionSingleResult.getError();
log.error(
"Unexpected error on bulk action processing. This error is reported to the caller: {}",
error.getMessage());
"Unexpected error on bulk action processing. This error is reported to the caller: ",
error);
if (error instanceof BulkActionEntityException) {
return new ErrorEntry(

View file

@ -673,10 +673,15 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
final Long examId) {
if (StringUtils.isNotBlank(userSessionId)) {
if (StringUtils.isNoneBlank(clientConnection.userSessionId)) {
log.warn(
"ClientConnection integrity violation: clientConnection has already a userSessionId: {} : {}",
userSessionId, clientConnection);
if (StringUtils.isNoneBlank(clientConnection.userSessionId)
&& clientConnection.userSessionId.contains(userSessionId)) {
if (log.isDebugEnabled()) {
log.debug("SEB sent LMS userSessionId but clientConnection has already a userSessionId");
}
return clientConnection;
}
// try to get user account display name

View file

@ -376,9 +376,15 @@ public abstract class EntityController<T extends Entity, M extends Entity> {
}
final EntityType entityType = this.entityDAO.entityType();
final Collection<EntityKey> sources = ids
.stream()
.map(this::logDelete)
final Collection<EntityKey> sources = ids.stream()
.map(id -> {
return this.entityDAO.byModelId(id)
.flatMap(exam -> this.validForDelete(exam))
.getOr(null);
})
.filter(Objects::nonNull)
.map(exam -> exam.getModelId())
.map(id -> new EntityKey(id, entityType))
.collect(Collectors.toList());

View file

@ -500,6 +500,11 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
}
}
@Override
protected Result<Exam> validForDelete(final Exam entity) {
return checkNoActiveSEBClientConnections(entity);
}
private Exam checkExamSupporterRole(final Exam exam) {
final Set<String> examSupporter = this.userDAO.all(
this.authorization.getUserService().getCurrentUser().getUserInfo().institutionId,

View file

@ -457,6 +457,7 @@ sebserver.exam.action.save=Save Exam
sebserver.exam.action.activate=Activate Exam
sebserver.exam.action.deactivate=Deactivate Exam
sebserver.exam.action.delete=Delete Exam
sebserver.exam.action.delete.consistency.error=Deletion Failed.<br/>Please make sure there are no active SEB clients connected to the exam before deletion.
sebserver.exam.action.sebrestriction.enable=Apply SEB Lock
sebserver.exam.action.sebrestriction.disable=Release SEB Lock
sebserver.exam.action.sebrestriction.details=SEB Restriction Details