added external server name for GUI component

This commit is contained in:
anhefti 2020-08-20 18:00:10 +02:00
parent feb3836b12
commit 343643b331
4 changed files with 20 additions and 3 deletions

View file

@ -307,7 +307,7 @@ public class MonitoringClientConnection implements TemplateComposer {
final String webserviceServerAddress = this.pageService.getAuthorizationContextHolder()
.getWebserviceURIService()
.getWebserviceServerAddress();
.getExternalServerURL();
final JavaScriptExecutor javaScriptExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
final String script = String.format(OPEN_SINGEL_ROOM_SCRIPT, roomName, webserviceServerAddress, roomName);

View file

@ -14,6 +14,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import io.micrometer.core.instrument.util.StringUtils;
@Component
@GuiProfile
@ -22,13 +23,15 @@ public class WebserviceURIService {
private final String servletContextPath;
private final String webserviceServerAddress;
private final UriComponentsBuilder webserviceURIBuilder;
private final UriComponentsBuilder externaGUIURIBuilder;
public WebserviceURIService(
@Value("${sebserver.gui.webservice.protocol}") final String webserviceProtocol,
@Value("${sebserver.gui.webservice.address}") final String webserviceServerAddress,
@Value("${sebserver.gui.webservice.port}") final String webserviceServerPort,
@Value("${server.servlet.context-path}") final String servletContextPath,
@Value("${sebserver.gui.webservice.apipath}") final String webserviceAPIPath) {
@Value("${sebserver.gui.webservice.apipath}") final String webserviceAPIPath,
@Value("${sebserver.gui.webservice.address.external}") final String externalServerName) {
this.servletContextPath = servletContextPath;
this.webserviceServerAddress =
@ -38,6 +41,19 @@ public class WebserviceURIService {
.port(webserviceServerPort)
.path(servletContextPath)
.path(webserviceAPIPath);
if (StringUtils.isNotBlank(externalServerName)) {
this.externaGUIURIBuilder = UriComponentsBuilder
.fromHttpUrl(webserviceProtocol + "://" + externalServerName)
.port(webserviceServerPort);
} else {
this.externaGUIURIBuilder = UriComponentsBuilder
.fromHttpUrl(webserviceProtocol + "://" + webserviceServerAddress)
.port(webserviceServerPort);
}
}
public String getExternalServerURL() {
return this.externaGUIURIBuilder.toUriString();
}
public String getWebserviceServerAddress() {

View file

@ -16,6 +16,7 @@ sebserver.gui.date.displayformat=de
sebserver.gui.entrypoint=/gui
sebserver.gui.webservice.protocol=http
sebserver.gui.webservice.address=localhost
sebserver.gui.webservice.address.external=${sebserver.webservice.http.external.servername}
sebserver.gui.webservice.port=8080
sebserver.gui.webservice.apipath=${sebserver.webservice.api.admin.endpoint}
# defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page

View file

@ -71,7 +71,7 @@ public abstract class GuiIntegrationTest {
final HttpSession sessionMock = Mockito.mock(HttpSession.class);
final WebserviceURIService webserviceURIService = new WebserviceURIService(
"http", "localhost", "8080", "/", this.endpoint);
"http", "localhost", "8080", "/", this.endpoint, "localhost");
final ClientHttpRequestFactoryService clientHttpRequestFactoryService = Mockito
.mock(ClientHttpRequestFactoryService.class);