// during the session so the session view of the site can
// be cached unless locators do change; if the context
// is invalid, (perhaps because the session was persisted
// and is now being reloaded in a new server), it must be
// replaced with a newly created session context
PortalSiteSessionContext sessionContext = (PortalSiteSessionContext)request.getSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY);
String pipeline = request.getPipeline().getName();
if ((sessionContext == null) || !sessionContext.isValid() || hasPipelineChanged(pipeline, sessionContext.getPipeline()))
{
sessionContext = portalSite.newSessionContext();
sessionContext.setPipeline(pipeline);
request.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, sessionContext);
}
// construct and save a new portalsite request context
// using session context, locators map, fallback, and
// folder page histories; the request context uses the
// locators to initialize or resets the session context if
// locators have changed for this request; the request
// context also acts as a short term request cache for the
// selected page and built menus; however, creating the
// request context here does not select the page or build
// menus: that is done when the request context is
// accessed subsequently
PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators, requestFallback, useHistory);
request.setAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY, requestContext);
// additionally save request context under legacy key
// to support existing decorator access
request.setAttribute(PROFILED_PAGE_CONTEXT_ATTR_KEY, requestContext);