diff --git a/src/main/java/de/rwth/idsg/steve/ocpp/CommunicationTask.java b/src/main/java/de/rwth/idsg/steve/ocpp/CommunicationTask.java index 2cc485d2c..b9c988cff 100644 --- a/src/main/java/de/rwth/idsg/steve/ocpp/CommunicationTask.java +++ b/src/main/java/de/rwth/idsg/steve/ocpp/CommunicationTask.java @@ -125,7 +125,7 @@ public void addNewError(String chargeBoxId, String errorMessage) { } } - protected void success(String chargeBoxId, RESPONSE response) { + public void success(String chargeBoxId, RESPONSE response) { for (OcppCallback c : callbackList) { try { c.success(chargeBoxId, response); @@ -135,7 +135,7 @@ protected void success(String chargeBoxId, RESPONSE response) { } } - protected void failed(String chargeBoxId, Exception exception) { + public void failed(String chargeBoxId, Exception exception) { for (OcppCallback c : callbackList) { try { c.failed(chargeBoxId, exception); diff --git a/src/main/java/de/rwth/idsg/steve/ocpp/soap/ChargePointServiceSoapInvoker.java b/src/main/java/de/rwth/idsg/steve/ocpp/soap/ChargePointServiceSoapInvoker.java index 946a6d58f..77d12ad93 100644 --- a/src/main/java/de/rwth/idsg/steve/ocpp/soap/ChargePointServiceSoapInvoker.java +++ b/src/main/java/de/rwth/idsg/steve/ocpp/soap/ChargePointServiceSoapInvoker.java @@ -50,6 +50,9 @@ @Service public class ChargePointServiceSoapInvoker implements ChargePointServiceInvoker { + public static final Exception EXCEPTION_V12 = new IllegalArgumentException("This operation is not supported by this OCPP 1.2 station"); + public static final Exception EXCEPTION_V15 = new IllegalArgumentException("This operation is not supported by this OCPP 1.5 station"); + private final ClientProviderWithCache soapV12Helper; private final ClientProviderWithCache soapV15Helper; private final ClientProviderWithCache soapV16Helper; @@ -150,7 +153,7 @@ public void remoteStopTransaction(ChargePointSelect cp, RemoteStopTransactionTas @Override public void dataTransfer(ChargePointSelect cp, DataTransferTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); case V_15 -> createV15(cp).dataTransferAsync(task.getOcpp15Request(), cp.getChargeBoxId(), task.getOcpp15Handler(cp.getChargeBoxId())); case V_16 -> createV16(cp).dataTransferAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } @@ -159,7 +162,7 @@ public void dataTransfer(ChargePointSelect cp, DataTransferTask task) { @Override public void getConfiguration(ChargePointSelect cp, GetConfigurationTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); case V_15 -> createV15(cp).getConfigurationAsync(task.getOcpp15Request(), cp.getChargeBoxId(), task.getOcpp15Handler(cp.getChargeBoxId())); case V_16 -> createV16(cp).getConfigurationAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } @@ -168,7 +171,7 @@ public void getConfiguration(ChargePointSelect cp, GetConfigurationTask task) { @Override public void getLocalListVersion(ChargePointSelect cp, GetLocalListVersionTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); case V_15 -> createV15(cp).getLocalListVersionAsync(task.getOcpp15Request(), cp.getChargeBoxId(), task.getOcpp15Handler(cp.getChargeBoxId())); case V_16 -> createV16(cp).getLocalListVersionAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } @@ -177,7 +180,7 @@ public void getLocalListVersion(ChargePointSelect cp, GetLocalListVersionTask ta @Override public void sendLocalList(ChargePointSelect cp, SendLocalListTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); case V_15 -> createV15(cp).sendLocalListAsync(task.getOcpp15Request(), cp.getChargeBoxId(), task.getOcpp15Handler(cp.getChargeBoxId())); case V_16 -> createV16(cp).sendLocalListAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } @@ -186,7 +189,7 @@ public void sendLocalList(ChargePointSelect cp, SendLocalListTask task) { @Override public void reserveNow(ChargePointSelect cp, ReserveNowTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); case V_15 -> createV15(cp).reserveNowAsync(task.getOcpp15Request(), cp.getChargeBoxId(), task.getOcpp15Handler(cp.getChargeBoxId())); case V_16 -> createV16(cp).reserveNowAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } @@ -195,7 +198,7 @@ public void reserveNow(ChargePointSelect cp, ReserveNowTask task) { @Override public void cancelReservation(ChargePointSelect cp, CancelReservationTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); case V_15 -> createV15(cp).cancelReservationAsync(task.getOcpp15Request(), cp.getChargeBoxId(), task.getOcpp15Handler(cp.getChargeBoxId())); case V_16 -> createV16(cp).cancelReservationAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } @@ -208,7 +211,8 @@ public void cancelReservation(ChargePointSelect cp, CancelReservationTask task) @Override public void clearChargingProfile(ChargePointSelect cp, ClearChargingProfileTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12, V_15 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); + case V_15 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V15); case V_16 -> createV16(cp).clearChargingProfileAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } } @@ -216,7 +220,8 @@ public void clearChargingProfile(ChargePointSelect cp, ClearChargingProfileTask @Override public void setChargingProfile(ChargePointSelect cp, SetChargingProfileTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12, V_15 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); + case V_15 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V15); case V_16 -> createV16(cp).setChargingProfileAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } } @@ -224,7 +229,8 @@ public void setChargingProfile(ChargePointSelect cp, SetChargingProfileTask task @Override public void getCompositeSchedule(ChargePointSelect cp, GetCompositeScheduleTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12, V_15 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); + case V_15 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V15); case V_16 -> createV16(cp).getCompositeScheduleAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } } @@ -232,7 +238,8 @@ public void getCompositeSchedule(ChargePointSelect cp, GetCompositeScheduleTask @Override public void triggerMessage(ChargePointSelect cp, TriggerMessageTask task) { switch (cp.getOcppProtocol().getVersion()) { - case V_12, V_15 -> throw new IllegalArgumentException("Not supported"); + case V_12 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V12); + case V_15 -> task.failed(cp.getChargeBoxId(), EXCEPTION_V15); case V_16 -> createV16(cp).triggerMessageAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId())); } } diff --git a/src/main/java/de/rwth/idsg/steve/ocpp/ws/ChargePointServiceJsonInvoker.java b/src/main/java/de/rwth/idsg/steve/ocpp/ws/ChargePointServiceJsonInvoker.java index 7ff10ef1a..9cd8f4f3d 100644 --- a/src/main/java/de/rwth/idsg/steve/ocpp/ws/ChargePointServiceJsonInvoker.java +++ b/src/main/java/de/rwth/idsg/steve/ocpp/ws/ChargePointServiceJsonInvoker.java @@ -63,7 +63,7 @@ public void runPipeline(ChargePointSelect cps, CommunicationTask task) { } catch (Exception e) { log.error("Exception occurred", e); // Outgoing call failed due to technical problems. Pass the exception to handler to inform the user - task.defaultCallback().failed(cps.getChargeBoxId(), e); + task.failed(cps.getChargeBoxId(), e); } }