Page History
...
The default BaaS Flow Starter is com.aquima.web.aaas.DefaultBaasFlowStarter. This implementation creates a session without a for the current user and starts the flow, if any exists:
...
Code Block |
---|
package com.aquima.web.aaas; import com.aquima.interactions.portal.IApplication; import com.aquima.interactions.portal.IPortalSession; import com.aquima.interactions.portal.IWebServiceOperationDefinition; import com.aquima.interactions.portal.model.session.PortalEventBus; import com.aquima.interactions.portal.model.session.PortalMessageBus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; import java.util.Map; /** * Default {@link BaasFlowStarter} implementation. This class can be used as a starting point for custom flow starters, * either via extension or via delegation. * * @since 11.4 */ public class DefaultBaasFlowStarter implements BaasFlowStarter { private static final Logger LOG = LoggerFactory.getLogger(DefaultBaasFlowStarter.class); private final IAuthorisationManager authManager; public DefaultBaasFlowStarter(IAuthorisationManager authManager) { this.authManager = authManager; } @Override public IPortalSession createSession(IApplication application) { IUserData userData = authManager.getUserData(); return application.createSession(new PortalMessageBus()null, new PortalEventBus()userData); } @Override public void startFlow(IApplication application, IWebServiceOperationDefinition operation, IPortalSession session) { String flowName = operation.getFlowName(); if (flowName != null) { if (LOG.isInfoEnabled()) { LOG.info("Starting flow: " + flowName); } session.startFlow(flowName, getFlowParameters(), true); } } /** * Returns the flow parameters, which will be added to the request scope. May return null if there are no parameters. * This class always returns null from this method. Subclasses may override this method to add flow parameters. * * @return the flow parameters or null */ protected Map<String, Serializable> getFlowParameters() { return null; } } |
...
Code Block |
---|
package com.example; import com.aquima.interactions.portal.IApplication; import com.aquima.interactions.portal.IPortalSession; import com.aquima.interactions.portal.IWebServiceOperationDefinition; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; @Component public class CustomBaasFlowStarter extends DefaultBaasFlowStarter { private final @Autowired private HttpServletRequest httpRequest;HttpServletRequest httpRequest; public CustomBaasFlowStarter (IAuthorisationManager authManager, HttpServletRequest httpRequest) { // wrap the auth manager in a custom implementation that is also aware of the current HTTP request super(new CustomAuthorisationManager(authManager, httpRequest); this.httpRequest = httpRequest; } @Override public IPortalSession createSession(IApplication application) { IPortalSession result = super.createSession(application); // custom logic, for example execute an action handler to modify the profile before the request is mapped return result; } @Override public void startFlow(IApplication application, IWebServiceOperationDefinition operation, IPortalSession session) { // custom logic before the flow is started, for example: // - setting session scoped attributes // - modify the profile after the request is mapped super.startFlow(application, operation, session); } @Override protected Map<String, Serializable> getFlowParameters() { Map<String, Serializable> parameters = new HashMap<>(); parameters.put("example.custom_parameter", httpRequest.getHeader("X-Custom-Header")); return parameters; } } |
...
Overview
Content Tools