Node Director
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
sfi.director.application.DirectorPackage Class Reference

Implements basic packaging functions for Director's native package format. More...

Public Member Functions

 DirectorPackage ()
 DirectorPackage (DBObject desc) throws DirectorException
 Init package object from a database entry.
void close ()
 Close this package object.
DBObject todb () throws DirectorException
 Dump package description into a database entry of class directorApplication.
DBObject topkgdb () throws DirectorException
 Dump package description into a database entry of class directorApplicationPackage.
void setReleaseDir (String dir)
 Set release directory.
void setRelease (String release) throws DirectorException
 Set release number.
void setFreezeMode (int mode)
 Set freeze mode for next freeze().
void incrementRelease ()
 increment the release number by one.
void getInfo (ZipInputStream archive) throws DirectorException
 Read application info from a package file.
void getInfo () throws DirectorException
 Read application info from .rel/meta/app_info.dat file this is mainly used when using "app_import" to import an application from another director environment.
void getInfo (BufferedReader info) throws DirectorException
 Read application info from an anonymous app_info.dat stream.
String getRelease () throws DirectorException
 return string representation of the application's release
boolean haveFreeze () throws DirectorException
 return true if there is an archive containing a freeze for the current release, false otherwise.
void writeInfo () throws DirectorException
 Dump application info into .rel/meta/app_info.dat.
void determineFilesInRelease (OutputStream fullInfo, OutputStream list, OutputStream deleteList, String baseListName) throws DirectorException
 Determine the paths of all the files that should be included in the current release.
int execScript (String nameAndArgs)
 Execute a package related script.
int execMetaScript (String name) throws DirectorException
 Execute a package related script, e.g.
void setReason (String reason)
 Set reason for next freeze().
void setUser (String user)
 Set freezing user for next freeze().
synchronized void freeze () throws DirectorException
 Freeze a specified application.
void unpackCpio (InputStream archive, String targetDir) throws DirectorException
void install (InputStream packageStream) throws DirectorException
 Install a package.

Static Public Member Functions

static Vector deleteTree (Vector tree)
 Recursively delete all files listed in a Vector.
static void scanRepository (RemoteJob job) throws DirectorException
 Scan a directory for director packages and send a list of found packages back to our caller.
static void main (String args[])

Static Public Attributes

static final int BASELINE = 0
 possible freeze modes set via setFreezeMode are BASELINE, UPDATE and PATCH.
static final int UPDATE = 1
static final int PATCH = 2

Protected Member Functions

void finalize ()
File removeOnClose (File file)
 Add file to the list of files to be deleted during close().
File removeOnClose (String filename)
 Create file object for file with the specified name and add it to the list of files to be deleted during close()
void fromDesc (DBObject desc) throws DirectorException
 Set package variables from a database entry.
String relDir () throws DirectorException
String metaDir () throws DirectorException
void determineRelease (boolean next) throws DirectorException
OutputStream packCpio (final OutputStream archive) throws DirectorException
void setExecutable (String path)
void deleteRecursively (String fname, int depth)
DirectorException moveFiles (String source, String target, int depth)
 Move a directory tree located under 'source' to a directory 'target'.
synchronized void unpackUsingArchiver (final InputStream archive, String targetDir, String command, boolean packNmove, boolean verboseList) throws DirectorException
ZipEntry extractMetaFiles (ZipEntry next, String prefix, ZipInputStream archive) throws IOException, DirectorException
void cleanUpSub (FileListComparer comparer, String dir, String prefix) throws DirectorException
void cleanUp (String dir, String prefix, BufferedReader fileList) throws DirectorException

Protected Attributes

Process packer = null
StoppableThread packerThread = null
DirectorException bgerror = null

Detailed Description

Implements basic packaging functions for Director's native package format.

Functions include creation and installation of packages.

Constructor & Destructor Documentation

sfi.director.application.DirectorPackage.DirectorPackage ( )
sfi.director.application.DirectorPackage.DirectorPackage ( DBObject  desc) throws DirectorException

Init package object from a database entry.

References sfi.director.application.DirectorPackage.fromDesc().

Member Function Documentation

