Class InstallFeatureUtil

  • All Implemented Interfaces:
    CommonLoggerI

    public abstract class InstallFeatureUtil
    extends ServerFeatureUtil
    Utility class to install features from Maven repositories.
    • Constructor Detail

      • InstallFeatureUtil

        public InstallFeatureUtil​(File installDirectory,
                                  File buildDirectory,
                                  String from,
                                  String to,
                                  Set<String> pluginListedEsas,
                                  List<InstallFeatureUtil.ProductProperties> propertiesList,
                                  String openLibertyVersion,
                                  String containerName,
                                  List<String> additionalJsons)
                           throws PluginScenarioException,
                                  PluginExecutionException
        Initialize the utility and check for unsupported scenarios.
        Parameters:
        installDirectory - The install directory
        from - The "from" parameter specified in the plugin configuration, or null if not specified
        to - The "to" parameter specified in the plugin configuration, or null if not specified
        pluginListedEsas - The list of ESAs specified in the plugin configuration, or null if not specified
        propertiesList - The list of product properties installed with the Open Liberty runtime
        openLibertyVersion - The version of the Open Liberty runtime
        containerName - The container name if the features should be installed in a container. Otherwise null.
        additionalJsons - The list of additional JSONS to search for features from
        Throws:
        PluginScenarioException - If the current scenario is not supported
        PluginExecutionException - If properties files cannot be found in the installDirectory/lib/versions
    • Method Detail

      • downloadArtifact

        public abstract File downloadArtifact​(String groupId,
                                              String artifactId,
                                              String type,
                                              String version)
                                       throws PluginExecutionException
        Download the artifact from the specified Maven coordinates, or retrieve it from the cache if it already exists.
        Parameters:
        groupId - The group ID
        artifactId - The artifact ID
        type - The type e.g. esa
        version - The version
        Returns:
        The file corresponding to the downloaded artifact
        Throws:
        PluginExecutionException - If the artifact could not be downloaded
      • combineToSet

        public Set<String> combineToSet​(Collection<String>... collections)
        Combine the given String collections into a set using case-insensitive matching. If there are multiple instances of the same string but with different capitalization, only the first one found will be included.
        Parameters:
        collections - a collection of strings
        Returns:
        the combined set of strings, ignoring case
      • isOpenLibertyBetaVersion

        public static boolean isOpenLibertyBetaVersion​(String olVersion)
      • getOpenLibertyFeatureSet

        public static Set<String> getOpenLibertyFeatureSet​(Set<File> jsons)
                                                    throws PluginExecutionException
        Gets the set of all Open Liberty features by scanning the product JSONs.
        Parameters:
        jsons - The set of product JSON files to scan
        Returns:
        set of all Open Liberty features
        Throws:
        PluginExecutionException - if any of the JSONs could not be found
      • containsIgnoreCase

        public static boolean containsIgnoreCase​(Collection<String> reference,
                                                 Collection<String> target)
        Returns whether the reference collection contains all of the strings in the target collection, ignoring case.
        Parameters:
        reference - The reference collection
        target - The target collection
        Returns:
        true if reference contains all Strings from target, ignoring case
      • installFeatures

        public void installFeatures​(boolean isAcceptLicense,
                                    List<String> featuresList)
                             throws PluginExecutionException
        Resolve, download, and install features from a Maven repository. This method calls the resolver with the given JSONs and feature list, downloads the ESAs corresponding to the resolved features, then installs those features. If user listed feature esa and installUtility/featureUtility is not available to install user feature esa, then copy esa feature manually to Liberty install.
        Parameters:
        isAcceptLicense - flag for accepting the license terms
        featuresList - The list of features to install.
        Throws:
        PluginExecutionException - if any of the features could not be installed
      • getOverrideBundleDescriptor

        public String getOverrideBundleDescriptor​(String groupId,
                                                  String artifactId)
                                           throws PluginExecutionException
        Download the override bundle from the repository with the given groupId and artifactId, corresponding to the latest version in the range between the current Open Liberty version (inclusive) and the next version (exclusive). Returns a string in the format "filepath;BundleName" where BundleName is the bundle symbolic name from its manifest.
        Parameters:
        groupId - the groupId of the bundle to download
        artifactId - the artifactId of the bundle to download
        Returns:
        a String representing the bundle in filepath;BundleName format
        Throws:
        PluginExecutionException
      • extractSymbolicName

        public static String extractSymbolicName​(File jar)
                                          throws PluginExecutionException
        Extracts the bundle symbolic name from the jar manifest.
        Parameters:
        jar - the jar from which the symbolic name will be extracted
        Returns:
        the Bundle-SymbolicName
        Throws:
        PluginExecutionException
      • getMapBasedInstallKernelJar

        public static File getMapBasedInstallKernelJar​(File dir)
        Find latest install map jar from specified directory
        Returns:
        the install map jar file
      • productInfo

        public static String productInfo​(File installDirectory,
                                         String action)
                                  throws PluginExecutionException
        Runs the productInfo command and returns the output Made public static for tests to use in LMP/LGP
        Parameters:
        installDirectory - The directory of the installed runtime
        action - The action to perform for the productInfo command
        Returns:
        The command output
        Throws:
        PluginExecutionException - if the exit value of the command was not 0