org.pentaho.packageManagement
Class DefaultPackage

java.lang.Object
  extended by org.pentaho.packageManagement.Package
      extended by org.pentaho.packageManagement.DefaultPackage
All Implemented Interfaces:
Cloneable

public class DefaultPackage
extends Package

A concrete implementation of Package that uses Java properties files/classes to manage package meta data. Assumes that meta data for individual packages is stored on the central repository (or possibly in a local cache - both accessible via http) in properties files that live in a sub-directory 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: 51361 $
Author:
mhall (mhall{[at]}pentaho{[dot]}com).

Field Summary
protected  File m_packageHome
          Holds the home directory for installed packages
protected  PackageManager m_packageManager
          The package manager in use
 
Fields inherited from class org.pentaho.packageManagement.Package
m_packageMetaData
 
Constructor Summary
DefaultPackage(File packageHome, PackageManager manager)
          Constructs a new DefaultPackage.
DefaultPackage(File packageHome, PackageManager manager, Map<?,?> packageMetaData)
          Constructs an new DefaultPackage.
 
Method Summary
 Object clone()
          Clone this package.
 List<Dependency> getBaseSystemDependency()
          Gets the dependency on the base system that this package requires.
 List<Dependency> getDependencies()
          Get the list of packages that this package depends on.
 List<Dependency> getIncompatibleDependencies()
          Gets a list of installed packages that this package depends on that are currently incompatible with this package.
 List<Dependency> getIncompatibleDependencies(List<Package> packages)
          Gets those packages from the supplied list that this package depends on and are currently incompatible with this package.
 List<Dependency> getMissingDependencies()
          Gets a list of packages that this package depends on that are not currently installed.
 List<Dependency> getMissingDependencies(List<Package> packages)
          Gets a list of packages that this package depends on that are not in the supplied list of packages.
 String getName()
          Convenience method to return the name of this package.
 URL getPackageURL()
          Convenience method that returns the URL to the package (i.e the provider's URL).
 void install()
          Install this package.
 boolean isCompatibleBaseSystem()
          Returns true if this package is compatible with the currently installed version of the base system.
 boolean isInstalled()
          Returns true if this package is already installed ²@return true if this package is installed
static void main(String[] args)
           
 void setPackageMetaDataElement(Object key, Object value)
          Adds a key, value pair to the meta data map.
protected static String[] splitNameVersion(String nameAndVersion)
           
 String toString()
           
 
Methods inherited from class org.pentaho.packageManagement.Package
equals, getPackageMetaData, getPackageMetaDataElement, setPackageMetaData
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_packageHome

protected File m_packageHome
Holds the home directory for installed packages


m_packageManager

protected PackageManager m_packageManager
The package manager in use

Constructor Detail

DefaultPackage

public DefaultPackage(File packageHome,
                      PackageManager manager,
                      Map<?,?> packageMetaData)
Constructs an new DefaultPackage.

Parameters:
packageHome - the directory that packages are installed into.
manager - the package manager in use.
packageMetaData - A Map of package meta data for this package.

DefaultPackage

public DefaultPackage(File packageHome,
                      PackageManager manager)
Constructs a new DefaultPackage.

Parameters:
packageHome - the directory that packages are installed into.
manager - the package manager in use.
Method Detail

clone

public Object clone()
Clone this package. Only makes a shallow copy of the meta data map

Specified by:
clone in class Package
Returns:
a copy of this package

getPackageURL

public URL getPackageURL()
                  throws Exception
Convenience method that returns the URL to the package (i.e the provider's URL). This information is assumed to be stored in the package meta data.

Specified by:
getPackageURL in class Package
Returns:
the URL to the package or null if the URL is not available for some reason
Throws:
Exception - if the URL can't be retrieved for some reason

getName

public String getName()
Convenience method to return the name of this package.

Specified by:
getName in class Package
Returns:
the name of this package.

splitNameVersion

protected static String[] splitNameVersion(String nameAndVersion)

getDependencies

public List<Dependency> getDependencies()
                                 throws Exception
Get the list of packages that this package depends on.

Specified by:
getDependencies in class Package
Returns:
the list of packages that this package depends on.
Throws:
Exception - if a problem occurs while getting the list of dependencies.

getBaseSystemDependency

public List<Dependency> getBaseSystemDependency()
                                         throws Exception
Gets the dependency on the base system that this package requires.

Specified by:
getBaseSystemDependency in class Package
Returns:
the base system dependency(s) for this package
Throws:
Exception - if the base system dependency can't be determined for some reason.

getMissingDependencies

public List<Dependency> getMissingDependencies(List<Package> packages)
                                        throws Exception
Gets a list of packages that this package depends on that are not in the supplied list of packages.

Specified by:
getMissingDependencies in class Package
Parameters:
packages - a list of packages to compare this package's dependencies against.
Returns:
those packages that this package depends on that aren't in the supplied list.
Throws:
Exception - if the list of missing depenencies can't be determined for some reason.

getMissingDependencies

public List<Dependency> getMissingDependencies()
                                        throws Exception
Gets a list of packages that this package depends on that are not currently installed.

Specified by:
getMissingDependencies in class Package
Returns:
a list of missing packages that this package depends on.
Throws:
Exception

getIncompatibleDependencies

public List<Dependency> getIncompatibleDependencies(List<Package> packages)
                                             throws Exception
Gets those packages from the supplied list that this package depends on and are currently incompatible with this package.

Specified by:
getIncompatibleDependencies in class Package
Parameters:
packages - a list of packages to compare this package's dependencies against
Returns:
those packages from the supplied list that are incompatible with respect to this package's dependencies
Throws:
Exception - if the list of incompatible dependencies can't be generated for some reason.

getIncompatibleDependencies

public List<Dependency> getIncompatibleDependencies()
                                             throws Exception
Gets a list of installed packages that this package depends on that are currently incompatible with this package.

Specified by:
getIncompatibleDependencies in class Package
Returns:
a list of incompatible installed packages that this package depends on.
Throws:
Exception

isCompatibleBaseSystem

public boolean isCompatibleBaseSystem()
                               throws Exception
Returns true if this package is compatible with the currently installed version of the base system.

Specified by:
isCompatibleBaseSystem in class Package
Returns:
true if this package is compatible with the main software system.
Throws:
Exception - if a problem occurs while checking compatibility.

install

public void install()
             throws Exception
Install this package.

Specified by:
install in class Package
Throws:
Exception - if something goes wrong during installation.

isInstalled

public boolean isInstalled()
Returns true if this package is already installed ²@return true if this package is installed

Specified by:
isInstalled in class Package
Returns:
true if this package is installed

main

public static void main(String[] args)

setPackageMetaDataElement

public void setPackageMetaDataElement(Object key,
                                      Object value)
                               throws Exception
Adds a key, value pair to the meta data map.

Specified by:
setPackageMetaDataElement in class Package
Parameters:
key - the key
value - the value to add
Throws:
Exception - if there is no meta data map to add to.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.