diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java index 20e1fabf..bce56121 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java @@ -64,6 +64,10 @@ public final class ViewContext { this.readonly = readonly; } + public boolean isReadonly() { + return this.readonly; + } + public I18nSupport getI18nSupport() { return this.i18nSupport; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java index 8d7686f5..16328215 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java @@ -45,7 +45,7 @@ public class BrowserViewModeRule implements ValueChangeRule { final ConfigurationAttribute attribute, final ConfigurationValue value) { - if (StringUtils.isBlank(value.value)) { + if (context.isReadonly() || StringUtils.isBlank(value.value)) { return; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/IgnoreSEBService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/IgnoreSEBService.java index e28f0b8e..e5f8e7b5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/IgnoreSEBService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/IgnoreSEBService.java @@ -41,6 +41,10 @@ public class IgnoreSEBService implements ValueChangeRule { final ConfigurationAttribute attribute, final ConfigurationValue value) { + if (context.isReadonly()) { + return; + } + if (KEY_IGNORE_SEB_SERVICE.equals(attribute.name)) { if (BooleanUtils.toBoolean(value.value)) { context.disable(KEY_SEB_SERVICE_POLICY); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigIO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigIO.java index 6f60a330..9e77af50 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigIO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigIO.java @@ -37,6 +37,7 @@ import org.xml.sax.SAXException; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.Configuration; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; @@ -140,7 +141,7 @@ public class ExamConfigIO { .collect(Collectors.toList()); final Function configurationValueSupplier = - getConfigurationValueSupplier(institutionId, configurationId); + getConfigurationValueSupplier(configurationId); writeHeader(exportFormat, out); @@ -316,11 +317,13 @@ public class ExamConfigIO { } private Function getConfigurationValueSupplier( - final Long institutionId, final Long configurationId) { + final Configuration configuration = this.configurationDAO.byPK(configurationId) + .getOrThrow(); + final Map mapping = this.configurationValueDAO - .allRootAttributeValues(institutionId, configurationId) + .allRootAttributeValues(configuration.institutionId, configurationId) .getOrThrow() .stream() .collect(Collectors.toMap( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java index 144de3f8..46870da6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigServiceImpl.java @@ -267,26 +267,6 @@ public class ExamConfigServiceImpl implements ExamConfigService { log.debug("Start to stream plain JSON SEB Configuration data for Config-Key generation"); } -// if (true) { -// PipedOutputStream pout; -// PipedInputStream pin; -// try { -// pout = new PipedOutputStream(); -// pin = new PipedInputStream(pout); -// this.examConfigIO.exportPlain( -// ConfigurationFormat.JSON, -// pout, -// institutionId, -// configurationNodeId); -// -// final String json = IOUtils.toString(pin, "UTF-8"); -// -// log.trace("SEB Configuration JSON to create Config-Key: {}", json); -// } catch (final Exception e) { -// log.error("Failed to trace SEB Configuration JSON: ", e); -// } -// } - PipedOutputStream pout = null; PipedInputStream pin = null; try { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverter.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverter.java index 964f2336..96c3ade4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverter.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/TableConverter.java @@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.converter; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -73,9 +74,6 @@ public class TableConverter implements AttributeValueConverter { this.configurationAttributeDAO = configurationAttributeDAO; this.configurationValueDAO = configurationValueDAO; - - log.info("******************************* inject ConfigurationValueDAO is {} configurationAttributeDAO is {}", - configurationValueDAO, configurationAttributeDAO); } @Override @@ -112,15 +110,17 @@ public class TableConverter implements AttributeValueConverter { final ConfigurationValue value, final boolean xml) throws IOException { - log.info("******************************** Convert: {} -- {} -- {}", attribute, this.configurationValueDAO, - value); - - final List> values = this.configurationValueDAO.getOrderedTableValues( - value.institutionId, - value.configurationId, - attribute.id) - .onError(error -> log.error("Failed to get table values for attribute: {}", attribute.name, error)) - .getOrElse(() -> Collections.emptyList()); + final List> values = new ArrayList<>(); + if (value != null) { + values.addAll(this.configurationValueDAO.getOrderedTableValues( + value.institutionId, + value.configurationId, + attribute.id) + .onError(error -> log.error("Failed to get table values for attribute: {}", attribute.name, error)) + .getOrElse(() -> Collections.emptyList())); + } else { + log.warn("No ConfigurationValue for table: {}. Convert to empty table", attribute); + } final boolean noValues = CollectionUtils.isEmpty(values);