Package org.codelibs.fess.helper
Class PluginHelper
java.lang.Object
org.codelibs.fess.helper.PluginHelper
Helper class for managing Fess plugins and artifacts.
This class provides functionality to discover, install, and manage various types of plugins
including data stores, themes, ingest processors, scripts, web applications, thumbnails, and crawlers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a plugin artifact with name, version, and URL information.static enumEnumeration of different artifact types supported by Fess. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.google.common.cache.LoadingCache<PluginHelper.ArtifactType, PluginHelper.Artifact[]> Cache for storing available artifacts by type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.codelibs.curl.CurlRequestcreateCurlRequest(String url) Creates a CURL request for the specified URL with proxy configuration if available.voiddeleteInstalledArtifact(PluginHelper.Artifact artifact) Deletes an installed artifact.getArtifact(String name, String version) Gets an artifact by name and version from available artifacts.protected PluginHelper.ArtifactgetArtifactFromFileName(PluginHelper.ArtifactType artifactType, String filename) Creates an artifact instance from a filename.getArtifactFromFileName(PluginHelper.ArtifactType artifactType, String filename, String url) Creates an artifact instance from a filename with a specified URL.getAvailableArtifacts(PluginHelper.ArtifactType artifactType) Retrieves available artifacts of the specified type from configured repositories.getInstalledArtifacts(PluginHelper.ArtifactType artifactType) Gets the list of installed artifacts of the specified type.protected String[]Gets the list of configured plugin repositories.protected StringRetrieves the content of a repository URL.protected StringgetSnapshotActualVersion(DocumentBuilder builder, String pluginUrl, String version) Gets the actual version string for a SNAPSHOT artifact by parsing the snapshot metadata.protected voidinstall(PluginHelper.Artifact artifact) Installs an artifact by downloading it from its URL.voidinstallArtifact(PluginHelper.Artifact artifact) Installs an artifact based on its type.protected booleanisExcludedName(PluginHelper.ArtifactType artifactType, String name) Checks if an artifact name should be excluded from the results.protected booleanisTargetPluginVersion(String version) Checks if a plugin version is a target version for the current Fess installation.protected List<PluginHelper.Artifact> Loads artifacts from a YAML-based repository.protected List<PluginHelper.Artifact> processRepository(PluginHelper.ArtifactType artifactType, String url) Processes a Maven-style repository to extract artifacts of the specified type.protected voidUninstalls an artifact by deleting its JAR file.
-
Field Details
-
availableArtifacts
protected com.google.common.cache.LoadingCache<PluginHelper.ArtifactType,PluginHelper.Artifact[]> availableArtifactsCache for storing available artifacts by type. The cache expires after 5 minutes and has a maximum size of 10 entries.
-
-
Constructor Details
-
PluginHelper
public PluginHelper()Default constructor for PluginHelper. Initializes the plugin helper with default settings.
-
-
Method Details
-
getAvailableArtifacts
Retrieves available artifacts of the specified type from configured repositories.- Parameters:
artifactType- the type of artifacts to retrieve- Returns:
- an array of available artifacts
- Throws:
PluginException- if failed to access the artifact repository
-
getRepositories
Gets the list of configured plugin repositories.- Returns:
- an array of repository URLs
-
loadArtifactsFromRepository
Loads artifacts from a YAML-based repository.- Parameters:
url- the URL of the YAML repository- Returns:
- a list of artifacts loaded from the repository
- Throws:
PluginException- if failed to parse the repository content
-
processRepository
protected List<PluginHelper.Artifact> processRepository(PluginHelper.ArtifactType artifactType, String url) Processes a Maven-style repository to extract artifacts of the specified type.- Parameters:
artifactType- the type of artifacts to processurl- the URL of the repository- Returns:
- a list of artifacts found in the repository
-
isExcludedName
Checks if an artifact name should be excluded from the results.- Parameters:
artifactType- the type of the artifactname- the name of the artifact- Returns:
- true if the artifact should be excluded, false otherwise
-
isTargetPluginVersion
Checks if a plugin version is a target version for the current Fess installation.- Parameters:
version- the version to check- Returns:
- true if the version is a target version, false otherwise
-
getSnapshotActualVersion
protected String getSnapshotActualVersion(DocumentBuilder builder, String pluginUrl, String version) throws SAXException, IOException Gets the actual version string for a SNAPSHOT artifact by parsing the snapshot metadata.- Parameters:
builder- the document builder to use for parsing XMLpluginUrl- the URL of the pluginversion- the snapshot version- Returns:
- the actual version string with timestamp and build number, or null if not found
- Throws:
SAXException- if XML parsing failsIOException- if I/O error occurs
-
getRepositoryContent
Retrieves the content of a repository URL.- Parameters:
url- the URL to retrieve content from- Returns:
- the content as a string
- Throws:
org.lastaflute.di.exception.IORuntimeException- if I/O error occurs
-
getInstalledArtifacts
Gets the list of installed artifacts of the specified type.- Parameters:
artifactType- the type of artifacts to retrieve- Returns:
- an array of installed artifacts
-
getArtifactFromFileName
protected PluginHelper.Artifact getArtifactFromFileName(PluginHelper.ArtifactType artifactType, String filename) Creates an artifact instance from a filename.- Parameters:
artifactType- the type of the artifactfilename- the filename to parse- Returns:
- an artifact instance
-
getArtifactFromFileName
public PluginHelper.Artifact getArtifactFromFileName(PluginHelper.ArtifactType artifactType, String filename, String url) Creates an artifact instance from a filename with a specified URL.- Parameters:
artifactType- the type of the artifactfilename- the filename to parseurl- the URL of the artifact- Returns:
- an artifact instance
-
installArtifact
Installs an artifact based on its type.- Parameters:
artifact- the artifact to install
-
install
Installs an artifact by downloading it from its URL.- Parameters:
artifact- the artifact to install- Throws:
PluginException- if installation fails
-
createCurlRequest
Creates a CURL request for the specified URL with proxy configuration if available.- Parameters:
url- the URL to create a request for- Returns:
- a configured CURL request
-
deleteInstalledArtifact
Deletes an installed artifact.- Parameters:
artifact- the artifact to delete- Throws:
PluginException- if the artifact does not exist or deletion fails
-
uninstall
Uninstalls an artifact by deleting its JAR file.- Parameters:
fileName- the name of the file to deletejarPath- the path to the JAR file- Throws:
PluginException- if deletion fails
-
getArtifact
Gets an artifact by name and version from available artifacts.- Parameters:
name- the name of the artifactversion- the version of the artifact- Returns:
- the artifact if found, null otherwise
-