Class FolderScanningSiteListResolver

java.lang.Object
org.craftercms.engine.service.context.FolderScanningSiteListResolver
All Implemented Interfaces:
SiteListResolver, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ResourceLoaderAware

public class FolderScanningSiteListResolver extends Object implements SiteListResolver, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.InitializingBean
Default implementation of SiteListResolver. Basically, parses the site root folder path to separate the folder where all the sites reside and the site folder format. Then, iterates through the children of the folder looking for site folders that match the format, extracting the site names from the folder name. To better illustrate, here's an example:

Assume the site root folder path is file:/opt/websites/{siteName}app. The sites folder, or basically the folder that contains all sites, is resolved to /opt/websites. The children of this folder are brochureapp, corporateapp and plutonapp. By using the {siteName}app site name format, the site names are finally determined to be brochure, corporate and pluton.

Author:
avasquez
  • Field Details

    • SITE_ROOT_FOLDER_PATH_REGEX

      public static final String SITE_ROOT_FOLDER_PATH_REGEX
      See Also:
    • SITES_FOLDER_PATH_GROUP

      public static final int SITES_FOLDER_PATH_GROUP
      See Also:
    • SITE_FOLDER_NAME_FORMAT_GROUP

      public static final int SITE_FOLDER_NAME_FORMAT_GROUP
      See Also:
    • siteRootFolderPath

      protected String siteRootFolderPath
    • siteNameMacroName

      protected String siteNameMacroName
    • macroResolver

      protected MacroResolver macroResolver
    • resourceLoader

      protected org.springframework.core.io.ResourceLoader resourceLoader
    • sitesFolderPath

      protected String sitesFolderPath
    • siteFolderNamePattern

      protected Pattern siteFolderNamePattern
  • Constructor Details

    • FolderScanningSiteListResolver

      public FolderScanningSiteListResolver(String siteRootFolderPath, MacroResolver macroResolver)
  • Method Details

    • setSiteNameMacroName

      public void setSiteNameMacroName(String siteNameMacroName)
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • getSiteList

      public Collection<String> getSiteList()
      Description copied from interface: SiteListResolver
      Returns the entire list of sites.
      Specified by:
      getSiteList in interface SiteListResolver
    • getSitesFolder

      protected File getSitesFolder()