Skip to content

Commit 41e8f34

Browse files
authored
Merge pull request #2 from in-fke/features/backport-maven-artifacts
Backport to "maven artifacts" and result of "goJF"
2 parents 1610225 + 8f8d724 commit 41e8f34

File tree

14 files changed

+129
-110
lines changed

14 files changed

+129
-110
lines changed

OCPP-J/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<dependencies>
5050
<dependency>
5151
<groupId>eu.chargetime.ocpp</groupId>
52-
<artifactId>common</artifactId>
52+
<artifactId>ocpp-common</artifactId>
5353
<version>1.0.1</version>
5454
</dependency>
5555
<dependency>
@@ -127,6 +127,7 @@
127127
</execution>
128128
</executions>
129129
</plugin>
130+
<!-- disable
130131
<plugin>
131132
<groupId>org.apache.maven.plugins</groupId>
132133
<artifactId>maven-gpg-plugin</artifactId>
@@ -141,6 +142,7 @@
141142
</execution>
142143
</executions>
143144
</plugin>
145+
-->
144146
<plugin>
145147
<groupId>org.sonatype.plugins</groupId>
146148
<artifactId>nexus-staging-maven-plugin</artifactId>

OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ public WebSocketListener(ISessionFactory sessionFactory, Draft... drafts) {
8282
public void open(String hostname, int port, ListenerEvents handler) {
8383
server =
8484
new WebSocketServer(
85-
new InetSocketAddress(hostname, port),
86-
configuration.getParameter(JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT),
87-
drafts) {
85+
new InetSocketAddress(hostname, port),
86+
configuration.getParameter(
87+
JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT),
88+
drafts) {
8889
@Override
8990
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
9091
logger.debug(
@@ -115,9 +116,9 @@ public void relay(String message) {
115116
String proxiedAddress = clientHandshake.getFieldValue(HTTP_HEADER_PROXIED_ADDRESS);
116117

117118
logger.debug(
118-
"New web-socket connection opened from address: {} proxied for: {}",
119-
webSocket.getRemoteSocketAddress(),
120-
proxiedAddress);
119+
"New web-socket connection opened from address: {} proxied for: {}",
120+
webSocket.getRemoteSocketAddress(),
121+
proxiedAddress);
121122

122123
SessionInformation information =
123124
new SessionInformation.Builder()
@@ -131,13 +132,14 @@ public void relay(String message) {
131132
}
132133

133134
@Override
134-
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket webSocket, Draft draft,
135-
ClientHandshake clientHandshake) throws InvalidDataException {
135+
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(
136+
WebSocket webSocket, Draft draft, ClientHandshake clientHandshake)
137+
throws InvalidDataException {
136138
SessionInformation information =
137-
new SessionInformation.Builder()
138-
.Identifier(clientHandshake.getResourceDescriptor())
139-
.InternetAddress(webSocket.getRemoteSocketAddress())
140-
.build();
139+
new SessionInformation.Builder()
140+
.Identifier(clientHandshake.getResourceDescriptor())
141+
.InternetAddress(webSocket.getRemoteSocketAddress())
142+
.build();
141143

142144
String username = null;
143145
byte[] password = null;
@@ -150,25 +152,26 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket web
150152
// split credentials on username and password
151153
for (int i = 0; i < credDecoded.length; i++) {
152154
if (credDecoded[i] == ':') {
153-
username = new String(Arrays.copyOfRange(credDecoded, 0, i), StandardCharsets.UTF_8);
155+
username =
156+
new String(Arrays.copyOfRange(credDecoded, 0, i), StandardCharsets.UTF_8);
154157
if (i + 1 < credDecoded.length) {
155158
password = Arrays.copyOfRange(credDecoded, i + 1, credDecoded.length);
156159
}
157160
break;
158161
}
159162
}
160163
}
161-
if (password == null || password.length < OCPPJ_CP_MIN_PASSWORD_LENGTH || password.length > OCPPJ_CP_MAX_PASSWORD_LENGTH)
164+
if (password == null
165+
|| password.length < OCPPJ_CP_MIN_PASSWORD_LENGTH
166+
|| password.length > OCPPJ_CP_MAX_PASSWORD_LENGTH)
162167
throw new InvalidDataException(401, "Invalid password length");
163168
}
164169

165170
try {
166171
handler.authenticateSession(information, username, password);
167-
}
168-
catch (AuthenticationException e) {
172+
} catch (AuthenticationException e) {
169173
throw new InvalidDataException(e.getErrorCode(), e.getMessage());
170-
}
171-
catch (Exception e) {
174+
} catch (Exception e) {
172175
throw new InvalidDataException(401, e.getMessage());
173176
}
174177
return super.onWebsocketHandshakeReceivedAsServer(webSocket, draft, clientHandshake);

ocpp-common/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>eu.chargetime.ocpp</groupId>
8-
<artifactId>common</artifactId>
8+
<artifactId>ocpp-common</artifactId>
99
<version>1.0.1</version>
1010

1111
<name>Java-OCA-OCPP common</name>
@@ -128,6 +128,7 @@
128128
</execution>
129129
</executions>
130130
</plugin>
131+
<!-- disable
131132
<plugin>
132133
<groupId>org.apache.maven.plugins</groupId>
133134
<artifactId>maven-gpg-plugin</artifactId>
@@ -142,6 +143,7 @@
142143
</execution>
143144
</executions>
144145
</plugin>
146+
-->
145147
<plugin>
146148
<groupId>org.sonatype.plugins</groupId>
147149
<artifactId>nexus-staging-maven-plugin</artifactId>

ocpp-common/src/main/java/eu/chargetime/ocpp/ListenerEvents.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ of this software and associated documentation files (the "Software"), to deal
2828
import eu.chargetime.ocpp.model.SessionInformation;
2929

3030
public interface ListenerEvents {
31-
void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException;
31+
void authenticateSession(SessionInformation information, String username, byte[] password)
32+
throws AuthenticationException;
33+
3234
void newSession(ISession session, SessionInformation information);
3335
}

ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java

Lines changed: 68 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ of this software and associated documentation files (the "Software"), to deal
2828
import eu.chargetime.ocpp.feature.Feature;
2929
import eu.chargetime.ocpp.model.Confirmation;
3030
import eu.chargetime.ocpp.model.Request;
31+
import eu.chargetime.ocpp.model.SessionInformation;
3132
import java.util.Map;
3233
import java.util.Optional;
3334
import java.util.UUID;
3435
import java.util.concurrent.CompletableFuture;
3536
import java.util.concurrent.ConcurrentHashMap;
36-
37-
import eu.chargetime.ocpp.model.SessionInformation;
3837
import org.slf4j.Logger;
3938
import org.slf4j.LoggerFactory;
4039

@@ -83,76 +82,80 @@ public void open(String hostname, int port, ServerEvents serverEvents) {
8382
new ListenerEvents() {
8483

8584
@Override
86-
public void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException {
85+
public void authenticateSession(
86+
SessionInformation information, String username, byte[] password)
87+
throws AuthenticationException {
8788
serverEvents.authenticateSession(information, username, password);
8889
}
8990

9091
@Override
9192
public void newSession(ISession session, SessionInformation information) {
9293
session.accept(
93-
new SessionEvents() {
94-
@Override
95-
public void handleConfirmation(String uniqueId, Confirmation confirmation) {
96-
97-
Optional<CompletableFuture<Confirmation>> promiseOptional =
98-
promiseRepository.getPromise(uniqueId);
99-
if (promiseOptional.isPresent()) {
100-
promiseOptional.get().complete(confirmation);
101-
promiseRepository.removePromise(uniqueId);
102-
} else {
103-
logger.debug("Promise not found for confirmation {}", confirmation);
104-
}
105-
}
106-
107-
@Override
108-
public Confirmation handleRequest(Request request)
109-
throws UnsupportedFeatureException {
110-
Optional<Feature> featureOptional = featureRepository.findFeature(request);
111-
if (featureOptional.isPresent()) {
112-
Optional<UUID> sessionIdOptional = getSessionID(session);
113-
if (sessionIdOptional.isPresent()) {
114-
return featureOptional.get().handleRequest(sessionIdOptional.get(), request);
115-
} else {
116-
logger.error(
117-
"Unable to handle request ({}), the active session was not found.",
118-
request);
119-
throw new IllegalStateException("Active session not found");
120-
}
121-
} else {
122-
throw new UnsupportedFeatureException();
123-
}
94+
new SessionEvents() {
95+
@Override
96+
public void handleConfirmation(String uniqueId, Confirmation confirmation) {
97+
98+
Optional<CompletableFuture<Confirmation>> promiseOptional =
99+
promiseRepository.getPromise(uniqueId);
100+
if (promiseOptional.isPresent()) {
101+
promiseOptional.get().complete(confirmation);
102+
promiseRepository.removePromise(uniqueId);
103+
} else {
104+
logger.debug("Promise not found for confirmation {}", confirmation);
105+
}
106+
}
107+
108+
@Override
109+
public Confirmation handleRequest(Request request)
110+
throws UnsupportedFeatureException {
111+
Optional<Feature> featureOptional = featureRepository.findFeature(request);
112+
if (featureOptional.isPresent()) {
113+
Optional<UUID> sessionIdOptional = getSessionID(session);
114+
if (sessionIdOptional.isPresent()) {
115+
return featureOptional
116+
.get()
117+
.handleRequest(sessionIdOptional.get(), request);
118+
} else {
119+
logger.error(
120+
"Unable to handle request ({}), the active session was not found.",
121+
request);
122+
throw new IllegalStateException("Active session not found");
124123
}
125-
126-
@Override
127-
public void handleError(
128-
String uniqueId, String errorCode, String errorDescription, Object payload) {
129-
Optional<CompletableFuture<Confirmation>> promiseOptional =
130-
promiseRepository.getPromise(uniqueId);
131-
if (promiseOptional.isPresent()) {
132-
promiseOptional
133-
.get()
134-
.completeExceptionally(
135-
new CallErrorException(errorCode, errorDescription, payload));
136-
promiseRepository.removePromise(uniqueId);
137-
} else {
138-
logger.debug("Promise not found for error {}", errorDescription);
139-
}
140-
}
141-
142-
@Override
143-
public void handleConnectionClosed() {
144-
Optional<UUID> sessionIdOptional = getSessionID(session);
145-
if (sessionIdOptional.isPresent()) {
146-
serverEvents.lostSession(sessionIdOptional.get());
147-
sessions.remove(sessionIdOptional.get());
148-
} else {
149-
logger.warn("Active session not found");
150-
}
151-
}
152-
153-
@Override
154-
public void handleConnectionOpened() {}
155-
});
124+
} else {
125+
throw new UnsupportedFeatureException();
126+
}
127+
}
128+
129+
@Override
130+
public void handleError(
131+
String uniqueId, String errorCode, String errorDescription, Object payload) {
132+
Optional<CompletableFuture<Confirmation>> promiseOptional =
133+
promiseRepository.getPromise(uniqueId);
134+
if (promiseOptional.isPresent()) {
135+
promiseOptional
136+
.get()
137+
.completeExceptionally(
138+
new CallErrorException(errorCode, errorDescription, payload));
139+
promiseRepository.removePromise(uniqueId);
140+
} else {
141+
logger.debug("Promise not found for error {}", errorDescription);
142+
}
143+
}
144+
145+
@Override
146+
public void handleConnectionClosed() {
147+
Optional<UUID> sessionIdOptional = getSessionID(session);
148+
if (sessionIdOptional.isPresent()) {
149+
serverEvents.lostSession(sessionIdOptional.get());
150+
sessions.remove(sessionIdOptional.get());
151+
} else {
152+
logger.warn("Active session not found");
153+
}
154+
}
155+
156+
@Override
157+
public void handleConnectionOpened() {}
158+
});
156159

157160
sessions.put(session.getSessionId(), session);
158161

ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ of this software and associated documentation files (the "Software"), to deal
2929
import java.util.UUID;
3030

3131
public interface ServerEvents {
32-
default void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException {}
32+
default void authenticateSession(SessionInformation information, String username, byte[] password)
33+
throws AuthenticationException {}
3334

3435
void newSession(UUID sessionIndex, SessionInformation information);
3536

ocpp-v1_6-example/json-client-implementation/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<name>json-client-implementation</name>
1515
<description>Demo project for a json client application, written in form of tests</description>
1616
<properties>
17-
<java.version>11</java.version>
17+
<java.version>8</java.version>
1818
</properties>
1919
<dependencies>
2020
<dependency>
@@ -45,13 +45,13 @@
4545
</dependency>
4646
<dependency>
4747
<groupId>eu.chargetime.ocpp</groupId>
48-
<artifactId>v1_6</artifactId>
49-
<version>1.0.1</version>
48+
<artifactId>ocpp-v1_6</artifactId>
49+
<version>1.0.2</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>org.testng</groupId>
5353
<artifactId>testng</artifactId>
54-
<version>RELEASE</version>
54+
<version>7.5</version>
5555
<scope>test</scope>
5656
</dependency>
5757
<dependency>

ocpp-v1_6-example/json_server_example/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>eu.chargetime.ocpp</groupId>
12-
<artifactId>json-server-implementation </artifactId>
12+
<artifactId>json-server-implementation</artifactId>
1313
<version>0.0.1-SNAPSHOT</version>
1414
<name>json-server-implementation </name>
15-
<description>Example Spring Application of a json server </description>
15+
<description>Example Spring Application of a json server</description>
1616
<properties>
17-
<java.version>11</java.version>
17+
<java.version>8</java.version>
1818
</properties>
1919
<dependencies>
2020
<dependency>
@@ -45,13 +45,13 @@
4545
</dependency>
4646
<dependency>
4747
<groupId>eu.chargetime.ocpp</groupId>
48-
<artifactId>v1_6</artifactId>
49-
<version>1.0.1</version>
48+
<artifactId>ocpp-v1_6</artifactId>
49+
<version>1.0.2</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>org.testng</groupId>
5353
<artifactId>testng</artifactId>
54-
<version>RELEASE</version>
54+
<version>7.5</version>
5555
<scope>test</scope>
5656
</dependency>
5757
<dependency>

ocpp-v1_6-test/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>eu.chargetime.ocpp</groupId>
8-
<artifactId>v1_6-test</artifactId>
8+
<artifactId>ocpp-v1_6-test</artifactId>
99
<version>1.0.2</version>
1010

1111
<name>Java-OCA-OCPP v1.6 - Integration test</name>
@@ -48,12 +48,12 @@
4848
<dependencies>
4949
<dependency>
5050
<groupId>eu.chargetime.ocpp</groupId>
51-
<artifactId>common</artifactId>
51+
<artifactId>ocpp-common</artifactId>
5252
<version>1.0.1</version>
5353
</dependency>
5454
<dependency>
5555
<groupId>eu.chargetime.ocpp</groupId>
56-
<artifactId>v1_6</artifactId>
56+
<artifactId>ocpp-v1_6</artifactId>
5757
<version>1.0.2</version>
5858
</dependency>
5959
<dependency>

0 commit comments

Comments
 (0)