diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ExamConfigService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ExamConfigService.java index 552533f3..e8e09611 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ExamConfigService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/ExamConfigService.java @@ -49,19 +49,14 @@ public interface ExamConfigService { * * @param out The output stream to write the plain XML text to. * @param institutionId The identifier of the institution of the requesting user - * @param configurationNodeId the identifier of the ConfigurationNode to export */ - void exportPlainXML(OutputStream out, Long institutionId, Long configurationNodeId); - - /** Used to export a specified SEB Exam Configuration as plain JSON - * This exports the values of the follow-up configuration defined by a given - * ConfigurationNode (configurationNodeId) and sorts the attributes recording to - * the SEB configuration JSON specification to create a Config-Key as - * described here: https://www.safeexambrowser.org/developer/seb-config-key.html - * - * @param out The output stream to write the plain JSON text to. - * @param institutionId The identifier of the institution of the requesting user - * @param configurationNodeId the identifier of the ConfigurationNode to export */ - void exportPlainJSON(OutputStream out, Long institutionId, Long configurationNodeId); + * @param configurationNodeId the identifier of the ConfigurationNode to export + * @param followup indicates if the follow-up configuration entry shall be used or otherwise the last stable + * to export SEB Settings */ + void exportPlainXML( + OutputStream out, + Long institutionId, + Long configurationNodeId, + boolean followup); /** Used to export the default SEB Exam Configuration for a given exam identifier. * either with encryption if defined or as plain text within the SEB Configuration format @@ -102,7 +97,7 @@ public interface ExamConfigService { * * @param institutionId the institutional id * @param configurationNodeId the configurationNodeId - * @param stable indicates if the follow-up configuration entey shall be used or otherwise the last stable + * @param followup indicates if the follow-up configuration entry shall be used or otherwise the last stable * to calculate the config key * @return Result refer to the generated Config-Key or to an error if happened. */ Result generateConfigKey( 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 3ffd726e..2f5bd361 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 @@ -104,6 +104,17 @@ public class ExamConfigIO { exportPlain(exportFormat, out, institutionId, configurationNodeId, null); } + @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) + void exportForConfig( + final ConfigurationFormat exportFormat, + final OutputStream out, + final Long institutionId, + final Long configurationNodeId, + final Long configId) throws Exception { + + exportPlain(exportFormat, out, institutionId, configurationNodeId, configId); + } + @Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME) void exportForConfig( final OutputStream out, 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 b7950998..e19d4749 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 @@ -146,18 +146,14 @@ public class ExamConfigServiceImpl implements ExamConfigService { public void exportPlainXML( final OutputStream out, final Long institutionId, - final Long configurationNodeId) { + final Long configurationNodeId, + final boolean followup) { - this.exportPlainOnly(ConfigurationFormat.XML, out, institutionId, configurationNodeId); - } - - @Override - public void exportPlainJSON( - final OutputStream out, - final Long institutionId, - final Long configurationNodeId) { - - this.exportPlainOnly(ConfigurationFormat.JSON, out, institutionId, configurationNodeId); + Long configId = null; + if (followup) { + configId = this.configurationDAO.getFollowupConfigurationId(configurationNodeId).getOr(null); + } + this.exportPlainOnly(ConfigurationFormat.XML, out, institutionId, configurationNodeId, configId); } public Result getDefaultConfigurationIdForExam(final Long examId) { @@ -264,7 +260,7 @@ public class ExamConfigServiceImpl implements ExamConfigService { } } else { // just export in plain text XML format - this.exportPlainXML(out, institutionId, configurationNodeId); + this.exportPlainXML(out, institutionId, configurationNodeId, false); } return configurationNodeId; @@ -505,7 +501,8 @@ public class ExamConfigServiceImpl implements ExamConfigService { final ConfigurationFormat exportFormat, final OutputStream out, final Long institutionId, - final Long configurationNodeId) { + final Long configurationNodeId, + final Long configId) { if (log.isDebugEnabled()) { log.debug("Start to stream plain text SEB Configuration data"); @@ -517,11 +514,12 @@ public class ExamConfigServiceImpl implements ExamConfigService { pout = new PipedOutputStream(); pin = new PipedInputStream(pout); - this.examConfigIO.exportPlain( + this.examConfigIO.exportForConfig( exportFormat, pout, institutionId, - configurationNodeId); + configurationNodeId, + configId); IOUtils.copyLarge(pin, out); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java index beb2624e..80794cf3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java @@ -275,10 +275,12 @@ public class ConfigurationNodeController extends EntityController