com.tivoli.twg.SoftwarePackageEditor
Class TWGSwPkgMgr

java.lang.Object
  extended bycom.tivoli.twg.SoftwarePackageEditor.TWGSwPkgMgr

public class TWGSwPkgMgr
extends java.lang.Object

Class to use to manage the creation and deletion of packages programatically.


Nested Class Summary
static interface TWGSwPkgMgr.PkgTaskListener
          Interface those classes interested in listening for package creation events should implement
 
Field Summary
static int CANNOT_ACCESS_PACKAGE
          Another ServiceNode has a lock on this package
static int COMMUNICATION_ERROR
          A problem communicating with, or starting the server
protected static int CREATE
          Control variables for package saving and creation
protected static int DELETE
           
static int FAIL_DUPLICATE_PKG_NAME
          A package with the same name already exists
static int FILE_SIGNATURE_INVALID
          A file does not have a valid signature
static int FILE_SIZE_LIMIT_EXCEEDED
          Package has exceeded its total file size limit or a file has exceeded its size limit
static int FULL_FUNCTION_REQUIRED
          You cannot do this without a full function release of Director
static int GENERAL_ERROR
          A general failure occured
static int IO_ERROR
          An error occured reading or writing data
static int PACKAGE_SIGNATURE_INVALID
          This package does not have a valid signature, and we require one
protected static int SAVE
           
static int SUCCESS
          Action was sucessful
 
Constructor Summary
TWGSwPkgMgr()
           
 
Method Summary
static long createDistributionJob(java.lang.String pkgId, LongValueSet moids, int flags, int maxActs, int maxDays, ServiceNode sn)
          Creates a distribute job.
static long createDistributionJob(java.lang.String pkgId, LongValueSet moids, ServiceNode sn)
          Creates a distribute job.
static void createPackage(TWGSwPackage toCreate, ServiceNode sn, TWGSwPkgMgr.PkgTaskListener ptl)
          Deprecated. As of Director 3.1
static void createPkg(com.tivoli.twg.SoftwarePackageEditor.pkg.PkgInstall pkg, ServiceNode sn, TWGSwPkgMgr.PkgTaskListener ptl)
          Creates the given software package.
static void createPkgUninstall(java.lang.String pkgId, ServiceNode sn, java.lang.String pkgName, TWGSwPkgMgr.PkgTaskListener ptl)
          Creates an uninstall package from the given custom package.
static void deletePackage(java.lang.String pkgId, ServiceNode sn, TWGSwPkgMgr.PkgTaskListener ptl)
          Delete a package
static void exportPackage(FileSource fs, java.lang.String path, ServiceNode sn, java.lang.String pkgId, TWGSwPkgMgr.PkgTaskListener ptl)
          Exports a package to a .bfp file.
static java.util.ArrayList getPackageIds(ServiceNode sn)
          Gets the packages that exist on the server.
static void importPackage(FileSource fs, java.lang.String path, ServiceNode sn, java.lang.String title, boolean webReq, TWGSwPkgMgr.PkgTaskListener ptl)
          Imports a package from a .bfp file.
static TWGSwPackage loadPackage(java.lang.String pkgId, ServiceNode sn)
          Load Package from the server
static com.tivoli.twg.SoftwarePackageEditor.pkg.PkgInstall loadPkg(java.lang.String pkgId, ServiceNode sn)
           
static boolean lockForRead(java.lang.String pkgId, ServiceNode sn)
          Lock a package for read
static TWGSwPackage lockForWrite(java.lang.String pkgId, ServiceNode sn)
          Lock a package for write.
static java.lang.String pkgIdToTaskId(java.lang.String pkgId)
          Converts a package id to a task id.
static void savePackage(java.lang.String pkgId, TWGSwPackage toSave, ServiceNode sn, TWGSwPkgMgr.PkgTaskListener ptl)
          Saves the given software package over an existing one.
static void savePkg(java.lang.String pkgId, com.tivoli.twg.SoftwarePackageEditor.pkg.PkgInstall pkg, ServiceNode sn, TWGSwPkgMgr.PkgTaskListener ptl)
           
static java.lang.String taskIdToPkgId(java.lang.String taskId)
          Converts a task id to a package id.
static boolean unlockForRead(java.lang.String pkgId, ServiceNode sn)
          Release a package that is locked for read
static boolean unlockForWrite(java.lang.String pkgId, ServiceNode sn)
          Release a package that is locked for write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUCCESS

public static final int SUCCESS
Action was sucessful

See Also:
Constant Field Values

GENERAL_ERROR

public static final int GENERAL_ERROR
A general failure occured

See Also:
Constant Field Values

COMMUNICATION_ERROR

public static final int COMMUNICATION_ERROR
A problem communicating with, or starting the server

