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)); .valueOf(form.getFieldValue(ProctoringServiceSettings.ATTR_SERVER_TYPE));
final String features = form.getFieldValue(ProctoringServiceSettings.ATTR_ENABLED_FEATURES); final String features = form.getFieldValue(ProctoringServiceSettings.ATTR_ENABLED_FEATURES);
final EnumSet<ProctoringFeature> featureFlags = final EnumSet<ProctoringFeature> featureFlags = (StringUtils.isNotBlank(features))
EnumSet.copyOf(Arrays.asList(StringUtils.split(features, Constants.LIST_SEPARATOR)) ? EnumSet.copyOf(Arrays.asList(StringUtils.split(features, Constants.LIST_SEPARATOR))
.stream() .stream()
.map(str -> ProctoringFeature.valueOf(str)) .map(str -> ProctoringFeature.valueOf(str))
.collect(Collectors.toSet())); .collect(Collectors.toSet()))
: EnumSet.noneOf(ProctoringFeature.class);
examProctoring = new ProctoringServiceSettings( examProctoring = new ProctoringServiceSettings(
Long.parseLong(entityKey.modelId), Long.parseLong(entityKey.modelId),

View file

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