Class PluginHelper

java.lang.Object
org.codelibs.fess.helper.PluginHelper

public class PluginHelper extends Object
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.
  • Field Details

    • availableArtifacts

      protected com.google.common.cache.LoadingCache<PluginHelper.ArtifactType,PluginHelper.Artifact[]> availableArtifacts
      Cache 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

      public PluginHelper.Artifact[] getAvailableArtifacts(PluginHelper.ArtifactType artifactType)
      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

      protected String[] getRepositories()
      Gets the list of configured plugin repositories.
      Returns:
      an array of repository URLs
    • loadArtifactsFromRepository

      protected List<PluginHelper.Artifact> loadArtifactsFromRepository(String url)
      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 process
      url - the URL of the repository
      Returns:
      a list of artifacts found in the repository
    • isExcludedName

      protected boolean isExcludedName(PluginHelper.ArtifactType artifactType, String name)
      Checks if an artifact name should be excluded from the results.
      Parameters:
      artifactType - the type of the artifact
      name - the name of the artifact
      Returns:
      true if the artifact should be excluded, false otherwise
    • isTargetPluginVersion

      protected boolean isTargetPluginVersion(String version)
      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 XML
      pluginUrl - the URL of the plugin
      version - the snapshot version
      Returns:
      the actual version string with timestamp and build number, or null if not found
      Throws:
      SAXException - if XML parsing fails
      IOException - if I/O error occurs
    • getRepositoryContent

      protected String getRepositoryContent(String url)
      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

      public PluginHelper.Artifact[] getInstalledArtifacts(PluginHelper.ArtifactType artifactType)
      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 artifact
      filename - 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 artifact
      filename - the filename to parse
      url - the URL of the artifact
      Returns:
      an artifact instance
    • installArtifact

      public void installArtifact(PluginHelper.Artifact artifact)
      Installs an artifact based on its type.
      Parameters:
      artifact - the artifact to install
    • install

      protected void install(PluginHelper.Artifact artifact)
      Installs an artifact by downloading it from its URL.
      Parameters:
      artifact - the artifact to install
      Throws:
      PluginException - if installation fails
    • createCurlRequest

      protected org.codelibs.curl.CurlRequest createCurlRequest(String url)
      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

      public void deleteInstalledArtifact(PluginHelper.Artifact artifact)
      Deletes an installed artifact.
      Parameters:
      artifact - the artifact to delete
      Throws:
      PluginException - if the artifact does not exist or deletion fails
    • uninstall

      protected void uninstall(String fileName, Path jarPath)
      Uninstalls an artifact by deleting its JAR file.
      Parameters:
      fileName - the name of the file to delete
      jarPath - the path to the JAR file
      Throws:
      PluginException - if deletion fails
    • getArtifact

      public PluginHelper.Artifact getArtifact(String name, String version)
      Gets an artifact by name and version from available artifacts.
      Parameters:
      name - the name of the artifact
      version - the version of the artifact
      Returns:
      the artifact if found, null otherwise