Package weka.core.packageManagement
Class PackageManager
- java.lang.Object
-
- weka.core.packageManagement.PackageManager
-
- Direct Known Subclasses:
DefaultPackageManager
public abstract class PackageManager extends java.lang.ObjectAbstract base class for package managers. Contains methods to manage the location of the central package repository, the home directory for installing packages, the name and version of the base software system and a http proxy.- Version:
- $Revision: 52568 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
-
Constructor Summary
Constructors Constructor Description PackageManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidapplySettings(Settings settings)Apply the supplied settings.static PackageManagercreate()voidestablishProxy()Tries to configure a Proxy object for use in an Authenticator if there is a proxy defined by the properties http.proxyHost and http.proxyPort, and if the user has set values for the properties (note, these are not standard java properties) http.proxyUser and http.proxyPassword.abstract 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.abstract java.util.List<Package>getAllPackages(java.io.PrintStream... progress)Get all packages that the system knows about (i.e.abstract java.util.List<Package>getAvailablePackages()Get a list of packages that are not currently installed.java.lang.StringgetBaseSystemName()Get the name of the main software system for which we manage packages.java.lang.ObjectgetBaseSystemVersion()Get the current installed version of the main system for which we manage packages.DefaultsgetDefaultSettings()Get the default settings of this package manager.abstract PackagegetInstalledPackageInfo(java.lang.String packageName)Get package information on the named installed package.abstract java.util.List<Package>getInstalledPackages()Get a list of installed packages.abstract PackagegetPackageArchiveInfo(java.lang.String packageArchivePath)Get package information from the supplied package archive file.java.io.FilegetPackageHome()Get the location (directory) of installed packagesjava.net.URLgetPackageRepositoryURL()Get the URL to the repository of package meta data.java.net.ProxygetProxy()Get the proxy in use.abstract PackagegetRepositoryPackageInfo(java.lang.String packageName)Get package information on the named package from the repository.abstract PackagegetRepositoryPackageInfo(java.lang.String packageName, java.lang.Object version)Get package information on the named package from the repository.abstract byte[]getRepositoryPackageMetaDataOnlyAsZip(java.io.PrintStream... progress)Gets an array of bytes containing a zip of all the repository meta data and supporting files.abstract java.util.List<java.lang.Object>getRepositoryPackageVersions(java.lang.String packageName)Get a list of available versions of the named package.abstract PackagegetURLPackageInfo(java.net.URL packageURL)Get package information on the package at the given URL.abstract java.lang.StringinstallPackageFromArchive(java.lang.String packageArchivePath, java.io.PrintStream... progress)Install a package from an archive on the local file system.abstract voidinstallPackageFromRepository(java.lang.String packageName, java.lang.Object version, java.io.PrintStream... progress)Install a package sourced from the repository.abstract java.lang.StringinstallPackageFromURL(java.net.URL packageURL, java.io.PrintStream... progress)Install a package sourced from a given URL.abstract voidinstallPackages(java.util.List<Package> toInstall, java.io.PrintStream... progress)Installs all the packages in the supplied list.voidsetBaseSystemName(java.lang.String baseS)Set the name of the main software system for which we manage packages.voidsetBaseSystemVersion(java.lang.Object systemV)Set the current version of the base system for which we manage packages.voidsetPackageHome(java.io.File packageHome)Set the location (directory) of installed packages.voidsetPackageRepositoryURL(java.net.URL repositoryURL)Set the URL to the repository of package meta data.voidsetProxy(java.net.Proxy proxyToUse)Set a proxy to use for accessing the internet (default is no proxy).booleansetProxyAuthentication(java.net.URL urlToConnectTo)Sets an new default Authenticator that will return the values set through setProxyUsername() and setProxyPassword() (if applicable).voidsetProxyPassword(java.lang.String proxyPassword)Set the password for authentication with the proxy.voidsetProxyUsername(java.lang.String proxyUsername)Set the user name for authentication with the proxy.abstract voiduninstallPackage(java.lang.String packageName, java.io.PrintStream... progress)Uninstall a package.
-
-
-
Method Detail
-
create
public static PackageManager create()
-
establishProxy
public void establishProxy()
Tries to configure a Proxy object for use in an Authenticator if there is a proxy defined by the properties http.proxyHost and http.proxyPort, and if the user has set values for the properties (note, these are not standard java properties) http.proxyUser and http.proxyPassword.
-
setProxyAuthentication
public boolean setProxyAuthentication(java.net.URL urlToConnectTo)
Sets an new default Authenticator that will return the values set through setProxyUsername() and setProxyPassword() (if applicable).- Returns:
- true if a proxy is to be used and (if applicable) the Authenticator was set successfully.
-
setPackageHome
public void setPackageHome(java.io.File packageHome)
Set the location (directory) of installed packages.- Parameters:
packageHome- the file system location of installed packages.
-
getPackageHome
public java.io.File getPackageHome()
Get the location (directory) of installed packages- Returns:
- the directory containing installed packages.
-
setBaseSystemName
public void setBaseSystemName(java.lang.String baseS)
Set the name of the main software system for which we manage packages.- Parameters:
baseS- the name of the base software system
-
getBaseSystemName
public java.lang.String getBaseSystemName()
Get the name of the main software system for which we manage packages.- Returns:
- the name of the base software system.
-
setBaseSystemVersion
public void setBaseSystemVersion(java.lang.Object systemV)
Set the current version of the base system for which we manage packages.- Parameters:
systemV- the current version of the main software system.
-
getBaseSystemVersion
public java.lang.Object getBaseSystemVersion()
Get the current installed version of the main system for which we manage packages.- Returns:
- the installed version of the base system.
-
setPackageRepositoryURL
public void setPackageRepositoryURL(java.net.URL repositoryURL)
Set the URL to the repository of package meta data.- Parameters:
repositoryURL- the URL to the repository of package meta data.
-
getPackageRepositoryURL
public java.net.URL getPackageRepositoryURL()
Get the URL to the repository of package meta data.- Returns:
- the URL to the repository of package meta data.
-
setProxy
public void setProxy(java.net.Proxy proxyToUse)
Set a proxy to use for accessing the internet (default is no proxy).- Parameters:
proxyToUse- a proxy to use.
-
getProxy
public java.net.Proxy getProxy()
Get the proxy in use.- Returns:
- the proxy in use or null if no proxy is being used.
-
setProxyUsername
public void setProxyUsername(java.lang.String proxyUsername)
Set the user name for authentication with the proxy.- Parameters:
proxyUsername- the user name to use for proxy authentication.
-
setProxyPassword
public void setProxyPassword(java.lang.String proxyPassword)
Set the password for authentication with the proxy.- Parameters:
proxyPassword- the password to use for proxy authentication.
-
getDefaultSettings
public Defaults getDefaultSettings()
Get the default settings of this package manager. Default implementation returns null. Subclasses to override if they have default settings- Returns:
- the default settings of this package manager
-
applySettings
public void applySettings(Settings settings)
Apply the supplied settings. Default implementation does nothing. Subclasses should override to take note of settings changes.- Parameters:
settings- the settings to apply
-
getRepositoryPackageMetaDataOnlyAsZip
public abstract 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.- 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
-
getPackageArchiveInfo
public abstract Package getPackageArchiveInfo(java.lang.String packageArchivePath) throws java.lang.Exception
Get package information from the supplied package archive file.- 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 abstract Package getInstalledPackageInfo(java.lang.String packageName) throws java.lang.Exception
Get package information on the named installed package.- 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.
-
getRepositoryPackageInfo
public abstract 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.- 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.
-
getRepositoryPackageInfo
public abstract Package getRepositoryPackageInfo(java.lang.String packageName, java.lang.Object version) throws java.lang.Exception
Get package information on the named package from the repository.- 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.
-
getRepositoryPackageVersions
public abstract java.util.List<java.lang.Object> getRepositoryPackageVersions(java.lang.String packageName) throws java.lang.ExceptionGet a list of available versions of the named package.- 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.
-
getURLPackageInfo
public abstract Package getURLPackageInfo(java.net.URL packageURL) throws java.lang.Exception
Get package information on the package at the given URL.- 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.
-
installPackageFromArchive
public abstract 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.- 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.
-
installPackageFromRepository
public abstract void installPackageFromRepository(java.lang.String packageName, java.lang.Object version, java.io.PrintStream... progress) throws java.lang.ExceptionInstall a package sourced from the repository.- 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 abstract java.lang.String installPackageFromURL(java.net.URL packageURL, java.io.PrintStream... progress) throws java.lang.ExceptionInstall a package sourced from a given URL.- 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.
-
installPackages
public abstract void installPackages(java.util.List<Package> toInstall, java.io.PrintStream... progress) throws java.lang.Exception
Installs all the packages in the supplied list.- 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.
-
uninstallPackage
public abstract void uninstallPackage(java.lang.String packageName, java.io.PrintStream... progress) throws java.lang.ExceptionUninstall a package.- 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.
-
getInstalledPackages
public abstract java.util.List<Package> getInstalledPackages() throws java.lang.Exception
Get a list of installed packages.- Returns:
- a list of installed packages.
- Throws:
java.lang.Exception- if a list of packages can't be determined.
-
getAllPackages
public abstract 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).- 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 abstract java.util.List<Package> getAvailablePackages() throws java.lang.Exception
Get a list of packages that are not currently installed.- Returns:
- a list of packages that are not currently installed.
- Throws:
java.lang.Exception- if a list of packages can't be determined.
-
getAllDependenciesForPackage
public abstract 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.- 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.
-
-