Package org.codelibs.fess.util
Class ResourceUtil
java.lang.Object
org.codelibs.fess.util.ResourceUtil
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 Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor to prevent instantiation of this utility class. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGets the application type from the environment variable FESS_APP_TYPE.static PathgetClassesPath(String... names) Gets the path to compiled classes directory.static PathgetConfOrClassesPath(String... names) Gets the path to configuration files, falling back to classpath resources if not found.static PathgetConfPath(String... names) Gets the path to configuration files.static PathgetCssPath(String... names) Gets the path to CSS files directory.static PathgetDictionaryPath(String... names) Gets the path to dictionary files directory.static PathgetEnvPath(String envName, String... names) Gets the path to environment-specific files directory.static StringGets the HTTP URL for the OpenSearch (Fesen) server.static PathgetImagePath(String... names) Gets the path to image files directory.static File[]getJarFiles(String namePrefix) Gets JAR files from the WEB-INF/lib directory that start with the specified prefix.static PathgetJavaScriptPath(String... names) Gets the path to JavaScript files directory.static PathgetMailTemplatePath(String... names) Gets the path to email template files directory.static PathgetOrigPath(String... names) Gets the path to original files directory.static org.dbflute.optional.OptionalEntity<String> Gets the override configuration path from environment variable when running in Docker.protected static PathGets the path by trying multiple locations in order of preference.static File[]getPluginJarFiles(FilenameFilter filter) Gets plugin JAR files from the plugin directory that match the specified filter.static File[]getPluginJarFiles(String namePrefix) Gets plugin JAR files from the plugin directory that start with the specified prefix.static PathgetPluginPath(String... names) Gets the path to plugin files directory.static PathGets the path to the project properties file.static PathgetSitePath(String... names) Gets the path to site-specific files directory.static PathgetThumbnailPath(String... names) Gets the path to thumbnail files directory.static PathgetViewTemplatePath(String... names) Gets the path to view template files directory.static StringResolves system properties in a given string.
-
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Gets the path to the project properties file.- Returns:
- the Path object pointing to the project.properties file
-
getImagePath
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
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
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
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
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
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
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
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
Resolves system properties in a given string.- Parameters:
value- The string to resolve.- Returns:
- The resolved string.
-