Class AppContextImpl

  • All Implemented Interfaces:
    AppContext, BeanContext

    public class AppContextImpl
    extends BeanContextImpl
    implements AppContext
    This class implements the AppContext. The AppContext includes the objects that the microstrategy application expects to pass information between the different components. It saves an instance of specific applications objects, such as the SessionManager, the Preferences and the RequestKeys.
    Since:
    MicroStrategy Web 7.3.1 or earlier
    • Constructor Detail

      • AppContextImpl

        public AppContextImpl()
        Constructor.
    • Method Detail

      • setSessionManager

        public void setSessionManager​(SessionManager sessionManager)
        Deprecated.
        Use WebAppSessionManager instead, via the getAppSessionManager method.
        Sets the SessionManager object associated with this application context. The SessionManager manages the different sessions to the Intelligence Server.
        Specified by:
        setSessionManager in interface AppContext
        Parameters:
        sessionManager - the session manager to associated with this AppContext
      • getPreferences

        public Preferences getPreferences()
        Returns the Preferences object associated with this application context. The Preferences mantains the current settings of the application at different levels.
        Specified by:
        getPreferences in interface AppContext
        Returns:
        the Preferences object associated with this application context.
      • setAppSessionManager

        public void setAppSessionManager​(WebAppSessionManager sm)
        Description copied from interface: AppContext
        This method sets the Application Session Manager associated with this application context.
        Specified by:
        setAppSessionManager in interface AppContext
        Since:
        MicroStrategy Web 9.0.0
      • setPreferences

        public void setPreferences​(Preferences preferences)
        Sets the Preferences object associated with this application context. The Preferences mantains the current settings of the application at different levels.
        Specified by:
        setPreferences in interface AppContext
        Parameters:
        preferences - the Preferences object associated with this application context.
      • getPageManager

        public PageManager getPageManager()
        This method gets the PageManager object associated with this application context. If no PageManager has been explicitly associated, it will automatically used the one specified by the configuration parameters of the ContainerServices.
        Specified by:
        getPageManager in interface AppContext
        Returns:
        the PageManager object associated with this application context.
      • getPageManagerPath

        protected java.lang.String getPageManagerPath()
        Returns the path to use for the PageManager file. This is only used if a PageManager has not been explicitly set through the setPageManager(com.microstrategy.web.app.PageManager). This method will calculate the path based on the configuration parameters in the ContainerServices.
        Since:
        MicroStrategy Web 9.0.0
      • setPageManager

        public void setPageManager​(PageManager pageManager)
        This method sets the PageManager object associated with this application context.
        Specified by:
        setPageManager in interface AppContext
        Parameters:
        pageManager - A PageManager object.
      • getDocumentFromFileResource

        public org.w3c.dom.Document getDocumentFromFileResource​(java.lang.String filePath)
        This method returns a DOM Document from a file resource. The method works by attempting the following operations, in order:
        1. Try to call the same method on BeanContext first. If that succeeds, return.
        2. Next, it tries to get the real path to this file relative to the web application. If it retrieves a valid path, it again calls the BeanContext's version of this method. If it succeeds, it returns.
        3. At this point, we cannot resolve the reference as a physical file. We then try to use the ServletContext's getResourceAsInput method to retrieve the contents of the file as resource that may be embedded within a WAR file. If this succeeeds, we load the contents into a DOM document and return it.THIS IS ONLY POSSIBLE WITHIN A JAVA ENVIRONMENT.
        4. If we get to this step, then we return an Exception.
        Specified by:
        getDocumentFromFileResource in interface AppContext
        Parameters:
        filePath - The absolute or relative path to the file resource.
        Returns:
        the Document node that contains the file contents.
      • getFileContentsAsString

        public java.lang.String getFileContentsAsString​(java.lang.String filePath)
        Description copied from interface: AppContext
        Returns the contents of the resource file as string from the file path provided. it does not dispense the file
        Specified by:
        getFileContentsAsString in interface AppContext
        Parameters:
        filePath - location of the resource file (relative path)
        Returns:
        the contents of the resource file.
      • getFileContentsAsString

        public java.lang.String getFileContentsAsString​(java.lang.String filePath,
                                                        java.lang.String encoding)
        Description copied from interface: AppContext
        Returns the contents of the resource file as string from the file path provided using the named character encoding. it does not dispense the file
        Specified by:
        getFileContentsAsString in interface AppContext
        Parameters:
        filePath - location of the resource file (relative path)
        encoding - The name of a supported character encoding.
        Returns:
        the contents of the resource file.
      • getResourceFileAsString

        public java.lang.String getResourceFileAsString​(java.lang.String filePath,
                                                        java.lang.String resourceFileName)
        Returns the contents of the resource file as string from the file path provided. If the resource cannot be found in the location, it will be dispensed
        Specified by:
        getResourceFileAsString in interface AppContext
        Parameters:
        filePath - location of the resource file
        resourceFileName - resource file
        Returns:
        the contents of the resource file.
      • getRootName

        public java.lang.String getRootName()
        Description copied from interface: AppContext
        Returns the name of the root component In the case of the jsp/servlet enviroment,it will be the name of the main servlet component This corresponds to the value of the parameter AppContext.CONFIG_SERVLET_NAME
        Specified by:
        getRootName in interface AppContext
        Since:
        MicroStrategy Web 9.0.0
      • getRealPath

        public java.lang.String getRealPath​(java.lang.String filePath)
        Return the absolute path of the relative path provided
        Specified by:
        getRealPath in interface AppContext
        Parameters:
        filePath - relative path to get the relative path from
        Returns:
        the absolute path
      • dispenseFile

        public void dispenseFile​(java.lang.String realPath,
                                 java.lang.String resourcePath)
                          throws java.lang.IllegalArgumentException,
                                 MSTRUncheckedException
        If the file does not exist, a duplicate is made from the specified resource. This method is used to generate user customizable files from resource templates. Its also a means of creating file system accessible files when the application is deployed as an unexpanded WAR (i.e. configuration files cannot be easily modified).
        Specified by:
        dispenseFile in interface AppContext
        Parameters:
        realPath - Actual location of the file.
        resourcePath - Location of the master copy resource.
        Throws:
        java.lang.IllegalArgumentException - Thrown if either the file or resource path is empty.
        MSTRUncheckedException - Thrown if the resource could not be located, or if an error occurs during duplication.
      • setServletPath

        public void setServletPath​(java.lang.String servletPath)
        Define the full application path to the Servlet. This value is read form the configuration file and if is not set it will be automatically generated from the request.
        Specified by:
        setServletPath in interface AppContext
        Parameters:
        servletPath - a String with the servlet path
      • getServletPath

        public java.lang.String getServletPath()
        Get the full application path to the Servlet. This value is read form the configuration file and if is not set it will be automatically generated from the request.
        Specified by:
        getServletPath in interface BeanContext
        Overrides:
        getServletPath in class BeanContextImpl
        Returns:
        a String with the servlet path
      • setConfigServletPath

        public void setConfigServletPath​(java.lang.String configServletPath)
        Define the full application path to the Servlet as defined in the configuration file.
        Specified by:
        setConfigServletPath in interface AppContext
        Parameters:
        configServletPath - a String with the servlet path
      • getConfigServletPath

        public java.lang.String getConfigServletPath()
        Get the full application path to the Servlet as defined in the configuration file
        Specified by:
        getConfigServletPath in interface AppContext
        Returns:
        a String with the servlet path
      • getBrowserLocaleId

        public java.lang.String getBrowserLocaleId()
        This method returns the Locale Id defined in web preferences as Language. If default, it'll return browser's locale Id instead.
        Specified by:
        getBrowserLocaleId in interface AppContext
        Returns:
        a String with the Locale ID.
      • getBrowserServerLocaleId

        public java.lang.String getBrowserServerLocaleId()
        This method returns the Locale associated with Date and Number format locale web preference.If default, it'll return browser's locale Id instead.
        Specified by:
        getBrowserServerLocaleId in interface AppContext
        Returns:
        a String with the Locale ID.
      • getBrowserHeaderLocaleId

        public java.lang.String getBrowserHeaderLocaleId()
        This method will extract from request header a value corresponding to browser's locale info. This info will be resolved in order to return current browser's locale id.
        Specified by:
        getBrowserHeaderLocaleId in interface AppContext
        Returns:
        a String with the Locale ID.
      • getConfigParameter

        public java.lang.String getConfigParameter​(java.lang.String param)
        Returns the value of the configuration parameter
        Specified by:
        getConfigParameter in interface AppContext
        Parameters:
        param - name of the parameter to retrieve
        Returns:
        the value of the parameter
      • putConfigParameter

        public void putConfigParameter​(java.lang.String key,
                                       java.lang.String value)
        Appends a configuration parameter to the collection
        Specified by:
        putConfigParameter in interface AppContext
        Parameters:
        key - name of the configuration parameter
        value - value of the configuration parameter
      • getResourcesFolder

        public java.lang.String getResourcesFolder​(java.lang.String folderType)
        Return the path to the resources folder indicated on the configuration file, corresponding to the type sent as parameter.
        This is actually a convenience method for the getConfigParameter. This method returns all configuration parameters that starts with RESOURCE_FOLDER_PREFIX and folderType is whatever goes after that. This method also makes sure that the name of the folder has always a backslash "/" at the end.
        Specified by:
        getResourcesFolder in interface AppContext
        Parameters:
        folderType - integer constant that specifies the type of resource folder to return
        Returns:
        the path of the base folder for the folder type requested
      • setDefaultEvent

        public void setDefaultEvent​(int eventID)
        This method will first check if the config parameter for default event is not present. If it is present then this method will not do anything. If the config paramter is not present, then this method will set the value of the config parameter with the @param eventID.
        Specified by:
        setDefaultEvent in interface AppContext
        Parameters:
        eventID - identifier of the event to become default if not specified on the configuration parameters.
      • getFontSize

        public java.lang.String getFontSize()
        A string with the base font size to use, the string might contain the type of size (i.e, pt, px, etc.)
        Specified by:
        getFontSize in interface AppContext
        Returns:
        a string with size of the font to use
      • getFontName

        public java.lang.String getFontName()
        Returns a string with the name of the fonts, or the list of fonts that a browser should use when rendering the page. This is usually retrieved from user Preferences
        Specified by:
        getFontName in interface AppContext
        Returns:
        a String with a comma separated list of the fonts to use in this page.
      • isDoubleByte

        public boolean isDoubleByte()
        Returns true if the locale is a double byte language like Chinese, Korean or Japenese.
        Specified by:
        isDoubleByte in interface AppContext
        Returns:
        true if the locale is a double byte language like Chinese, Korean or Japenese.