Skip to content

Commit

Permalink
SEBSP-116 finished implementation, still need to test
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Nov 7, 2024
1 parent 1ace132 commit 02f8388
Show file tree
Hide file tree
Showing 135 changed files with 3,460 additions and 3,092 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import javax.annotation.Generated;

@Generated(value="org.mybatis.generator.api.MyBatisGenerator",comments="ch.ethz.seb.sebserver.gen.DomainModelNameReferencePlugin",date="2024-10-30T11:40:34.601+01:00")
@Generated(value="org.mybatis.generator.api.MyBatisGenerator",comments="ch.ethz.seb.sebserver.gen.DomainModelNameReferencePlugin",date="2024-11-04T15:08:40.821+01:00")
public enum EntityType {
CONFIGURATION_ATTRIBUTE,
CONFIGURATION_VALUE,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/ethz/seb/sebserver/gbl/model/Domain.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/** Defines the global names of the domain model and domain model fields.
* This shall be used as a static overall domain model names reference within SEB Server Web-Service as well as within the integrated GUI
* This file is generated by the org.eth.demo.sebserver.gen.DomainModelNameReferencePlugin and must not be edited manually.**/
@Generated(value="org.mybatis.generator.api.MyBatisGenerator",comments="ch.ethz.seb.sebserver.gen.DomainModelNameReferencePlugin",date="2024-10-30T11:40:34.565+01:00")
@Generated(value="org.mybatis.generator.api.MyBatisGenerator",comments="ch.ethz.seb.sebserver.gen.DomainModelNameReferencePlugin",date="2024-11-04T15:08:40.789+01:00")
public interface Domain {

interface CONFIGURATION_ATTRIBUTE {
Expand Down Expand Up @@ -169,7 +169,7 @@ interface SCREEN_PROCTORING_GROUP {
String ATTR_NAME = "name";
String ATTR_SIZE = "size";
String ATTR_DATA = "data";
String ATTR_COLLECTING_STRATEGY = "collectingStrategy";
String ATTR_IS_FALLBACK = "isFallback";
String ATTR_SEB_GROUP_ID = "sebGroupId";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ public ClientGroup(

switch (this.type) {
case IP_V4_RANGE: {
final String[] split = StringUtils.split(data, Constants.EMBEDDED_LIST_SEPARATOR);
this.ipRangeStart = split[0];
this.ipRangeEnd = split[1];
if (StringUtils.isNotBlank(data)) {
final String[] split = StringUtils.split(data, Constants.EMBEDDED_LIST_SEPARATOR);
this.ipRangeStart = (split.length > 0 && StringUtils.isNotBlank(split[0])) ? split[0] : null;
this.ipRangeEnd = (split.length > 1 && StringUtils.isNotBlank(split[1])) ? split[1] : null;
} else {
this.ipRangeStart = null;
this.ipRangeEnd = null;
}
this.clientOS = ClientOS.NONE;
this.nameRangeStartLetter = null;
this.nameRangeEndLetter = null;
Expand All @@ -136,9 +141,14 @@ public ClientGroup(
this.ipRangeStart = null;
this.ipRangeEnd = null;
this.clientOS = ClientOS.NONE;
final String[] split = StringUtils.split(data, Constants.EMBEDDED_LIST_SEPARATOR);
this.nameRangeStartLetter = split[0];
this.nameRangeEndLetter = split[1];
if (StringUtils.isNotBlank(data)) {
final String[] split = StringUtils.split(data, Constants.EMBEDDED_LIST_SEPARATOR);
this.nameRangeStartLetter = (split.length > 0 && StringUtils.isNotBlank(split[0])) ? split[0] : null;
this.nameRangeEndLetter = (split.length > 1 && StringUtils.isNotBlank(split[1])) ? split[1] : null;
} else {
this.nameRangeStartLetter = null;
this.nameRangeEndLetter = null;
}
break;
}
default: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

public enum CollectingStrategy {
EXAM,
SEB_GROUP,
FIX_SIZE
APPLY_SEB_GROUPS,
// FIX_SIZE
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public enum ProctoringFeature {
public static final String ATTR_COLLECT_ALL_ROOM_NAME = "collectAllRoomName";
public static final String ATTR_SERVICE_IN_USE = "serviceInUse";
public static final String ATTR_USE_ZOOM_APP_CLIENT_COLLECTING_ROOM = "useZoomAppClientForCollectingRoom";

public static final String ATTR_ADDITIONAL_ATTRIBUTE_STORE_NAME = "LIVE_PROCTORING_SETTINGS";

@JsonProperty(Domain.EXAM.ATTR_ID)
public final Long examId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

package ch.ethz.seb.sebserver.gbl.model.exam;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Objects;

import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.model.Entity;
import org.apache.commons.lang3.BooleanUtils;
import org.hibernate.validator.constraints.URL;

Expand All @@ -21,7 +25,7 @@
import ch.ethz.seb.sebserver.gbl.model.Domain;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ScreenProctoringSettings implements SPSAPIAccessData {
public class ScreenProctoringSettings implements SPSAPIAccessData, Entity {

public static final String ATTR_ENABLE_SCREEN_PROCTORING = "enableScreenProctoring";
public static final String ATTR_SPS_SERVICE_URL = "spsServiceURL";
Expand All @@ -33,9 +37,12 @@ public class ScreenProctoringSettings implements SPSAPIAccessData {
public static final String ATTR_SPS_ACCOUNT_PASSWORD = "spsAccountPassword";

public static final String ATTR_COLLECTING_STRATEGY = "spsCollectingStrategy";
public static final String ATTR_COLLECTING_GROUP_NAME = "spsCollectingGroupName";
public static final String ATTR_COLLECTING_GROUP_SIZE = "spsCollectingGroupSize";
public static final String ATT_SEB_GROUPS_SELECTION = "spsSEBGroupsSelection";

public static final String ATTR_SPS_BUNDLED = "bundled";
public static final String ATTR_ADDITIONAL_ATTRIBUTE_STORE_NAME = "SCREEN_PROCTORING_SETTINGS";

@JsonProperty(Domain.EXAM.ATTR_ID)
public final Long examId;
Expand All @@ -62,9 +69,16 @@ public class ScreenProctoringSettings implements SPSAPIAccessData {
@JsonProperty(ATTR_COLLECTING_STRATEGY)
public final CollectingStrategy collectingStrategy;

@JsonProperty(ATTR_COLLECTING_GROUP_NAME)
@NotEmpty(message = "screenProctoringSettings:spsCollectingGroupName:notNull")
public final String collectingGroupName;

@JsonProperty(ATTR_COLLECTING_GROUP_SIZE)
public final Integer collectingGroupSize;

@JsonProperty(ATT_SEB_GROUPS_SELECTION)
public final String sebGroupsSelection;

@JsonProperty(ATTR_SPS_BUNDLED)
public final boolean bundled;

Expand All @@ -78,7 +92,9 @@ public ScreenProctoringSettings(
@JsonProperty(ATTR_SPS_ACCOUNT_ID) final String spsAccountId,
@JsonProperty(ATTR_SPS_ACCOUNT_PASSWORD) final CharSequence spsAccountPassword,
@JsonProperty(ATTR_COLLECTING_STRATEGY) final CollectingStrategy collectingStrategy,
@JsonProperty(ATTR_COLLECTING_GROUP_NAME) final String collectingGroupName,
@JsonProperty(ATTR_COLLECTING_GROUP_SIZE) final Integer collectingGroupSize,
@JsonProperty(ATT_SEB_GROUPS_SELECTION) final String sebGroupsSelection,
@JsonProperty(ATTR_SPS_BUNDLED) final boolean bundled) {

this.examId = examId;
Expand All @@ -89,7 +105,9 @@ public ScreenProctoringSettings(
this.spsAccountId = spsAccountId;
this.spsAccountPassword = spsAccountPassword;
this.collectingStrategy = collectingStrategy;
this.collectingGroupName = collectingGroupName;
this.collectingGroupSize = collectingGroupSize;
this.sebGroupsSelection = sebGroupsSelection;
this.bundled = bundled;
}

Expand All @@ -102,7 +120,9 @@ public ScreenProctoringSettings(
final String spsAccountId,
final CharSequence spsAccountPassword,
final CollectingStrategy collectingStrategy,
final Integer collectingGroupSize) {
final String collectingGroupName,
final Integer collectingGroupSize,
final String sebGroupsSelection) {

this.examId = examId;
this.enableScreenProctoring = enableScreenProctoring;
Expand All @@ -112,34 +132,25 @@ public ScreenProctoringSettings(
this.spsAccountId = spsAccountId;
this.spsAccountPassword = spsAccountPassword;
this.collectingStrategy = collectingStrategy;
this.collectingGroupName = collectingGroupName;
this.collectingGroupSize = collectingGroupSize;
this.sebGroupsSelection = sebGroupsSelection;
this.bundled = false;
}

public ScreenProctoringSettings(final Exam exam) {
if (exam == null) {
throw new IllegalStateException("Exam has null reference");
}
if (!exam.additionalAttributesIncluded()) {
throw new IllegalStateException("Exam has no additional attributes");
}

this.examId = exam.id;
this.enableScreenProctoring = BooleanUtils.toBooleanObject(exam.additionalAttributes.getOrDefault(
ATTR_ENABLE_SCREEN_PROCTORING,
Constants.FALSE_STRING));
this.spsServiceURL = exam.additionalAttributes.get(ATTR_SPS_SERVICE_URL);
this.spsAPIKey = exam.additionalAttributes.get(ATTR_SPS_API_KEY);
this.spsAPISecret = exam.additionalAttributes.get(ATTR_SPS_API_SECRET);
this.spsAccountId = exam.additionalAttributes.get(ATTR_SPS_ACCOUNT_ID);
this.spsAccountPassword = exam.additionalAttributes.get(ATTR_SPS_ACCOUNT_PASSWORD);
this.collectingStrategy = CollectingStrategy.valueOf(exam.additionalAttributes.getOrDefault(
ATTR_COLLECTING_STRATEGY,
CollectingStrategy.EXAM.name()));
this.collectingGroupSize = Integer.parseInt(exam.additionalAttributes.getOrDefault(
ATTR_COLLECTING_GROUP_SIZE,
"-1"));
this.bundled = false;
@Override
public String getModelId() {
return (this.examId != null) ? String.valueOf(this.examId) : null;
}

@Override
public EntityType entityType() {
return EntityType.EXAM_PROCTOR_DATA;
}

@Override
public String getName() {
return this.spsServiceURL;
}

public Long getExamId() {
Expand Down Expand Up @@ -178,6 +189,14 @@ public Integer getCollectingGroupSize() {
return this.collectingGroupSize;
}

public String getCollectingGroupName() {
return collectingGroupName;
}

public String getSebGroupsSelection() {
return sebGroupsSelection;
}

@Override
public int hashCode() {
return Objects.hash(this.examId);
Expand All @@ -201,27 +220,17 @@ public boolean equals(final Object obj) {

@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("ScreenProctoringSettings [examId=");
builder.append(this.examId);
builder.append(", enableScreenProctoring=");
builder.append(this.enableScreenProctoring);
builder.append(", spsServiceURL=");
builder.append(this.spsServiceURL);
builder.append(", spsAPIKey=");
builder.append(this.spsAPIKey);
builder.append(", spsAPISecret=");
builder.append(this.spsAPISecret);
builder.append(", spsAccountId=");
builder.append(this.spsAccountId);
builder.append(", spsAccountPassword=");
builder.append(this.spsAccountPassword);
builder.append(", collectingStrategy=");
builder.append(this.collectingStrategy);
builder.append(", collectingGroupSize=");
builder.append(this.collectingGroupSize);
builder.append("]");
return builder.toString();
return "ScreenProctoringSettings{" +
"examId=" + examId +
", enableScreenProctoring=" + enableScreenProctoring +
", spsServiceURL='" + spsServiceURL + '\'' +
", spsAPIKey='" + spsAPIKey + '\'' +
", spsAccountId='" + spsAccountId + '\'' +
", collectingStrategy=" + collectingStrategy +
", collectingGroupName='" + collectingGroupName + '\'' +
", collectingGroupSize=" + collectingGroupSize +
", sebGroupsSelection='" + sebGroupsSelection + '\'' +
", bundled=" + bundled +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.util.Objects;

import ch.ethz.seb.sebserver.gbl.model.exam.CollectingStrategy;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -38,8 +37,8 @@ public class ScreenProctoringGroup {
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_DATA)
public final String additionalData;

@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_COLLECTING_STRATEGY)
public final CollectingStrategy collectingStrategy;
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_IS_FALLBACK)
public final Boolean isFallback;

@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_SEB_GROUP_ID)
public final Long sebGroupId;
Expand All @@ -52,7 +51,7 @@ public ScreenProctoringGroup(
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_NAME) final String name,
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_SIZE) final Integer size,
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_DATA) final String additionalData,
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_COLLECTING_STRATEGY) final CollectingStrategy collectingStrategy,
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_IS_FALLBACK) final Boolean isFallback,
@JsonProperty(Domain.SCREEN_PROCTORING_GROUP.ATTR_SEB_GROUP_ID) final Long sebGroupId) {

this.id = id;
Expand All @@ -61,7 +60,7 @@ public ScreenProctoringGroup(
this.name = name;
this.size = size;
this.additionalData = additionalData;
this.collectingStrategy = collectingStrategy;
this.isFallback = isFallback;
this.sebGroupId = sebGroupId;
}

Expand Down Expand Up @@ -89,10 +88,10 @@ public String getAdditionalData() {
return this.additionalData;
}

public CollectingStrategy getCollectingStrategy() {
return collectingStrategy;
public Boolean getFallback() {
return isFallback;
}

public Long getSebGroupId() {
return sebGroupId;
}
Expand Down Expand Up @@ -123,7 +122,7 @@ public String toString() {
", name='" + name + '\'' +
", size=" + size +
", additionalData='" + additionalData + '\'' +
", collectingStrategy=" + collectingStrategy +
", isFallback=" + isFallback +
", sebGroupId=" + sebGroupId +
'}';
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -941,4 +941,14 @@ private static String reduceFormUrlAttributes(final MultiValueMap<String, String
StringBuilder::append)
.toString();
}

public static List<String> reduceToErrorMessages(final Throwable error) {
final List<String> result = new ArrayList<>();
Throwable e = error;
while (e != null) {
result.add(e.getMessage());
e = e.getCause();
}
return result;
}
}
Loading

0 comments on commit 02f8388

Please sign in to comment.