Skip to content

Commit f3554fc

Browse files
committed
refactor: create thymeleaf module and update existing
1 parent ca35cd6 commit f3554fc

158 files changed

Lines changed: 5773 additions & 357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
<module>steve-ocpp-2-x</module>
2424
<module>steve-ocpp-soap</module>
2525
<module>steve-ocpp-websocket</module>
26+
<module>steve-ui</module>
2627
<module>steve-ui-jsp</module>
28+
<module>steve-ui-thymeleaf</module>
2729
</modules>
2830

2931
<properties>
@@ -85,11 +87,21 @@
8587
<artifactId>steve-api</artifactId>
8688
<version>${project.version}</version>
8789
</dependency>
90+
<dependency>
91+
<groupId>de.rwth.idsg</groupId>
92+
<artifactId>steve-ui</artifactId>
93+
<version>${project.version}</version>
94+
</dependency>
8895
<dependency>
8996
<groupId>de.rwth.idsg</groupId>
9097
<artifactId>steve-ui-jsp</artifactId>
9198
<version>${project.version}</version>
9299
</dependency>
100+
<dependency>
101+
<groupId>de.rwth.idsg</groupId>
102+
<artifactId>steve-ui-thymeleaf</artifactId>
103+
<version>${project.version}</version>
104+
</dependency>
93105
<dependency>
94106
<groupId>org.springframework</groupId>
95107
<artifactId>spring-framework-bom</artifactId>
@@ -104,6 +116,13 @@
104116
<type>pom</type>
105117
<scope>import</scope>
106118
</dependency>
119+
<dependency>
120+
<groupId>org.eclipse.jetty.ee10</groupId>
121+
<artifactId>jetty-ee10-bom</artifactId>
122+
<version>${jetty.version}</version>
123+
<type>pom</type>
124+
<scope>import</scope>
125+
</dependency>
107126
<dependency>
108127
<groupId>org.junit</groupId>
109128
<artifactId>junit-bom</artifactId>

steve-core/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<groupId>org.slf4j</groupId>
5959
<artifactId>slf4j-api</artifactId>
6060
</dependency>
61+
<dependency>
62+
<groupId>ch.qos.logback</groupId>
63+
<artifactId>logback-classic</artifactId>
64+
</dependency>
6165

6266
<dependency>
6367
<groupId>com.google.guava</groupId>
@@ -67,5 +71,9 @@
6771
<groupId>com.neovisionaries</groupId>
6872
<artifactId>nv-i18n</artifactId>
6973
</dependency>
74+
<dependency>
75+
<groupId>org.eclipse.jetty.ee10</groupId>
76+
<artifactId>jetty-ee10-webapp</artifactId>
77+
</dependency>
7078
</dependencies>
7179
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
3+
* Copyright (C) 2013-2025 SteVe Community Team
4+
* All Rights Reserved.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
package de.rwth.idsg.steve;
20+
21+
import org.eclipse.jetty.ee10.webapp.WebAppContext;
22+
23+
public interface JettyCustomizer {
24+
void configure(WebAppContext ctx);
25+
}

steve-core/src/main/java/de/rwth/idsg/steve/SteveConfiguration.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public static class Paths {
4848
private final String routerEndpointPath;
4949

5050
private final @Nullable String contextPath;
51+
52+
public String getLocation() {
53+
return contextPath + managerMapping + "/home";
54+
}
55+
56+
public String getWsPathInfix() {
57+
return routerEndpointPath + websocketMapping;
58+
}
5159
}
5260

5361
private final Paths paths;

steve-core/src/main/java/de/rwth/idsg/steve/utils/DateTimeUtils.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.time.OffsetDateTime;
2929
import java.time.ZoneId;
3030
import java.time.ZoneOffset;
31-
import java.time.ZonedDateTime;
3231
import java.time.format.DateTimeFormatter;
3332

