@CommandHandler public void handle(AcceptChargingStationCommand command) { checkCommandAllowed(command.getIdentityContext(), command.getClass()); if (isAccepted) { throw new IllegalStateException("Cannot accept an already accepted charging station"); } apply(new ChargingStationAcceptedEvent(command.getChargingStationId(), command.getIdentityContext())); }
@CommandHandler public ChargingStation(CreateAndAcceptChargingStationCommand command) { this(); apply(new ChargingStationCreatedEvent(command.getChargingStationId(), command.getUserIdentitiesWithAllPermissions(), command.getIdentityContext())); // created event sets authorization, check if this command is checkCommandAllowed(command.getIdentityContext(), command.getClass()); apply(new ChargingStationAcceptedEvent(command.getChargingStationId(), command.getIdentityContext())); }