Class PortalSession
java.lang.Object
com.aquima.interactions.portal.model.session.PortalSession
- All Implemented Interfaces:
Interruptible
,ITimerListener
,IPortalSession
,ISessionLifecycle
,Serializable
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 Summary
ConstructorsConstructorDescriptionPortalSession
(ISolution application, IModule module, ITimeTracker timeTracker, ISessionState sessionDump, IPortalMessageBus messageBus, IPortalEventBus eventBus) Constructs the portal session from a (previous) session state.PortalSession
(ISolution application, IModule module, ITimeTracker timeTracker, ISessionState sessionDump, IPortalMessageBus messageBus, IPortalEventBus eventBus, String recomposeNeededCause) Constructs the portal session from a (previous) session state.PortalSession
(ISolution solution, IModule module, Channel channel, IUserData user, ITimeTracker timeTracker, IPortalMessageBus messageBus, IPortalEventBus eventBus) Constructor to create a session for a specific application. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ISessionActivationContext sessionActivationContext) This method may be used for activating the objects after deserialization.protected void
activeContextInstances
(RequestAction action) boolean
close()
This method will close the session, releasing resources if needed.protected IPage
composePage
(String pageId, EventErrors errors) protected RequestAction
determineRequestAction
(PortalEvent pageEvent) executeAction
(String handlerName, Map<String, ?> parameters) This method will invoke an action handler using the current portal session context.void
executeCallback
(IPortalSessionCallback callback) Executes a callback.executeInlineAction
(IActionHandler handler, Map<String, ? extends Object> parameters) This method will invoke an action handler using the current portal session context.protected com.aquima.interactions.portal.model.session.PortalSession.HandleResult
flowToNextPage
(RequestAction action, String exitEvent, EventErrors errors) This method returns the ID of the application/project for which the session was created.Returns the AuditEngineReturns the optional CaseEngineClientThis method returns an object containing the project wide configuration and definitions.This method exposes the internal state of the session.Returns the current channel.Returns the current flowReturns the current flowState.Returns the current language active within the portal-engine.Returns the last generated page for rendering to the client.Returns the event bus used by this session.Returns the messagebus.This method returns an object containing the static definitions of the various components as defined by the current module.This method will return a session monitor object containing information about this portal session.Returns the optional ID of this session.getState()
Returns the state of the session (for serialization)protected com.aquima.interactions.portal.model.session.PortalSession.HandleResult
handleCallbacks
(RequestAction action, EventErrors errors, PortalEvent pageEvent, IValueFormatter inputParser, boolean beforeValidation) handleEvent
(PortalEvent portalEvent) This method will process the event passed, and continue the flow if needed.protected PortalResponse
handleFlow
(PortalEvent pageEvent, IValueFormatter inputParser, RequestAction requestAction, EventErrors errors) protected PortalResponse
handleRefresh
(PortalEvent pageEvent, IValueFormatter formatter, RequestAction requestAction, EventErrors errors) protected boolean
handleRequest
(PortalEvent pageEvent, IValueFormatter inputParser, RequestAction action, EventErrors errors) void
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 anInterruptedException
.boolean
Indicates whether the interrupted flag has been set.void
onTimerEvent
(ITimerEvent timerEvent) Calling this method will update the value for system.today.void
This method may be used for preparing the objects for serialization.void
reset()
Resets the portal session.void
restore
(IPortalSessionState state) Clears the current state and overrides it with the provided state.void
setCurrentLanguage
(String languageCode) Changes the current language for this portal session.void
setSessionId
(String id) Sets the optional ID of this session.startFlow
(String flowName, Map<String, Serializable> parameters, boolean allowUnexposedFlows) This method will start the flow with the specified name.void
stopFlow
(boolean commitPendingChanges) This method will stop the current flow and commit or rollback any pending changes.
-
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 monitoringmessageBus
- The message bus which is shared among all related sessionseventBus
- 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 monitoringsessionDump
- Object containing the information needed to restore the session.messageBus
- The portal message buseventBus
- 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 monitoringsessionDump
- Object containing the information needed to restore the session.messageBus
- The portal message buseventBus
- The portal event busrecomposeNeededCause
- 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
Description copied from interface:IPortalSession
Returns the optional ID of this session.- Specified by:
getSessionId
in interfaceIPortalSession
- Returns:
- the id if available, otherwise null.
-
setSessionId
Description copied from interface:IPortalSession
Sets the optional ID of this session.- Specified by:
setSessionId
in interfaceIPortalSession
- Parameters:
id
- the id of the session, may be null.
-
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 interfaceIPortalSession
- Returns:
- The ID of the application/project for which the session was created.
-
getConfiguration
Description copied from interface:IPortalSession
This method returns an object containing the project wide configuration and definitions.- Specified by:
getConfiguration
in interfaceIPortalSession
- Returns:
- an object containing the project wide configuration and definitions.
-
getApplication
-
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 interfaceIPortalSession
- Returns:
- Object containing the static definitions of the various components as defined by the current module.
-
getProfile
-
getMonitor
Description copied from interface:IPortalSession
This method will return a session monitor object containing information about this portal session.- Specified by:
getMonitor
in interfaceIPortalSession
- 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 interfaceIPortalSession
- Returns:
- Boolean indicating if the session was successfully closed.
-
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 interfaceIPortalSession
- Returns:
- IPage the current page model.
-
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
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 interfaceIPortalSession
- 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
-
flowToNextPage
protected com.aquima.interactions.portal.model.session.PortalSession.HandleResult flowToNextPage(RequestAction action, String exitEvent, EventErrors errors) -
determineRequestAction
-
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 interfaceIPortalSession
- 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 interfaceIPortalSession
- Parameters:
commitPendingChanges
- Boolean indicating if pending changes should be committed.
-
composePage
-
getCurrentFlowState
Description copied from interface:IPortalSession
Returns the current flowState.- Specified by:
getCurrentFlowState
in interfaceIPortalSession
- Returns:
- Object containing information about the current flow path.
-
executeAction
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 interfaceIPortalSession
- 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 interfaceIPortalSession
- 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
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 interfaceIPortalSession
- Parameters:
callback
- the callback which should be executed (may not be null)
-
getCurrentLanguage
Description copied from interface:IPortalSession
Returns the current language active within the portal-engine.- Specified by:
getCurrentLanguage
in interfaceIPortalSession
- Returns:
- The current language object.
-
setCurrentLanguage
Description copied from interface:IPortalSession
Changes the current language for this portal session.- Specified by:
setCurrentLanguage
in interfaceIPortalSession
- Parameters:
languageCode
- The code of the language
-
onTimerEvent
Calling this method will update the value for system.today.- Specified by:
onTimerEvent
in interfaceITimerListener
- Parameters:
timerEvent
- The time event.
-
getState
Description copied from interface:IPortalSession
Returns the state of the session (for serialization)- Specified by:
getState
in interfaceIPortalSession
- Returns:
- returns the current state of the session.
-
restore
Description copied from interface:IPortalSession
Clears the current state and overrides it with the provided state.- Specified by:
restore
in interfaceIPortalSession
- 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 interfaceIPortalSession
-
getCurrentChannel
Description copied from interface:IPortalSession
Returns the current channel.- Specified by:
getCurrentChannel
in interfaceIPortalSession
- Returns:
- The channel.
-
getMessageBus
Description copied from interface:IPortalSession
Returns the messagebus.- Specified by:
getMessageBus
in interfaceIPortalSession
- Returns:
- The messagebus, not null.
-
getEventBus
Description copied from interface:IPortalSession
Returns the event bus used by this session.- Specified by:
getEventBus
in interfaceIPortalSession
- Returns:
- the event bus, not null.
-
getCurrentFlow
Description copied from interface:IPortalSession
Returns the current flow- Specified by:
getCurrentFlow
in interfaceIPortalSession
- Returns:
- The current flow
-
getCaseEngineClient
Description copied from interface:IPortalSession
Returns the optional CaseEngineClient- Specified by:
getCaseEngineClient
in interfaceIPortalSession
- Returns:
- The CaseEngineClient
-
getAuditEngine
Description copied from interface:IPortalSession
Returns the AuditEngine- Specified by:
getAuditEngine
in interfaceIPortalSession
- Returns:
- The AuditEngine
-
activate
Description copied from interface:ISessionLifecycle
This method may be used for activating the objects after deserialization.- Specified by:
activate
in interfaceISessionLifecycle
- 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 interfaceISessionLifecycle
-
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 anInterruptedException
.- Specified by:
interrupt
in interfaceInterruptible
-
isInterrupted
public boolean isInterrupted()Description copied from interface:Interruptible
Indicates whether the interrupted flag has been set.- Specified by:
isInterrupted
in interfaceInterruptible
- Returns:
- true if the interrupted flag is set, false otherwise.
-