Skip to content

Commit

Permalink
Handle security analysis parameters. (#71)
Browse files Browse the repository at this point in the history
Signed-off-by: AAJELLAL <[email protected]>
  • Loading branch information
AAJELLAL authored Feb 13, 2024
1 parent adc92d0 commit a90530e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public DirectoryService(
STUDY, studyService,
DIRECTORY, this,
CASE, caseService,
ParametersType.VOLTAGE_INIT_PARAMETERS.name(), parametersService);
ParametersType.VOLTAGE_INIT_PARAMETERS.name(), parametersService,
ParametersType.SECURITY_ANALYSIS_PARAMETERS.name(), parametersService);
}

public void setDirectoryServerBaseUri(String directoryServerBaseUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ParametersService implements IDirectoryElementsService {

private DirectoryService directoryService;

private final Map<ParametersType, String> genericParametersServices = Map.of(ParametersType.VOLTAGE_INIT_PARAMETERS, "voltage-init-server");
private final Map<ParametersType, String> genericParametersServices = Map.of(ParametersType.VOLTAGE_INIT_PARAMETERS, "voltage-init-server", ParametersType.SECURITY_ANALYSIS_PARAMETERS, "security-analysis-server");

private RemoteServicesProperties remoteServicesProperties;

Expand Down Expand Up @@ -86,12 +86,11 @@ public void updateParameters(UUID parametersUuid, String parameters, ParametersT
public UUID createParameters(UUID sourceParametersUuid, ParametersType parametersType) {
String parametersServerBaseUri = remoteServicesProperties.getServiceUri(genericParametersServices.get(parametersType));
Objects.requireNonNull(sourceParametersUuid);

String urlParams = parametersType == ParametersType.VOLTAGE_INIT_PARAMETERS ? "?" + HEADER_DUPLICATE_FROM + "=" + sourceParametersUuid : "/" + sourceParametersUuid;
var path = UriComponentsBuilder
.fromPath(DELIMITER + SERVER_API_VERSION + "/parameters")
.queryParam(HEADER_DUPLICATE_FROM, sourceParametersUuid)
.toUriString();

.fromPath(DELIMITER + SERVER_API_VERSION + "/parameters" + urlParams)
.buildAndExpand()
.toUriString();
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> httpEntity = new HttpEntity<>(headers);
return restTemplate.exchange(parametersServerBaseUri + path, HttpMethod.POST, httpEntity, UUID.class).getBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
public enum ParametersType {

VOLTAGE_INIT_PARAMETERS,
SECURITY_ANALYSIS_PARAMETERS

}
4 changes: 3 additions & 1 deletion src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ gridsuite:
-
name: voltage-init-server
base-uri: http://localhost:5038

-
name: security-analysis-server
base-uri: http://localhost:5023

0 comments on commit a90530e

Please sign in to comment.