SEBSERV-412 fixed config key
This commit is contained in:
parent
eb4f758328
commit
191b10b8be
7 changed files with 37 additions and 15 deletions
|
@ -174,6 +174,7 @@ public final class API {
|
|||
|
||||
public static final String CONFIGURATION_NODE_ENDPOINT = "/configuration-node";
|
||||
public static final String CONFIGURATION_FOLLOWUP_PATH_SEGMENT = "/followup";
|
||||
public static final String PARAM_FOLLOWUP = "followup";
|
||||
public static final String CONFIGURATION_CONFIG_KEY_PATH_SEGMENT = "/configkey";
|
||||
public static final String CONFIGURATION_SETTINGS_PUBLISHED_PATH_SEGMENT = "/settings_published";
|
||||
public static final String CONFIGURATION_ENDPOINT = "/configuration";
|
||||
|
|
|
@ -336,7 +336,7 @@ public class SEBExamConfigForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_GET_CONFIG_KEY)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(SEBExamConfigForm.getConfigKeyFunction(this.pageService))
|
||||
.withExec(SEBExamConfigForm.getConfigKeyFunction(this.pageService, true))
|
||||
.noEventPropagation()
|
||||
.publishIf(() -> modifyGrant && isReadonly)
|
||||
|
||||
|
@ -504,11 +504,15 @@ public class SEBExamConfigForm implements TemplateComposer {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static Function<PageAction, PageAction> getConfigKeyFunction(final PageService pageService) {
|
||||
public static Function<PageAction, PageAction> getConfigKeyFunction(
|
||||
final PageService pageService,
|
||||
final boolean followup) {
|
||||
|
||||
final RestService restService = pageService.getResourceService().getRestService();
|
||||
return action -> {
|
||||
final ConfigKey configKey = restService.getBuilder(ExportConfigKey.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, action.getEntityKey().modelId)
|
||||
.withQueryParam(API.PARAM_FOLLOWUP, String.valueOf(followup))
|
||||
.call()
|
||||
.getOrThrow();
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ public class ExamFormConfigs implements TemplateComposer {
|
|||
if (examConfigMappingKey != null) {
|
||||
action.withEntityKey(examConfigMappingKey);
|
||||
return SEBExamConfigForm
|
||||
.getConfigKeyFunction(this.pageService)
|
||||
.getConfigKeyFunction(this.pageService, false)
|
||||
.apply(action);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface ExamConfigService {
|
|||
Result<Long> getFollowupConfigurationId(final Long examConfigNodeId);
|
||||
|
||||
/** Used to export a specified SEB Exam Configuration as plain XML
|
||||
* This exports the values of the follow-up configuration defined by a given
|
||||
* This exports the values of the last published changes of a given
|
||||
* ConfigurationNode (configurationNodeId)
|
||||
*
|
||||
* @param out The output stream to write the plain XML text to.
|
||||
|
@ -102,8 +102,13 @@ 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
|
||||
* to calculate the config key
|
||||
* @return Result refer to the generated Config-Key or to an error if happened. */
|
||||
Result<String> generateConfigKey(Long institutionId, Long configurationNodeId);
|
||||
Result<String> generateConfigKey(
|
||||
Long institutionId,
|
||||
Long configurationNodeId,
|
||||
boolean followup);
|
||||
|
||||
/** Generates a list of Config-Key from a given Exam by collecting all the SEB Exam Configurations that are attached
|
||||
* to this Exam
|
||||
|
|
|
@ -105,7 +105,7 @@ public class ExamConfigIO {
|
|||
}
|
||||
|
||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||
void exportForConfigKeyGeneration(
|
||||
void exportForConfig(
|
||||
final OutputStream out,
|
||||
final Long institutionId,
|
||||
final Long configurationNodeId,
|
||||
|
@ -122,7 +122,7 @@ public class ExamConfigIO {
|
|||
final Long configId) throws Exception {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Start export SEB plain XML configuration asynconously");
|
||||
log.debug("Start export SEB plain XML configuration asynchronously");
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -273,11 +273,18 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
|||
@Override
|
||||
public Result<String> generateConfigKey(
|
||||
final Long institutionId,
|
||||
final Long configurationNodeId) {
|
||||
final Long configurationNodeId,
|
||||
final boolean followup) {
|
||||
|
||||
return this.configurationDAO
|
||||
.getConfigurationLastStableVersion(configurationNodeId)
|
||||
.flatMap(config -> generateConfigKey(institutionId, configurationNodeId, config.id));
|
||||
if (followup) {
|
||||
return this.configurationDAO
|
||||
.getFollowupConfiguration(configurationNodeId)
|
||||
.flatMap(config -> generateConfigKey(institutionId, configurationNodeId, config.id));
|
||||
} else {
|
||||
return this.configurationDAO
|
||||
.getConfigurationLastStableVersion(configurationNodeId)
|
||||
.flatMap(config -> generateConfigKey(institutionId, configurationNodeId, config.id));
|
||||
}
|
||||
}
|
||||
|
||||
private Result<String> generateConfigKey(
|
||||
|
@ -295,7 +302,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
|||
pout = new PipedOutputStream();
|
||||
pin = new PipedInputStream(pout);
|
||||
|
||||
this.examConfigIO.exportForConfigKeyGeneration(
|
||||
this.examConfigIO.exportForConfig(
|
||||
pout,
|
||||
institutionId,
|
||||
configurationNodeId,
|
||||
|
@ -335,7 +342,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
|||
return this.examConfigurationMapDAO.getConfigurationNodeIds(examId)
|
||||
.map(ids -> ids
|
||||
.stream()
|
||||
.map(id -> generateConfigKey(institutionId, id)
|
||||
.map(id -> generateConfigKey(institutionId, id, false)
|
||||
.getOrThrow())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.validation.Valid;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.dynamic.sql.SqlTable;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -239,13 +240,17 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
|
|||
@RequestParam(
|
||||
name = API.PARAM_INSTITUTION_ID,
|
||||
required = true,
|
||||
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId) {
|
||||
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
||||
@RequestParam(
|
||||
name = API.PARAM_FOLLOWUP,
|
||||
required = false,
|
||||
defaultValue = "false") final Boolean followup) {
|
||||
|
||||
this.entityDAO.byPK(modelId)
|
||||
.flatMap(this.authorization::checkRead);
|
||||
|
||||
final String configKey = this.sebExamConfigService
|
||||
.generateConfigKey(institutionId, modelId)
|
||||
.generateConfigKey(institutionId, modelId, BooleanUtils.toBoolean(followup))
|
||||
.getOrThrow();
|
||||
|
||||
return new ConfigKey(configKey);
|
||||
|
|
Loading…
Reference in a new issue