Skip to content

Commit 236af92

Browse files
authored
Add loadflow an security analysis server to gateway (#74)
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
1 parent 99a9616 commit 236af92

File tree

7 files changed

+96
-2
lines changed

7 files changed

+96
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public RouteLocator myRoutes(RouteLocatorBuilder builder, ApplicationContext con
5454
.route(p -> context.getBean(UserAdminServer.class).getRoute(p))
5555
.route(p -> context.getBean(CgmesGlServer.class).getRoute(p))
5656
.route(p -> context.getBean(SensitivityAnalysisServer.class).getRoute(p))
57+
.route(p -> context.getBean(LoadFlowServer.class).getRoute(p))
58+
.route(p -> context.getBean(SecurityAnalysisServer.class).getRoute(p))
5759
.build();
5860
}
5961
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,9 @@ public class ServiceURIsConfig {
8787
@Value("${gridsuite.services.sensitivity-analysis-server.base-uri:http://sensitivity-analysis-server/}")
8888
String sensitivityAnalysisServerBaseUri;
8989

90+
@Value("${gridsuite.services.loadflow-server.base-uri:http://loadflow-server/}")
91+
String loadFlowServerBaseUri;
92+
93+
@Value("${gridsuite.services.security-analysis-server.base-uri:http://security-analysis-server/}")
94+
String securityAnalysisServerBaseUri;
9095
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
package org.gridsuite.gateway.endpoints;
8+
9+
import org.gridsuite.gateway.ServiceURIsConfig;
10+
import org.springframework.stereotype.Component;
11+
12+
/**
13+
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
14+
*/
15+
@Component(value = LoadFlowServer.ENDPOINT_NAME)
16+
public class LoadFlowServer implements EndPointServer {
17+
18+
public static final String ENDPOINT_NAME = "loadflow";
19+
20+
private final ServiceURIsConfig servicesURIsConfig;
21+
22+
public LoadFlowServer(ServiceURIsConfig servicesURIsConfig) {
23+
this.servicesURIsConfig = servicesURIsConfig;
24+
}
25+
26+
@Override
27+
public String getEndpointBaseUri() {
28+
return servicesURIsConfig.getLoadFlowServerBaseUri();
29+
}
30+
31+
@Override
32+
public String getEndpointName() {
33+
return ENDPOINT_NAME;
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
package org.gridsuite.gateway.endpoints;
8+
9+
import org.gridsuite.gateway.ServiceURIsConfig;
10+
import org.springframework.stereotype.Component;
11+
12+
/**
13+
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
14+
*/
15+
@Component(value = SecurityAnalysisServer.ENDPOINT_NAME)
16+
public class SecurityAnalysisServer implements EndPointServer {
17+
18+
public static final String ENDPOINT_NAME = "security-analysis";
19+
20+
private final ServiceURIsConfig servicesURIsConfig;
21+
22+
public SecurityAnalysisServer(ServiceURIsConfig servicesURIsConfig) {
23+
this.servicesURIsConfig = servicesURIsConfig;
24+
}
25+
26+
@Override
27+
public String getEndpointBaseUri() {
28+
return servicesURIsConfig.getSecurityAnalysisServerBaseUri();
29+
}
30+
31+
@Override
32+
public String getEndpointName() {
33+
return ENDPOINT_NAME;
34+
}
35+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public String getEndpointName() {
3737

3838
@Override
3939
public Set<String> getUncontrolledRootPaths() {
40-
return Set.of("search", "svg-component-libraries", "export-network-formats", "loadflow-default-provider");
40+
return Set.of("search", "svg-component-libraries", "export-network-formats", "loadflow-default-provider",
41+
"security-analysis-default-provider", "sensitivity-analysis-default-provider");
4142
}
4243
}

src/main/resources/application-local.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ gridsuite:
5050
base-uri: http://localhost:8095
5151
sensitivity-analysis-server:
5252
base-uri: http://localhost:5030
53-
53+
loadflow-server:
54+
base-uri: http://localhost:5008
55+
security-analysis-server:
56+
base-uri: http://localhost:5023

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ public void testWithNoControl() {
130130
stubFor(get(urlEqualTo("/v1/svg-component-libraries")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
131131
stubFor(get(urlEqualTo("/v1/export-network-formats")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
132132
stubFor(get(urlEqualTo("/v1/loadflow-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
133+
stubFor(get(urlEqualTo("/v1/loadflow-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
134+
stubFor(get(urlEqualTo("/v1/security-analysis-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
135+
stubFor(get(urlEqualTo("/v1/sensitivity-analysis-default-provider")).withHeader("userId", equalTo("user1")).willReturn(aResponse()));
133136
webClient
134137
.get().uri("study/v1/search")
135138
.header("Authorization", "Bearer " + tokenUser1)
@@ -150,6 +153,16 @@ public void testWithNoControl() {
150153
.header("Authorization", "Bearer " + tokenUser1)
151154
.exchange()
152155
.expectStatus().isOk();
156+
webClient
157+
.get().uri("study/v1/security-analysis-default-provider")
158+
.header("Authorization", "Bearer " + tokenUser1)
159+
.exchange()
160+
.expectStatus().isOk();
161+
webClient
162+
.get().uri("study/v1/sensitivity-analysis-default-provider")
163+
.header("Authorization", "Bearer " + tokenUser1)
164+
.exchange()
165+
.expectStatus().isOk();
153166
}
154167

155168
@Test

0 commit comments

Comments
 (0)