SEBSERV-202 fix

This commit is contained in:
anhefti 2021-07-07 17:30:56 +02:00
parent 6043d752a6
commit bcdd8b87bd
2 changed files with 20 additions and 17 deletions

View file

@ -139,11 +139,12 @@ public class ExamProctoringSettings {
.valueOf(form.getFieldValue(ProctoringServiceSettings.ATTR_SERVER_TYPE));
final String features = form.getFieldValue(ProctoringServiceSettings.ATTR_ENABLED_FEATURES);
final EnumSet<ProctoringFeature> featureFlags =
EnumSet.copyOf(Arrays.asList(StringUtils.split(features, Constants.LIST_SEPARATOR))
final EnumSet<ProctoringFeature> featureFlags = (StringUtils.isNotBlank(features))
? EnumSet.copyOf(Arrays.asList(StringUtils.split(features, Constants.LIST_SEPARATOR))
.stream()
.map(str -> ProctoringFeature.valueOf(str))
.collect(Collectors.toSet()));
.collect(Collectors.toSet()))
: EnumSet.noneOf(ProctoringFeature.class);
examProctoring = new ProctoringServiceSettings(
Long.parseLong(entityKey.modelId),

View file

@ -328,20 +328,22 @@ public class ExamAdminServiceImpl implements ExamAdminService {
if (mapping.containsKey(ProctoringServiceSettings.ATTR_ENABLED_FEATURES)) {
try {
final String value = mapping.get(ProctoringServiceSettings.ATTR_ENABLED_FEATURES).getValue();
return EnumSet.copyOf(Arrays.asList(StringUtils.split(value, Constants.LIST_SEPARATOR))
.stream()
.map(str -> {
try {
return ProctoringFeature.valueOf(str);
} catch (final Exception e) {
log.error(
"Failed to enabled single features for proctoring settings. Skipping. {}",
e.getMessage());
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toSet()));
return StringUtils.isNotBlank(value)
? EnumSet.copyOf(Arrays.asList(StringUtils.split(value, Constants.LIST_SEPARATOR))
.stream()
.map(str -> {
try {
return ProctoringFeature.valueOf(str);
} catch (final Exception e) {
log.error(
"Failed to enabled single features for proctoring settings. Skipping. {}",
e.getMessage());
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toSet()))
: EnumSet.noneOf(ProctoringFeature.class);
} catch (final Exception e) {
log.error("Failed to get enabled features for proctoring settings. Enable all. {}", e.getMessage());
return EnumSet.allOf(ProctoringFeature.class);