private List<Session> getSessionList(final HstRequestContext requestContext) { return (List<Session>)requestContext.getAttribute(SESSIONS_KEY_LIST_ATTR_NAME); }
private Map<DelegateSessionKey, Session> getSessionMap(final HstRequestContext requestContext) { return (Map<DelegateSessionKey, Session>)requestContext.getAttribute(SESSIONS_KEY_MAP_ATTR_NAME); }
/** * Return the current Content Serialization phase. * @return the current Content Serialization phase */ public static Phase getCurrentPhase() { final HstRequestContext requestContext = RequestContextProvider.get(); if (requestContext == null) { return null; } Phase phase = (Phase) requestContext.getAttribute(PHASE_ATTR); return phase; }
public String getHostGroupNameForCmsHost() { String hostGroupNameForCmsHost = (String)RequestContextProvider.get().getAttribute(HOST_GROUP_NAME_FOR_CMS_HOST); if (hostGroupNameForCmsHost == null) { throw new IllegalStateException("For cms rest request there should be a request context attr for '"+HOST_GROUP_NAME_FOR_CMS_HOST+"' " + "but wasn't found."); } return hostGroupNameForCmsHost; } public void setChannelManager(final ChannelManager channelManager) {
/** * Return the current {@link AggregatedPageModel} object. * @return the current {@link AggregatedPageModel} object */ public static AggregatedPageModel getCurrentAggregatedPageModel() { final HstRequestContext requestContext = RequestContextProvider.get(); if (requestContext != null) { return (AggregatedPageModel) requestContext.getAttribute(AGGREGATED_PAGE_MODEL_ATTR); } return null; }
/** * Exit from the last top level bean's serialization sub-context. */ public static String endTopLevelContentBean() { final HstRequestContext requestContext = RequestContextProvider.get(); Stack<String> baseModelIdStack = (Stack<String>) requestContext .getAttribute(TOP_LEVEL_BEAN_IDS_STACK_ATTR_NAME); if (baseModelIdStack == null || baseModelIdStack.empty()) { throw new IllegalStateException("No current top level content bean representation ID in the internal stack."); } return baseModelIdStack.pop(); }
/** * Get the current top level bean's {@code representationId} from the content bean serialization sub-context. * @return the current top level bean's {@code representationId} from the internal stack */ private static String getCurrentTopLevelContentBeanRepresentationId() { final HstRequestContext requestContext = RequestContextProvider.get(); final Stack<String> topLevelBeanModelIdStack = (Stack<String>) requestContext .getAttribute(TOP_LEVEL_BEAN_IDS_STACK_ATTR_NAME); if (topLevelBeanModelIdStack == null || topLevelBeanModelIdStack.empty()) { throw new IllegalStateException("No current top level content bean representation ID in the internal stack."); } return topLevelBeanModelIdStack.peek(); }
public String getRequestConfigIdentifier() { return (String) getRequestContext().getAttribute(CXFJaxrsHstConfigService.REQUEST_CONFIG_NODE_IDENTIFIER); }
/** * Get the <code>Set</code> for the current top level content bean's serialization sub-context, specified by * the {@code topLevelContentBeanRepresentationId}. * @param topLevelContentBeanRepresentationId the top level content bean's representation ID * @return the <code>Set</code> for the current top level content bean's serialization sub-context, * specified by the {@code topLevelContentBeanRepresentationId} */ @SuppressWarnings("unchecked") public static Set<HippoBeanWrapperModel> getContentBeanModelSet( final String topLevelContentBeanRepresentationId) { final HstRequestContext requestContext = RequestContextProvider.get(); Map<String, Set<HippoBeanWrapperModel>> modelSetMap = (Map<String, Set<HippoBeanWrapperModel>>) requestContext .getAttribute(BEAN_MODEL_SET_MAP_ATTR_NAME); if (modelSetMap == null) { return null; } return modelSetMap.get(topLevelContentBeanRepresentationId); }
private String getHostGroupNameFromContext() throws ChannelException { // FIXME: move all modification methods to the 'cmsrest' module and use the // CmsRestSecurityValve#HOST_GROUP_NAME_FOR_CMS_HOST constant instead of the hardcoded string "HOST_GROUP_NAME_FOR_CMS_HOST" final String hostGroupForCmsHost = (String) RequestContextProvider.get().getAttribute("HOST_GROUP_NAME_FOR_CMS_HOST"); if (StringUtils.isEmpty(hostGroupForCmsHost)) { throw new ChannelException("There is no hostgroup for cms host available. Cannot get or create virtual hosts"); } return hostGroupForCmsHost; }
/** * Enter into a specific top level bean's (referred to by {@code representationId}) content bean serialization sub-context. * @param representationId the top level bean's {@code representationId} */ public static void beginTopLevelContentBean(final String representationId) { final HstRequestContext requestContext = RequestContextProvider.get(); Stack<String> baseModelIdStack = (Stack<String>) requestContext .getAttribute(TOP_LEVEL_BEAN_IDS_STACK_ATTR_NAME); if (baseModelIdStack == null) { baseModelIdStack = new Stack<>(); requestContext.setAttribute(TOP_LEVEL_BEAN_IDS_STACK_ATTR_NAME, baseModelIdStack); } baseModelIdStack.push(representationId); }
/** * Add the {@code model} to the serialization sub-context. * @param model the content bean model to add */ @SuppressWarnings("unchecked") public static void addSerializableContentBeanModel(HippoBeanWrapperModel model) { final HstRequestContext requestContext = RequestContextProvider.get(); Map<String, Set<HippoBeanWrapperModel>> modelSetMap = (Map<String, Set<HippoBeanWrapperModel>>) requestContext .getAttribute(BEAN_MODEL_SET_MAP_ATTR_NAME); if (modelSetMap == null) { modelSetMap = new HashMap<>(); requestContext.setAttribute(BEAN_MODEL_SET_MAP_ATTR_NAME, modelSetMap); } final String topLevelBeanRepresentationId = getCurrentTopLevelContentBeanRepresentationId(); Set<HippoBeanWrapperModel> modelSet = modelSetMap.get(topLevelBeanRepresentationId); if (modelSet == null) { modelSet = new LinkedHashSet<>(); modelSetMap.put(topLevelBeanRepresentationId, modelSet); } modelSet.add(model); }
protected void clearSubjectSession(ValveContext valveContext, HstRequestContext requestContext, boolean sessionStateful) throws ContainerException { LazySession lazySession = null; if (sessionStateful) { /* * We do not log out or refresh session stateful jcr session: This is done by either: * 1) The JCRSessionStatefulConcurrencyValve refreshes the jcr session when needed * 2) When the HttpSession container the jcr session is invalidated (unbinded), the LazySession logs itself out in the finally part */ } else { lazySession = (LazySession) requestContext.getAttribute(SubjectBasedSessionValve.SUBJECT_BASED_SESSION_ATTR_NAME); if (lazySession != null) { try { if (lazySession.isLive()) { lazySession.logout(); } } catch (Exception e) { if (log.isDebugEnabled()) { log.warn("Failed to logout session.", e); } else if (log.isWarnEnabled()) { log.warn("Failed to logout session. " + e); } } requestContext.removeAttribute(SubjectBasedSessionValve.SUBJECT_BASED_SESSION_ATTR_NAME); } } } }
lazySession = (LazySession) requestContext.getAttribute(SUBJECT_BASED_SESSION_ATTR_NAME);
Session persistableSession = (Session) requestContext.getAttribute(PERSISTABLE_SESSION_ATTR);
final Mount unDecoratedMount = (Mount) requestContext.getAttribute(ContainerConstants.UNDECORATED_MOUNT); resolvedMount.setMount(unDecoratedMount); HstLink bestLink = getBestLink(uuid, type);
Session session = (Session) requestContext.getAttribute(disposableKey); if (session != null) { log.debug("There is already a disposable session for '{}' on the request context. Return that session", disposablePoolSessionUserId);