Class SimpleHybrisWidgetResourceLoader

    • Field Detail

      • COCKPITNG_RESOURCELOADER_CACHE_EXPIRATION

        public static final java.lang.String COCKPITNG_RESOURCELOADER_CACHE_EXPIRATION
        See Also:
        Constant Field Values
      • COCKPITNG_WIDGET_RESOURCE_LOADER_CACHE_CONTROL

        public static final java.lang.String COCKPITNG_WIDGET_RESOURCE_LOADER_CACHE_CONTROL
        See Also:
        Constant Field Values
      • CSS_CACHE_ENABLED

        public static final java.lang.String CSS_CACHE_ENABLED
        See Also:
        Constant Field Values
      • CSS_LEGACY_IE_IMPORT

        public static final java.lang.String CSS_LEGACY_IE_IMPORT
        See Also:
        Constant Field Values
      • APPLICATION_THEME_CSS

        public static final java.lang.String APPLICATION_THEME_CSS
        See Also:
        Constant Field Values
      • MAX_LEGACY_IE_IMPORT_FILES

        public static final int MAX_LEGACY_IE_IMPORT_FILES
        See Also:
        Constant Field Values
      • MAX_LEGACY_IE_IMPORT_FILES_LEVEL_1

        public static final int MAX_LEGACY_IE_IMPORT_FILES_LEVEL_1
        See Also:
        Constant Field Values
      • MAX_LEGACY_IE_IMPORT_FILES_NESTING_LEVEL

        public static final int MAX_LEGACY_IE_IMPORT_FILES_NESTING_LEVEL
        See Also:
        Constant Field Values
      • CACHED_MERGED_CSS

        protected static final java.util.Map<java.lang.String,​java.lang.String> CACHED_MERGED_CSS
      • IE_CSS_SPLIT_CACHE

        protected static final java.util.Map<java.lang.String,​java.lang.String> IE_CSS_SPLIT_CACHE
      • JS_DEPENDENCY_VARIABLE

        protected static final java.lang.String JS_DEPENDENCY_VARIABLE
        See Also:
        Constant Field Values
    • Constructor Detail

      • SimpleHybrisWidgetResourceLoader

        public SimpleHybrisWidgetResourceLoader()
    • Method Detail

      • init

        public void init()
                  throws javax.servlet.ServletException
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • clearCssCache

        public static void clearCssCache()
      • createHtmlDateFormat

        public static java.text.DateFormat createHtmlDateFormat()
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse resp)
                      throws javax.servlet.ServletException,
                             java.io.IOException
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • doGetInternal

        protected void doGetInternal​(javax.servlet.http.HttpServletRequest req,
                                     javax.servlet.http.HttpServletResponse resp)
                              throws javax.servlet.ServletException,
                                     java.io.IOException
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • processResponseHeader

        protected void processResponseHeader​(java.lang.String requestURI,
                                             javax.servlet.http.HttpServletResponse resp)
      • getFallbackResourceLoader

        public ResourceLoader getFallbackResourceLoader()
      • getApplicationContext

        protected org.springframework.web.context.WebApplicationContext getApplicationContext()
      • getResourceAsStreamFromJar

        protected java.io.InputStream getResourceAsStreamFromJar​(WidgetJarLibInfo widgetJarLibInfo,
                                                                 java.lang.String resourceName)
      • getResourceAsStreamFromJar

        protected java.io.InputStream getResourceAsStreamFromJar​(java.io.File jarFile,
                                                                 java.lang.String resourceName)
      • getResourceAsStreamFromJar

        protected java.io.InputStream getResourceAsStreamFromJar​(java.lang.String uri)
      • hasResourceInJar

        protected boolean hasResourceInJar​(java.lang.String uri)
      • getResourceAsStream

        protected java.io.InputStream getResourceAsStream​(java.lang.String uri)
      • processRequestURI

        protected java.lang.String processRequestURI​(java.lang.String requestURI,
                                                     javax.servlet.http.HttpServletRequest req)
      • writeMergedWidgetCss

        protected void writeMergedWidgetCss​(java.lang.String mainSlotId,
                                            javax.servlet.http.HttpServletRequest req,
                                            javax.servlet.http.HttpServletResponse resp)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • splitImportsForLegacyIe

        protected void splitImportsForLegacyIe​(java.lang.String idPrefix,
                                               java.util.List<java.lang.String> urls,
                                               java.lang.StringBuilder builder,
                                               int level)
        Method used to distribute the files according to the limit of imports allowed by legacy IE versions.
        Parameters:
        idPrefix - prefix for caching partial css files
        urls - collection of files to import
        builder - content of a file should be written to the builder
      • isSplitForLegacyIeEnabled

        protected boolean isSplitForLegacyIeEnabled()
        As described here on MSDN legacy IE versions may struggle interpreting more than 31 import declarations in css stylesheets. This method allows to enable legacy IE support workaround.
        Returns:
        true if legacy IE should be supported
      • writeCachedCssChunkForLegacyIe

        protected void writeCachedCssChunkForLegacyIe​(java.lang.String cacheKey,
                                                      javax.servlet.http.HttpServletRequest req,
                                                      javax.servlet.http.HttpServletResponse resp)
                                               throws java.io.IOException
        The method should write the content of the requested resource into the output stream.
        Parameters:
        cacheKey - key under which the css is stored
        req - http request
        resp - http response
        Throws:
        java.io.IOException
      • getCssFilesAsStrings

        protected java.util.List<java.lang.String> getCssFilesAsStrings​(java.lang.String mainSlotId,
                                                                        javax.servlet.http.HttpServletRequest request)
        Returns all css resources that should be preloaded as strings.
        Parameters:
        mainSlotId - the widgets mainSlot id
        request - the request passed to doGet(HttpServletRequest, HttpServletResponse)
      • isCssCached

        protected boolean isCssCached()
      • appendResponse

        protected void appendResponse​(java.io.InputStream is,
                                      javax.servlet.http.HttpServletResponse resp)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • reset

        public void reset()
        Description copied from interface: Resettable
        Resets the something the implementation provides.
        Specified by:
        reset in interface Resettable