uk.gov.hmrc.play.fsm

# JourneyController

###
Related Doc: package fsm

#### trait JourneyController[RequestContext] extends AnyRef

Controller mixin for journeys implementing Finite State Machine.

Provides 3 main extension points:

- getCallFor: what is the endpoint representing given state
- renderState: how to render given state
- context: custom request context to carry over to the service layer

and actions DSL

Linear Supertypes
AnyRef, Any
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. JourneyController
2. AnyRef
3. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Type Members

1. #### sealed trait Executable extends AnyRef

   Interface of the action building blocks.

   Interface of the action building blocks.

   Provides common post-processing functions:

   - display to force display - displayUsing to force display using custom renderer - redirect to force redirect - redirectOrDisplayIfSame to display if state didn't change, otherwise redirect - redirectOrDisplayUsingIfSame to display using custom renderer if state didn't change, otherwise redirect - redirectOrDisplayIf to display if state of some type, otherwise redirect - redirectOrDisplayUsingIf to display using custom renderer if state of some type, otherwise redirect - displayOrRedirectIf to redirect if state of some type, otherwise display - displayUsingOrRedirectIf to redirect if state of some type, otherwise display using custom renderer - andCleanBreadcrumbs to clean history (breadcrumbs) - transform to transform final result - recover to recover from an error using custom strategy - recoverWith to recover from an error using custom strategy

2. #### type ExpectedStates = PartialFunction[State, Unit]

3. #### type Fallback = (RequestContext, Request[_], ExecutionContext) ⇒ Future[Result]

4. #### type Outcome = (Request[_]) ⇒ Result

5. #### type OutcomeFactory = (StateAndBreadcrumbs) ⇒ Outcome

6. #### type Renderer = (Request[_]) ⇒ (State, Breadcrumbs, Option[Form[_]]) ⇒ Result

7. #### case class Settings(outcomeFactoryOpt: Option[OutcomeFactory] = None) extends Product with Serializable

   Customizable execution-time settings.

8. #### type WithAuthorised[User] = (Request[_]) ⇒ ((User) ⇒ Future[Result]) ⇒ Future[Result]

### Abstract Value Members

1. #### abstract def context(implicit rh: RequestHeader): RequestContext

   Implement to provide customized request context you require in the service layer *

2. #### abstract def getCallFor(state: State)(implicit request: Request[_]): Call

   Implement to map states into endpoints for redirection and back linking

3. #### abstract val journeyService: JourneyService[RequestContext]

   This has to be injected in the concrete controller

4. #### abstract def renderState(state: State, breadcrumbs: Breadcrumbs, formWithErrors: Option[Form[_]])(implicit request: Request[_]): Result

   Implement to render state after transition or when form validation fails

### Concrete Value Members

1. #### final def !=(arg0: Any): Boolean

   Definition Classes
     AnyRef → Any

2. #### final def ##(): Int

   Definition Classes
     AnyRef → Any

3. #### final def ==(arg0: Any): Boolean

   Definition Classes
     AnyRef → Any

4. #### object Settings extends Serializable

5. #### final def action(body: (Request[_]) ⇒ Future[Result])(implicit ec: ExecutionContext): Action[AnyContent]

   Creates an action for a given async result function.

   Creates an action for a given async result function.

   Attributes
     protected

6. #### object actions

   Collection of DSL-style action builders

7. #### final def apply(transition: Transition, outcomeFactory: OutcomeFactory)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

   Apply state transition and redirect to the URL matching the new state.

   Apply state transition and redirect to the URL matching the new state.

   Attributes
     protected

8. #### final def asInstanceOf[T0]: T0

   Definition Classes
     Any

9. #### final def backLinkFor(breadcrumbs: Breadcrumbs)(implicit request: Request[_]): Call

   Returns a call to the previous state.

   Returns a call to the previous state.

   Attributes
     protected

