weka.core

## Class WekaPackageManager

- java.lang.Object
- - weka.core.WekaPackageManager

-     public class WekaPackageManager
      extends java.lang.Object

  Class providing package management and manipulation routines. Also provides a command line interface for package management.
  Version:
    $Revision: 11144 $
  Author:
    Mark Hall (mhall{[at]}pentaho{[dot]}com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.Set<java.lang.String>` | `m_doNotLoadList` The set of packages that the user has requested not to load
    `static boolean` | `m_initialPackageLoadingInProcess` Package loading in progress?
    `static boolean` | `m_noPackageMetaDataAvailable`
    `static boolean` | `m_offline` Operating offline?
    `static java.io.File` | `PACKAGES_DIR` The default packages directory
    `static java.io.File` | `PROPERTIES_DIR` The default properties directory
    `static java.io.File` | `WEKA_HOME` Default path to where Weka's configuration and packages are stored

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WekaPackageManager()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `checkForMissingClasses(org.pentaho.packageManagement.Package toLoad, java.io.PrintStream... progress)` Checks to see if there are any classes that we should try to instantiate before allowing this package to be loaded.
    `static boolean` | `checkForMissingFiles(org.pentaho.packageManagement.Package toLoad, java.io.File packageRoot, java.io.PrintStream... progress)` Checks to see if there are any missing files/directories for a given package.
    `static java.lang.Exception` | `checkForNewPackages(java.io.PrintStream... progress)` Check for new packages on the server and refresh the local cache if needed
    `static boolean` | `checkForUnsetEnvVar(org.pentaho.packageManagement.Package toLoad, java.io.PrintStream... progress)` Checks to see if there are any environment variables or properties that should be set at startup before allowing this package to be loaded.
    `static java.lang.Exception` | `establishCacheIfNeeded(java.io.PrintStream... progress)` Establish the local copy of the package meta data if needed
    `static java.util.List<org.pentaho.packageManagement.Dependency>` | `getAllDependenciesForPackage(org.pentaho.packageManagement.Package target, java.util.Map<java.lang.String,java.util.List<org.pentaho.packageManagement.Dependency>> conflicts)` Get a list of dependencies for a given package
    `static java.util.List<org.pentaho.packageManagement.Package>` | `getAllPackages()` Get a list of all packages
    `static java.util.List<org.pentaho.packageManagement.Package>` | `getAvailableCompatiblePackages()` Get a list of the most recent version of all available packages (i.e.
    `static java.util.List<org.pentaho.packageManagement.Package>` | `getAvailablePackages()` Get a list of all available packages (i.e.
    `static org.pentaho.packageManagement.Package` | `getInstalledPackageInfo(java.lang.String packageName)` Get meta data for an installed package
    `static java.util.List<org.pentaho.packageManagement.Package>` | `getInstalledPackages()` Get a list of installed packages
    `static org.pentaho.packageManagement.Package` | `getPackageArchiveInfo(java.lang.String packageArchivePath)` Extract meta data from a package archive
    `static java.io.File` | `getPackageHome()`
    `static java.util.Map<java.lang.String,java.lang.String>` | `getPackageList(boolean local)` Just get a list of the package names.
    `static java.net.URL` | `getPackageRepositoryURL()` Get the package repository URL
    `static org.pentaho.packageManagement.Package` | `getRepositoryPackageInfo(java.lang.String packageName)` Get meta data for the latest version of a package from the repository
    `static org.pentaho.packageManagement.Package` | `getRepositoryPackageInfo(java.lang.String packageName, java.lang.String version)` Get meta data for a specific version of a package from the repository
    `static java.util.List<java.lang.Object>` | `getRepositoryPackageVersions(java.lang.String packageName)` Get the versions of the supplied package available on the server
    `static org.pentaho.packageManagement.PackageManager` | `getUnderlyingPackageManager()` Get the underlying package manager implementation
    `static boolean` | `installedPackageResourceExists(java.lang.String packageName, java.lang.String resourceName)` Check if a named resource exists in an installed package
    `static java.lang.String` | `installPackageFromArchive(java.lang.String packageArchivePath, java.io.PrintStream... progress)` Install a package from an archive
    `static boolean` | `installPackageFromRepository(java.lang.String packageName, java.lang.String version, java.io.PrintStream... progress)` Install a named package by retrieving the location of the archive from the meta data stored in the repository
    `static java.lang.String` | `installPackageFromURL(java.net.URL packageURL, java.io.PrintStream... progress)` Insstall a package from the supplied URL
    `static boolean` | `installPackages(java.util.List<org.pentaho.packageManagement.Package> toInstall, java.io.PrintStream... progress)` Install the supplied list of packages
    `static boolean` | `loadCheck(org.pentaho.packageManagement.Package toLoad, java.io.File packageRoot, java.io.PrintStream... progress)` Check whether a package should be loaded or not.
    `static void` | `loadPackages(boolean verbose)` Load all packages
    `static void` | `loadPackages(boolean verbose, boolean avoidTriggeringFullClassDiscovery, boolean refreshGOEProperties)` Load all packages
    `static void` | `main(java.lang.String[] args)` Main method for using the package manager from the command line
    `static org.pentaho.packageManagement.Package` | `mostRecentVersionWithRespectToConstraint(org.pentaho.packageManagement.PackageConstraint toCheck)` Find the most recent version of the package encapsulated in the supplied PackageConstraint argument that satisfies the constraint
    `static int` | `numRepositoryPackages()` Get the number of packages that are available at the repository.
    `static java.lang.Exception` | `refreshCache(java.io.PrintStream... progress)` Refresh the local copy of the package meta data
    `static void` | `refreshGOEProperties()` Refresh the generic object editor properties via re-running of the dynamic class discovery process.
    `static void` | `removeExplorerProps(java.lang.String installedPackageName)` Remove any ExplorerDefaults properties specified in the supplied package
    `static int` | `repoZipArchiveSize()` Retrieves the size (in KB) of the repository zip archive stored on the server.
    `static java.util.List<java.lang.String>` | `toggleLoadStatus(java.util.List<java.lang.String> packageNames)` Toggle the load status of the supplied list of package names
    `static void` | `uninstallPackage(java.lang.String packageName, boolean updateKnowledgeFlow, java.io.PrintStream... progress)` Uninstall a named package

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### WEKA_HOME

          public static java.io.File WEKA_HOME

      Default path to where Weka's configuration and packages are stored

    - #### PACKAGES_DIR

          public static java.io.File PACKAGES_DIR

      The default packages directory

    - #### PROPERTIES_DIR

          public static java.io.File PROPERTIES_DIR

      The default properties directory

    - #### m_offline

          public static boolean m_offline

      Operating offline?

    - #### m_initialPackageLoadingInProcess

          public static boolean m_initialPackageLoadingInProcess

      Package loading in progress?

    - #### m_noPackageMetaDataAvailable

          public static boolean m_noPackageMetaDataAvailable

    - #### m_doNotLoadList

          public static java.util.Set<java.lang.String> m_doNotLoadList

      The set of packages that the user has requested not to load

  - ### Constructor Detail

    - #### WekaPackageManager

          public WekaPackageManager()

  - ### Method Detail

    - #### removeExplorerProps

          public static void removeExplorerProps(java.lang.String installedPackageName)

      Remove any ExplorerDefaults properties specified in the supplied package
      Parameters:
        `installedPackageName` - the package specifying properties that should be removed from ExplorerDefaults

    - #### loadCheck

          public static boolean loadCheck(org.pentaho.packageManagement.Package toLoad,
                          java.io.File packageRoot,
                          java.io.PrintStream... progress)

      Check whether a package should be loaded or not. Checks for missing classes, unset environment variables, missing dependencies etc.
      Parameters:
        `toLoad` - the package to check
        `packageRoot` - the root directory of the package
        `progress` - for reporting loading progress
      Returns:
        true if the package is good to load

    - #### checkForUnsetEnvVar

          public static boolean checkForUnsetEnvVar(org.pentaho.packageManagement.Package toLoad,
                                    java.io.PrintStream... progress)

      Checks to see if there are any environment variables or properties that should be set at startup before allowing this package to be loaded. This is useful for packages that might not be able to function correctly if certain variables are not set correctly.
      Parameters:
        `toLoad` - the package to check
      Returns:
        true if good to go

    - #### checkForMissingClasses

          public static boolean checkForMissingClasses(org.pentaho.packageManagement.Package toLoad,
                                       java.io.PrintStream... progress)

      Checks to see if there are any classes that we should try to instantiate before allowing this package to be loaded. This is useful for checking to see if third-party classes are accessible. An example would be Java3D, which has an installer that installs into the JRE/JDK.
      Parameters:
        `toLoad` - the package to check
      Returns:
        true if good to go

    - #### checkForMissingFiles

          public static boolean checkForMissingFiles(org.pentaho.packageManagement.Package toLoad,
                                     java.io.File packageRoot,
                                     java.io.PrintStream... progress)

      Checks to see if there are any missing files/directories for a given package. If there are missing files, then the package can't be loaded. An example would be a connector package that, for whatever reason, can't include a necessary third-party jar file in its lib folder, and requires the user to download and install this jar file manually.
      Parameters:
        `toLoad` - the package to check
        `packageRoot` - the root directory of the package
      Returns:
        true if good to go

    - #### toggleLoadStatus

          public static java.util.List<java.lang.String> toggleLoadStatus(java.util.List<java.lang.String> packageNames)
                                                                   throws java.lang.Exception

      Toggle the load status of the supplied list of package names
      Parameters:
        `packageNames` - the packages to toggle the load status for
      Returns:
        a list of unknown packages (i.e. any supplied package names that don't appear to be installed)
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### loadPackages

          public static void loadPackages(boolean verbose)

      Load all packages
      Parameters:
        `verbose` - true if loading progress should be output

    - #### loadPackages

          public static void loadPackages(boolean verbose,
                          boolean avoidTriggeringFullClassDiscovery,
                          boolean refreshGOEProperties)

      Load all packages
      Parameters:
        `verbose` - true if loading progress should be output
        `avoidTriggeringFullClassDiscovery` - true if we should avoid processing any properties files that might cause a full class discovery run, and may involve instantiating GUI classes.
        `refreshGOEProperties` - true if the GOE properties should be refreshed after loading (i.e. a re-run of the class discovery mechanism, re-initialization of the Knowledge Flow etc.)

    - #### refreshGOEProperties

          public static void refreshGOEProperties()

      Refresh the generic object editor properties via re-running of the dynamic class discovery process.

    - #### getUnderlyingPackageManager

          public static org.pentaho.packageManagement.PackageManager getUnderlyingPackageManager()

      Get the underlying package manager implementation
      Returns:
        the underlying concrete package management implementation.

    - #### repoZipArchiveSize

          public static int repoZipArchiveSize()

      Retrieves the size (in KB) of the repository zip archive stored on the server.
      Returns:
        the size of the repository zip archive in KB.

    - #### numRepositoryPackages

          public static int numRepositoryPackages()

      Get the number of packages that are available at the repository.
      Returns:
        the number of packages that are available (or -1 if this can't be determined for some reason.

    - #### getPackageList

          public static java.util.Map<java.lang.String,java.lang.String> getPackageList(boolean local)

      Just get a list of the package names. This is faster than calling getAllPackages(), especially if fetching from the online repository, since the full meta data for each package doesn't have to be read.
      Parameters:
        `local` - true if the local package list in the cache should be read rather than the online repository
      Returns:
        a Map of all the package names available either locally or at the repository

    - #### establishCacheIfNeeded

          public static java.lang.Exception establishCacheIfNeeded(java.io.PrintStream... progress)

      Establish the local copy of the package meta data if needed
      Parameters:
        `progress` - for reporting progress
      Returns:
        any Exception raised or null if all is good

    - #### checkForNewPackages

          public static java.lang.Exception checkForNewPackages(java.io.PrintStream... progress)

      Check for new packages on the server and refresh the local cache if needed
      Parameters:
        `progress` - to report progress to
      Returns:
        any Exception raised or null if all is good

    - #### refreshCache

          public static java.lang.Exception refreshCache(java.io.PrintStream... progress)

      Refresh the local copy of the package meta data
      Parameters:
        `progress` - to report progress to
      Returns:
        any Exception raised or null if all is successful

    - #### installedPackageResourceExists

          public static boolean installedPackageResourceExists(java.lang.String packageName,
                                               java.lang.String resourceName)

      Check if a named resource exists in an installed package
      Parameters:
        `packageName` - the name of the package in question
        `resourceName` - the name of the resource to check for
      Returns:
        true if the resource exists in the package

    - #### getPackageHome

          public static java.io.File getPackageHome()

    - #### mostRecentVersionWithRespectToConstraint

          public static org.pentaho.packageManagement.Package mostRecentVersionWithRespectToConstraint(org.pentaho.packageManagement.PackageConstraint toCheck)
                                                                                                throws java.lang.Exception

      Find the most recent version of the package encapsulated in the supplied PackageConstraint argument that satisfies the constraint
      Parameters:
        `toCheck` - the PackageConstraint containing the package in question
      Returns:
        the most recent version of the package satisfying the constraint
      Throws:
        `java.lang.Exception` - if a version can't be found that satisfies the constraint or an error occurs while communicating with the respository

    - #### installPackages

          public static boolean installPackages(java.util.List<org.pentaho.packageManagement.Package> toInstall,
                                java.io.PrintStream... progress)
                                         throws java.lang.Exception

      Install the supplied list of packages
      Parameters:
        `toInstall` - packages to install
        `progress` - to report progress to
      Returns:
        true if successful
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getRepositoryPackageVersions

          public static java.util.List<java.lang.Object> getRepositoryPackageVersions(java.lang.String packageName)
                                                                               throws java.lang.Exception

      Get the versions of the supplied package available on the server
      Parameters:
        `packageName` - the package name to get available versions for
      Returns:
        a list of available versions
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getPackageRepositoryURL

          public static java.net.URL getPackageRepositoryURL()

      Get the package repository URL
      Returns:
        the package repository URL

    - #### getAllPackages

          public static java.util.List<org.pentaho.packageManagement.Package> getAllPackages()
                                                                                      throws java.lang.Exception

      Get a list of all packages
      Returns:
        a list of all packages
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getAvailablePackages

          public static java.util.List<org.pentaho.packageManagement.Package> getAvailablePackages()
                                                                                            throws java.lang.Exception

      Get a list of all available packages (i.e. those not yet installed(.
      Returns:
        a list of all available packages
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getAvailableCompatiblePackages

          public static java.util.List<org.pentaho.packageManagement.Package> getAvailableCompatiblePackages()
                                                                                                      throws java.lang.Exception

      Get a list of the most recent version of all available packages (i.e. those not yet installed) that are compatible with the version of Weka that is installed.
      Returns:
        a list of packages that are compatible with the installed version of Weka
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getInstalledPackages

          public static java.util.List<org.pentaho.packageManagement.Package> getInstalledPackages()
                                                                                            throws java.lang.Exception

      Get a list of installed packages
      Returns:
        a list of installed packages
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getAllDependenciesForPackage

          public static java.util.List<org.pentaho.packageManagement.Dependency> getAllDependenciesForPackage(org.pentaho.packageManagement.Package target,
                                                                                              java.util.Map<java.lang.String,java.util.List<org.pentaho.packageManagement.Dependency>> conflicts)
                                                                                                       throws java.lang.Exception

      Get a list of dependencies for a given package
      Parameters:
        `target` - the package to get the dependencies for
        `conflicts` - will hold any conflicts
      Returns:
        a list of dependencies for the target package
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getPackageArchiveInfo

          public static org.pentaho.packageManagement.Package getPackageArchiveInfo(java.lang.String packageArchivePath)
                                                                             throws java.lang.Exception

      Extract meta data from a package archive
      Parameters:
        `packageArchivePath` - the path to the package archive
      Returns:
        the meta data for the package
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getInstalledPackageInfo

          public static org.pentaho.packageManagement.Package getInstalledPackageInfo(java.lang.String packageName)
                                                                               throws java.lang.Exception

      Get meta data for an installed package
      Parameters:
        `packageName` - the name of the package
      Returns:
        the meta data for the package
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getRepositoryPackageInfo

          public static org.pentaho.packageManagement.Package getRepositoryPackageInfo(java.lang.String packageName)
                                                                                throws java.lang.Exception

      Get meta data for the latest version of a package from the repository
      Parameters:
        `packageName` - the name of the package
      Returns:
        the meta data for the package
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### getRepositoryPackageInfo

          public static org.pentaho.packageManagement.Package getRepositoryPackageInfo(java.lang.String packageName,
                                                                       java.lang.String version)
                                                                                throws java.lang.Exception

      Get meta data for a specific version of a package from the repository
      Parameters:
        `packageName` - the name of the package
        `version` - the version to get meta data for
      Returns:
        the meta data for the package
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### installPackageFromRepository

          public static boolean installPackageFromRepository(java.lang.String packageName,
                                             java.lang.String version,
                                             java.io.PrintStream... progress)
                                                      throws java.lang.Exception

      Install a named package by retrieving the location of the archive from the meta data stored in the repository
      Parameters:
        `packageName` - the name of the package to install
        `version` - the version of the package to install
        `progress` - for reporting progress
      Returns:
        true if the package was installed successfully
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### installPackageFromArchive

          public static java.lang.String installPackageFromArchive(java.lang.String packageArchivePath,
                                                   java.io.PrintStream... progress)
                                                            throws java.lang.Exception

      Install a package from an archive
      Parameters:
        `packageArchivePath` - the path to the package archive file to install
        `progress` - for reporting progress
      Returns:
        true if the package was installed successfully
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### installPackageFromURL

          public static java.lang.String installPackageFromURL(java.net.URL packageURL,
                                               java.io.PrintStream... progress)
                                                        throws java.lang.Exception

      Insstall a package from the supplied URL
      Parameters:
        `packageURL` - the URL to the package archive to install
        `progress` - for reporting progress
      Returns:
        true if the package was installed successfully
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### uninstallPackage

          public static void uninstallPackage(java.lang.String packageName,
                              boolean updateKnowledgeFlow,
                              java.io.PrintStream... progress)
                                       throws java.lang.Exception

      Uninstall a named package
      Parameters:
        `packageName` - the name of the package to remove
        `updateKnowledgeFlow` - true if any Knowledge Flow beans provided by the package should be deregistered from the KnoweledgeFlow
        `progress` - for reporting progress
      Throws:
        `java.lang.Exception` - if a problem occurs

    - #### main

          public static void main(java.lang.String[] args)

      Main method for using the package manager from the command line
      Parameters:
        `args` - command line arguments