void sfi.director.application.DirectorPackage.cleanUp ( String  dir,
String  prefix,
BufferedReader  fileList 
) throws DirectorException
protected
void sfi.director.application.DirectorPackage.cleanUpSub ( FileListComparer  comparer,
String  dir,
String  prefix 
) throws DirectorException
protected
void sfi.director.application.DirectorPackage.close ( )

Close this package object.

Cleans up temporary files, etc.

References sfi.director.application.DirectorPackage.deleteTree().

Referenced by sfi.director.application.DirectorPackage.finalize().

void sfi.director.application.DirectorPackage.deleteRecursively ( String  fname,
int  depth 
)
protected
static Vector sfi.director.application.DirectorPackage.deleteTree ( Vector  tree)
static
void sfi.director.application.DirectorPackage.determineFilesInRelease ( OutputStream  fullInfo,
OutputStream  list,
OutputStream  deleteList,
String  baseListName 
) throws DirectorException

Determine the paths of all the files that should be included in the current release.

Parameters
fullInfostream where the full file info (including file attributes) is written to
liststream where the paths (one per line) are written to
deleteListstream where the paths of the files to be deleted in this release are written to
baseListNamename of a file containing the full file info of a former (baseline) release this release is an incremental from. The baseListName file is a file originally written by determineFilesInRelease via the fullInfo argument.

References sfi.director.application.DirectorPackage.BASELINE, sfi.director.util.FileListComparer.close(), sfi.director.util.FileListComparer.compareNext(), sfi.director.util.FileListComparer.getDeleted(), sfi.director.application.DirectorPackage.relDir(), and sfi.director.system.Files.stat().

Referenced by sfi.director.application.DirectorPackage.freeze().

void sfi.director.application.DirectorPackage.determineRelease ( boolean  next) throws DirectorException
protected
int sfi.director.application.DirectorPackage.execMetaScript ( String  name) throws DirectorException
int sfi.director.application.DirectorPackage.execScript ( String  nameAndArgs)

Execute a package related script.

ExecScript changes directory to the release/installation directory before invoking the script.

References sfi.director.util.Tools.execWait().

Referenced by sfi.director.application.DirectorPackage.execMetaScript(), and sfi.director.application.DirectorPackage.install().

ZipEntry sfi.director.application.DirectorPackage.extractMetaFiles ( ZipEntry  next,
String  prefix,
ZipInputStream  archive 
) throws IOException, DirectorException
protected
void sfi.director.application.DirectorPackage.finalize ( )
protected
synchronized void sfi.director.application.DirectorPackage.freeze ( ) throws DirectorException
void sfi.director.application.DirectorPackage.fromDesc ( DBObject  desc) throws DirectorException
protected
void sfi.director.application.DirectorPackage.getInfo ( ZipInputStream  archive) throws DirectorException
void sfi.director.application.DirectorPackage.getInfo ( ) throws DirectorException

Read application info from .rel/meta/app_info.dat file this is mainly used when using "app_import" to import an application from another director environment.

References sfi.director.application.DirectorPackage.metaDir().

Referenced by sfi.director.application.DirectorPackage.getInfo(), and sfi.director.application.DirectorPackage.install().

void sfi.director.application.DirectorPackage.getInfo ( BufferedReader  info) throws DirectorException

Read application info from an anonymous app_info.dat stream.

References sfi.director.application.DirectorPackage.setRelease(), and sfi.director.util.Tools.split().

String sfi.director.application.DirectorPackage.getRelease ( ) throws DirectorException
boolean sfi.director.application.DirectorPackage.haveFreeze ( ) throws DirectorException

return true if there is an archive containing a freeze for the current release, false otherwise.

References sfi.director.application.DirectorPackage.getRelease(), and sfi.director.application.DirectorPackage.relDir().

void sfi.director.application.DirectorPackage.incrementRelease ( )

increment the release number by one.

Depending on the contents of the update variable the respective chunk of the number will be incremented.

See Also
setFreezeMode(int)

Referenced by sfi.director.application.DirectorPackage.determineRelease().

void sfi.director.application.DirectorPackage.install ( InputStream  packageStream) throws DirectorException
static void sfi.director.application.DirectorPackage.main ( String  args[])
static
String sfi.director.application.DirectorPackage.metaDir ( ) throws DirectorException
protected
DirectorException sfi.director.application.DirectorPackage.moveFiles ( String  source,
String  target,
int  depth 
)
protected