10. #### final def backLinkToMostRecent[S <: State](breadcrumbs: Breadcrumbs, fallback: Option[Call] = None)(implicit arg0: ClassTag[S], request: Request[_]): Call

    Returns a call to the latest state of S type if exists, otherwise returns a fallback call if defined, or a call to the root state.

    Returns a call to the latest state of S type if exists, otherwise returns a fallback call if defined, or a call to the root state.

    Attributes
      protected

11. #### final def bindForm[T](form: Form[T], transition: (T) ⇒ Transition, outcomeFactory: OutcomeFactory, fallback: ⇒ Future[Result])(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Bind form and apply transition if success, otherwise redirect to the current state with form errors in the flash scope.

    Bind form and apply transition if success, otherwise redirect to the current state with form errors in the flash scope.

    Attributes
      protected

12. #### final def bindForm[T](form: Form[T], transition: (T) ⇒ Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Bind form and apply transition if success, otherwise redirect to the current state with form errors in the flash scope.

    Bind form and apply transition if success, otherwise redirect to the current state with form errors in the flash scope.

    Attributes
      protected

13. #### implicit def build(executable: Executable)(implicit ec: ExecutionContext): Action[AnyContent]

    Implicitly converts Executable to an action.

    Implicitly converts Executable to an action.

    Attributes
      protected

14. #### def clone(): AnyRef

    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

15. #### val defaultShowFallback: Fallback

    Override to change the default behaviour of the actions.show[State].

16. #### final val display: OutcomeFactory

    Display the current state using renderState.

    Display the current state using renderState.

    Attributes
      protected

17. #### final def displayOrRedirectIf[S <: State](implicit arg0: ClassTag[S]): OutcomeFactory

    If the current state is of type S then redirect using URL returned by getCallFor, otherwise display using renderState.

    If the current state is of type S then redirect using URL returned by getCallFor, otherwise display using renderState.

    Attributes
      protected

18. #### final def displayUsing(renderState: Renderer): OutcomeFactory

    Display the current state using custom renderer.

    Display the current state using custom renderer.

    Attributes
      protected

19. #### final def displayUsingOrRedirectIf[S <: State](renderState: Renderer)(implicit arg0: ClassTag[S]): OutcomeFactory

    If the current state is of type S then redirect using URL returned by getCallFor, otherwise display using custom renderer.

    If the current state is of type S then redirect using URL returned by getCallFor, otherwise display using custom renderer.

    Attributes
      protected

20. #### final def eq(arg0: AnyRef): Boolean

    Definition Classes
      AnyRef

21. #### def equals(arg0: Any): Boolean

    Definition Classes
      AnyRef → Any

22. #### def finalize(): Unit

    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )

23. #### final def getClass(): Class[_]

    Definition Classes
      AnyRef → Any

24. #### final def hasRecentState[S <: State](breadcrumbs: Breadcrumbs)(implicit arg0: ClassTag[S]): Boolean

    Check if state of type S exists in the journey history (breadcrumbs).

    Check if state of type S exists in the journey history (breadcrumbs).

    Attributes
      protected

25. #### final def hasState(filter: PartialFunction[State, Unit], stateAndBreadcrumbs: StateAndBreadcrumbs): Boolean

    Check if the expected state exists in the journey history (breadcrumbs).

    Check if the expected state exists in the journey history (breadcrumbs).

    Attributes
      protected
    Annotations
      @tailrec()

26. #### def hashCode(): Int

    Definition Classes
      AnyRef → Any

27. #### final def is[S <: State](state: State)(implicit arg0: ClassTag[S]): Boolean

    Attributes
      protected

28. #### final def isInstanceOf[T0]: Boolean

    Definition Classes
      Any

29. #### final def ne(arg0: AnyRef): Boolean

    Definition Classes
      AnyRef

30. #### final def notify(): Unit

    Definition Classes
      AnyRef

31. #### final def notifyAll(): Unit

    Definition Classes
      AnyRef

32. #### final def parseJson[T](transition: (T) ⇒ Transition, outcomeFactory: OutcomeFactory)(implicit arg0: Reads[T], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Parse request's body as JSON and apply transition if success, otherwise return ifFailure result.

    Parse request's body as JSON and apply transition if success, otherwise return ifFailure result.

    Attributes
      protected

33. #### final val redirect: OutcomeFactory

    Redirect to the current state using URL returned by getCallFor.

    Redirect to the current state using URL returned by getCallFor.

    Attributes
      protected

34. #### final def redirectOrDisplayIf[S <: State](implicit arg0: ClassTag[S]): OutcomeFactory

    If the current state is of type S then display using renderState, otherwise redirect using URL returned by getCallFor.

    If the current state is of type S then display using renderState, otherwise redirect using URL returned by getCallFor.

    Attributes
      protected

35. #### final def redirectOrDisplayIfSame(origin: State): OutcomeFactory

    If the current state is same as the origin then display using renderState, otherwise redirect using URL returned by getCallFor.

    If the current state is same as the origin then display using renderState, otherwise redirect using URL returned by getCallFor.

    Attributes
      protected

36. #### final def redirectOrDisplayUsingIf[S <: State](renderState: Renderer)(implicit arg0: ClassTag[S]): OutcomeFactory

    If the current state is of type S then display using custom renderer, otherwise redirect using URL returned by getCallFor.

    If the current state is of type S then display using custom renderer, otherwise redirect using URL returned by getCallFor.

    Attributes
      protected

37. #### final def redirectOrDisplayUsingIfSame(origin: State, renderState: Renderer): OutcomeFactory

    If the current state is same as the origin then display using custom renderer, otherwise redirect using URL returned by getCallFor.

    If the current state is same as the origin then display using custom renderer, otherwise redirect using URL returned by getCallFor.

    Attributes
      protected

38. #### final def redirectToCurrentState(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Sync view, redirect back to the current state.

    Sync view, redirect back to the current state.

    Attributes
      protected

39. #### final val redirectToCurrentStateFallback: Fallback

40. #### final def redirectToStart(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Default fallback result is to redirect back to the Start state.

    Default fallback result is to redirect back to the Start state.

    Attributes
      protected

41. #### final val redirectToStartFallback: Fallback

42. #### final def rollbackTo[S <: State](fallback: Fallback, outcomeFactory: OutcomeFactory)(stateAndBreadcrumbsOpt: Option[StateAndBreadcrumbs])(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Rollback journey state and history (breadcrumbs) back to the most recent state of type S.

    Rollback journey state and history (breadcrumbs) back to the most recent state of type S.

    Attributes
      protected

43. #### final def rollbackTo(expectedState: PartialFunction[State, Unit])(fallback: ⇒ Future[Result])(stateAndBreadcrumbsOpt: Option[StateAndBreadcrumbs])(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Rollback journey state and history (breadcrumbs) back to the most recent state matching expectation.

    Rollback journey state and history (breadcrumbs) back to the most recent state matching expectation.

    Attributes
      protected

44. #### final def showState[S <: State](outcomeFactory: OutcomeFactory, rollback: Boolean = true, fallback: Fallback)(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the state requested by the type parameter S.

    Display the state requested by the type parameter S. If the current state is not of type S, when rollback flag is true try to rollback to the most recent state matching S, otherwise redirect back to the root state.

    S

      type of the state to display

    outcomeFactory

      outcome factory to use

    Attributes
      protected

45. #### final def showState(expectedStates: ExpectedStates)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the state requested by the type parameter S.

    Display the state requested by the type parameter S. If the current state is not of type S, try rollback to the most recent state matching S, or redirect back to the root state.

    Attributes
      protected

46. #### final def showStateOrApply[S <: State](transition: Transition, outcomeFactory: OutcomeFactory, rollback: Boolean)(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the state requested by the type parameter S.

    Display the state requested by the type parameter S. If the current state is not of type S, when rollback flag is true try to rollback to the most recent state matching S, otherwise apply the transition and, depending on the outcome, redirect to the new state or display if S. If transition is not allowed then redirect back to the current state.

    S

      type of the state to display

    transition

      transition to apply when state S not found

    outcomeFactory

      outcome factory to use

    Attributes
      protected

47. #### final def showStateUsingMergerOrApply[S <: State](merger: Merger[S], outcomeFactory: OutcomeFactory)(transition: Transition)(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the journey state requested by the type parameter S.

    Display the journey state requested by the type parameter S. If the current state is not of type S, try rollback to the most recent state matching S and apply merge function to reconcile the new state with the current state. If there exists no matching state S in the history, apply the transition and, depending on the outcome, redirect to the new state or display if S. If transition is not allowed then redirect back to the current state.

    S

      type of the state to display

    Attributes
      protected

48. #### final def showStateWhenAuthorised[User](withAuthorised: WithAuthorised[User])(expectedStates: ExpectedStates)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    When user is authorized then render current state or rewind to the previous state matching expectation.

    When user is authorized then render current state or rewind to the previous state matching expectation.

    Attributes
      protected

49. #### final def showStateWithRollbackUsingMerger[S <: State](merger: Merger[S], outcomeFactory: OutcomeFactory, fallback: Fallback)(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the state requested by the type parameter S.

    Display the state requested by the type parameter S. If the current state is not of type S try rollback to the most recent state matching S and apply merge function to reconcile the new state with the previous state, or redirect back to the root state.

    Attributes
      protected

50. #### final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
      AnyRef

51. #### def toString(): String

    Definition Classes
      AnyRef → Any

52. #### final def wait(): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

53. #### final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

54. #### final def wait(arg0: Long): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

55. #### final def waitFor[S <: State](interval: Long, maxTimestamp: Long)(outcomeFactory: OutcomeFactory)(ifTimeout: (Request[_]) ⇒ Future[Result])(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Wait for a state to become of type S at most until maxTimestamp.

    Wait for a state to become of type S at most until maxTimestamp. Check in intervals. If the timeout expires, execute ifTimeout.

    Attributes
      protected

56. #### final def whenAuthorised[User](withAuthorised: WithAuthorised[User])(transition: (User) ⇒ Transition)(outcomeFactory: OutcomeFactory)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Apply transition parametrized by an authorised user data.

    Apply transition parametrized by an authorised user data.

    Attributes
      protected

57. #### final def whenAuthorisedWithBootstrapAndForm[User, Payload, T](bootstrap: Transition)(withAuthorised: WithAuthorised[User])(form: Form[Payload])(transition: (User) ⇒ (Payload) ⇒ Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Apply two transitions in order: - first: simple transition - second: transition parametrized by an authorised user data and form output

    Apply two transitions in order: - first: simple transition - second: transition parametrized by an authorised user data and form output

    Attributes
      protected

58. #### final def whenAuthorisedWithForm[User, Payload](withAuthorised: WithAuthorised[User])(form: Form[Payload])(transition: (User) ⇒ (Payload) ⇒ Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Apply transition parametrized by an authorised user data and form output.

    Apply transition parametrized by an authorised user data and form output.

    Attributes
      protected

59. #### def withValidRequest(body: ⇒ Future[Result])(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Interceptor: override to do basic checks on every incoming request (headers, session, etc.)

### Deprecated Value Members

1. #### final def actionShowState(expectedStates: ExpectedStates)(implicit ec: ExecutionContext): Action[AnyContent]

   Attributes
     protected
   Deprecated

     use DSL actions.show[ExpectedState]

2. #### final def actionShowStateWhenAuthorised[User](withAuthorised: WithAuthorised[User])(expectedStates: ExpectedStates)(implicit ec: ExecutionContext): Action[AnyContent]

   Attributes
     protected
   Deprecated

     use DSL actions.whenAuthorised(withAuthorised).show[ExpectedState]

### Inherited from AnyRef

### Inherited from Any

### Ungrouped