Class CmsContextInfo

  • All Implemented Interfaces:
    java.io.Serializable

    public class CmsContextInfo
    extends java.lang.Object
    implements java.io.Serializable
    Contains user information for automated creation of a CmsRequestContext during system runtime.

    Since:
    6.0.0
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ATTRIBUTE_REQUEST_TIME
      Name of the http session attribute the request time is stored in.
      static long CURRENT_TIME
      Indicates the request time should always be the current time.
      static java.lang.String LOCALHOST
      Localhost ip used in fallback cases.
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsContextInfo()
      Creates a new instance, initializing the variables with some reasonable default values.
      CmsContextInfo​(java.lang.String userName)
      Creates a new instance, initializing the user name as provided and all other vaiables with the same default values as in CmsContextInfo().
      CmsContextInfo​(CmsRequestContext requestContext)
      Creates a new instance with all context variables initialized from the given request context.
      CmsContextInfo​(CmsUser user, CmsProject project, java.lang.String requestedUri, CmsSiteMatcher requestMatcher, java.lang.String siteRoot, boolean isSecureRequest, java.util.Locale locale, java.lang.String encoding, java.lang.String remoteAddr, long requestTime, java.lang.String ouFqn, boolean isForceAbsoluteLinks)
      Creates a new instance with all context variables initialized.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkFrozen()
      Checks if this context info configuration is frozen.
      java.lang.Object clone()
      Creates a clone of this context info object.
      void freeze()
      Finalizes (freezes) the configuration of this context information.
      CmsResource getDetailResource()
      Gets the detail content resource.
      java.lang.String getEncoding()
      Returns the encoding.
      java.util.Locale getLocale()
      Returns the locale.
      java.lang.String getLocaleName()
      Returns the locale name.
      java.lang.String getOuFqn()
      Returns the fully qualified name of the organizational unit.
      CmsProject getProject()
      Returns the project, or null if the project has not been configured.
      java.lang.String getProjectName()
      Returns the project name.
      java.lang.String getRemoteAddr()
      Returns the remote ip address.
      java.lang.String getRequestedUri()
      Returns the requested uri.
      CmsSiteMatcher getRequestMatcher()
      Returns the matcher for the current request, that is the host part of the URI from the original http request.
      long getRequestTime()
      Returns the request time used for validation of resource publication and expiration dates.
      java.lang.String getSiteRoot()
      Returns the siteroot.
      CmsUser getUser()
      Returns the user, or null if the user has not been configured.
      java.lang.String getUserName()
      Returns the username.
      boolean isForceAbsoluteLinks()
      Returns true if links to the current site should be generated with a server prefix.
      boolean isSecureRequest()
      Returns true if this a secure request.
      void setDetailResource​(CmsResource detailResource)
      Sets the detail content resource.
      void setEncoding​(java.lang.String encoding)
      Sets the encoding.
      void setForceAbsoluteLinks​(boolean isForceAbsoluteLinks)
      Enables/disables usage of the server prefix for links to the current site.
      void setIsSecureRequest​(boolean isSecureRequest)
      Sets the 'isSecureRequest' attribute.
      void setLocale​(java.util.Locale locale)
      Sets the locale.
      void setLocaleName​(java.lang.String localeName)
      Sets the locale name.
      void setOuFqn​(java.lang.String ouFqn)
      Sets the fully qualified name of the organizational unit.
      void setProjectName​(java.lang.String projectName)
      Sets the project name.
      void setRemoteAddr​(java.lang.String remoteAddr)
      Sets the remote ip address.
      void setRequestedUri​(java.lang.String requestedUri)
      Sets the requested uri.
      void setRequestMatcher​(CmsSiteMatcher requestMatcher)
      Sets the matcher for the current request, that is the host part of the URI from the original http request.
      void setRequestTime​(long requestTime)
      Sets the request time used for validation of resource publication and expiration dates.
      void setSiteRoot​(java.lang.String siteRoot)
      Sets the siteroot.
      void setUserName​(java.lang.String userName)
      Sets the username.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CmsContextInfo

        public CmsContextInfo()
        Creates a new instance, initializing the variables with some reasonable default values.

        The default values are:

        User name
        (configured default guest user)
        Project name
        Online
        Requested URI
        /
        Site root
        /
        Locale name
        (configured default locale name)
        Encoding
        (configured default system encoding)
        Remote address
        127.0.0.1
        Organizational unit
        /

      • CmsContextInfo

        public CmsContextInfo​(CmsRequestContext requestContext)
        Creates a new instance with all context variables initialized from the given request context.

        Parameters:
        requestContext - the request context to initialize this context info with
      • CmsContextInfo

        public CmsContextInfo​(CmsUser user,
                              CmsProject project,
                              java.lang.String requestedUri,
                              CmsSiteMatcher requestMatcher,
                              java.lang.String siteRoot,
                              boolean isSecureRequest,
                              java.util.Locale locale,
                              java.lang.String encoding,
                              java.lang.String remoteAddr,
                              long requestTime,
                              java.lang.String ouFqn,
                              boolean isForceAbsoluteLinks)
        Creates a new instance with all context variables initialized.

        Parameters:
        user - the user to create the context with
        project - the project to create the context with
        requestedUri - the request URI to create the context with
        requestMatcher - the matcher for the current request, that is the host part of the URI from the original http request
        siteRoot - the site root to create the context with
        isSecureRequest - if this a secure request
        locale - the locale to create the context with
        encoding - the encoding to create the context with
        remoteAddr - the remote ip address to create the context with
        requestTime - the time of the request (used for resource publication / expiration date)
        ouFqn - the fully qualified name of the organizational unit to create the context with
        isForceAbsoluteLinks - a flag indicating whether links to the current site should be generated with a server prefix
      • CmsContextInfo

        public CmsContextInfo​(java.lang.String userName)
        Creates a new instance, initializing the user name as provided and all other vaiables with the same default values as in CmsContextInfo().

        Parameters:
        userName - the user name to create the context with
        See Also:
        CmsContextInfo()
    • Method Detail

      • clone

        public java.lang.Object clone()
        Creates a clone of this context info object.

        Overrides:
        clone in class java.lang.Object
        See Also:
        Object.clone()
      • freeze

        public void freeze()
        Finalizes (freezes) the configuration of this context information.

        After this entry has been frozen, any attempt to change the configuration of this context info with one of the "set..." methods will lead to a RuntimeException.

      • getOuFqn

        public java.lang.String getOuFqn()
        Returns the fully qualified name of the organizational unit.

        Returns:
        the fully qualified name of the organizational unit
      • getRequestMatcher

        public CmsSiteMatcher getRequestMatcher()
        Returns the matcher for the current request, that is the host part of the URI from the original http request.

        Returns:
        the matcher for the current request, that is the host part of the URI from the original http request
      • getRequestTime

        public long getRequestTime()
        Returns the request time used for validation of resource publication and expiration dates.

        Returns:
        the request time used for validation of resource publication and expiration dates
        See Also:
        CmsRequestContext.getRequestTime()
      • isForceAbsoluteLinks

        public boolean isForceAbsoluteLinks()
        Returns true if links to the current site should be generated with a server prefix.
        Returns:
        true if links to current site should be absolute
      • isSecureRequest

        public boolean isSecureRequest()
        Returns true if this a secure request.

        Returns:
        true if this is a secure request
      • setDetailResource

        public void setDetailResource​(CmsResource detailResource)
        Sets the detail content resource.

        Parameters:
        detailResource - the detail content resource to set
      • setForceAbsoluteLinks

        public void setForceAbsoluteLinks​(boolean isForceAbsoluteLinks)
        Enables/disables usage of the server prefix for links to the current site.
        Parameters:
        isForceAbsoluteLinks - true if links to the current site should be generated with a server prefix
      • setIsSecureRequest

        public void setIsSecureRequest​(boolean isSecureRequest)
        Sets the 'isSecureRequest' attribute.

        Parameters:
        isSecureRequest - true if this a secure request
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Sets the locale.

        Setting the locale name will override the currently selected locale and vice-versa. The locale name and the locale will always match.

        Parameters:
        locale - the locale to set
        See Also:
        setLocaleName(String), CmsRequestContext.getLocale()
      • setLocaleName

        public void setLocaleName​(java.lang.String localeName)
        Sets the locale name.

        Setting the locale name will override the currently selected locale and vice-versa. The locale name and the locale will always match.

        Parameters:
        localeName - the locale name to set
        See Also:
        setLocale(Locale), CmsRequestContext.getLocale()
      • setOuFqn

        public void setOuFqn​(java.lang.String ouFqn)
        Sets the fully qualified name of the organizational unit.

        Parameters:
        ouFqn - the fully qualified name of the organizational unit to set
      • setRequestMatcher

        public void setRequestMatcher​(CmsSiteMatcher requestMatcher)
        Sets the matcher for the current request, that is the host part of the URI from the original http request.

        Parameters:
        requestMatcher - the matcher for the current request
      • setRequestTime

        public void setRequestTime​(long requestTime)
        Sets the request time used for validation of resource publication and expiration dates.

        Parameters:
        requestTime - the request time to set
        See Also:
        CmsRequestContext.getRequestTime()