com.sun.pkg.client
Class Image

java.lang.Object
  extended by com.sun.pkg.client.Image

public class Image
extends java.lang.Object

An Image is a directory tree containing the laid-down contents of a self-consistent graph of Packages.

An Image has a root path.

Author:
trm

Nested Class Summary
static class Image.FmriState
          An FmriState represents the current state of an Fmri within the image.
 
Field Summary
static int IMG_ENTIRE
           
static int IMG_PARTIAL
           
static int IMG_USER
           
 
Constructor Summary
Image(java.io.File path)
          Create an Image object for an existing user image based on a File.
Image(java.lang.String path)
          Create an Image object for an existing user image based on a String
 
Method Summary
 Catalog getCatalog()
          Obtain the Catalog for this image.
 java.util.List<Image.FmriState> getInventory(java.lang.String[] pkg_list, boolean all_known)
          Get the inventory of packages and their associated state.
 Manifest getManifest(Fmri fmri)
          Get the manifest for a package.
 java.lang.String getPreferredAuthorityName()
           
 java.io.File getRootDirectory()
          Obtain the root directory for this image.
 void hideMetaDirectory()
           
 void installPackages(java.util.List<Fmri> pkgs)
          Install packages and any required dependencies.
 void installPackages(java.lang.String[] pkgNames)
          Install packages and any required dependencies.
 void refreshCatalogs()
           
 void saveConfig()
          Save the configuration for the image.
 void setAuthority(java.lang.String authname, java.net.URL origin, java.lang.String uuid)
          Set image authority attributes.
 void uninstallPackages(java.util.List<Fmri> pkgs)
          Uninstall packages.
 void uninstallPackages(java.lang.String[] pkgNames)
          Uninstall packages.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMG_ENTIRE

public static final int IMG_ENTIRE
See Also:
Constant Field Values

IMG_PARTIAL

public static final int IMG_PARTIAL
See Also:
Constant Field Values

IMG_USER

public static final int IMG_USER
See Also:
Constant Field Values
Constructor Detail

Image

public Image(java.lang.String path)
      throws java.lang.Exception
Create an Image object for an existing user image based on a String

Parameters:
path - The path for a file or directory within the image.
Throws:
java.lang.Exception

Image

public Image(java.io.File path)
      throws java.lang.Exception
Create an Image object for an existing user image based on a File.

Parameters:
path - A File within the image.
Throws:
java.lang.Exception
Method Detail

getRootDirectory

public java.io.File getRootDirectory()
Obtain the root directory for this image.

Returns:
the root directory for this image

getCatalog

public Catalog getCatalog()
Obtain the Catalog for this image.

Returns:
the Catalog for this image

hideMetaDirectory

public void hideMetaDirectory()
                       throws java.io.IOException
Throws:
java.io.IOException

saveConfig

public void saveConfig()
                throws java.io.IOException
Save the configuration for the image. Adjust the origin in the cfgfile so that it matches that of the current platform as determined by origin_for_* properties. This method writes a new version of the cfgfile.

Throws:
java.io.IOException

getPreferredAuthorityName

public java.lang.String getPreferredAuthorityName()

setAuthority

public void setAuthority(java.lang.String authname,
                         java.net.URL origin,
                         java.lang.String uuid)
Set image authority attributes. If authname names an authority that currently doesn't exist, it is added to the image. For adding an authority, the origin URL is required. For an existing authority, the origin or uuid parameters may be null and in that case the value for the attribute is not changed.

NOTE: setting the uuid is effective only if a uuid attribute is already there
NOTE: adding an authority doesn't yet save it to disk

Parameters:
authname - - the name of the authority to change
origin - - the origin URL for the authority
uuid - - the UUID for the authority
Throws:
java.lang.IllegalArgumentException - - if the authority is not currently in the image and origin is null.

refreshCatalogs

public void refreshCatalogs()
                     throws java.io.IOException
Throws:
java.io.IOException

getInventory

public java.util.List<Image.FmriState> getInventory(java.lang.String[] pkg_list,
                                                    boolean all_known)
Get the inventory of packages and their associated state. The inventory is returned in FmriState objects that consist of an Fmri and the four states for the Fmri. These states are: *

Parameters:
pkg_list - Limit the inventory to packages that match entries in the list of package names
all_known - If true, return all package versions. Otherwise only return the most recent version of each package.
Returns:
A List of FmriState objects that identify the Fmris that are available for the image.

installPackages

public void installPackages(java.lang.String[] pkgNames)
                     throws java.io.IOException
Install packages and any required dependencies. The catalog is searched for a matching package for each entry in the pkgNames array. If multiple packages match an entry, the most recent package is installed. If no matching package is found, the entry is ignored.

Parameters:
pkgNames - names of packages to install
Throws:
java.io.IOException

installPackages

public void installPackages(java.util.List<Fmri> pkgs)
                     throws java.io.IOException
Install packages and any required dependencies.

Parameters:
pkgs - List of valid Fmris from the image catalog for packages to install.
Throws:
java.io.IOException

uninstallPackages

public void uninstallPackages(java.lang.String[] pkgNames)
                       throws java.io.IOException
Uninstall packages. The installed package list is searched for a matching package for each entry in the pkgNames array. If no matching package is found, the entry is ignored.

Parameters:
pkgNames - names of packages to uninstall
Throws:
java.io.IOException

uninstallPackages

public void uninstallPackages(java.util.List<Fmri> pkgs)
                       throws java.io.IOException
Uninstall packages.

Parameters:
pkgs - List of valid Fmris to uninstall.
Throws:
java.io.IOException

getManifest

public Manifest getManifest(Fmri fmri)
                     throws java.io.IOException
Get the manifest for a package.

Returns:
a Manifest
Throws:
java.io.IOException