3433
/**
@@ -149,9 +148,4 @@ public static String timeElapsed(Instant from, Instant to) {
149148

150149
return sb.toString().trim();
151150
}
152-
153-
public static long getOffsetFromUtcInSeconds() {
154-
var offset = ZonedDateTime.now().getOffset();
155-
return offset.getTotalSeconds();
156-
}
157151
}

steve-ui-jsp/src/main/java/de/rwth/idsg/steve/utils/LogFileRetriever.java renamed to steve-core/src/main/java/de/rwth/idsg/steve/utils/LogFileRetriever.java

File renamed without changes.

steve-ocpp-websocket/src/main/java/de/rwth/idsg/steve/config/OcppWebSocketConfiguration.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package de.rwth.idsg.steve.config;
2020

2121
import com.google.common.collect.Lists;
22+
import de.rwth.idsg.steve.SteveConfiguration;
2223
import de.rwth.idsg.steve.ocpp.ws.OcppWebSocketHandshakeHandler;
2324
import de.rwth.idsg.steve.ocpp.ws.ocpp12.Ocpp12WebSocketEndpoint;
2425
import de.rwth.idsg.steve.ocpp.ws.ocpp15.Ocpp15WebSocketEndpoint;
@@ -45,13 +46,13 @@
4546
@RequiredArgsConstructor
4647
public class OcppWebSocketConfiguration implements WebSocketConfigurer {
4748

48-
public static final String PATH_INFIX = "/websocket/CentralSystemService/";
49-
public static final Duration PING_INTERVAL = Duration.ofMinutes(15);
50-
public static final Duration IDLE_TIMEOUT = Duration.ofHours(2);
51-
public static final int MAX_MSG_SIZE = 8_388_608; // 8 MB for max message size
49+
public static final Duration WS_PING_INTERVAL = Duration.ofMinutes(15);
50+
public static final Duration WS_IDLE_TIMEOUT = Duration.ofHours(2);
51+
public static final int WS_MAX_MSG_SIZE = 8_388_608; // 8 MB for max message size
5252

5353
private final ChargePointRegistrationService chargePointRegistrationService;
5454
private final ChargeBoxIdValidator chargeBoxIdValidator;
55+
private final SteveConfiguration config;
5556

5657
private final Ocpp12WebSocketEndpoint ocpp12WebSocketEndpoint;
5758
private final Ocpp15WebSocketEndpoint ocpp15WebSocketEndpoint;
@@ -60,13 +61,16 @@ public class OcppWebSocketConfiguration implements WebSocketConfigurer {
6061
@Override
6162
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
6263

63-
OcppWebSocketHandshakeHandler handshakeHandler = new OcppWebSocketHandshakeHandler(
64+
var handshakeHandler = new OcppWebSocketHandshakeHandler(
6465
chargeBoxIdValidator,
6566
new DefaultHandshakeHandler(),
6667
Lists.newArrayList(ocpp16WebSocketEndpoint, ocpp15WebSocketEndpoint, ocpp12WebSocketEndpoint),
67-
chargePointRegistrationService);
68+
chargePointRegistrationService,
69+
config.getPaths().getWsPathInfix() + "/");
6870

69-
registry.addHandler(handshakeHandler.getDummyWebSocketHandler(), PATH_INFIX + "*")
71+
registry.addHandler(
72+
handshakeHandler.getDummyWebSocketHandler(),
73+
config.getPaths().getWsPathInfix() + "/*")
7074
.setHandshakeHandler(handshakeHandler)
7175
.setAllowedOrigins("*");
7276
}

steve-ocpp-websocket/src/main/java/de/rwth/idsg/steve/ocpp/ws/AbstractWebSocketEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ public void onOpen(WebSocketSession session) throws Exception {
130130
// the connection because of a idle timeout, we ping-pong at fixed intervals.
131131
var pingSchedule = asyncTaskScheduler.scheduleAtFixedRate(
132132
new PingTask(chargeBoxId, session),
133-
Instant.now().plus(OcppWebSocketConfiguration.PING_INTERVAL),
134-
OcppWebSocketConfiguration.PING_INTERVAL);
133+
Instant.now().plus(OcppWebSocketConfiguration.WS_PING_INTERVAL),
134+
OcppWebSocketConfiguration.WS_PING_INTERVAL);
135135

136136
futureResponseContextStore.addSession(session);
137137

steve-ocpp-websocket/src/main/java/de/rwth/idsg/steve/ocpp/ws/ConcurrentWebSocketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public abstract class ConcurrentWebSocketHandler implements WebSocketHandler {
3737

3838
private static final int SEND_TIME_LIMIT = (int) TimeUnit.SECONDS.toMillis(10);
39-
private static final int BUFFER_SIZE_LIMIT = 5 * OcppWebSocketConfiguration.MAX_MSG_SIZE;
39+
private static final int BUFFER_SIZE_LIMIT = 5 * OcppWebSocketConfiguration.WS_MAX_MSG_SIZE;
4040

4141
private final Map<String, ConcurrentWebSocketSessionDecorator> sessions = new ConcurrentHashMap<>();
4242

steve-ocpp-websocket/src/main/java/de/rwth/idsg/steve/ocpp/ws/OcppWebSocketHandshakeHandler.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package de.rwth.idsg.steve.ocpp.ws;
2020

2121
import com.google.common.base.Strings;
22-
import de.rwth.idsg.steve.config.OcppWebSocketConfiguration;
2322
import de.rwth.idsg.steve.service.ChargePointRegistrationService;
2423
import de.rwth.idsg.steve.web.validation.ChargeBoxIdValidator;
2524
import lombok.RequiredArgsConstructor;
@@ -51,6 +50,7 @@ public class OcppWebSocketHandshakeHandler implements HandshakeHandler {
5150
private final DefaultHandshakeHandler delegate;
5251
private final List<AbstractWebSocketEndpoint> endpoints;
5352
private final ChargePointRegistrationService chargePointRegistrationService;
53+
private final String wsPathInfix;
5454

5555
/**
5656
* We need some WebSocketHandler just for Spring to register it for the path. We will not use it for the actual
@@ -73,7 +73,7 @@ public boolean doHandshake(
7373
// 1. Check the chargeBoxId
7474
// -------------------------------------------------------------------------
7575

76-
var chargeBoxId = getLastBitFromUrl(request.getURI().getPath());
76+
var chargeBoxId = getLastBitFromUrl(wsPathInfix, request.getURI().getPath());
7777
var isValid = chargeBoxIdValidator.isValid(chargeBoxId);
7878
if (!isValid) {
7979
log.error("ChargeBoxId '{}' violates the configured pattern.", chargeBoxId);
@@ -133,17 +133,15 @@ public boolean doHandshake(
133133
return null;
134134
}
135135

136-
public static String getLastBitFromUrl(final String input) {
136+
public static String getLastBitFromUrl(String path, String input) {
137137
if (Strings.isNullOrEmpty(input)) {
138138
return "";
139139
}
140140

141-
var substring = OcppWebSocketConfiguration.PATH_INFIX;
142-
143-
var index = input.indexOf(substring);
141+
var index = input.indexOf(path);
144142
if (index == -1) {
145143
return "";
146144
}
147-
return input.substring(index + substring.length());
145+
return input.substring(index + path.length());
148146
}
149147
}

0 commit comments

Comments
 (0)