Interface HstRequestContext

  • All Superinterfaces:
    ModelContributable
    All Known Subinterfaces:
    HstMutableRequestContext

    public interface HstRequestContext
    extends ModelContributable
    HstRequestContext provides repository content context and page/components configuration context. Also, HstRequestContext is shared among all the HstComponent windows in a request lifecycle.
    Version:
    $Id$
    • Method Detail

      • getServletContext

        javax.servlet.ServletContext getServletContext()
        Returns the ServletContext for this request
        Returns:
        the ServletContext for this request
      • getServletRequest

        javax.servlet.http.HttpServletRequest getServletRequest()
        Returns the current HttpServletRequest
        Returns:
        the current HttpServletRequest
      • getServletResponse

        javax.servlet.http.HttpServletResponse getServletResponse()
        Returns the current HttpServletResponse
        Returns:
        the current HttpServletResponse
      • getSession

        javax.jcr.Session getSession()
                              throws javax.jcr.LoginException,
                                     javax.jcr.RepositoryException
        Returns a session which is normally retrieved from a session pooling repository.

        Returns the current javax.jcr.Session associated with this requestContext or, if if there is no current JCR session, creates and returns a new JCR session.

        Returns:
        a session, which is normally retrieved from a session pooling repository
        Throws:
        javax.jcr.LoginException
        javax.jcr.RepositoryException
      • getSession

        javax.jcr.Session getSession​(boolean create)
                              throws javax.jcr.LoginException,
                                     javax.jcr.RepositoryException
        Returns a session which can be retrieved from a session pooling repository.

        Returns the current javax.jcr.Session associated with this requestContext or, if if there is no current JCR session and create is true, returns a new JCR session.

        If create is false and the requestContext has no javax.jcr.Session, this method returns null.

        Returns:
        a session, which is normally retrieved from a session pooling repository
        Throws:
        javax.jcr.LoginException
        javax.jcr.RepositoryException
      • isPreview

        boolean isPreview()
        Returns:
        true when this request is matched to a preview site
        See Also:
        Mount.isPreview()
      • getBaseURL

        HstContainerURL getBaseURL()
        Returns the base container URL (HstContainerURL ) of the current request lifecycle.
        Returns:
        HstContainerURL
      • setAttribute

        void setAttribute​(String name,
                          Object object)
        Set an attribute to be shared among each HstComponent windows. Because this attribute is not prefixed by the reference namespace of the HstComponent window, this method can be used if the attribute is to be shared among HstComponent windows.
        Parameters:
        name - attribute name
        object - attribute value
      • getAttribute

        Object getAttribute​(String name)
        Retrieve the attribute value by the attribute name. Because this attribute is not prefixed by the reference namespace of the HstComponent window, this method can be used if the attribute is to be shared among HstComponent windows.
      • removeAttribute

        void removeAttribute​(String name)
        Removes the attribute by the attribute name.
      • getAttributeNames

        Enumeration<String> getAttributeNames()
        Enumerates the attribute names
      • getAttributes

        Map<String,​Object> getAttributes()
        Returns attribute map which is unmodifiable. So, do not try to put or remove items directly from the returned map.
        Returns:
        attribute map which is unmodifiable. So, do not try to put or remove items directly from the returned map.
      • getVirtualHost

        VirtualHost getVirtualHost()
        Returns the matched virtual host object
        Returns:
        the matched virtual host object
      • isChannelManagerPreviewRequest

        boolean isChannelManagerPreviewRequest()
        Returns:
        true when the request is for the preview of the site in the Channel Manager
      • isChannelManagerRestRequest

        boolean isChannelManagerRestRequest()
        Returns:
        true when the request is for a REST invocation in the Channel Manager
      • isPageModelApiRequest

        boolean isPageModelApiRequest()
        Returns:
        true in case the current request is a Page Model API request
      • isRenderingHistory

        boolean isRenderingHistory()

        when the current request is rendering a history version, this boolean is true (note a node from version history does not per se mean that the request is rendering history since it might be the most recent version of a branch still. This is true only when really a specific older historic version is being rendered.

        Only when isChannelManagerPreviewRequest() is true, this method isRenderingHistory() can be true

        Returns:
        true in case the current request is rendering a history version
      • getContextCredentialsProvider

        ContextCredentialsProvider getContextCredentialsProvider()
        Returns the context credentials provider
        Returns:
        the context credentials provider
      • getSubject

        Subject getSubject()
        Gets the subject associated with the authorized entity.
        Returns:
        The JAAS subject on this request.
      • getPreferredLocale

        Locale getPreferredLocale()
        Gets the preferred locale associated with this request.
        Returns:
        The preferred locale associated with this request.
      • getLocales

        Enumeration<Locale> getLocales()
        Returns an Enumeration of Locale objects
        Returns:
        The locale associated with this request.
      • getPathSuffix

        String getPathSuffix()
        Returns the path suffix from the resolved site map item. If it is null, then returns the path suffix from the resolved Mount.
        Returns:
        the matched path suffix and null if there is no path suffix
      • getMount

        Mount getMount​(String alias)

        a mount with Mount.getAlias() equal to alias and at least one common type with the mount from the current request. Thus, at least one of the types of the found Mount.getTypes() must be equal to one of the types of the mount of the current request.

        If there can be found a Mount with the same primary type ( Mount.getType() ) as the one for the mount of the current request, this Mount has precedence. If there is no primary type match, we'll return the mount that has most types in common

        There will be looked if the Mount of the current HstRequestContext has a property that is called hst:mountXXX where XXX is equal to alias. If so, there will be tried to return a Mount that has an alias equal to the value of this mappedAlias property hst:mountXXX. If there cannot be found a Mount for via a mapped hst:mountXXX property, there will be looked for a Mount with which has Mount.getAlias() equal to alias. Thus a mapped alias has precedence!

        Parameters:
        alias - the alias the found Mount or XXX in hst:mountXXX property
        Returns:
        a mount with Mount.getAlias() equal to alias or mappedAlias and at least one common type with the mount from the current request. null if there is no suitable mount.
        Throws:
        IllegalArgumentException - when alias is null
      • getMount

        Mount getMount​(String alias,
                       String type)

        a mount with Mount.getAlias() equal to alias and one of its Mount.getTypes() equal to type.

        There will be looked if the Mount of the current HstRequestContext has a property that is called hst:mountXXX where XXX is equal to alias. If so, there will be tried to return a Mount that has an alias equal to the value of this mappedAlias property hst:mountXXX. If there cannot be found a Mount for via a mapped hst:mountXXX property, there will be looked for a Mount with which has Mount.getAlias() equal to alias.

        Parameters:
        alias - the alias the found Mount or or XXX in hst:mountXXX property
        type - the type the found Mount should have
        Returns:
        a mount with Mount.getAlias() equal to alias or mappedAlias and one of its Mount.getTypes() equal to type. null if there is no suitable mount.
        Throws:
        IllegalArgumentException - when alias or type is null
      • getComponentFilterTags

        Set<String> getComponentFilterTags()

        Expert: The tags that will be used to render container items. These tags can be used by a HstComponentFactory implementation to decide to load some specific HstComponentWindows only.

        This method is in general not useful for frontend developers and is more targetted for the HST Core

        HST Core HstComponentFactory implementations behave as follows: When tags are available, and there is a container item in a container that matches the tag, those container items will be rendered at the exclusion of the other items. If no tags are provided, or none matches any of the tags on the container items, only those container items that do not have a tag will be rendered.

        Returns:
        The (immutable) active set of filter tags, empty when conditional rendering is not used.
      • getComponentWindowFilters

        List<HstComponentWindowFilter> getComponentWindowFilters()

        Expert: Option to add filters to the HstRequestContext. Note that this only affects outcome if it is done before the actual doBeforeRender / doAction etc or rendering is invoked by the HST

        Returns:
        the (immutable) List of HstComponentWindowFilters and if none present, return a empty List
      • isFullyQualifiedURLs

        boolean isFullyQualifiedURLs()
        Returns:
        true when all URLs must be fully qualified, ie, including scheme, domain and portnumber (if present)
      • getRenderHost

        String getRenderHost()
        Returns:
        the render host to use for rendering the request or null when no specific render host is defined. Typically, there is only a render host when the request originated from the CMS
      • getSiteContentBasePath

        String getSiteContentBasePath()
        Returns:
        the root content path relative to the root node for the ResolvedMount belonging to the current HttpServletRequest. The path never starts with a "/" as it is relative to the root node.
      • getHeadContributable

        HeadContributable getHeadContributable​(String name)
        Return HeadContributable object by the name if found. null if not found.
        Parameters:
        name - the name of the logical head contributor.
        Returns:
        HeadContributable object by the name if found. null if not found
      • isSearchEngineOrBotRequest

        boolean isSearchEngineOrBotRequest()
        Return true if it was determined that the request comes from a search engine.
        Returns:
        true if it was determined that the request comes from a search engine