See Also:
Constant Field Values

CANNOT_ACCESS_PACKAGE

public static final int CANNOT_ACCESS_PACKAGE
Another ServiceNode has a lock on this package

See Also:
Constant Field Values

PACKAGE_SIGNATURE_INVALID

public static final int PACKAGE_SIGNATURE_INVALID
This package does not have a valid signature, and we require one

See Also:
Constant Field Values

IO_ERROR

public static final int IO_ERROR
An error occured reading or writing data

See Also:
Constant Field Values

FULL_FUNCTION_REQUIRED

public static final int FULL_FUNCTION_REQUIRED
You cannot do this without a full function release of Director

See Also:
Constant Field Values

FILE_SIZE_LIMIT_EXCEEDED

public static final int FILE_SIZE_LIMIT_EXCEEDED
Package has exceeded its total file size limit or a file has exceeded its size limit

See Also:
Constant Field Values

FILE_SIGNATURE_INVALID

public static final int FILE_SIGNATURE_INVALID
A file does not have a valid signature

See Also:
Constant Field Values

FAIL_DUPLICATE_PKG_NAME

public static final int FAIL_DUPLICATE_PKG_NAME
A package with the same name already exists

See Also:
Constant Field Values

CREATE

protected static final int CREATE
Control variables for package saving and creation

See Also:
Constant Field Values

SAVE

protected static final int SAVE
See Also:
Constant Field Values

DELETE

protected static final int DELETE
See Also:
Constant Field Values
Constructor Detail

TWGSwPkgMgr

public TWGSwPkgMgr()
Method Detail

pkgIdToTaskId

public static java.lang.String pkgIdToTaskId(java.lang.String pkgId)
Converts a package id to a task id.


taskIdToPkgId

public static java.lang.String taskIdToPkgId(java.lang.String taskId)
Converts a task id to a package id.

Throws:
java.lang.IllegalArgumentException - if given taskId is not a valid software package taskId.

createDistributionJob

public static long createDistributionJob(java.lang.String pkgId,
                                         LongValueSet moids,
                                         ServiceNode sn)
Creates a distribute job. Returns the Job Id of the job created. The distribution can be done by activating the job, or by setting a trigger for the job. The label for the job is the package name. TWGRemoteJobManager must be initialized for this to work. This version uses default flag settings: JOB_FLAG_ENABLED | JOB_FLAG_NOT_USER_DELETABLE | JOB_FLAG_MONITOR_MO_STATE Sets maxActs to 1000 and maxDays to 365

Parameters:
pkgId - the package to distribute.
moids - a set of moids the package should be distributed to.
sn - the service node to use for task commands to the server.
Returns:
long The job Id of the new job, or 0 if the creation failed.

createDistributionJob

public static long createDistributionJob(java.lang.String pkgId,
                                         LongValueSet moids,
                                         int flags,
                                         int maxActs,
                                         int maxDays,
                                         ServiceNode sn)
Creates a distribute job. Returns the Job Id of the job created. The distribution can be done by activating the job, or by setting a trigger for the job. The label for the job is the package name. TWGRemoteJobManager must be initialized for this to work.

Parameters:
pkgId - the package to distribute.
moids - a set of moids the package should be distributed to.
sn - the service node to use for task commands to the server.
flags - the flags for the created job
maxActs - the maximum number of jobActivations to keep as history
maxDays - the maximum number of days to keep a TWGJobActivation object as history
Returns:
The job Id of the new job, or 0 if the creation failed.

createPkg

public static void createPkg(com.tivoli.twg.SoftwarePackageEditor.pkg.PkgInstall pkg,
                             ServiceNode sn,
                             TWGSwPkgMgr.PkgTaskListener ptl)
Creates the given software package. Launches a thread which calls the packageCreationComplete method of the PkgTaskListener when the creation is complete.

Parameters:
pkg - - package to create
sn - - service node to send commands to the server on
ptl - - listener to listen for the completion of the creation. can be null if not needed

createPackage

public static void createPackage(TWGSwPackage toCreate,
                                 ServiceNode sn,
                                 TWGSwPkgMgr.PkgTaskListener ptl)
Deprecated. As of Director 3.1

Creates the given software package. Launches a thread which calls the packageCreationComplete method of the PkgTaskListener when the creation is complete.

Parameters:
toCreate - the package definition
sn - the service node to send commands to the server on
ptl - a listener to listen for the completion of the creation. Can be null if not needed.
See Also:
createPkg

createPkgUninstall

public static void createPkgUninstall(java.lang.String pkgId,
                                      ServiceNode sn,
                                      java.lang.String pkgName,
                                      TWGSwPkgMgr.PkgTaskListener ptl)
Creates an uninstall package from the given custom package. Launches a thread which calls the packageCreationComplete method of the PkgTaskListener when the creation is complete.

