@CommandHandler public void handle(BootChargingStationCommand command) { ChargingStationBootedEvent chargingStationBootedEvent; if (isConfigured) { chargingStationBootedEvent = new ConfiguredChargingStationBootedEvent(command.getChargingStationId(), command.getProtocol(), command.getAttributes(), command.getIdentityContext()); } else { chargingStationBootedEvent = new UnconfiguredChargingStationBootedEvent(command.getChargingStationId(), command.getProtocol(), command.getAttributes(), command.getIdentityContext()); } apply(chargingStationBootedEvent); }
public BootChargingStationResult bootChargingStation(ChargingStationId chargingStationId, String protocol, AttributeMap<String, String> attributes, AddOnIdentity addOnIdentity) { // Check if we already know the charging station, or have to create one ChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId.getId()); IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (chargingStation == null) { LOG.debug("Not a known charging station on boot notification, we send a CreateChargingStationCommand."); commandGateway.send(new CreateChargingStationCommand(chargingStationId, userIdentitiesWithAllPermissions, identityContext), new CreateChargingStationCommandCallback( chargingStationId, protocol, attributes, addOnIdentity, chargingStationRepository, this)); // we didn't know the charging station when this bootNotification occurred so we reject it. return new BootChargingStationResult(false, heartbeatInterval, new Date()); } // Keep track of the address on which we can reach the charging station chargingStation.setIpAddress(attributes.get(AttributeMapKeys.CHARGING_STATION_ADDRESS)); chargingStation = chargingStationRepository.createOrUpdate(chargingStation); commandGateway.send(new BootChargingStationCommand(chargingStationId, protocol, attributes, identityContext)); return new BootChargingStationResult(chargingStation.isRegisteredAndConfigured(), heartbeatInterval, new Date()); }