use of uk.gov.ida.hub.policy.domain.controller.CountrySelectingStateController in project verify-hub by alphagov.
the class CountriesService method setSelectedCountry.
public void setSelectedCountry(SessionId sessionId, String countryCode) {
ensureTransactionSupportsEidas(sessionId);
List<EidasCountryDto> supportedCountries = getCountries(sessionId);
Optional<EidasCountryDto> selectedCountry = supportedCountries.stream().filter(country -> country.getSimpleId().equals(countryCode)).findFirst();
if (!selectedCountry.isPresent()) {
throw new EidasCountryNotSupportedException(sessionId, countryCode);
}
Class<? extends State> expectedStateClass = SessionStartedState.class;
if (sessionRepository.isSessionInState(sessionId, CountrySelectedState.class)) {
expectedStateClass = CountrySelectedState.class;
}
CountrySelectingStateController countrySelectingStateController = (CountrySelectingStateController) sessionRepository.getStateController(sessionId, expectedStateClass);
countrySelectingStateController.selectCountry(selectedCountry.get().getEntityId());
}
Aggregations