Parameters:
pkgId - - custom package id
sn - - the service node to send commands to the server on
pkgName - - name of the new uninstall package
ptl - - a listener to listen for the completion of the creation. Can be null if not needed.

savePkg

public static void savePkg(java.lang.String pkgId,
                           com.tivoli.twg.SoftwarePackageEditor.pkg.PkgInstall pkg,
                           ServiceNode sn,
                           TWGSwPkgMgr.PkgTaskListener ptl)

savePackage

public static void savePackage(java.lang.String pkgId,
                               TWGSwPackage toSave,
                               ServiceNode sn,
                               TWGSwPkgMgr.PkgTaskListener ptl)
Saves the given software package over an existing one. Launches a thread which calls the packageSaveComplete method of the PkgTaskListener when the save is complete. It is important that you have called lockForWrite on the package you wish to overwrite before using this method, and unlockForWrite afterwards.

Parameters:
toSave - the package definition to save
sn - the service node to send commands to the server on
ptl - a listener to listen for the completion of the save. Can be null if not needed.
pkgId - the id of the package to replace
See Also:
lockForWrite, unlockForWrite

getPackageIds

public static java.util.ArrayList getPackageIds(ServiceNode sn)
Gets the packages that exist on the server.

Parameters:
sn - the service node to use for communication
Returns:
an ArrayList of package ids

loadPkg

public static com.tivoli.twg.SoftwarePackageEditor.pkg.PkgInstall loadPkg(java.lang.String pkgId,
                                                                          ServiceNode sn)

loadPackage

public static TWGSwPackage loadPackage(java.lang.String pkgId,
                                       ServiceNode sn)
Load Package from the server

Parameters:
pkgId - the id of the package to load.
Returns:
a TWGSwPackage object representing the loaded package.

exportPackage

public static void exportPackage(FileSource fs,
                                 java.lang.String path,
                                 ServiceNode sn,
                                 java.lang.String pkgId,
                                 TWGSwPkgMgr.PkgTaskListener ptl)
Exports a package to a .bfp file. Launches a thread which calls the packageCreationComplete method of PkgTaskListener when the export is complete.

Parameters:
fs - The FileSource that these files should be loaded from.
path - The path of the .bfp file to export the software package to.
sn - The service node for use when communicating with the server.
pkgId - The package id of the package to export
ptl - Who is listening for the end of the import

importPackage

public static void importPackage(FileSource fs,
                                 java.lang.String path,
                                 ServiceNode sn,
                                 java.lang.String title,
                                 boolean webReq,
                                 TWGSwPkgMgr.PkgTaskListener ptl)
Imports a package from a .bfp file. Launches a thread which calls the packageCreationComplete method of the PkgTaskListener when the import is complete.

Parameters:
fs - The FileSource that these files should be loaded from.
path - The path of the .bfp file to import the software package from.
sn - The service node for use when communicating with the server.
title - The title to give the imported package.
webReq - Should this package be web requestable once imported.
ptl - Who is listening for the end of the import

deletePackage

public static void deletePackage(java.lang.String pkgId,
                                 ServiceNode sn,
                                 TWGSwPkgMgr.PkgTaskListener ptl)
Delete a package

Parameters:
pkgId - the id pf the package to delete
sn - the service node to use when communicating with the server
ptl - a listener fo the result of the delete

lockForRead

public static boolean lockForRead(java.lang.String pkgId,
                                  ServiceNode sn)
Lock a package for read

Parameters:
pkgId - the id of the package to lock for read
sn - the service node to use to communicate with server. You must use this servicenode to unlock the package
Returns:
false if we could not lock the package

unlockForRead

public static boolean unlockForRead(java.lang.String pkgId,
                                    ServiceNode sn)
Release a package that is locked for read

Parameters:
pkgId - the id of the package to release the lock for read for
sn - the service node to use to communicate to the server. Must be the same service node used to lock the package.
Returns:
false if we could not unlock the package, usually because we do not actually have a lock.

lockForWrite

public static TWGSwPackage lockForWrite(java.lang.String pkgId,
                                        ServiceNode sn)
Lock a package for write. Should be called before calling savePackage.

Parameters:
pkgId - the id of the package to lock for write
sn - the service node to use to communicate with server. You must use this servicenode to unlock the package
Returns:
null if we could not lock the package, the package definition otherwise

unlockForWrite

public static boolean unlockForWrite(java.lang.String pkgId,
                                     ServiceNode sn)
Release a package that is locked for write. Should be called after calling savePackage.

Parameters:
pkgId - the id of the package to release the lock for write for
sn - the service node to use to communicate to the server. Must be the same service node used to lock the package.
Returns:
false if we could not unlock the package, usually because we do not actually have a lock.