SEBSERV-412 fixed

This commit is contained in:
anhefti 2023-04-06 09:46:15 +02:00
parent 191b10b8be
commit cbc54fb3d0
4 changed files with 36 additions and 30 deletions

View file

@ -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<String> generateConfigKey(

View file

@ -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,

View file

@ -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<Long> 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);

View file

@ -275,10 +275,12 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
final ServletOutputStream outputStream = response.getOutputStream();
try {
this.sebExamConfigService.exportPlainXML(
outputStream,
institutionId,
modelId);
modelId,
true);
response.setStatus(HttpStatus.OK.value());
} catch (final Exception e) {