Search in sources :

Example 1 with InvalidSessionStateException

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());
}
Also used : TimeoutState(uk.gov.ida.hub.policy.domain.state.TimeoutState) SessionStartedState(uk.gov.ida.hub.policy.domain.state.SessionStartedState) UserAccountCreatedState(uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) SuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState) ErrorResponsePreparedState(uk.gov.ida.hub.policy.domain.state.ErrorResponsePreparedState) TimeoutState(uk.gov.ida.hub.policy.domain.state.TimeoutState) InvalidSessionStateException(uk.gov.ida.hub.policy.exception.InvalidSessionStateException) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 ErrorResponsePreparedState (uk.gov.ida.hub.policy.domain.state.ErrorResponsePreparedState)1 SessionStartedState (uk.gov.ida.hub.policy.domain.state.SessionStartedState)1 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)1 TimeoutState (uk.gov.ida.hub.policy.domain.state.TimeoutState)1 UserAccountCreatedState (uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState)1 InvalidSessionStateException (uk.gov.ida.hub.policy.exception.InvalidSessionStateException)1