Move a directory tree located under 'source' to a directory 'target'.

Do not throw Exceptions. Instead, try to traverse the whole tree and only then return a possible Exception as the return value.

References sfi.director.application.DirectorPackage.deleteRecursively(), sfi.director.util.Setup.fileSeparator, sfi.director.system.FileStats.isDirectory(), and sfi.director.system.Files.lstat().

Referenced by sfi.director.application.DirectorPackage.unpackUsingArchiver().

OutputStream sfi.director.application.DirectorPackage.packCpio ( final OutputStream  archive) throws DirectorException
protected
String sfi.director.application.DirectorPackage.relDir ( ) throws DirectorException
protected
File sfi.director.application.DirectorPackage.removeOnClose ( File  file)
protected

Add file to the list of files to be deleted during close().

File sfi.director.application.DirectorPackage.removeOnClose ( String  filename)
protected

Create file object for file with the specified name and add it to the list of files to be deleted during close()

static void sfi.director.application.DirectorPackage.scanRepository ( RemoteJob  job) throws DirectorException
static

Scan a directory for director packages and send a list of found packages back to our caller.

If job argument "freeze" is set baseline freeze any application which is not frozen yet.

References sfi.director.retriever.RemoteFile.connectSend(), sfi.director.util.Logger.ERR, sfi.director.util.Setup.fileSeparator, sfi.director.retriever.RetrieverManager.getConnection(), sfi.director.util.Tools.log(), sfi.director.util.Setup.pathSeparator, and sfi.director.util.Tools.split().

void sfi.director.application.DirectorPackage.setExecutable ( String  path)
protected
void sfi.director.application.DirectorPackage.setFreezeMode ( int  mode)

Set freeze mode for next freeze().

Valid freeze modes are BASELINE, UPDATE and PATCH.

See Also
freeze()

Referenced by sfi.director.application.DirectorPackage.main(), and sfi.director.application.DirectorPackage.setRelease().

void sfi.director.application.DirectorPackage.setReason ( String  reason)

Set reason for next freeze().

void sfi.director.application.DirectorPackage.setRelease ( String  release) throws DirectorException
void sfi.director.application.DirectorPackage.setReleaseDir ( String  dir)
void sfi.director.application.DirectorPackage.setUser ( String  user)

Set freezing user for next freeze().

DBObject sfi.director.application.DirectorPackage.todb ( ) throws DirectorException

Dump package description into a database entry of class directorApplication.

References sfi.director.application.DirectorPackage.getRelease(), and sfi.director.repository.DBObject.setDN().

DBObject sfi.director.application.DirectorPackage.topkgdb ( ) throws DirectorException
void sfi.director.application.DirectorPackage.unpackCpio ( InputStream  archive,
String  targetDir 
) throws DirectorException
synchronized void sfi.director.application.DirectorPackage.unpackUsingArchiver ( final InputStream  archive,
String  targetDir,
String  command,
boolean  packNmove,
boolean  verboseList 
) throws DirectorException
protected
void sfi.director.application.DirectorPackage.writeInfo ( ) throws DirectorException

Member Data Documentation

final int sfi.director.application.DirectorPackage.BASELINE = 0
static

possible freeze modes set via setFreezeMode are BASELINE, UPDATE and PATCH.

A release number is always a three-chunk number like 001.02.03. The BASELINE/UPDATE/PATCH constants correspond with the respective chunk's index.

See Also
setFreezeMode(int)

Referenced by sfi.director.application.scripttask.FreezeApplication.create(), sfi.director.application.DirectorPackage.determineFilesInRelease(), sfi.director.application.DirectorPackage.determineRelease(), sfi.director.application.DirectorPackage.freeze(), sfi.director.application.DirectorPackage.install(), and sfi.director.application.DirectorPackage.setRelease().

DirectorException sfi.director.application.DirectorPackage.bgerror = null
protected
Process sfi.director.application.DirectorPackage.packer = null
protected
StoppableThread sfi.director.application.DirectorPackage.packerThread = null
protected
final int sfi.director.application.DirectorPackage.PATCH = 2
static
final int sfi.director.application.DirectorPackage.UPDATE = 1
static

The documentation for this class was generated from the following file: