Skip to content

Commit 4fcdf56

Browse files
AbdelHedhilijonenst
andcommitted
springboot 3.1.2 (#344)
Signed-off-by: Abdelsalem <[email protected]> Co-authored-by: HARPER Jon <[email protected]>
1 parent 2442ae3 commit 4fcdf56

File tree

20 files changed

+82
-40
lines changed

20 files changed

+82
-40
lines changed

network-store-client/pom.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,21 @@
4141
<groupId>org.springframework</groupId>
4242
<artifactId>spring-web</artifactId>
4343
</dependency>
44-
4544
<dependency>
4645
<groupId>org.jgrapht</groupId>
4746
<artifactId>jgrapht-core</artifactId>
4847
</dependency>
48+
<dependency>
49+
<groupId>org.slf4j</groupId>
50+
<artifactId>slf4j-api</artifactId>
51+
<version>${slf4j.version}</version>
52+
</dependency>
4953

5054
<!-- runtime scope -->
5155
<dependency>
5256
<groupId>org.slf4j</groupId>
5357
<artifactId>log4j-over-slf4j</artifactId>
58+
<version>${slf4j.version}</version>
5459
<scope>runtime</scope>
5560
</dependency>
5661

network-store-client/src/main/java/com/powsybl/network/store/client/NetworkStoreService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import org.springframework.beans.factory.annotation.Value;
3333
import org.springframework.stereotype.Service;
3434

35-
import javax.annotation.PostConstruct;
36-
import javax.annotation.PreDestroy;
35+
import jakarta.annotation.PostConstruct;
36+
import jakarta.annotation.PreDestroy;
3737
import java.nio.file.Path;
3838
import java.util.*;
3939
import java.util.concurrent.ExecutorService;

network-store-client/src/main/java/com/powsybl/network/store/client/RestClientImpl.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
*/
77
package com.powsybl.network.store.client;
88

9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
import com.fasterxml.jackson.datatype.joda.JodaModule;
911
import com.powsybl.commons.PowsyblException;
1012
import com.powsybl.network.store.model.*;
1113
import org.springframework.beans.factory.annotation.Autowired;
1214
import org.springframework.boot.web.client.RestTemplateBuilder;
1315
import org.springframework.core.ParameterizedTypeReference;
1416
import org.springframework.http.*;
17+
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
1518
import org.springframework.web.client.RestTemplate;
1619
import org.springframework.web.util.DefaultUriBuilderFactory;
1720
import org.springframework.web.util.UriComponentsBuilder;
@@ -37,11 +40,22 @@ public RestClientImpl(RestTemplateBuilder restTemplateBuilder) {
3740
}
3841

3942
public static RestTemplateBuilder createRestTemplateBuilder(String baseUri) {
40-
return new RestTemplateBuilder()
41-
.uriTemplateHandler(new DefaultUriBuilderFactory(UriComponentsBuilder.fromUriString(baseUri)
43+
return new RestTemplateBuilder(restTemplate1 -> restTemplate1.setMessageConverters(List.of(createMapping()))).uriTemplateHandler(new DefaultUriBuilderFactory(UriComponentsBuilder.fromUriString(baseUri)
4244
.path(NetworkStoreApi.VERSION)));
4345
}
4446

47+
private static ObjectMapper createObjectMapper() {
48+
ObjectMapper objectMapper = new ObjectMapper();
49+
objectMapper.registerModule(new JodaModule());
50+
return objectMapper;
51+
}
52+
53+
private static MappingJackson2HttpMessageConverter createMapping() {
54+
var converter = new MappingJackson2HttpMessageConverter();
55+
converter.setObjectMapper(createObjectMapper());
56+
return converter;
57+
}
58+
4559
private <T extends IdentifiableAttributes> ResponseEntity<TopLevelDocument<T>> getDocument(String url, Object... uriVariables) {
4660
return restTemplate.exchange(url,
4761
HttpMethod.GET,
@@ -59,8 +73,8 @@ private static <T extends IdentifiableAttributes> TopLevelDocument<T> getBody(Re
5973
return body;
6074
}
6175

62-
private static PowsyblException createHttpException(String url, String method, HttpStatus httpStatus) {
63-
return new PowsyblException("Fail to " + method + " at " + url + ", status: " + httpStatus);
76+
private static PowsyblException createHttpException(String url, String method, HttpStatusCode httpStatusCode) {
77+
return new PowsyblException("Fail to " + method + " at " + url + ", status: " + httpStatusCode);
6478
}
6579

6680
@Override

network-store-client/src/main/java/com/powsybl/network/store/client/RestNetworkStoreClient.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package com.powsybl.network.store.client;
99

1010
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.datatype.joda.JodaModule;
1112
import com.google.common.base.Stopwatch;
1213
import com.google.common.collect.Lists;
1314
import com.powsybl.commons.PowsyblException;
@@ -46,6 +47,8 @@ public RestNetworkStoreClient(RestClient restClient) {
4647
public RestNetworkStoreClient(RestClient restClient, ObjectMapper objectMapper) {
4748
this.restClient = Objects.requireNonNull(restClient);
4849
this.objectMapper = Objects.requireNonNull(objectMapper);
50+
objectMapper.registerModule(new JodaModule());
51+
4952
}
5053

5154
// network
@@ -234,7 +237,7 @@ public Optional<Resource<SubstationAttributes>> getSubstation(UUID networkUuid,
234237

235238
@Override
236239
public void updateSubstations(UUID networkUuid, List<Resource<SubstationAttributes>> substationResources, AttributeFilter attributeFilter) {
237-
updateAll("substation", "/networks/{networkUuid}/substations/", substationResources, attributeFilter, networkUuid);
240+
updateAll("substation", "/networks/{networkUuid}/substations", substationResources, attributeFilter, networkUuid);
238241
}
239242

240243
public void removeSubstations(UUID networkUuid, int variantNum, List<String> substationsId) {

network-store-client/src/main/java/com/powsybl/network/store/client/RestTemplateResponseErrorHandler.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,23 @@
1919
import java.nio.charset.StandardCharsets;
2020
import java.util.Optional;
2121

22-
import static org.springframework.http.HttpStatus.Series.CLIENT_ERROR;
23-
import static org.springframework.http.HttpStatus.Series.SERVER_ERROR;
24-
2522
/**
2623
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
2724
*/
2825
public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
2926

3027
@Override
3128
public boolean hasError(ClientHttpResponse response) throws IOException {
32-
return response.getStatusCode().series() == CLIENT_ERROR
33-
|| response.getStatusCode().series() == SERVER_ERROR;
29+
return response.getStatusCode().is4xxClientError()
30+
|| response.getStatusCode().is5xxServerError();
3431
}
3532

3633
@Override
3734
public void handleError(ClientHttpResponse response) throws IOException {
38-
if (response.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) {
35+
if (response.getStatusCode().is5xxServerError()) {
3936
throw new HttpServerErrorException(response.getStatusCode(), response.getStatusText(),
4037
response.getBody().readAllBytes(), StandardCharsets.UTF_8);
41-
} else if (response.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR) {
38+
} else if (response.getStatusCode().is4xxClientError()) {
4239
if (response.getStatusCode() != HttpStatus.NOT_FOUND) {
4340
throw new HttpClientErrorException(response.getStatusCode(), response.getStatusText(),
4441
response.getBody().readAllBytes(), StandardCharsets.UTF_8);

network-store-client/src/test/java/com/powsybl/network/store/client/RestNetworkStoreClientTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package com.powsybl.network.store.client;
99

1010
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.datatype.joda.JodaModule;
1112
import com.google.common.collect.ImmutableList;
1213
import com.powsybl.commons.PowsyblException;
1314
import com.powsybl.iidm.network.*;
@@ -68,6 +69,7 @@ public class RestNetworkStoreClientTest {
6869

6970
@Before
7071
public void setUp() throws IOException {
72+
objectMapper.registerModule(new JodaModule());
7173
Resource<NetworkAttributes> n1 = Resource.networkBuilder()
7274
.id("n1")
7375
.attributes(NetworkAttributes.builder()

network-store-iidm-impl/pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@
6868
<dependency>
6969
<groupId>org.slf4j</groupId>
7070
<artifactId>log4j-over-slf4j</artifactId>
71+
<version>${slf4j.version}</version>
7172
<scope>test</scope>
7273
</dependency>
7374
<dependency>
7475
<groupId>org.slf4j</groupId>
7576
<artifactId>slf4j-simple</artifactId>
77+
<version>${slf4j.version}</version>
7678
<scope>test</scope>
7779
</dependency>
7880

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/AbstractBranchAdder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected void checkNodeBus1() {
9191

9292
private String getConnectionBus1() {
9393
if (bus1 != null) {
94-
if ((connectableBus1 != null) && (!bus1.equals(connectableBus1))) {
94+
if (!bus1.equals(connectableBus1)) {
9595
throw new ValidationException(this, "connection bus 1 is different to connectable bus 1");
9696
}
9797
return bus1;
@@ -172,7 +172,7 @@ protected void checkNodeBus2() {
172172

173173
private String getConnectionBus2() {
174174
if (bus2 != null) {
175-
if ((connectableBus2 != null) && (!bus2.equals(connectableBus2))) {
175+
if (connectableBus2 != null && !bus2.equals(connectableBus2)) {
176176
throw new ValidationException(this, "connection bus 2 is different to connectable bus 2");
177177
}
178178
return bus2;

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/AbstractInjectionAdder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void checkNode() {
100100

101101
private String getConnectionBus() {
102102
if (bus != null) {
103-
if ((connectableBus != null) && (!bus.equals(connectableBus))) {
103+
if (connectableBus != null && !bus.equals(connectableBus)) {
104104
throw new ValidationException(this, "connection bus is different to connectable bus");
105105
}
106106
return bus;

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/NodeBreakerTopology.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ protected boolean isCalculatedBusValid(Set<Integer> nodesOrBusesConnected, Map<I
9494
EquipmentCount<Integer> equipmentCount = new EquipmentCount<>();
9595
equipmentCount.count(nodesOrBusesConnected, verticesByNodeOrBus);
9696
return !isBusView ? !nodesOrBusesConnected.isEmpty() :
97-
(equipmentCount.busbarSectionCount >= 1 && equipmentCount.feederCount >= 1)
98-
|| (equipmentCount.branchCount >= 1 && equipmentCount.feederCount >= 2);
97+
equipmentCount.busbarSectionCount >= 1 && equipmentCount.feederCount >= 1
98+
|| equipmentCount.branchCount >= 1 && equipmentCount.feederCount >= 2;
9999
}
100100

101101
@Override

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/NodeBreakerViewImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ public int getInternalConnectionCount() {
370370
@Override
371371
public void removeInternalConnections(int node1, int node2) {
372372
if (!getVoltageLevelResource().getAttributes().getInternalConnections()
373-
.removeIf(attributes -> (attributes.getNode1() == node1 && attributes.getNode2() == node2) ||
374-
(attributes.getNode1() == node2 && attributes.getNode2() == node1))) {
373+
.removeIf(attributes -> attributes.getNode1() == node1 && attributes.getNode2() == node2 ||
374+
attributes.getNode1() == node2 && attributes.getNode2() == node1)) {
375375
throw new PowsyblException("Internal connection not found between " + node1 + " and " + node2);
376376
}
377377
}

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/SubstationUtil.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private static void checkRemovability(Substation substation, Branch branch) {
3939
Objects.requireNonNull(branch);
4040
Substation s1 = branch.getTerminal1().getVoltageLevel().getSubstation().orElse(null);
4141
Substation s2 = branch.getTerminal2().getVoltageLevel().getSubstation().orElse(null);
42-
if ((s1 != substation) || (s2 != substation)) {
42+
if (s1 != substation || s2 != substation) {
4343
throw createIsolationException(substation);
4444
}
4545
}
@@ -50,7 +50,7 @@ private static void checkRemovability(Substation substation, ThreeWindingsTransf
5050
Substation s1 = twt.getLeg1().getTerminal().getVoltageLevel().getSubstation().orElse(null);
5151
Substation s2 = twt.getLeg2().getTerminal().getVoltageLevel().getSubstation().orElse(null);
5252
Substation s3 = twt.getLeg3().getTerminal().getVoltageLevel().getSubstation().orElse(null);
53-
if ((s1 != substation) || (s2 != substation) || (s3 != substation)) {
53+
if (s1 != substation || s2 != substation || s3 != substation) {
5454
throw createIsolationException(substation);
5555
}
5656
}
@@ -62,7 +62,7 @@ private static void checkRemovability(Substation substation, HvdcConverterStatio
6262
if (hvdcLine != null) {
6363
Substation s1 = hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getSubstation().orElse(null);
6464
Substation s2 = hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getSubstation().orElse(null);
65-
if ((s1 != substation) || (s2 != substation)) {
65+
if (s1 != substation || s2 != substation) {
6666
throw createIsolationException(substation);
6767
}
6868
}

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public boolean isConnected() {
348348
return this.getBusView().getBus() != null;
349349
} else {
350350
var attributes = getAttributes();
351-
return (attributes.getBus() != null) && attributes.getBus().equals(attributes.getConnectableBus());
351+
return attributes.getBus() != null && attributes.getBus().equals(attributes.getConnectableBus());
352352
}
353353
}
354354

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ThreeWindingsTransformerAdderImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected void checkParams() {
136136

137137
private String getConnectionBus() {
138138
if (bus != null) {
139-
if ((connectableBus != null) && (!bus.equals(connectableBus))) {
139+
if (connectableBus != null && !bus.equals(connectableBus)) {
140140
throw new ValidationException(this, "connection bus leg " + legNumber + " is different to connectable bus");
141141
}
142142
return bus;

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/VoltageLevelUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void checkRemovability(VoltageLevel voltageLevel) {
2323
if (MULTIPLE_TERMINALS_CONNECTABLE_TYPES.contains(type)) {
2424
// Reject lines, 2WT and 3WT
2525
throw new AssertionError("The voltage level '" + voltageLevel.getId() + "' cannot be removed because of a remaining " + type);
26-
} else if ((type == IdentifiableType.HVDC_CONVERTER_STATION) && (network.getHvdcLine((HvdcConverterStation<?>) connectable) != null)) {
26+
} else if (type == IdentifiableType.HVDC_CONVERTER_STATION && network.getHvdcLine((HvdcConverterStation<?>) connectable) != null) {
2727
// Reject all converter stations connected to a HVDC line
2828
throw new AssertionError("The voltage level '" + voltageLevel.getId() + "' cannot be removed because of a remaining HVDC line");
2929
}

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/HvdcOperatorActivePowerRangeImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public HvdcOperatorActivePowerRangeImpl setOprFromCS2toCS1(float oprFromCS2toCS1
6060
}
6161

6262
private float checkOPR(float opr, HvdcConverterStation<?> from, HvdcConverterStation<?> to) {
63-
if ((!Float.isNaN(opr)) && (opr < 0)) {
63+
if (!Float.isNaN(opr) && opr < 0) {
6464
String message = "OPR from " + from.getId() + " to " + to.getId() + " must be greater than 0 (current value " + opr + ").";
6565
throw new IllegalArgumentException(message);
6666
}

network-store-model/pom.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<name>Network store model</name>
2121

2222
<properties>
23-
<swagger-annotations.version>2.1.10</swagger-annotations.version>
23+
<swagger-annotations.version>2.2.9</swagger-annotations.version>
2424
</properties>
2525

2626
<build>
@@ -56,9 +56,9 @@
5656
<artifactId>jackson-datatype-joda</artifactId>
5757
</dependency>
5858
<dependency>
59-
<groupId>io.swagger.core.v3</groupId>
60-
<artifactId>swagger-annotations</artifactId>
61-
<version>${swagger-annotations.version}</version>
59+
<groupId>io.swagger.core.v3</groupId>
60+
<artifactId>swagger-annotations-jakarta</artifactId>
61+
<version>${swagger-annotations.version}</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>org.apache.commons</groupId>
@@ -90,6 +90,7 @@
9090
<dependency>
9191
<groupId>org.slf4j</groupId>
9292
<artifactId>slf4j-simple</artifactId>
93+
<version>${slf4j.version}</version>
9394
<scope>test</scope>
9495
</dependency>
9596
</dependencies>

network-store-model/src/main/java/com/powsybl/network/store/model/ReactiveLimitsAttributes.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
include = JsonTypeInfo.As.PROPERTY,
2020
property = "type")
2121
@JsonSubTypes({
22-
@JsonSubTypes.Type(value = ReactiveCapabilityCurveAttributes.class, name = "ReactiveCapabilityCurve"),
23-
@JsonSubTypes.Type(value = MinMaxReactiveLimitsAttributes.class, name = "MinMaxReactiveLimits")
22+
@JsonSubTypes.Type(value = ReactiveCapabilityCurveAttributes.class, name = "ReactiveCapabilityCurve"),
23+
@JsonSubTypes.Type(value = MinMaxReactiveLimitsAttributes.class, name = "MinMaxReactiveLimits")
2424
})
2525
@JsonInclude(JsonInclude.Include.NON_NULL)
2626
public interface ReactiveLimitsAttributes {

network-store-model/src/main/java/com/powsybl/network/store/model/ShuntCompensatorModelAttributes.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
include = JsonTypeInfo.As.PROPERTY,
2020
property = "type")
2121
@JsonSubTypes({
22-
@JsonSubTypes.Type(value = ShuntCompensatorLinearModelAttributes.class, name = "LinearModel"),
23-
@JsonSubTypes.Type(value = ShuntCompensatorNonLinearModelAttributes.class, name = "NonLinearModel")
22+
@JsonSubTypes.Type(value = ShuntCompensatorLinearModelAttributes.class, name = "LinearModel"),
23+
@JsonSubTypes.Type(value = ShuntCompensatorNonLinearModelAttributes.class, name = "NonLinearModel")
2424
})
2525
@JsonInclude(JsonInclude.Include.NON_NULL)
2626
public interface ShuntCompensatorModelAttributes {

pom.xml

+21-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<groupId>com.powsybl</groupId>
1515
<artifactId>powsybl-parent</artifactId>
16-
<version>12</version>
16+
<version>15</version>
1717
<relativePath/>
1818
</parent>
1919

@@ -47,11 +47,12 @@
4747
</developers>
4848

4949
<properties>
50-
<springboot.version>2.7.3</springboot.version>
50+
<springboot.version>3.1.2</springboot.version>
5151
<commons-lang3.version>3.9</commons-lang3.version>
5252
<powsybl-dependencies.version>2023.2.1</powsybl-dependencies.version>
5353
<powsybl-ws-commons.version>1.5.0</powsybl-ws-commons.version>
54-
54+
<slf4j.version>2.0.4</slf4j.version>
55+
<logback.version>1.4.5</logback.version>
5556
<sonar.coverage.jacoco.xmlReportPaths>
5657
../network-store-client-distribution/target/site/jacoco-aggregate/jacoco.xml,
5758
../../network-store-client-distributiont/target/site/jacoco-aggregate/jacoco.xml,
@@ -86,6 +87,23 @@
8687
<scope>import</scope>
8788
</dependency>
8889

90+
<!-- Force compatible version with springboot 3 that is otherwise set by powsybl -->
91+
<dependency>
92+
<groupId>ch.qos.logback</groupId>
93+
<artifactId>logback-classic</artifactId>
94+
<version>${logback.version}</version>
95+
</dependency>
96+
<dependency>
97+
<groupId>ch.qos.logback</groupId>
98+
<artifactId>logback-core</artifactId>
99+
<version>${logback.version}</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.slf4j</groupId>
103+
<artifactId>slf4j-api</artifactId>
104+
<version>${slf4j.version}</version>
105+
</dependency>
106+
89107
<!-- project specific dependencies (also overrides imports, but separate for clarity) -->
90108
<dependency>
91109
<groupId>com.powsybl</groupId>

0 commit comments

Comments
 (0)