Class SkinService

All Implemented Interfaces:
org.picocontainer.Startable

public class SkinService extends AbstractResourceService implements org.picocontainer.Startable
  • Field Details

    • LOG

      protected static final org.exoplatform.services.log.Log LOG
    • DEFAULT_SKIN_PARAM_NAME

      public static final String DEFAULT_SKIN_PARAM_NAME
      See Also:
    • CUSTOM_MODULE_ID

      public static final String CUSTOM_MODULE_ID
      See Also:
    • MAX_AGE

      public static final long MAX_AGE
  • Constructor Details

    • SkinService

      public SkinService(org.exoplatform.container.xml.InitParams initParams, org.exoplatform.container.ExoContainerContext context, ResourceCompressor compressor)
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.picocontainer.Startable
    • stop

      public void stop()
      Specified by:
      stop in interface org.picocontainer.Startable
    • initData

      public void initData()
      Cache data after startup
    • getSkinList

      public String[] getSkinList()
      Get all available skin
      Returns:
      all available skin
    • reloadSkins

      public void reloadSkins()
      Clean cache, reload all Skins
    • invalidateCachedSkin

      public void invalidateCachedSkin(String path)
      Invalidate skin from the cache
      Parameters:
      path - the key
    • getSkinModuleContent

      public String getSkinModuleContent(String fileWebAppPath, int fileContentHash, org.exoplatform.services.resources.Orientation orientation, boolean compress) throws IOException
      Parameters:
      fileWebAppPath - File Path including webapp context name
      fileContentHash - File Content Hash
      orientation - Orientation of UI requesting for the CSS
      compress - whether to compress the CSS or not
      Returns:
      File representing the CSS File content
      Throws:
      IOException - when an error happens while reading file
    • getSkinModuleFileContent

      public String getSkinModuleFileContent(String fileWebAppPath) throws IOException
      Returns CSS file content switch file request path
      Parameters:
      fileWebAppPath - file request path including context path
      Returns:
      file content
      Throws:
      IOException - if file not found or an error occurred while reading it
    • getDefaultSkin

      public String getDefaultSkin()
    • addPortalSkin

      public void addPortalSkin(String module, String skinName, String cssPath)
      Add a portal skin with the priority is Integer.MAX_VALUE and the overwrite is false by default
      Parameters:
      module -
      skinName -
      cssPath -
    • addPortalSkin

      public void addPortalSkin(String module, String skinName, String cssPath, boolean overwrite)
      Add a portal skin with the priority is Integer.MAX_VALUE by default
      Parameters:
      module -
      skinName -
      cssPath -
      overwrite -
    • addPortalSkin

      public void addPortalSkin(String module, String skinName, String cssPath, int priority, boolean overwrite)
      Register a portal skin
      Parameters:
      module - skin module identifier
      skinName - skin name
      cssPath - path uri to the css file. This is relative to the root context, use leading '/'
      priority - priority to support sorting in skin list
      overwrite - if any previous skin should be replaced by that one
    • addPortalSkin

      public SkinConfig addPortalSkin(String module, String skinName, String cssPath, int priority, boolean overwrite, boolean filtered)
      Register a portal skin
      Parameters:
      module - skin module identifier
      skinName - skin name
      cssPath - path uri to the css file. This is relative to the root context, use leading '/'
      priority - priority to support sorting in skin list
      overwrite - if any previous skin should be replaced by that one
      filtered - if true, then the portal skin will be loaded only when required by a portlet
      Returns:
    • addSkin

      public void addSkin(String module, String skinName, String cssPath)
      Add a skin with the priority is Integer.MAX_VALUE and the overwrite is false by default
      Parameters:
      module -
      skinName -
      cssPath -
    • addSkin

      public void addSkin(String module, String skinName, String cssPath, boolean overwrite)
      Add a portal skin with the priority is Integer.MAX_VALUE
      Parameters:
      module -
      skinName -
      cssPath -
      overwrite -
    • addSkin

      public void addSkin(String module, String skinName, String cssPath, int priority, boolean overwrite)
      Register the Skin for available portal Skins. Support priority
      Parameters:
      module - skin module identifier
      skinName - skin name
      cssPath - path uri to the css file. This is relative to the root context, use leading '/'
      priority - priority to support sorting in skin list
      overwrite - if any previous skin should be replaced by that one
    • addSkin

      public SkinConfig addSkin(String module, String skinName, String cssPath, int priority, boolean overwrite, List<String> additionalModules)
    • addTheme

      public void addTheme(String categoryName, List<String> themesName)
      Registry theme category with its themes for portlet Theme
      Parameters:
      categoryName - category name that will be registried
      themesName - list theme name of categoryName
    • getAvailableSkinNames

      public Set<String> getAvailableSkinNames()
      Get names of all the currently registered skins.
      Returns:
      an unmodifiable Set of the currently registered skins
    • renderCSS

      @Deprecated(forRemoval=true, since="7.0") public boolean renderCSS(org.exoplatform.web.ControllerContext context, ResourceRenderer renderer, boolean compress) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      since not used for CSS content retrieval anymore. Kept for retro compatibility with UIs making static reference to Portal Skin CSS paths
      Render css content of the file specified by the given URI
      Parameters:
      context -
      renderer - the webapp's ResourceRenderer
      compress -
      Returns:
      true if the CSS resource is found and rendered; false otherwise.
      Throws:
      IOException
    • getPortalSkins

      public Collection<SkinConfig> getPortalSkins(String skinName)
      Return a collection of Portal Skins that its elements are ordered by CSS priority
      Parameters:
      skinName - name of Portal Skin
      Returns:
      all org.exoplatform.portal.resource.SkinConfig of Portal Skin
    • findSkins

      public Collection<SkinConfig> findSkins(SkinVisitor visitor)
      Return a collection of SkinConfig based on SkinVisitor provided as the argument
      Parameters:
      visitor -
      Returns:
    • getCustomPortalSkins

      public Collection<SkinConfig> getCustomPortalSkins(String skinName)
      Return the collection of custom portal skins
      Parameters:
      skinName -
      Returns:
      the map of custom portal skins
    • getPortletThemes

      public Map<String,Set<String>> getPortletThemes()
      Return the map of portlet themes
      Returns:
      the map of portlet themes
    • getSkin

      public SkinConfig getSkin(String module, String skinName)
      Return a SkinConfig mapping by the module and skin name
      Parameters:
      module -
      skinName -
      Returns:
      SkinConfig by SkinKey(module, skinName), or SkinConfig by SkinKey(module, defaultSkin)
    • getPortalSkin

      public SkinConfig getPortalSkin(String module, String skinName)
      Return a Portal SkinConfig mapping by the module and skin name
      Parameters:
      module -
      skinName -
      Returns:
      SkinConfig by SkinKey(module, skinName), or SkinConfig by SkinKey(module, SkinService.DEFAULT_SKIN)
    • getLastModified

      @Deprecated public long getLastModified(org.exoplatform.web.ControllerContext context)
      Deprecated.
      CSS Caching is using files mechanism instead of InMemory cache
      Returns last modified date of cached css.

      In development mode, it always returns Long.MAX_VALUE. Return null if cached css can not be found

      Parameters:
      context -
    • removeSkin

      public void removeSkin(SkinKey key)
      Remove a Skin mapped to the key
      Parameters:
      key - key whose mapping skin is to be removed from the service
    • removePortalSkin

      public void removePortalSkin(String module, String skinName)
      Remove a Skin from the service as well as its cache
      Parameters:
      module -
      skinName -
    • removePortalSkin

      public void removePortalSkin(SkinKey key)
      Remove a Skin mapped to the key
      Parameters:
      key - key whose mapping skin is to be removed from the service
    • removeSkins

      public void removeSkins(List<SkinKey> keys)
      Remove SkinConfig from Portal Skin Config by SkinKey
      Parameters:
      keys - SkinKey list these will be removed
    • removeSupportedSkin

      public void removeSupportedSkin(String skinName)
      Remove Skin from Portal available Skin by skin name
      Parameters:
      skinName - name of skin that will be removed
    • size

      public int size()
      Return the number of skin config maintaining in this SkinService
      Returns:
      the number of skin config maintaining in this SkinService
    • processCSSRecursively

      public void processCSSRecursively(String basePath, Reader sourceReader, Appendable appendable, org.exoplatform.services.resources.Orientation orientation) throws IOException
      Apply CSS for Skin
      If skin is null, do nothing
      Parameters:
      basePath -
      sourceReader -
      appendable -
      orientation -
      Throws:
      IOException
    • initSkinModuleCache

      public void initSkinModuleCache(SkinConfig skin)