Skip to content

Use Spotless #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
![SteVe](src/main/resources/webapp/static/images/logo.png)
![SteVe](src/main/resources/webapp/static/images/logo.png)

[![build and run tests](https://github.com/steve-community/steve/actions/workflows/main.yml/badge.svg)](https://github.com/steve-community/steve/actions/workflows/main.yml)


# Introduction

SteVe started its life at the RWTH Aachen University [in 2013](https://github.com/steve-community/steve/issues/827).
The name is derived from _Steckdosenverwaltung_ in German (in English: socket administration).
The aim of SteVe is to support the deployment and popularity of electric mobility, so it is easy to install and to use.
SteVe started its life at the RWTH Aachen University [in 2013](https://github.com/steve-community/steve/issues/827).
The name is derived from _Steckdosenverwaltung_ in German (in English: socket administration).
The aim of SteVe is to support the deployment and popularity of electric mobility, so it is easy to install and to use.
It provides basic functions for the administration of charge points, user data, and RFID cards for user authentication and was tested successfully in operation.

SteVe is considered as an open platform to implement, test and evaluate novel ideas for electric mobility, like authentication protocols, reservation mechanisms for charge points, and business models for electric mobility.
The project is distributed under [GPL](LICENSE.txt) and is free to use.
SteVe is considered as an open platform to implement, test and evaluate novel ideas for electric mobility, like authentication protocols, reservation mechanisms for charge points, and business models for electric mobility.
The project is distributed under [GPL](LICENSE.txt) and is free to use.
If you are going to deploy it we are happy to see the [logo](website/logo/managed-by-steve.pdf) on a charge point.

### Charge Point Support
@@ -30,12 +30,12 @@ https://github.com/steve-community/steve/wiki/Charging-Station-Compatibility

### System Requirements

SteVe requires
SteVe requires
* JDK 11 (both Oracle JDK and Adoptium are supported)
* Maven
* Maven
* MariaDB 10.2.1 or later. MySQL 5.7.7 or later works as well, but especially MySQL 8 introduces more hassle. We suggest MariaDB 10.4.

to build and run.
to build and run.

SteVe is designed to run standalone, a java servlet container / web server (e.g. Apache Tomcat), is **not** required.

@@ -47,27 +47,27 @@ SteVe is designed to run standalone, a java servlet container / web server (e.g.

Make sure MySQL is reachable via TCP (e.g., remove `skip-networking` from `my.cnf`).
The following MySQL statements can be used as database initialization (adjust database name and credentials according to your setup).

* For MariaDB (all LTS versions) and MySQL 5.7:
```
CREATE DATABASE stevedb CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'steve'@'localhost' IDENTIFIED BY 'changeme';
GRANT ALL PRIVILEGES ON stevedb.* TO 'steve'@'localhost';
GRANT SELECT ON mysql.proc TO 'steve'@'localhost';
```

* For MySQL 8:
```
CREATE DATABASE stevedb CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'steve'@'localhost' IDENTIFIED BY 'changeme';
GRANT ALL PRIVILEGES ON stevedb.* TO 'steve'@'localhost';
GRANT SUPER ON *.* TO 'steve'@'localhost';
```
Note: The statement `GRANT SUPER [...]` is only necessary to execute some of the previous migration files and is only needed for the initial database setup. Afterwards, you can remove this privilege by executing
Note: The statement `GRANT SUPER [...]` is only necessary to execute some of the previous migration files and is only needed for the initial database setup. Afterwards, you can remove this privilege by executing
```
REVOKE SUPER ON *.* FROM 'steve'@'localhost';
```

2. Download and extract tarball:

You can download and extract the SteVe releases using the following commands (replace X.X.X with the desired version number):
@@ -84,7 +84,7 @@ SteVe is designed to run standalone, a java servlet container / web server (e.g.
- You _must_ change [the host](src/main/resources/config/prod/main.properties#L22) to the correct IP address of your server
- You _must_ change [web interface credentials](src/main/resources/config/prod/main.properties#L17-L18)
- You _can_ access the application via HTTPS, by [enabling it and setting the keystore properties](src/main/resources/config/prod/main.properties#L32-L35)

For advanced configuration please see the [Configuration wiki](https://github.com/steve-community/steve/wiki/Configuration)

4. Build SteVe:
@@ -127,7 +127,7 @@ Then go to `k8s/yaml/Deployment.yaml` and change `### YOUR BUILT IMAGE HERE ###`
After this, create the namespace using `kubectl create ns steve` and apply your yaml with `kubectl apply -f k8s/yaml/Deployment.yaml` followed by `kubectl apply -f k8s/yaml/Service.yaml`


To access this publicaly, you'll also have to setup an ingress using something like nginx or traefik.
To access this publicaly, you'll also have to setup an ingress using something like nginx or traefik.

# Ubuntu

@@ -142,7 +142,7 @@ You'll find a tutorial how to setup SteVe in AWS using Lightsail here: https://g
After SteVe has successfully started, you can access the web interface using the configured credentials under:

http://<your-server-ip>:<port>/steve/manager

The default port number is 8080.

### Add a charge point
@@ -155,7 +155,7 @@ The default port number is 8080.


As soon as a heartbeat is received, you should see the status of the charge point in the SteVe Dashboard.

*Have fun!*

Screenshots
55 changes: 55 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -225,6 +225,61 @@
<configLocation>${basedir}/src/main/resources/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.39.0</version>
<configuration>
<ratchetFrom>origin/master</ratchetFrom>
<formats>
<format>
<includes>
<include>*.md</include>
<include>.gitignore</include>
</includes>
<trimTrailingWhitespace/>
<endWithNewline/>
<indent>
<spaces>true</spaces>
<spacesPerTab>4</spacesPerTab>
</indent>
</format>
</formats>
<java>
<cleanthat/>
<googleJavaFormat/>
<indent>
<tabs>true</tabs>
<spacesPerTab>2</spacesPerTab>
</indent>
<indent>
<spaces>true</spaces>
<spacesPerTab>4</spacesPerTab>
</indent>

<importOrder>
<order>,javax|java,\#</order>
</importOrder>

<removeUnusedImports />
<trimTrailingWhitespace/>
<endWithNewline/>
<formatAnnotations/>

<!-- some issues when apply -->
<!--licenseHeader>
<file>${project.basedir}/LICENSE-HEADER.txt</file>
</licenseHeader-->
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>io.github.git-commit-id</groupId>
5 changes: 4 additions & 1 deletion src/main/java/de/rwth/idsg/steve/Application.java
Original file line number Diff line number Diff line change
@@ -42,7 +42,10 @@ public Application() {

TimeZone.setDefault(TimeZone.getTimeZone(sc.getTimeZoneId()));
DateTimeZone.setDefault(DateTimeZone.forID(sc.getTimeZoneId()));
log.info("Date/time zone of the application is set to {}. Current date/time: {}", sc.getTimeZoneId(), DateTime.now());
log.info(
"Date/time zone of the application is set to {}. Current date/time: {}",
sc.getTimeZoneId(),
DateTime.now());

switch (sc.getProfile()) {
case DEV:
2 changes: 2 additions & 0 deletions src/main/java/de/rwth/idsg/steve/ApplicationStarter.java
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@
*/
public interface ApplicationStarter {
void start() throws Exception;

void join() throws Exception;

void stop() throws Exception;
}
44 changes: 19 additions & 25 deletions src/main/java/de/rwth/idsg/steve/JettyServer.java
Original file line number Diff line number Diff line change
@@ -69,9 +69,7 @@ public class JettyServer {
private static final long STOP_TIMEOUT = TimeUnit.SECONDS.toMillis(5);
private static final long IDLE_TIMEOUT = TimeUnit.MINUTES.toMillis(1);

/**
* A fully configured Jetty Server instance
*/
/** A fully configured Jetty Server instance */
private void prepare() {

// === jetty.xml ===
@@ -149,18 +147,18 @@ private ServerConnector httpsConnector(HttpConfiguration httpConfig) {
httpsConfig.addCustomizer(new SecureRequestCustomizer());

// SSL Connector
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
ServerConnector https =
new ServerConnector(
server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
https.setHost(CONFIG.getJetty().getServerHost());
https.setPort(CONFIG.getJetty().getHttpsPort());
https.setIdleTimeout(IDLE_TIMEOUT);
return https;
}

/**
* Starts the Jetty Server instance
*/
/** Starts the Jetty Server instance */
public void start() throws Exception {
prepare();

@@ -171,9 +169,7 @@ public void start() throws Exception {
}
}

/**
* Join the server thread with the current thread
*/
/** Join the server thread with the current thread */
public void join() throws Exception {
if (server != null) {
server.join();
@@ -206,9 +202,9 @@ private List<String> getConnectorPathList() {
}

return Arrays.stream(server.getConnectors())
.map(JettyServer::getConnectorPath)
.flatMap(Collection::stream)
.collect(Collectors.toList());
.map(JettyServer::getConnectorPath)
.flatMap(Collection::stream)
.collect(Collectors.toList());
}

private static List<String> getConnectorPath(Connector c) {
@@ -232,14 +228,12 @@ private static List<String> getConnectorPath(Connector c) {
String layout = "%s://%s:%d" + CONFIG.getContextPath();

return ips.stream()
.map(k -> String.format(layout, prefix, k, sc.getPort()))
.collect(Collectors.toList());
.map(k -> String.format(layout, prefix, k, sc.getPort()))
.collect(Collectors.toList());
}

private List<String> buildList(List<String> list, boolean replaceHttp) {
return list.stream()
.map(s -> getElementPrefix(s, replaceHttp))
.collect(Collectors.toList());
return list.stream().map(s -> getElementPrefix(s, replaceHttp)).collect(Collectors.toList());
}

private String getElementPrefix(String str, boolean replaceHttp) {
@@ -250,9 +244,7 @@ private String getElementPrefix(String str, boolean replaceHttp) {
}
}

/**
* Uses different APIs to find out the IP of this machine.
*/
/** Uses different APIs to find out the IP of this machine. */
private static List<String> getPossibleIpAddresses() {
final String host = "treibhaus.informatik.rwth-aachen.de";
final List<String> ips = new ArrayList<>();
@@ -281,9 +273,11 @@ private static List<String> getPossibleIpAddresses() {

// https://stackoverflow.com/a/20418809
try {
for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) {
for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
ifaces.hasMoreElements(); ) {
NetworkInterface iface = ifaces.nextElement();
for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses();
inetAddrs.hasMoreElements(); ) {
InetAddress inetAddr = inetAddrs.nextElement();
if (!inetAddr.isLoopbackAddress() && (inetAddr instanceof Inet4Address)) {
ips.add(inetAddr.getHostAddress());
9 changes: 4 additions & 5 deletions src/main/java/de/rwth/idsg/steve/NotificationFeature.java
Original file line number Diff line number Diff line change
@@ -30,19 +30,18 @@ public enum NotificationFeature {

// Ocpp related
//
OcppStationBooted(" a charging station sends a boot notification (Note: This activates notifications about failed connection attempts for unregistered JSON stations, as well)"),
OcppStationBooted(
" a charging station sends a boot notification (Note: This activates notifications about failed connection attempts for unregistered JSON stations, as well)"),
OcppStationStatusFailure(" a connector gets faulted"),
OcppStationWebSocketConnected(" a JSON charging station connects"),
OcppStationWebSocketDisconnected(" a JSON charging station disconnects"),
OcppTransactionStarted(" a charging station starts a transaction"),
OcppTransactionEnded(" a charging station ends a transaction");


@Getter
private final String text;
@Getter private final String text;

public static NotificationFeature fromName(String v) {
for (NotificationFeature c: NotificationFeature.values()) {
for (NotificationFeature c : NotificationFeature.values()) {
if (c.name().equalsIgnoreCase(v)) {
return c;
}
29 changes: 13 additions & 16 deletions src/main/java/de/rwth/idsg/steve/SteveAppContext.java
Original file line number Diff line number Diff line change
@@ -69,17 +69,13 @@ public SteveAppContext() {
}

public HandlerCollection getHandlers() {
return new HandlerList(
getRedirectHandler(),
getWebApp()
);
return new HandlerList(getRedirectHandler(), getWebApp());
}

/**
* Otherwise, defaults come from {@link WebSocketConstants}
*/
/** Otherwise, defaults come from {@link WebSocketConstants} */
public void configureWebSocket() {
JettyWebSocketServerContainer container = JettyWebSocketServerContainer.getContainer(webAppContext.getServletContext());
JettyWebSocketServerContainer container =
JettyWebSocketServerContainer.getContainer(webAppContext.getServletContext());
container.setMaxTextMessageSize(MAX_MSG_SIZE);
container.setIdleTimeout(IDLE_TIMEOUT);
}
@@ -107,7 +103,8 @@ private WebAppContext initWebApp() {
// Disable directory listings if no index.html is found.
ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

ServletHolder web = new ServletHolder("spring-dispatcher", new DispatcherServlet(springContext));
ServletHolder web =
new ServletHolder("spring-dispatcher", new DispatcherServlet(springContext));
ServletHolder cxf = new ServletHolder("cxf", new CXFServlet());

ctx.addEventListener(new ContextLoaderListener(springContext));
@@ -117,11 +114,12 @@ private WebAppContext initWebApp() {
if (CONFIG.getProfile().isProd()) {
// If PROD, add security filter
ctx.addFilter(
// The bean name is not arbitrary, but is as expected by Spring
new FilterHolder(new DelegatingFilterProxy(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)),
CONFIG.getSpringMapping() + "*",
EnumSet.allOf(DispatcherType.class)
);
// The bean name is not arbitrary, but is as expected by Spring
new FilterHolder(
new DelegatingFilterProxy(
AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)),
CONFIG.getSpringMapping() + "*",
EnumSet.allOf(DispatcherType.class));
}

initJSP(ctx);
@@ -160,8 +158,7 @@ private HashSet<String> getRedirectSet() {
}

/**
* Help by:
* https://github.com/jetty-project/embedded-jetty-jsp
* Help by: https://github.com/jetty-project/embedded-jetty-jsp
* https://github.com/jasonish/jetty-springmvc-jsp-template
* http://examples.javacodegeeks.com/enterprise-java/jetty/jetty-jsp-example
*/
Loading