Class ResourceUtil

java.lang.Object
org.codelibs.fess.util.ResourceUtil

public class ResourceUtil extends Object
Utility class for accessing various resource paths and files in the Fess application. This class provides methods to retrieve paths for configuration files, templates, dictionaries, thumbnails, plugins, and other resources required by the Fess search engine. It supports both regular deployment and Docker container environments.
  • Constructor Details

    • ResourceUtil

      protected ResourceUtil()
      Protected constructor to prevent instantiation of this utility class. This class is designed to be used statically.
  • Method Details

    • getFesenHttpUrl

      public static String getFesenHttpUrl()
      Gets the HTTP URL for the OpenSearch (Fesen) server. First checks for a system-configured search engine address, then falls back to the URL configured in FessConfig.
      Returns:
      the HTTP URL for the OpenSearch server
    • getAppType

      public static String getAppType()
      Gets the application type from the environment variable FESS_APP_TYPE. This is used to determine the deployment environment (e.g., "docker").
      Returns:
      the application type string, or empty string if not set
    • getOverrideConfPath

      public static org.dbflute.optional.OptionalEntity<String> getOverrideConfPath()
      Gets the override configuration path from environment variable when running in Docker. This allows customization of the configuration directory location in containerized deployments.
      Returns:
      an OptionalEntity containing the override configuration path if set and running in Docker, or empty OptionalEntity otherwise
    • getConfPath

      public static Path getConfPath(String... names)
      Gets the path to configuration files. In Docker environments, checks /opt/fess first, then falls back to system property FESS_CONF_PATH, and finally to WEB-INF/conf.
      Parameters:
      names - the path components to append to the configuration directory
      Returns:
      the Path object pointing to the configuration file or directory
    • getConfOrClassesPath

      public static Path getConfOrClassesPath(String... names)
      Gets the path to configuration files, falling back to classpath resources if not found. First attempts to find the file in the configuration directory, then searches the classpath.
      Parameters:
      names - the path components to append to the configuration directory
      Returns:
      the Path object pointing to the configuration file, either in conf directory or classpath
    • getClassesPath

      public static Path getClassesPath(String... names)
      Gets the path to compiled classes directory.
      Parameters:
      names - the path components to append to the classes directory
      Returns:
      the Path object pointing to the classes directory
    • getOrigPath

      public static Path getOrigPath(String... names)
      Gets the path to original files directory.
      Parameters:
      names - the path components to append to the orig directory
      Returns:
      the Path object pointing to the original files directory
    • getMailTemplatePath

      public static Path getMailTemplatePath(String... names)
      Gets the path to email template files directory.
      Parameters:
      names - the path components to append to the mail template directory
      Returns:
      the Path object pointing to the mail template directory
    • getViewTemplatePath

      public static Path getViewTemplatePath(String... names)
      Gets the path to view template files directory.
      Parameters:
      names - the path components to append to the view template directory
      Returns:
      the Path object pointing to the view template directory
    • getDictionaryPath

      public static Path getDictionaryPath(String... names)
      Gets the path to dictionary files directory.
      Parameters:
      names - the path components to append to the dictionary directory
      Returns:
      the Path object pointing to the dictionary directory
    • getThumbnailPath

      public static Path getThumbnailPath(String... names)
      Gets the path to thumbnail files directory.
      Parameters:
      names - the path components to append to the thumbnails directory
      Returns:
      the Path object pointing to the thumbnails directory
    • getSitePath

      public static Path getSitePath(String... names)
      Gets the path to site-specific files directory.
      Parameters:
      names - the path components to append to the site directory
      Returns:
      the Path object pointing to the site directory
    • getPluginPath

      public static Path getPluginPath(String... names)
      Gets the path to plugin files directory.
      Parameters:
      names - the path components to append to the plugin directory
      Returns:
      the Path object pointing to the plugin directory
    • getProjectPropertiesFile

      public static Path getProjectPropertiesFile()
      Gets the path to the project properties file.
      Returns:
      the Path object pointing to the project.properties file
    • getImagePath

      public static Path getImagePath(String... names)
      Gets the path to image files directory.
      Parameters:
      names - the path components to append to the images directory
      Returns:
      the Path object pointing to the images directory
    • getCssPath

      public static Path getCssPath(String... names)
      Gets the path to CSS files directory.
      Parameters:
      names - the path components to append to the CSS directory
      Returns:
      the Path object pointing to the CSS directory
    • getJavaScriptPath

      public static Path getJavaScriptPath(String... names)
      Gets the path to JavaScript files directory.
      Parameters:
      names - the path components to append to the JavaScript directory
      Returns:
      the Path object pointing to the JavaScript directory
    • getEnvPath

      public static Path getEnvPath(String envName, String... names)
      Gets the path to environment-specific files directory.
      Parameters:
      envName - the environment name (e.g., "python", "ruby")
      names - the path components to append to the environment directory
      Returns:
      the Path object pointing to the environment-specific directory
    • getPath

      protected static Path getPath(String root, String base, String... names)
      Gets the path by trying multiple locations in order of preference. First tries to get the real path from servlet context, then checks various fallback locations including source and target directories.
      Parameters:
      root - the root directory (e.g., "WEB-INF/")
      base - the base directory under root (e.g., "conf", "classes")
      names - the path components to append to the base directory
      Returns:
      the Path object pointing to the requested resource
    • getJarFiles

      public static File[] getJarFiles(String namePrefix)
      Gets JAR files from the WEB-INF/lib directory that start with the specified prefix.
      Parameters:
      namePrefix - the prefix that JAR file names should start with
      Returns:
      an array of File objects representing matching JAR files, or empty array if none found
    • getPluginJarFiles

      public static File[] getPluginJarFiles(String namePrefix)
      Gets plugin JAR files from the plugin directory that start with the specified prefix.
      Parameters:
      namePrefix - the prefix that plugin JAR file names should start with
      Returns:
      an array of File objects representing matching plugin JAR files, or empty array if none found
    • getPluginJarFiles

      public static File[] getPluginJarFiles(FilenameFilter filter)
      Gets plugin JAR files from the plugin directory that match the specified filter.
      Parameters:
      filter - the FilenameFilter to apply when selecting plugin JAR files
      Returns:
      an array of File objects representing matching plugin JAR files, or empty array if none found
    • resolve

      public static String resolve(String value)
      Resolves system properties in a given string.
      Parameters:
      value - The string to resolve.
      Returns:
      The resolved string.