-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move validation to abstract parent class
- Loading branch information
Showing
4 changed files
with
26 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,11 @@ | |
*/ | ||
package de.rwth.idsg.steve.ocpp.task; | ||
|
||
import de.rwth.idsg.steve.SteveException; | ||
import de.rwth.idsg.steve.ocpp.Ocpp16AndAboveTask; | ||
import de.rwth.idsg.steve.web.dto.ocpp.SetChargingProfileParams; | ||
import ocpp.cp._2015._10.ChargingProfilePurposeType; | ||
import ocpp.cp._2015._10.SetChargingProfileRequest; | ||
|
||
/** | ||
* @author Sevket Goekay <[email protected]> | ||
|
@@ -30,4 +33,21 @@ public abstract class SetChargingProfileTask extends Ocpp16AndAboveTask<SetCharg | |
public SetChargingProfileTask(SetChargingProfileParams params) { | ||
super(params); | ||
} | ||
|
||
/** | ||
* Do some additional checks defined by OCPP spec, which cannot be captured with javax.validation | ||
*/ | ||
protected static void checkAdditionalConstraints(SetChargingProfileRequest request) { | ||
ChargingProfilePurposeType purpose = request.getCsChargingProfiles().getChargingProfilePurpose(); | ||
|
||
if (ChargingProfilePurposeType.CHARGE_POINT_MAX_PROFILE == purpose | ||
&& request.getConnectorId() != 0) { | ||
throw new SteveException("ChargePointMaxProfile can only be set at Charge Point ConnectorId 0"); | ||
} | ||
|
||
if (ChargingProfilePurposeType.TX_PROFILE == purpose | ||
&& request.getConnectorId() < 1) { | ||
throw new SteveException("TxProfile should only be set at Charge Point ConnectorId > 0"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters