Class PortalSession

java.lang.Object
com.aquima.interactions.portal.model.session.PortalSession
All Implemented Interfaces:
Interruptible, ITimerListener, IPortalSession, ISessionLifecycle, Serializable

public class PortalSession extends Object implements Serializable, IPortalSession, ITimerListener
Implementation class for the portal session interface. This class holds the session information of a single client.
Since:
5.0
Author:
O. Kerpershoek
See Also:
  • Constructor Details

    • PortalSession

      public PortalSession(ISolution solution, IModule module, Channel channel, IUserData user, ITimeTracker timeTracker, IPortalMessageBus messageBus, IPortalEventBus eventBus)
      Constructor to create a session for a specific application.
      Parameters:
      solution - The application object for which the session should be created.
      module - The module containing the definitions that should be used.
      channel - The channel for the portal session.
      user - The client user for the current session, when null the AnonymousUser is used.
      timeTracker - The time tracker to use for performance monitoring
      messageBus - The message bus which is shared among all related sessions
      eventBus - The eventBus to notify other portalsessions of events
      Throws:
      AppException - This exception is thrown when the session can not be initialized.
    • PortalSession

      public PortalSession(ISolution application, IModule module, ITimeTracker timeTracker, ISessionState sessionDump, IPortalMessageBus messageBus, IPortalEventBus eventBus)
      Constructs the portal session from a (previous) session state.
      Parameters:
      application - The application the session is created for.
      module - The main module of the application.
      timeTracker - The time tracker to use for performance monitoring
      sessionDump - Object containing the information needed to restore the session.
      messageBus - The portal message bus
      eventBus - The portal event bus
      Throws:
      AppException - This exception is thrown when the session could not be restored.
      Since:
      9.2
    • PortalSession

      public PortalSession(ISolution application, IModule module, ITimeTracker timeTracker, ISessionState sessionDump, IPortalMessageBus messageBus, IPortalEventBus eventBus, String recomposeNeededCause)
      Constructs the portal session from a (previous) session state. RecomposeNeeded will be set to true.
      Parameters:
      application - The application the session is created for.
      module - The main module of the application.
      timeTracker - The time tracker to use for performance monitoring
      sessionDump - Object containing the information needed to restore the session.
      messageBus - The portal message bus
      eventBus - The portal event bus
      recomposeNeededCause - The reason why a recompose should be performed
      Throws:
      AppException - This exception is thrown when the session could not be restored.
      Since:
      13.13
  • Method Details

    • getSessionId

      public String getSessionId()
      Description copied from interface: IPortalSession
      Returns the optional ID of this session.
      Specified by:
      getSessionId in interface IPortalSession
      Returns:
      the id if available, otherwise null.
    • setSessionId

      public void setSessionId(String id)
      Description copied from interface: IPortalSession
      Sets the optional ID of this session.
      Specified by:
      setSessionId in interface IPortalSession
      Parameters:
      id - the id of the session, may be null.
    • getApplicationId

      public ApplicationID getApplicationId()
      Description copied from interface: IPortalSession
      This method returns the ID of the application/project for which the session was created. NOTE: The ID of the application may differ from the ID returned by the getModule().getId() method.
      Specified by:
      getApplicationId in interface IPortalSession
      Returns:
      The ID of the application/project for which the session was created.
    • getConfiguration

      public IProject getConfiguration()
      Description copied from interface: IPortalSession
      This method returns an object containing the project wide configuration and definitions.
      Specified by:
      getConfiguration in interface IPortalSession
      Returns:
      an object containing the project wide configuration and definitions.
    • getApplication

      public IModule getApplication()
    • getModule

      public IModule getModule()
      Description copied from interface: IPortalSession
      This method returns an object containing the static definitions of the various components as defined by the current module.
      Specified by:
      getModule in interface IPortalSession
      Returns:
      Object containing the static definitions of the various components as defined by the current module.
    • getProfile

      public InferenceContext getProfile()
    • getMonitor

      public ISessionMonitor getMonitor()
      Description copied from interface: IPortalSession
      This method will return a session monitor object containing information about this portal session.
      Specified by:
      getMonitor in interface IPortalSession
      Returns:
      The session monitor of this session.
    • close

      public boolean close()
      Description copied from interface: IPortalSession
      This method will close the session, releasing resources if needed. Once the close method has been invoked, the session has become invalid and cannot be used anymore to handle requests.
      Specified by:
      close in interface IPortalSession
      Returns:
      Boolean indicating if the session was successfully closed.
    • getCurrentPage

      public IPage getCurrentPage()
      Description copied from interface: IPortalSession
      Returns the last generated page for rendering to the client. If there is no page generated yet this function returns null
      Specified by:
      getCurrentPage in interface IPortalSession
      Returns:
      IPage the current page model.
    • getContext

      public PortalContext getContext()
      This method exposes the internal state of the session. The method is only public to allow test cases access, but this method should never be exposed through the portal session interface.
      Returns:
      PortalContext object containing the internal state of the session.
    • handleEvent

      public PortalResponse handleEvent(PortalEvent portalEvent)
      Description copied from interface: IPortalSession
      This method will process the event passed, and continue the flow if needed. Depending on the type of event this method will either stay on the same page (refresh) or try to continue the flow to the next page (submit). The response that is returned by this method contains the page definition of the next page that should be displayed.
      Note: The next page to display may be the same as the page that was already shown.
      Specified by:
      handleEvent in interface IPortalSession
      Parameters:
      portalEvent - Event object containing input values from the client and the requested action.
      Returns:
      The response of the flow action containing the page definition of the page where the flow stopped.
    • handleFlow

      protected PortalResponse handleFlow(PortalEvent pageEvent, IValueFormatter inputParser, RequestAction requestAction, EventErrors errors)
    • handleRefresh

      protected PortalResponse handleRefresh(PortalEvent pageEvent, IValueFormatter formatter, RequestAction requestAction, EventErrors errors)
    • handleRequest

      protected boolean handleRequest(PortalEvent pageEvent, IValueFormatter inputParser, RequestAction action, EventErrors errors)
    • handleCallbacks

      protected com.aquima.interactions.portal.model.session.PortalSession.HandleResult handleCallbacks(RequestAction action, EventErrors errors, PortalEvent pageEvent, IValueFormatter inputParser, boolean beforeValidation)
    • activeContextInstances

      protected void activeContextInstances(RequestAction action)
    • flowToNextPage

      protected com.aquima.interactions.portal.model.session.PortalSession.HandleResult flowToNextPage(RequestAction action, String exitEvent, EventErrors errors)
    • determineRequestAction

      protected RequestAction determineRequestAction(PortalEvent pageEvent)
    • startFlow

      public PortalResponse startFlow(String flowName, Map<String,Serializable> parameters, boolean allowUnexposedFlows)
      Description copied from interface: IPortalSession
      This method will start the flow with the specified name. If another flow was active when this method is invoked, that flow will be aborted, and it's transaction will be rolled back.

      NOTE: As of version 7.0 an active flow must be stopped by using the stopFlow method before a new flow may be started.

      When the flow has been successfully started, the method will return a response containing the page definition of the first page encountered during the flow. The handleEvent method may be used to continue the flow. This method may fail for various reasons, for example when the flow name specified is unknown or not accessible. An object containing request parameters may be passed to this method. The parameters from this object will be available in the request scope, and allows services for instance to act on information passed through the URL starting the flow. The parameters object is optional, and if no additional parameters need to be passed to the flow, a null value may be supplied.
      Specified by:
      startFlow in interface IPortalSession
      Parameters:
      flowName - The name of the flow that should be started.
      parameters - Optional object containing parameters from the 'request' that should be available in the request scope.
      allowUnexposedFlows - indicator to specify if unexposed flows may be started
      Returns:
      The response of the flow action containing the page definition of the page where the flow stopped.
    • stopFlow

      public void stopFlow(boolean commitPendingChanges)
      Description copied from interface: IPortalSession
      This method will stop the current flow and commit or rollback any pending changes.
      Specified by:
      stopFlow in interface IPortalSession
      Parameters:
      commitPendingChanges - Boolean indicating if pending changes should be committed.
    • composePage

      protected IPage composePage(String pageId, EventErrors errors)
    • getCurrentFlowState

      public IFlowState getCurrentFlowState()
      Description copied from interface: IPortalSession
      Returns the current flowState.
      Specified by:
      getCurrentFlowState in interface IPortalSession
      Returns:
      Object containing information about the current flow path.
    • executeAction

      public IActionResult executeAction(String handlerName, Map<String,?> parameters)
      Description copied from interface: IPortalSession
      This method will invoke an action handler using the current portal session context. The action handler will be executed in the same transaction context of the current page. The parameters passed to this method will be exposed via the IRequestScope in the action handler.
      Specified by:
      executeAction in interface IPortalSession
      Parameters:
      handlerName - The name of the action handler that should be invoked.
      parameters - The parameters for the action handler.
      Returns:
      The result object from the action handler.
      See Also:
    • executeInlineAction

      public IActionResult executeInlineAction(IActionHandler handler, Map<String,? extends Object> parameters)
      Description copied from interface: IPortalSession
      This method will invoke an action handler using the current portal session context. The action handler will be executed in the same transaction context of the current page. The parameters passed to this method will be exposed via the IRequestScope in the action handler.
      Specified by:
      executeInlineAction in interface IPortalSession
      Parameters:
      handler - The action handler which should be executed.
      parameters - The parameters for the action handler.
      Returns:
      The result object from the action handler.
      See Also:
    • executeCallback

      public void executeCallback(IPortalSessionCallback callback)
      Description copied from interface: IPortalSession
      Executes a callback. It is up to the IPortalSession implementation to decide which IPortalSession is passed as parameter to the callback. In the general case, the IPortalSession parameter is the same instance as the IPortalSession which is executing the callback, but this is not a requirement and some IPortalSession implementations may deviate from the general case.
      Specified by:
      executeCallback in interface IPortalSession
      Parameters:
      callback - the callback which should be executed (may not be null)
    • getCurrentLanguage

      public ILanguage getCurrentLanguage()
      Description copied from interface: IPortalSession
      Returns the current language active within the portal-engine.
      Specified by:
      getCurrentLanguage in interface IPortalSession
      Returns:
      The current language object.
    • setCurrentLanguage

      public void setCurrentLanguage(String languageCode)
      Description copied from interface: IPortalSession
      Changes the current language for this portal session.
      Specified by:
      setCurrentLanguage in interface IPortalSession
      Parameters:
      languageCode - The code of the language
    • onTimerEvent

      public void onTimerEvent(ITimerEvent timerEvent)
      Calling this method will update the value for system.today.
      Specified by:
      onTimerEvent in interface ITimerListener
      Parameters:
      timerEvent - The time event.
    • getState

      public IPortalSessionState getState()
      Description copied from interface: IPortalSession
      Returns the state of the session (for serialization)
      Specified by:
      getState in interface IPortalSession
      Returns:
      returns the current state of the session.
    • restore

      public void restore(IPortalSessionState state)
      Description copied from interface: IPortalSession
      Clears the current state and overrides it with the provided state.
      Specified by:
      restore in interface IPortalSession
      Parameters:
      state - The new state for this session.
    • reset

      public void reset()
      Description copied from interface: IPortalSession
      Resets the portal session. Current page, profile and scopes will all be cleared. The message bus will not be cleared explicitly.
      Specified by:
      reset in interface IPortalSession
    • getCurrentChannel

      public Channel getCurrentChannel()
      Description copied from interface: IPortalSession
      Returns the current channel.
      Specified by:
      getCurrentChannel in interface IPortalSession
      Returns:
      The channel.
    • getMessageBus

      public IPortalMessageBus getMessageBus()
      Description copied from interface: IPortalSession
      Returns the messagebus.
      Specified by:
      getMessageBus in interface IPortalSession
      Returns:
      The messagebus, not null.
    • getEventBus

      public IPortalEventBus getEventBus()
      Description copied from interface: IPortalSession
      Returns the event bus used by this session.
      Specified by:
      getEventBus in interface IPortalSession
      Returns:
      the event bus, not null.
    • getCurrentFlow

      public String getCurrentFlow()
      Description copied from interface: IPortalSession
      Returns the current flow
      Specified by:
      getCurrentFlow in interface IPortalSession
      Returns:
      The current flow
    • getCaseEngineClient

      public CaseEngineClient getCaseEngineClient()
      Description copied from interface: IPortalSession
      Returns the optional CaseEngineClient
      Specified by:
      getCaseEngineClient in interface IPortalSession
      Returns:
      The CaseEngineClient
    • getAuditEngine

      public IAuditEngine getAuditEngine()
      Description copied from interface: IPortalSession
      Returns the AuditEngine
      Specified by:
      getAuditEngine in interface IPortalSession
      Returns:
      The AuditEngine
    • activate

      public void activate(ISessionActivationContext sessionActivationContext)
      Description copied from interface: ISessionLifecycle
      This method may be used for activating the objects after deserialization.
      Specified by:
      activate in interface ISessionLifecycle
      Parameters:
      sessionActivationContext - the current session activation context.
    • passivate

      public void passivate()
      Description copied from interface: ISessionLifecycle
      This method may be used for preparing the objects for serialization.
      Specified by:
      passivate in interface ISessionLifecycle
    • interrupt

      public void interrupt()
      Description copied from interface: Interruptible
      Sets the interrupted flag, indicating that this object should interrupt the computation it is currently performing (typically on another thread) as soon as possible, and exit by throwing an InterruptedException.
      Specified by:
      interrupt in interface Interruptible
    • isInterrupted

      public boolean isInterrupted()
      Description copied from interface: Interruptible
      Indicates whether the interrupted flag has been set.
      Specified by:
      isInterrupted in interface Interruptible
      Returns:
      true if the interrupted flag is set, false otherwise.