Skip to content

Commit 1874cb2

Browse files
authored
Merge pull request #188 from jmluy/add-opensession
Provide method to check if given session is still open
2 parents e40713e + 431dcd4 commit 1874cb2

File tree

9 files changed

+60
-23
lines changed

9 files changed

+60
-23
lines changed

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

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
1-
package eu.chargetime.ocpp; /*
2-
ChargeTime.eu - Java-OCA-OCPP
1+
package eu.chargetime.ocpp;
2+
/*
3+
ChargeTime.eu - Java-OCA-OCPP
34
4-
MIT License
5+
MIT License
56
6-
Copyright (C) 2016-2018 Thomas Volden <[email protected]>
7+
Copyright (C) 2016-2018 Thomas Volden <[email protected]>
78
8-
Permission is hereby granted, free of charge, to any person obtaining a copy
9-
of this software and associated documentation files (the "Software"), to deal
10-
in the Software without restriction, including without limitation the rights
11-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12-
copies of the Software, and to permit persons to whom the Software is
13-
furnished to do so, subject to the following conditions:
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
1415
15-
The above copyright notice and this permission notice shall be included in all
16-
copies or substantial portions of the Software.
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
1718
18-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24-
SOFTWARE.
25-
*/
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
*/
2627

27-
/** Exception returned to an outgoing request if an error is reported from the other end. */
28+
/**
29+
* Exception returned to an outgoing request if an error is reported from the other end.
30+
*/
2831
public class CallErrorException extends Exception {
32+
2933
private String errorCode;
3034
private String errorDescription;
3135
private Object payload;
3236

3337
/**
3438
* Constructor.
3539
*
36-
* @param errorCode send from the other end.
40+
* @param errorCode send from the other end.
3741
* @param errorDescription describing the error.
38-
* @param payload raw payload send from the other end.
42+
* @param payload raw payload send from the other end.
3943
*/
4044
public CallErrorException(String errorCode, String errorDescription, Object payload) {
4145
super(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ public CompletableFuture<Confirmation> send(UUID sessionIndex, Request request)
219219
return promise;
220220
}
221221

222+
public boolean isSessionOpen(UUID sessionIndex) {
223+
return sessions.containsKey(sessionIndex);
224+
}
225+
222226
/**
223227
* Close connection to a client
224228
*

ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public void addFeatureProfile(Profile profile) {
6969
featureRepository.addFeatureProfile(profile);
7070
}
7171

72+
@Override
73+
public boolean isSessionOpen(UUID session) {
74+
return server.isSessionOpen(session);
75+
}
76+
7277
@Override
7378
public void closeSession(UUID session) {
7479
server.closeSession(session);

ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public void addFeatureProfile(Profile profile) {
5252
featureRepository.addFeatureProfile(profile);
5353
}
5454

55+
@Override
56+
public boolean isSessionOpen(UUID session) {
57+
return server.isSessionOpen(session);
58+
}
59+
5560
@Override
5661
public void closeSession(UUID session) {
5762
server.closeSession(session);

ocpp-v1_6/src/main/java/eu/chargetime/ocpp/IServerAPI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ of this software and associated documentation files (the "Software"), to deal
3434
public interface IServerAPI {
3535
void addFeatureProfile(Profile profile);
3636

37+
boolean isSessionOpen(UUID session);
38+
3739
void closeSession(UUID session);
3840

3941
void open(String host, int port, ServerEvents serverEvents);

ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ public void addFeatureProfile(Profile profile) {
137137
featureRepository.addFeatureProfile(profile);
138138
}
139139

140+
@Override
141+
public boolean isSessionOpen(UUID session) {
142+
return server.isSessionOpen(session);
143+
}
144+
140145
@Override
141146
public void closeSession(UUID session) {
142147
server.closeSession(session);

ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public void addFeatureProfile(Profile profile) {
5252
featureRepository.addFeatureProfile(profile);
5353
}
5454

55+
@Override
56+
public boolean isSessionOpen(UUID session) {
57+
return server.isSessionOpen(session);
58+
}
59+
5560
@Override
5661
public void closeSession(UUID session) {
5762
server.closeSession(session);

ocpp-v2_0/src/main/java/eu/chargetime/ocpp/IServerAPI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ of this software and associated documentation files (the "Software"), to deal
3434
public interface IServerAPI {
3535
void addFeature(Feature feature);
3636

37+
boolean isSessionOpen(UUID session);
38+
3739
void closeSession(UUID session);
3840

3941
void open(String host, int port, ServerEvents serverEvents);

ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public void addFeature(Feature feature) {
124124
featureRepository.addFeature(feature);
125125
}
126126

127+
@Override
128+
public boolean isSessionOpen(UUID session) {
129+
return server.isSessionOpen(session);
130+
}
131+
127132
@Override
128133
public void closeSession(UUID session) {
129134
server.closeSession(session);

0 commit comments

Comments
 (0)