refactored downloads
This commit is contained in:
parent
b735e95587
commit
2f8f8296d7
16 changed files with 166 additions and 334 deletions
|
@ -144,7 +144,7 @@ public final class API {
|
|||
public static final String QUIZ_DISCOVERY_ENDPOINT = "/quiz";
|
||||
|
||||
public static final String EXAM_ADMINISTRATION_ENDPOINT = "/exam";
|
||||
public static final String EXAM_ADMINISTRATION_DOWNLOAD_CONFIG_PATH_SEGMENT = "/download-config";
|
||||
//public static final String EXAM_ADMINISTRATION_DOWNLOAD_CONFIG_PATH_SEGMENT = "/download-config";
|
||||
public static final String EXAM_ADMINISTRATION_CONSISTENCY_CHECK_PATH_SEGMENT = "/check-consistency";
|
||||
public static final String EXAM_ADMINISTRATION_CONSISTENCY_CHECK_INCLUDE_RESTRICTION = "include-restriction";
|
||||
public static final String EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT = "/seb-restriction";
|
||||
|
@ -170,7 +170,7 @@ public final class API {
|
|||
public static final String CONFIGURATION_VALUE_ENDPOINT = "/configuration_value";
|
||||
public static final String CONFIGURATION_TABLE_VALUE_PATH_SEGMENT = "/table";
|
||||
public static final String CONFIGURATION_ATTRIBUTE_ENDPOINT = "/configuration_attribute";
|
||||
public static final String CONFIGURATION_PLAIN_XML_DOWNLOAD_PATH_SEGMENT = "/downloadxml";
|
||||
public static final String CONFIGURATION_SEB_SETTINGS_DOWNLOAD_PATH_SEGMENT = "/downloadSettings";
|
||||
public static final String CONFIGURATION_IMPORT_PATH_SEGMENT = "/import";
|
||||
public static final String IMPORT_PASSWORD_ATTR_NAME = "importFilePassword";
|
||||
public static final String IMPORT_FILE_ATTR_NAME = "importFile";
|
||||
|
|
|
@ -50,7 +50,7 @@ import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SEBExamConfigPlaintextDownload;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SEBExamSettingsDownload;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurations;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode;
|
||||
|
@ -237,7 +237,7 @@ public class SEBSettingsForm implements TemplateComposer {
|
|||
.withExec(action -> {
|
||||
final String downloadURL = this.downloadService.createDownloadURL(
|
||||
entityKey.modelId,
|
||||
SEBExamConfigPlaintextDownload.class,
|
||||
SEBExamSettingsDownload.class,
|
||||
this.downloadFileName);
|
||||
urlLauncher.openURL(downloadURL);
|
||||
return action;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.content.monitoring;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -15,6 +16,8 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.tomcat.util.buf.StringUtils;
|
||||
import org.eclipse.rap.rwt.RWT;
|
||||
import org.eclipse.rap.rwt.client.service.UrlLauncher;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -24,12 +27,15 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.api.authorization.PrivilegeType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||
import ch.ethz.seb.sebserver.gbl.model.EntityName;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Page;
|
||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection;
|
||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent;
|
||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.ExportType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.session.ExtendedClientEvent;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
|
@ -42,6 +48,8 @@ import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.PageService.PageActionBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SEBClientLogExport;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.logs.GetClientEventNames;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.logs.GetExtendedClientEventPage;
|
||||
|
@ -84,23 +92,29 @@ public class SEBClientEvents implements TemplateComposer {
|
|||
private final ResourceService resourceService;
|
||||
private final RestService restService;
|
||||
private final I18nSupport i18nSupport;
|
||||
private final DownloadService downloadService;
|
||||
private final SEBClientEventDetailsPopup sebClientEventDetailsPopup;
|
||||
private final SEBClientEventDeletePopup sebClientEventDeletePopup;
|
||||
private final int pageSize;
|
||||
private final String exportFileName;
|
||||
|
||||
public SEBClientEvents(
|
||||
final PageService pageService,
|
||||
final DownloadService downloadService,
|
||||
final SEBClientEventDetailsPopup sebClientEventDetailsPopup,
|
||||
final SEBClientEventDeletePopup sebClientEventDeletePopup,
|
||||
@Value("${sebserver.gui.seb.client.logs.export.filename:SEBClientLogs}") final String exportFileName,
|
||||
@Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) {
|
||||
|
||||
this.pageService = pageService;
|
||||
this.downloadService = downloadService;
|
||||
this.resourceService = pageService.getResourceService();
|
||||
this.restService = this.resourceService.getRestService();
|
||||
this.i18nSupport = this.resourceService.getI18nSupport();
|
||||
this.sebClientEventDetailsPopup = sebClientEventDetailsPopup;
|
||||
this.sebClientEventDeletePopup = sebClientEventDeletePopup;
|
||||
this.pageSize = pageSize;
|
||||
this.exportFileName = exportFileName;
|
||||
|
||||
this.examFilter = new TableFilterAttribute(
|
||||
CriteriaType.SINGLE_SELECTION,
|
||||
|
@ -219,12 +233,52 @@ public class SEBClientEvents implements TemplateComposer {
|
|||
.noEventPropagation()
|
||||
.publish(false)
|
||||
|
||||
.newAction(ActionDefinition.LOGS_SEB_CLIENT_EXPORT_CSV)
|
||||
.withExec(action -> this.exportLogs(action, ExportType.CSV, table))
|
||||
.noEventPropagation()
|
||||
.publishIf(() -> writeGrant, table.hasAnyContent())
|
||||
|
||||
.newAction(ActionDefinition.LOGS_SEB_CLIENT_DELETE_ALL)
|
||||
.withExec(action -> this.getOpenDelete(action, table.getFilterCriteria()))
|
||||
.noEventPropagation()
|
||||
.publishIf(() -> writeGrant, table.hasAnyContent());
|
||||
}
|
||||
|
||||
private PageAction exportLogs(
|
||||
final PageAction action,
|
||||
final ExportType type,
|
||||
final EntityTable<ExtendedClientEvent> table) {
|
||||
|
||||
try {
|
||||
|
||||
final UrlLauncher urlLauncher = RWT.getClient().getService(UrlLauncher.class);
|
||||
final String fileName = this.exportFileName
|
||||
+ Constants.UNDERLINE
|
||||
+ this.i18nSupport.formatDisplayDate(Utils.getMillisecondsNow())
|
||||
.replace(" ", "_")
|
||||
.replace(".", "_")
|
||||
+ Constants.FILE_EXT_CSV;
|
||||
final Map<String, String> queryAttrs = new HashMap<>();
|
||||
|
||||
queryAttrs.put(API.SEB_CLIENT_EVENT_EXPORT_TYPE, type.name());
|
||||
final String sortAttr = table.getSortOrder().encode(table.getSortColumn());
|
||||
queryAttrs.put(Page.ATTR_SORT, sortAttr);
|
||||
table.getFilterCriteria().forEach((name, value) -> queryAttrs.put(name, value.get(0)));
|
||||
|
||||
final String downloadURL = this.downloadService
|
||||
.createDownloadURL(
|
||||
SEBClientLogExport.class,
|
||||
fileName,
|
||||
queryAttrs);
|
||||
|
||||
urlLauncher.openURL(downloadURL);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed open export log download: ", e);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
private PageAction getOpenDelete(
|
||||
final PageAction pageAction,
|
||||
final MultiValueMap<String, String> filterCriteria) {
|
||||
|
@ -270,4 +324,4 @@ public class SEBClientEvents implements TemplateComposer {
|
|||
.formatDisplayDateTime(Utils.toDateTimeUTC(event.serverTime));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -48,32 +48,35 @@ public class SEBClientConfigDownload extends AbstractDownloadServiceHandler {
|
|||
final OutputStream downloadOut,
|
||||
final HttpServletRequest request) {
|
||||
|
||||
final RestCall<InputStream>.RestCallBuilder restCallBuilder = this.restService
|
||||
final RestCall<Boolean>.RestCallBuilder restCallBuilder = this.restService
|
||||
.getBuilder(ExportClientConfig.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, modelId);
|
||||
.withURIVariable(API.PARAM_MODEL_ID, modelId)
|
||||
.withResponseExtractor(response -> {
|
||||
try {
|
||||
final InputStream input = response.getBody();
|
||||
IOUtils.copyLarge(input, downloadOut);
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while streaming to output-stream of download response: ", e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
downloadOut.flush();
|
||||
downloadOut.close();
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while trying to close download output-stream");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (StringUtils.isNotBlank(parentModelId)) {
|
||||
restCallBuilder.withQueryParam(EXAM.ATTR_ID, parentModelId);
|
||||
}
|
||||
|
||||
final InputStream input = restCallBuilder
|
||||
restCallBuilder
|
||||
.call()
|
||||
.getOrThrow();
|
||||
|
||||
try {
|
||||
IOUtils.copyLarge(input, downloadOut);
|
||||
} catch (final IOException e) {
|
||||
log.error(
|
||||
"Unexpected error while streaming incoming config data from web-service to output-stream of download response: ",
|
||||
e);
|
||||
} finally {
|
||||
try {
|
||||
downloadOut.flush();
|
||||
downloadOut.close();
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while trying to close download output-stream");
|
||||
}
|
||||
}
|
||||
.onError(error -> log.error("SEB exam settings download failed: ", error));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.springframework.util.MultiValueMap;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportSEBClientLogs;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.logs.ExportSEBClientLogs;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
|
@ -63,9 +63,8 @@ public class SEBClientLogExport extends AbstractDownloadServiceHandler {
|
|||
final InputStream input = response.getBody();
|
||||
IOUtils.copyLarge(input, downloadOut);
|
||||
} catch (final IOException e) {
|
||||
log.error(
|
||||
"Unexpected error while streaming incoming config data from web-service to output-stream of download response: ",
|
||||
e);
|
||||
log.error("Unexpected error while streaming to output-stream of download response: ", e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
downloadOut.flush();
|
||||
|
@ -79,8 +78,7 @@ public class SEBClientLogExport extends AbstractDownloadServiceHandler {
|
|||
})
|
||||
.withQueryParams(queryParams)
|
||||
.call()
|
||||
.onError(error -> log.error("Download failed: ", error));
|
||||
|
||||
.onError(error -> log.error("SEB Client logs download failed: ", error));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.download;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ExportPlainXML;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class SEBExamConfigPlaintextDownload extends AbstractDownloadServiceHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SEBExamConfigPlaintextDownload.class);
|
||||
|
||||
private final RestService restService;
|
||||
|
||||
protected SEBExamConfigPlaintextDownload(final RestService restService) {
|
||||
this.restService = restService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void webserviceCall(
|
||||
final String modelId,
|
||||
final String parentModelId,
|
||||
final OutputStream downloadOut,
|
||||
final HttpServletRequest request) {
|
||||
|
||||
final InputStream input = this.restService.getBuilder(ExportPlainXML.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, modelId)
|
||||
.call()
|
||||
.getOrThrow();
|
||||
|
||||
try {
|
||||
IOUtils.copyLarge(input, downloadOut);
|
||||
} catch (final IOException e) {
|
||||
log.error(
|
||||
"Unexpected error while streaming incoming config data from web-service to output-stream of download response: ",
|
||||
e);
|
||||
} finally {
|
||||
try {
|
||||
downloadOut.flush();
|
||||
downloadOut.close();
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while trying to close download output-stream");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -23,18 +23,18 @@ import org.springframework.stereotype.Component;
|
|||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportExamConfig;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportSEBSettingsConfig;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class SEBExamConfigDownload extends AbstractDownloadServiceHandler {
|
||||
public class SEBExamSettingsDownload extends AbstractDownloadServiceHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SEBExamConfigDownload.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(SEBExamSettingsDownload.class);
|
||||
|
||||
private final RestService restService;
|
||||
|
||||
protected SEBExamConfigDownload(final RestService restService) {
|
||||
protected SEBExamSettingsDownload(final RestService restService) {
|
||||
this.restService = restService;
|
||||
}
|
||||
|
||||
|
@ -45,26 +45,29 @@ public class SEBExamConfigDownload extends AbstractDownloadServiceHandler {
|
|||
final OutputStream downloadOut,
|
||||
final HttpServletRequest request) {
|
||||
|
||||
final InputStream input = this.restService.getBuilder(ExportExamConfig.class)
|
||||
this.restService
|
||||
.getBuilder(ExportSEBSettingsConfig.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, modelId)
|
||||
.withURIVariable(API.PARAM_PARENT_MODEL_ID, parentModelId)
|
||||
.call()
|
||||
.getOrThrow();
|
||||
.withResponseExtractor(response -> {
|
||||
try {
|
||||
final InputStream input = response.getBody();
|
||||
IOUtils.copyLarge(input, downloadOut);
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while streaming to output-stream of download response: ", e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
downloadOut.flush();
|
||||
downloadOut.close();
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while trying to close download output-stream");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
IOUtils.copyLarge(input, downloadOut);
|
||||
} catch (final IOException e) {
|
||||
log.error(
|
||||
"Unexpected error while streaming incoming config data from web-service to output-stream of download response: ",
|
||||
e);
|
||||
} finally {
|
||||
try {
|
||||
downloadOut.flush();
|
||||
downloadOut.close();
|
||||
} catch (final IOException e) {
|
||||
log.error("Unexpected error while trying to close download output-stream");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.call()
|
||||
.onError(error -> log.error("SEB exam settings download failed: ", error));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.ClientHttpRequest;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||
|
||||
@Deprecated // This is not streaming correctly. Use AbstractDownloadCall instead
|
||||
public abstract class AbstractExportCall extends RestCall<InputStream> {
|
||||
|
||||
protected AbstractExportCall(
|
||||
final TypeKey<InputStream> typeKey,
|
||||
final HttpMethod httpMethod,
|
||||
final MediaType contentType,
|
||||
final String path) {
|
||||
|
||||
super(typeKey, httpMethod, contentType, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<InputStream> exchange(final RestCallBuilder builder) {
|
||||
|
||||
return Result.tryCatch(() -> builder
|
||||
.getRestTemplate()
|
||||
.execute(
|
||||
builder.buildURI(),
|
||||
this.httpMethod,
|
||||
(final ClientHttpRequest requestCallback) -> {
|
||||
},
|
||||
response -> IOUtils.toBufferedInputStream(response.getBody()),
|
||||
builder.getURIVariables()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractExportCall;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class ExportExamConfig extends AbstractExportCall {
|
||||
|
||||
public ExportExamConfig() {
|
||||
super(new TypeKey<>(
|
||||
CallType.UNDEFINED,
|
||||
EntityType.EXAM,
|
||||
new TypeReference<InputStream>() {
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.EXAM_ADMINISTRATION_ENDPOINT
|
||||
+ API.MODEL_ID_VAR_PATH_SEGMENT
|
||||
+ API.EXAM_ADMINISTRATION_DOWNLOAD_CONFIG_PATH_SEGMENT
|
||||
+ API.PARENT_MODEL_ID_VAR_PATH_SEGMENT);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,38 +6,26 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig;
|
||||
|
||||
import java.io.InputStream;
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractExportCall;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractDownloadCall;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class ExportPlainXML extends AbstractExportCall {
|
||||
public class ExportSEBSettingsConfig extends AbstractDownloadCall {
|
||||
|
||||
public ExportPlainXML() {
|
||||
super(new TypeKey<>(
|
||||
CallType.UNDEFINED,
|
||||
EntityType.CONFIGURATION_NODE,
|
||||
new TypeReference<InputStream>() {
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
public ExportSEBSettingsConfig() {
|
||||
super(MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.CONFIGURATION_NODE_ENDPOINT
|
||||
+ API.MODEL_ID_VAR_PATH_SEGMENT
|
||||
+ API.CONFIGURATION_PLAIN_XML_DOWNLOAD_PATH_SEGMENT);
|
||||
+ API.CONFIGURATION_SEB_SETTINGS_DOWNLOAD_PATH_SEGMENT);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam;
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.logs;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.MediaType;
|
|
@ -8,33 +8,21 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractExportCall;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractDownloadCall;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class ExportClientConfig extends AbstractExportCall {
|
||||
public class ExportClientConfig extends AbstractDownloadCall {
|
||||
|
||||
public ExportClientConfig() {
|
||||
super(new TypeKey<>(
|
||||
CallType.UNDEFINED,
|
||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||
new TypeReference<InputStream>() {
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
super(MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.SEB_CLIENT_CONFIG_ENDPOINT
|
||||
+ API.SEB_CLIENT_CONFIG_DOWNLOAD_PATH_SEGMENT
|
||||
+ API.MODEL_ID_VAR_PATH_SEGMENT);
|
||||
|
|
|
@ -221,7 +221,7 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
|
|||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = API.MODEL_ID_VAR_PATH_SEGMENT + API.CONFIGURATION_PLAIN_XML_DOWNLOAD_PATH_SEGMENT,
|
||||
path = API.MODEL_ID_VAR_PATH_SEGMENT + API.CONFIGURATION_SEB_SETTINGS_DOWNLOAD_PATH_SEGMENT,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadPlainXMLConfig(
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.webservice.weblayer.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -17,16 +16,11 @@ import java.util.Set;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.dynamic.sql.SqlTable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
@ -73,7 +67,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService;
|
|||
import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamTemplateService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService;
|
||||
|
||||
|
@ -82,14 +75,11 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationSe
|
|||
@RequestMapping("${sebserver.webservice.api.admin.endpoint}" + API.EXAM_ADMINISTRATION_ENDPOINT)
|
||||
public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ExamAdministrationController.class);
|
||||
|
||||
private final ExamDAO examDAO;
|
||||
private final UserDAO userDAO;
|
||||
private final ExamAdminService examAdminService;
|
||||
private final ExamTemplateService examTemplateService;
|
||||
private final LmsAPIService lmsAPIService;
|
||||
private final ExamConfigService sebExamConfigService;
|
||||
private final ExamSessionService examSessionService;
|
||||
private final SEBRestrictionService sebRestrictionService;
|
||||
|
||||
|
@ -104,7 +94,6 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
|||
final UserDAO userDAO,
|
||||
final ExamAdminService examAdminService,
|
||||
final ExamTemplateService examTemplateService,
|
||||
final ExamConfigService sebExamConfigService,
|
||||
final ExamSessionService examSessionService,
|
||||
final SEBRestrictionService sebRestrictionService) {
|
||||
|
||||
|
@ -120,7 +109,6 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
|||
this.examAdminService = examAdminService;
|
||||
this.examTemplateService = examTemplateService;
|
||||
this.lmsAPIService = lmsAPIService;
|
||||
this.sebExamConfigService = sebExamConfigService;
|
||||
this.examSessionService = examSessionService;
|
||||
this.sebRestrictionService = sebRestrictionService;
|
||||
}
|
||||
|
@ -179,46 +167,6 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = API.MODEL_ID_VAR_PATH_SEGMENT
|
||||
+ API.EXAM_ADMINISTRATION_DOWNLOAD_CONFIG_PATH_SEGMENT
|
||||
+ API.PARENT_MODEL_ID_VAR_PATH_SEGMENT,
|
||||
method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadPlainXMLConfig(
|
||||
@PathVariable final Long modelId,
|
||||
@PathVariable final Long parentModelId,
|
||||
@RequestParam(
|
||||
name = API.PARAM_INSTITUTION_ID,
|
||||
required = true,
|
||||
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
||||
final HttpServletResponse response) throws IOException {
|
||||
|
||||
this.entityDAO.byPK(modelId)
|
||||
.flatMap(this.authorization::checkRead)
|
||||
.flatMap(this.userActivityLogDAO::logExport);
|
||||
|
||||
final ServletOutputStream outputStream = response.getOutputStream();
|
||||
|
||||
try {
|
||||
|
||||
this.sebExamConfigService.exportForExam(
|
||||
outputStream,
|
||||
institutionId,
|
||||
parentModelId,
|
||||
modelId);
|
||||
|
||||
response.setStatus(HttpStatus.OK.value());
|
||||
|
||||
} catch (final Exception e) {
|
||||
log.error("Unexpected error while trying to downstream exam config: ", e);
|
||||
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
} finally {
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
path = API.MODEL_ID_VAR_PATH_SEGMENT
|
||||
+ API.EXAM_ADMINISTRATION_CHECK_IMPORTED_PATH_SEGMENT,
|
||||
|
|
|
@ -17,7 +17,7 @@ logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.indicat
|
|||
#logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl=DEBUG
|
||||
#logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis=DEBUG
|
||||
#logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper=DEBUG
|
||||
logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordMapper=DEBUG
|
||||
#logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordMapper=DEBUG
|
||||
#logging.level.ch.ethz.seb.sebserver.webservice.weblayer.api.ExamAPI_V1_Controller=TRACE
|
||||
logging.level.com.zaxxer.hikari=DEBUG
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue