Package weka.core.packageManagement
Class DefaultPackageManager
- java.lang.Object
-
- weka.core.packageManagement.PackageManager
-
- weka.core.packageManagement.DefaultPackageManager
-
public class DefaultPackageManager extends PackageManager
A concrete implementation of PackageManager that uses Java properties files/class to manage package meta data. Assumes that meta data for individual packages is stored on the central repository (accessible via http) in properties files that live in a subdirectory with the same name as the package. Furthermore, each property file is assumed to be named as the version number of the package in question with a ".props" extension. A "Latest.props" file should exist for each package and should always hold meta data on the latest version of a package.- Version:
- $Revision: 52515 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
-
Constructor Summary
Constructors Constructor Description DefaultPackageManager()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplySettings(Settings settings)Apply settings.static voiddeleteDir(java.io.File dir, java.io.PrintStream... progress)java.util.List<Dependency>getAllDependenciesForPackage(Package target, java.util.Map<java.lang.String,java.util.List<Dependency>> conflicts)Gets a full list of packages (encapsulated in Dependency objects) that are required by directly and indirectly by the named target package.java.util.List<Package>getAllPackages(java.io.PrintStream... progress)Get all packages that the system knows about (i.e.java.util.List<Package>getAvailablePackages()Get a list of packages that are not currently installed.DefaultsgetDefaultSettings()Get the default settings for the default package managerPackagegetInstalledPackageInfo(java.lang.String packageName)Get package information on the named installed package.java.util.List<Package>getInstalledPackages()Get a list of installed packages.PackagegetPackageArchiveInfo(java.lang.String packageArchivePath)Get package information from the supplied package archive file.PackagegetRepositoryPackageInfo(java.lang.String packageName)Get package information on the named package from the repository.PackagegetRepositoryPackageInfo(java.lang.String packageName, java.lang.Object version)Get package information on the named package from the repository.byte[]getRepositoryPackageMetaDataOnlyAsZip(java.io.PrintStream... progress)Gets an array of bytes containing a zip of all the repository meta data and supporting files.byte[]getRepositoryPackageMetaDataOnlyAsZipLegacy(java.io.PrintStream... progress)Gets an array of bytes containing a zip of all the repository meta data and supporting files using the legacy approach.java.util.List<java.lang.Object>getRepositoryPackageVersions(java.lang.String packageName)Get a list of available versions of the named package.PackagegetURLPackageInfo(java.net.URL packageURL)Get package information on the package at the given URL.java.lang.StringinstallPackageFromArchive(java.lang.String packageArchivePath, java.io.PrintStream... progress)Install a package from an archive on the local file system.voidinstallPackageFromRepository(java.lang.String packageName, java.lang.Object version, java.io.PrintStream... progress)Install a package sourced from the repository.java.lang.StringinstallPackageFromURL(java.net.URL packageURL, java.io.PrintStream... progress)Install a package sourced from a given URL.voidinstallPackages(java.util.List<Package> toInstall, java.io.PrintStream... progress)Installs all the packages in the supplied list.static voidmain(java.lang.String[] args)voiduninstallPackage(java.lang.String packageName, java.io.PrintStream... progress)Uninstall a package.-
Methods inherited from class weka.core.packageManagement.PackageManager
create, establishProxy, getBaseSystemName, getBaseSystemVersion, getPackageHome, getPackageRepositoryURL, getProxy, setBaseSystemName, setBaseSystemVersion, setPackageHome, setPackageRepositoryURL, setProxy, setProxyAuthentication, setProxyPassword, setProxyUsername
-
-
-
-
Method Detail
-
getDefaultSettings
public Defaults getDefaultSettings()
Get the default settings for the default package manager- Overrides:
getDefaultSettingsin classPackageManager- Returns:
- the default settings
-
applySettings
public void applySettings(Settings settings)
Apply settings.- Overrides:
applySettingsin classPackageManager- Parameters:
settings- the settings to apply
-
getURLPackageInfo
public Package getURLPackageInfo(java.net.URL packageURL) throws java.lang.Exception
Get package information on the package at the given URL.- Specified by:
getURLPackageInfoin classPackageManager- Parameters:
packageURL- the URL to the package.- Returns:
- a Package object encapsulating the package meta data
- Throws:
java.lang.Exception- if the package meta data can't be retrieved.
-
getRepositoryPackageInfo
public Package getRepositoryPackageInfo(java.lang.String packageName) throws java.lang.Exception
Get package information on the named package from the repository. If multiple versions of the package are available, it assumes that the most recent is required.- Specified by:
getRepositoryPackageInfoin classPackageManager- Parameters:
packageName- the name of the package to get information about.- Returns:
- a Package object encapsulating the package meta data.
- Throws:
java.lang.Exception- if the package meta data can't be retrieved.
-
getRepositoryPackageVersions
public java.util.List<java.lang.Object> getRepositoryPackageVersions(java.lang.String packageName) throws java.lang.ExceptionGet a list of available versions of the named package.- Specified by:
getRepositoryPackageVersionsin classPackageManager- Parameters:
packageName- the name of the package to get versions.- Returns:
- a list of available versions (or null if not applicable)
- Throws:
java.lang.Exception- if something goes wrong while trying to retrieve the list of versions.
-
getRepositoryPackageInfo
public Package getRepositoryPackageInfo(java.lang.String packageName, java.lang.Object version) throws java.lang.Exception
Get package information on the named package from the repository.- Specified by:
getRepositoryPackageInfoin classPackageManager- Parameters:
packageName- the name of the package to get information about.version- the version of the package to retrieve (may be null if not applicable).- Returns:
- a Package object encapsulating the package meta data.
- Throws:
java.lang.Exception- if the package meta data can't be retrieved.
-
getPackageArchiveInfo
public Package getPackageArchiveInfo(java.lang.String packageArchivePath) throws java.lang.Exception
Get package information from the supplied package archive file.- Specified by:
getPackageArchiveInfoin classPackageManager- Parameters:
packageArchivePath- the path to the package archive file- Returns:
- a Package object encapsulating the package meta data.
- Throws:
java.lang.Exception- if the package meta data can't be retrieved.
-
getInstalledPackageInfo
public Package getInstalledPackageInfo(java.lang.String packageName) throws java.lang.Exception
Get package information on the named installed package.- Specified by:
getInstalledPackageInfoin classPackageManager- Parameters:
packageName- the name of the package to get information about.- Returns:
- a Package object encapsulating the package meta data or null if the package is not installed.
- Throws:
java.lang.Exception- if the package meta data can't be retrieved.
-
deleteDir
public static void deleteDir(java.io.File dir, java.io.PrintStream... progress) throws java.lang.Exception- Throws:
java.lang.Exception
-
uninstallPackage
public void uninstallPackage(java.lang.String packageName, java.io.PrintStream... progress) throws java.lang.ExceptionUninstall a package.- Specified by:
uninstallPackagein classPackageManager- Parameters:
packageName- the package to uninstall.progress- optional varargs parameter, that, if supplied, is expected to contain one or more PrintStream objects to write progress to.- Throws:
java.lang.Exception- if the named package could not be removed for some reason.
-
installPackageFromArchive
public java.lang.String installPackageFromArchive(java.lang.String packageArchivePath, java.io.PrintStream... progress) throws java.lang.ExceptionInstall a package from an archive on the local file system.- Specified by:
installPackageFromArchivein classPackageManager- Parameters:
packageArchivePath- the path to the package archive file.progress- optional varargs parameter, that, if supplied, is expected to contain one or more PrintStream objects to write progress to.- Returns:
- the name of the package installed
- Throws:
java.lang.Exception- if the package can't be installed for some reason.
-
installPackages
public void installPackages(java.util.List<Package> toInstall, java.io.PrintStream... progress) throws java.lang.Exception
Installs all the packages in the supplied list.- Specified by:
installPackagesin classPackageManager- Parameters:
toInstall- a list of Packages to install.progress- optional varargs parameter, that, if supplied, is expected to contain one or more PrintStream objects to write progress to.- Throws:
java.lang.Exception- if something goes wrong during the installation process.
-
getAllDependenciesForPackage
public java.util.List<Dependency> getAllDependenciesForPackage(Package target, java.util.Map<java.lang.String,java.util.List<Dependency>> conflicts) throws java.lang.Exception
Gets a full list of packages (encapsulated in Dependency objects) that are required by directly and indirectly by the named target package. Also builds a Map of any packages that are required by more than one package and where there is a conflict of some sort (e.g. multiple conflicting versions). The keys of this map are package names (strings), and each associated value is a list of Dependency objects.- Specified by:
getAllDependenciesForPackagein classPackageManager- Parameters:
target- the package for which a list of dependencies is required.conflicts- will hold any conflicts that are discovered while building the full dependency list.- Returns:
- a list of packages that are directly and indirectly required by the named target package.
- Throws:
java.lang.Exception- if a problem occurs while building the dependency list.
-
installPackageFromRepository
public void installPackageFromRepository(java.lang.String packageName, java.lang.Object version, java.io.PrintStream... progress) throws java.lang.ExceptionInstall a package sourced from the repository.- Specified by:
installPackageFromRepositoryin classPackageManager- Parameters:
packageName- the name of the package to installversion- the version of the package to install (may be null if not applicable).progress- optional varargs parameter, that, if supplied, is expected to contain one or more PrintStream objects to write progress to.- Throws:
java.lang.Exception- if the package can't be installed for some reason.
-
installPackageFromURL
public java.lang.String installPackageFromURL(java.net.URL packageURL, java.io.PrintStream... progress) throws java.lang.ExceptionInstall a package sourced from a given URL.- Specified by:
installPackageFromURLin classPackageManager- Parameters:
packageURL- the URL to the package.progress- optional varargs parameter, that, if supplied, is expected to contain one or more PrintStream objects to write progress to.- Returns:
- the name of the package installed
- Throws:
java.lang.Exception- if the package can't be installed for some reason.
-
getRepositoryPackageMetaDataOnlyAsZip
public byte[] getRepositoryPackageMetaDataOnlyAsZip(java.io.PrintStream... progress) throws java.lang.ExceptionGets an array of bytes containing a zip of all the repository meta data and supporting files. Does *not* contain any package archives etc., only a snapshot of the meta data. Could be used by clients to establish a cache of meta data.- Specified by:
getRepositoryPackageMetaDataOnlyAsZipin classPackageManager- Parameters:
progress- optional varargs parameter, that, if supplied, is expected to contain one or more PrintStream objects to write progress to.- Returns:
- a zip compressed array of bytes.
- Throws:
java.lang.Exception- if the repository meta data can't be returned as a zip
-
getRepositoryPackageMetaDataOnlyAsZipLegacy
public byte[] getRepositoryPackageMetaDataOnlyAsZipLegacy(java.io.PrintStream... progress) throws java.lang.ExceptionGets an array of bytes containing a zip of all the repository meta data and supporting files using the legacy approach. Does *not* contain any package archives etc., only a snapshot of the meta data. Could be used by clients to establish a cache of meta data.- Returns:
- a zip compressed array of bytes.
- Throws:
java.lang.Exception
-
getAllPackages
public java.util.List<Package> getAllPackages(java.io.PrintStream... progress) throws java.lang.Exception
Get all packages that the system knows about (i.e. all packages contained in the repository).- Specified by:
getAllPackagesin classPackageManager- Parameters:
progress- optional varargs parameter, that, if supplied is expected to contain one or more PrintStream objects to write progress to.- Returns:
- a list of all packages.
- Throws:
java.lang.Exception- if a list of packages can't be determined.
-
getAvailablePackages
public java.util.List<Package> getAvailablePackages() throws java.lang.Exception
Get a list of packages that are not currently installed.- Specified by:
getAvailablePackagesin classPackageManager- Returns:
- a list of packages that are not currently installed.
- Throws:
java.lang.Exception- if a list of packages can't be determined.
-
getInstalledPackages
public java.util.List<Package> getInstalledPackages() throws java.lang.Exception
Get a list of installed packages.- Specified by:
getInstalledPackagesin classPackageManager- Returns:
- a list of installed packages.
- Throws:
java.lang.Exception- if a list of packages can't be determined.
-
main
public static void main(java.lang.String[] args)
-
-