use of uk.gov.ida.hub.policy.exception.InvalidSessionStateException in project verify-hub by alphagov.
the class SessionRepository method getStateController.
@Timed(name = Urls.SESSION_REPO_TIMED_GROUP)
public <T extends State> StateController getStateController(final SessionId sessionId, final Class<T> expectedStateClass) {
validateSessionExists(sessionId);
State currentState = getCurrentState(sessionId);
Class<? extends State> currentStateClass = currentState.getClass();
handleTimeout(sessionId, currentState, currentStateClass, expectedStateClass);
if (isAKindOf(expectedStateClass, currentStateClass) || currentStateClass.equals(TimeoutState.class)) {
return controllerFactory.build(currentState, state -> dataStore.replace(sessionId, state));
}
throw new InvalidSessionStateException(sessionId, expectedStateClass, currentState.getClass());
}
Aggregations