Skip to content

Commit a69003a

Browse files
authored
Add dynamic simulation server to gateway (#78)
1 parent 5d73acc commit a69003a

File tree

6 files changed

+49
-1
lines changed

6 files changed

+49
-1
lines changed

src/main/java/org/gridsuite/gateway/GatewayConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public RouteLocator myRoutes(RouteLocatorBuilder builder, ApplicationContext con
5656
.route(p -> context.getBean(SensitivityAnalysisServer.class).getRoute(p))
5757
.route(p -> context.getBean(LoadFlowServer.class).getRoute(p))
5858
.route(p -> context.getBean(SecurityAnalysisServer.class).getRoute(p))
59+
.route(p -> context.getBean(DynamicSimulationServer.class).getRoute(p))
5960
.build();
6061
}
6162
}

src/main/java/org/gridsuite/gateway/ServiceURIsConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ public class ServiceURIsConfig {
9292

9393
@Value("${gridsuite.services.security-analysis-server.base-uri:http://security-analysis-server/}")
9494
String securityAnalysisServerBaseUri;
95+
96+
@Value("${gridsuite.services.dynamic-simulation-server.base-uri:http://dynamic-simulation-server/}")
97+
String dynamicSimulationServerBaseUri;
9598
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
package org.gridsuite.gateway.endpoints;
9+
10+
import org.gridsuite.gateway.ServiceURIsConfig;
11+
import org.springframework.stereotype.Component;
12+
13+
/**
14+
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
15+
*/
16+
@Component(value = DynamicSimulationServer.ENDPOINT_NAME)
17+
public class DynamicSimulationServer implements EndPointServer {
18+
19+
public static final String ENDPOINT_NAME = "dynamic-simulation";
20+
21+
private final ServiceURIsConfig servicesURIsConfig;
22+
23+
public DynamicSimulationServer(ServiceURIsConfig servicesURIsConfig) {
24+
this.servicesURIsConfig = servicesURIsConfig;
25+
}
26+
27+
@Override
28+
public String getEndpointBaseUri() {
29+
return servicesURIsConfig.getDynamicSimulationServerBaseUri();
30+
}
31+
32+
@Override
33+
public String getEndpointName() {
34+
return ENDPOINT_NAME;
35+
}
36+
}

src/main/java/org/gridsuite/gateway/endpoints/StudyServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public String getEndpointName() {
3838
@Override
3939
public Set<String> getUncontrolledRootPaths() {
4040
return Set.of("search", "svg-component-libraries", "export-network-formats", "loadflow-default-provider",
41-
"security-analysis-default-provider", "sensitivity-analysis-default-provider");
41+
"security-analysis-default-provider", "sensitivity-analysis-default-provider", "dynamic-simulation-default-provider");
4242
}
4343
}

src/main/resources/application-local.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ gridsuite:
5454
base-uri: http://localhost:5008
5555
security-analysis-server:
5656
base-uri: http://localhost:5023
57+
dynamic-simulation-server:
58+
base-uri: http://localhost:5032

src/test/java/org/gridsuite/gateway/ElementAccessControlTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public void testWithNoControl() {
133133
stubFor(get(urlEqualTo("/v1/loadflow-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
134134
stubFor(get(urlEqualTo("/v1/security-analysis-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
135135
stubFor(get(urlEqualTo("/v1/sensitivity-analysis-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
136+
stubFor(get(urlEqualTo("/v1/dynamic-simulation-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
136137
webClient
137138
.get().uri("study/v1/search")
138139
.header("Authorization", "Bearer " + tokenUser1)
@@ -163,6 +164,11 @@ public void testWithNoControl() {
163164
.header("Authorization", "Bearer " + tokenUser1)
164165
.exchange()
165166
.expectStatus().isOk();
167+
webClient
168+
.get().uri("study/v1/dynamic-simulation-default-provider")
169+
.header("Authorization", "Bearer " + tokenUser1)
170+
.exchange()
171+
.expectStatus().isOk();
166172
}
167173

168174
@Test

0 commit comments

Comments
 (0)